diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1b5f30ee17768bbf281583ab9b385a894f4f0744..55b6e79e6df2b1167ffdde294391b32d07dcd1b2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,9 +72,6 @@ to clean-up build results. ## Tests and validation -We use the usual `go` tools for this, to run those commands you need at least the linter which you can -install with `go get -u golang.org/x/lint/golint` - To run basic validation (fmt, test-short, lint, vet), and the project unit tests, call: $ make test diff --git a/Dockerfile b/Dockerfile index 935de0e6629fcfd6a23dacbfca27318253ac3224..f19f53d69d5cc2e8faa56b0c0cce47e67998e785 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,14 @@ -FROM golang:1.12.9 +FROM golang:1.21.1 RUN apt-get update && apt-get install -y --no-install-recommends \ openssh-client \ rsync \ - fuse \ + fuse3 \ sshfs \ && rm -rf /var/lib/apt/lists/* ENV GO111MODULE=on -RUN go get golang.org/x/tools@v0.1.12 -RUN go get golang.org/x/lint/golint -RUN go get golang.org/x/tools/cover - -ENV GO111MODULE=off - ENV USER root WORKDIR /go/src/github.com/docker/machine diff --git a/appveyor.yml b/appveyor.yml index a32b5620fc4385b45a27f099bb2721e076e0f3c1..3fbdd1ee8609961952c0c75c255ac9e86d54815a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,7 +10,7 @@ environment: clone_folder: c:\gopath\src\github.com\docker\machine build_script: - - go build -i -o ./bin/docker-machine.exe ./cmd/docker-machine + - go build -o ./bin/docker-machine.exe ./cmd/docker-machine test_script: - powershell -Command go test -v ./libmachine/shell diff --git a/commands/scp_unix.go b/commands/scp_unix.go index d26cf384e2128644c05001b7ad30291f3bc16089..b483449a69e7c5a5bb48df847e7923bdf2350922 100644 --- a/commands/scp_unix.go +++ b/commands/scp_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package commands diff --git a/drivers/virtualbox/vtx_intel.go b/drivers/virtualbox/vtx_intel.go index 852f451d13793051b76e0fc453e2e0cbf36ebc02..2d8088f62703f39efa5def695f025a60c5b50e3d 100644 --- a/drivers/virtualbox/vtx_intel.go +++ b/drivers/virtualbox/vtx_intel.go @@ -1,3 +1,4 @@ +//go:build 386 || amd64 // +build 386 amd64 package virtualbox diff --git a/drivers/virtualbox/vtx_other.go b/drivers/virtualbox/vtx_other.go index 5dbfd17553b1d8f8b4aa33f55f777e686005c5e0..f984ac3fb7c283a96d9c4054ef853b589d98b80e 100644 --- a/drivers/virtualbox/vtx_other.go +++ b/drivers/virtualbox/vtx_other.go @@ -1,3 +1,4 @@ +//go:build !386 && !amd64 // +build !386,!amd64 package virtualbox diff --git a/drivers/vmwarefusion/fusion.go b/drivers/vmwarefusion/fusion.go index be433e5fe7d56ba9a781a5f0c2ece7cab459970e..e2d588a2dcadc16131e51634b3560c8de7073e22 100644 --- a/drivers/vmwarefusion/fusion.go +++ b/drivers/vmwarefusion/fusion.go @@ -1,3 +1,4 @@ +//go:build !darwin // +build !darwin package vmwarefusion diff --git a/libmachine/drivers/plugin/localbinary/plugin.go b/libmachine/drivers/plugin/localbinary/plugin.go index c431c7eda9d7174fe98c66c08e6216cb8b5b18bd..ae32b1e9d9bae7afa5958edec831c0de2c985afa 100644 --- a/libmachine/drivers/plugin/localbinary/plugin.go +++ b/libmachine/drivers/plugin/localbinary/plugin.go @@ -93,9 +93,11 @@ func (e ErrPluginBinaryNotFound) Error() string { } // driverPath finds the path of a driver binary by its name. -// + If the driver is a core driver, there is no separate driver binary. We reuse current binary if it's `docker-machine` +// - If the driver is a core driver, there is no separate driver binary. We reuse current binary if it's `docker-machine` +// // or we assume `docker-machine` is in the PATH. -// + If the driver is NOT a core driver, then the separate binary must be in the PATH and it's name must be +// - If the driver is NOT a core driver, then the separate binary must be in the PATH and it's name must be +// // `docker-machine-driver-driverName` func driverPath(driverName string) string { for _, coreDriver := range CoreDrivers { diff --git a/libmachine/provision/provisiontest/sshcommander.go b/libmachine/provision/provisiontest/sshcommander.go index 3f9f8b71d26f83f8f93580ac621aaf036e58c7da..e826cb6859c2cc312fc0e3adc9c334db13c8f592 100644 --- a/libmachine/provision/provisiontest/sshcommander.go +++ b/libmachine/provision/provisiontest/sshcommander.go @@ -1,21 +1,21 @@ -//Package provisiontest provides utilities for testing provisioners +// Package provisiontest provides utilities for testing provisioners package provisiontest import "errors" -//FakeSSHCommanderOptions is intended to create a FakeSSHCommander without actually knowing the underlying sshcommands by passing it to NewSSHCommander +// FakeSSHCommanderOptions is intended to create a FakeSSHCommander without actually knowing the underlying sshcommands by passing it to NewSSHCommander type FakeSSHCommanderOptions struct { //Result of the ssh command to look up the FilesystemType FilesystemType string } -//FakeSSHCommander is an implementation of provision.SSHCommander to provide predictable responses set by testing code -//Extend it when needed +// FakeSSHCommander is an implementation of provision.SSHCommander to provide predictable responses set by testing code +// Extend it when needed type FakeSSHCommander struct { Responses map[string]string } -//NewFakeSSHCommander creates a FakeSSHCommander without actually knowing the underlying sshcommands +// NewFakeSSHCommander creates a FakeSSHCommander without actually knowing the underlying sshcommands func NewFakeSSHCommander(options FakeSSHCommanderOptions) *FakeSSHCommander { if options.FilesystemType == "" { options.FilesystemType = "ext4" @@ -29,7 +29,7 @@ func NewFakeSSHCommander(options FakeSSHCommanderOptions) *FakeSSHCommander { return sshCmder } -//SSHCommand is an implementation of provision.SSHCommander.SSHCommand to provide predictable responses set by testing code +// SSHCommand is an implementation of provision.SSHCommander.SSHCommand to provide predictable responses set by testing code func (sshCmder *FakeSSHCommander) SSHCommand(args string) (string, error) { response, commandRegistered := sshCmder.Responses[args] if !commandRegistered { diff --git a/libmachine/shell/shell.go b/libmachine/shell/shell.go index d0a271c9a9acfa1791b87a6b9144289b427eff58..348b369f7a2bc02fce11a6d76a615971680378ff 100644 --- a/libmachine/shell/shell.go +++ b/libmachine/shell/shell.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package shell diff --git a/libmachine/shell/shell_unix_test.go b/libmachine/shell/shell_unix_test.go index b9382071b39d8def6e6e81acd6d08b9d59e9cc30..16a76675f5a61c23d4fdb57f239b19b56d6b3a20 100644 --- a/libmachine/shell/shell_unix_test.go +++ b/libmachine/shell/shell_unix_test.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package shell diff --git a/mk/main.mk b/mk/main.mk index 5f63036049049e5be024ee8718a50d232d704595..2e24ee928e865289e80e87b01dc25f1763dd5b82 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -3,11 +3,7 @@ GO_LDFLAGS := -X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/de GO_GCFLAGS := # Full package list -PKGS := $(shell go list -tags "$(BUILDTAGS)" ./... | grep -v "/vendor/" | grep -v "/cmd") - -# Resolving binary dependencies for specific targets -GOLINT_BIN := $(GOPATH)/bin/golint -GOLINT := $(shell [ -x $(GOLINT_BIN) ] && echo $(GOLINT_BIN) || echo '') +PKGS := $(shell go list -tags "$(BUILDTAGS)" ./... | grep -v "/cmd") # Honor debug ifeq ($(DEBUG),true) diff --git a/mk/validate.mk b/mk/validate.mk index 5c05d6f184460749b70788c7a3c05d640929ebdc..b449018e1b0069bc56479019be005a5d3bc07f20 100644 --- a/mk/validate.mk +++ b/mk/validate.mk @@ -1,10 +1,12 @@ fmt: - @test -z "$$(gofmt -s -l . 2>&1 | grep -v vendor/ | tee /dev/stderr)" + @go mod download + @test -z "$$(gofmt -s -l . 2>&1 | tee /dev/stderr)" vet: + @go mod download @test -z "$$(go vet $(PKGS) 2>&1 | tee /dev/stderr)" lint: - $(if $(GOLINT), , \ - $(error Please install golint: go get -u golang.org/x/lint/golint)) - @test -z "$$($(GOLINT) ./... 2>&1 | grep -v vendor/ | grep -v "cli/" | grep -v "amazonec2/" |grep -v "openstack/" |grep -v "softlayer/" | grep -v "should have comment" | tee /dev/stderr)" + @go mod download + @go install golang.org/x/lint/golint@latest + @test -z "$$(golint ./... 2>&1 | grep -v "cli/" | grep -v "amazonec2/" |grep -v "openstack/" |grep -v "softlayer/" | grep -v "should have comment" | tee /dev/stderr)"