Add golangci-lint to project (#8686)

* Add golangci-lint as linting tool

* Disable failing staticchecks to start; GitHub issue to handle coming soon

* Run `goimports -w` to repair all source files that have improperly
formatted imports

* makefile: Add ci-lint target to run on travis

This change adds a new make target for running golangci-lint on newly
added Go files only. This target is expected to run during Packer ci builds.

* .github/contributing: Add code linting instructions

* travis: Update job configuration to run parallel builds
This commit is contained in:
Wilken Rivera 2020-02-14 11:42:29 -05:00 committed by GitHub
parent 2981fd627d
commit 9ec8b67392
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
58 changed files with 271 additions and 63 deletions

View File

@ -259,6 +259,28 @@ localized code generation. Say you are working on the Amazon builder: running
`go generate ./builder/amazon/...` will do that for you. Make sure that the `go generate ./builder/amazon/...` will do that for you. Make sure that the
latest code generation tool is installed by running `make install-gen-deps`. latest code generation tool is installed by running `make install-gen-deps`.
#### Code linting
Packer relies on [golangci-lint](https://github.com/golangci/golangci-lint) for linting its Go code base, excluding any generated code created by `go generate`. Linting is executed on new files during Travis builds via `make ci`; the linting of existing code base is only executed when running `make lint`. Linting a large project like Packer is an iterative process so existing code base will have issues that are actively being fixed; pull-requests that fix existing linting issues are always welcomed :smile:.
The main configuration for golangci-lint is the `.golangci.yml` in the project root. See `golangci-lint --help` for a list of flags that can be used to override the default configuration.
Run golangci-lint on the entire Packer code base.
```
make lint
```
Run golangci-lint on a single pkg or directory; PKG_NAME expands to /builder/amazon/...
```
make lint PKG_NAME=builder/amazon
```
Note: linting on Travis uses the `--new-from-rev=origin/master` flag to only lint new files added within a branch or pull-request. To run this check locally you can use the `ci-lint` make target. See [golangci-lint in CI](https://github.com/golangci/golangci-lint#faq) for more information.
```
make ci-lint
```
#### Running Unit Tests #### Running Unit Tests
You can run tests for individual packages using commands like this: You can run tests for individual packages using commands like this:

124
.golangci.yml Normal file
View File

@ -0,0 +1,124 @@
issues:
# List of regexps of issue texts to exclude, empty list by default.
# But independently from this option we use default exclude patterns,
# it can be disabled by `exclude-use-default: false`. To list all
# excluded by default patterns execute `golangci-lint run --help`
exclude-rules:
# Exclude gosimple bool check
- linters:
- gosimple
text: "S(1002|1008|1021)"
# Exclude failing staticchecks for now
- linters:
- staticcheck
text: "SA(1006|1019|4006|4010|4017|5007|6005|9004):"
# Exclude lll issues for long lines with go:generate
- linters:
- lll
source: "^//go:generate "
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0
linters:
disable-all: true
enable:
- deadcode
- errcheck
- goimports
- gosimple
- govet
- ineffassign
- staticcheck
- unconvert
- unused
- varcheck
fast: true
# options for analysis running
run:
# default concurrency is a available CPU number
concurrency: 4
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 10m
# exit code when at least one issue was found, default is 1
issues-exit-code: 1
# include test files or not, default is true
tests: true
# list of build tags, all linters use it. Default is empty list.
#build-tags:
# - mytag
# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# from this option's value (see skip-dirs-use-default).
#skip-dirs:
# - src/external_libs
# - autogenerated_by_my_lib
# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true
# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
skip-files:
- ".*\\.hcl2spec\\.go$"
# - lib/bad.go
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
# to go.mod are needed. This setting is most useful to check that go.mod does
# not need updates, such as in a continuous integration and testing system.
# If invoked with -mod=vendor, the go command assumes that the vendor
# directory holds the correct copies of dependencies and ignores
# the dependency descriptions in go.mod.
modules-download-mode: vendor
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number
# print lines of code with issue, default is true
print-issued-lines: true
# print linter name in the end of issue text, default is true
print-linter-name: true
# make issues output unique by line, default is true
uniq-by-line: true
# all available settings of specific linters
linters-settings:
errcheck:
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
# default is false: such cases aren't reported by default.
check-type-assertions: false
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
# default is false: such cases aren't reported by default.
check-blank: false
# [deprecated] comma-separated list of pairs of the form pkg:regex
# the regex is used to ignore names within pkg. (default "fmt:.*").
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
ignore: fmt:.*,io/ioutil:^Read.*,io:Close
# path to a file containing a list of functions to exclude from checking
# see https://github.com/kisielk/errcheck#excluding-functions for details
#exclude: /path/to/file.txt

View File

@ -4,20 +4,21 @@ env:
os: os:
- osx - osx
sudo: false
language: go language: go
go:
- 1.13.x
script:
- df -h
- travis_wait make ci
branches: branches:
only: only:
- master - master
matrix: jobs:
fast_finish: true fast_finish: true
include:
- go: "1.13.x"
name: "go test"
script:
- df -h
- travis_wait make ci
- go: "1.13.x"
name: "go lint"
script: travis_wait make ci-lint

View File

@ -18,7 +18,8 @@ GOLDFLAGS=-X $(GIT_IMPORT).GitCommit=$(GIT_COMMIT)$(GIT_DIRTY)
export GOLDFLAGS export GOLDFLAGS
.PHONY: bin checkversion ci default install-build-deps install-gen-deps fmt fmt-docs fmt-examples generate releasebin test testacc testrace .PHONY: bin checkversion ci ci-lint default install-build-deps install-gen-deps fmt fmt-docs fmt-examples generate install-lint-deps lint \
releasebin test testacc testrace
default: install-build-deps install-gen-deps generate testrace dev releasebin package dev fmt fmt-check mode-check fmt-docs fmt-examples default: install-build-deps install-gen-deps generate testrace dev releasebin package dev fmt fmt-check mode-check fmt-docs fmt-examples
@ -49,12 +50,16 @@ install-gen-deps: ## Install dependencies for code generation
# dir. `go get` will change our deps and the following deps are not part of # dir. `go get` will change our deps and the following deps are not part of
# out code dependencies; so a go mod tidy will remove them again. `go # out code dependencies; so a go mod tidy will remove them again. `go
# install` seems to install the last tagged version and we want to install # install` seems to install the last tagged version and we want to install
# master. # master.
@(cd $(TEMPDIR) && GO111MODULE=on go get github.com/mna/pigeon@master) @(cd $(TEMPDIR) && GO111MODULE=on go get github.com/mna/pigeon@master)
@(cd $(TEMPDIR) && GO111MODULE=on go get github.com/alvaroloes/enumer@master) @(cd $(TEMPDIR) && GO111MODULE=on go get github.com/alvaroloes/enumer@master)
@go install ./cmd/struct-markdown @go install ./cmd/struct-markdown
@go install ./cmd/mapstructure-to-hcl2 @go install ./cmd/mapstructure-to-hcl2
install-lint-deps: ## Install linter dependencies
@echo "==> Updating linter dependencies..."
@curl -sSfL -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.23.1
dev: ## Build and install a development build dev: ## Build and install a development build
@grep 'const VersionPrerelease = ""' version/version.go > /dev/null ; if [ $$? -eq 0 ]; then \ @grep 'const VersionPrerelease = ""' version/version.go > /dev/null ; if [ $$? -eq 0 ]; then \
echo "ERROR: You must add prerelease tags to version/version.go prior to making a dev build."; \ echo "ERROR: You must add prerelease tags to version/version.go prior to making a dev build."; \
@ -66,6 +71,20 @@ dev: ## Build and install a development build
@cp $(GOPATH)/bin/packer bin/packer @cp $(GOPATH)/bin/packer bin/packer
@cp $(GOPATH)/bin/packer pkg/$(GOOS)_$(GOARCH) @cp $(GOPATH)/bin/packer pkg/$(GOOS)_$(GOARCH)
lint: install-lint-deps ## Lint Go code
@if [ ! -z $(PKG_NAME) ]; then \
echo "golangci-lint run ./$(PKG_NAME)/..."; \
golangci-lint run ./$(PKG_NAME)/...; \
else \
echo "golangci-lint run"; \
golangci-lint run; \
fi
ci-lint: install-lint-deps ## On ci only lint newly added Go source files
@echo "==> Running linter on newly added Go source files..."
GO111MODULE=on golangci-lint run --new-from-rev=origin/master
fmt: ## Format Go code fmt: ## Format Go code
@go fmt ./... @go fmt ./...

View File

@ -10,11 +10,11 @@ package chroot
import ( import (
"context" "context"
"errors" "errors"
"github.com/hashicorp/packer/builder"
"runtime" "runtime"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/hcl/v2/hcldec"
"github.com/hashicorp/packer/builder"
awscommon "github.com/hashicorp/packer/builder/amazon/common" awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/common/chroot" "github.com/hashicorp/packer/common/chroot"

View File

@ -4,13 +4,13 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"github.com/hashicorp/packer/builder"
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/builder"
"github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"

View File

@ -3,10 +3,10 @@ package chroot
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/hashicorp/packer/builder"
"log" "log"
"os" "os"
"github.com/hashicorp/packer/builder"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
) )

View File

@ -1,12 +1,12 @@
package common package common
import ( import (
"github.com/hashicorp/packer/builder"
"reflect" "reflect"
"testing" "testing"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/builder"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
) )

View File

@ -3,6 +3,7 @@ package common
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"

View File

@ -11,6 +11,7 @@ package ebs
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/iam" "github.com/aws/aws-sdk-go/service/iam"
"github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/hcl/v2/hcldec"

View File

@ -9,6 +9,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/iam" "github.com/aws/aws-sdk-go/service/iam"
"github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/hcl/v2/hcldec"

View File

@ -1,9 +1,10 @@
package ebssurrogate package ebssurrogate
import ( import (
"github.com/hashicorp/packer/builder/amazon/common"
"testing" "testing"
"github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
) )

View File

@ -9,13 +9,13 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/hashicorp/packer/builder"
"os" "os"
"strings" "strings"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/iam" "github.com/aws/aws-sdk-go/service/iam"
"github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/hcl/v2/hcldec"
"github.com/hashicorp/packer/builder"
awscommon "github.com/hashicorp/packer/builder/amazon/common" awscommon "github.com/hashicorp/packer/builder/amazon/common"
"github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/communicator"

View File

@ -1,8 +1,9 @@
package builder package builder
import ( import (
"github.com/hashicorp/packer/helper/multistep"
"testing" "testing"
"github.com/hashicorp/packer/helper/multistep"
) )
func TestGeneratedData_Put(t *testing.T) { func TestGeneratedData_Put(t *testing.T) {

View File

@ -2,9 +2,9 @@ package lxc
import ( import (
"context" "context"
"github.com/hashicorp/packer/common"
"log" "log"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
) )

View File

@ -2,9 +2,9 @@ package lxd
import ( import (
"context" "context"
"github.com/hashicorp/packer/common"
"log" "log"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
) )

View File

@ -2,9 +2,9 @@ package chroot
import ( import (
"context" "context"
"github.com/hashicorp/packer/common"
"log" "log"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
) )

View File

@ -1,9 +1,10 @@
package common package common
import ( import (
"time"
"github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/template/interpolate" "github.com/hashicorp/packer/template/interpolate"
"time"
) )
// SSHConfig contains the configuration for SSH communicator. // SSHConfig contains the configuration for SSH communicator.

View File

@ -1,12 +1,13 @@
package common package common
import ( import (
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/template/interpolate"
"io/ioutil" "io/ioutil"
"os" "os"
"testing" "testing"
"time" "time"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/template/interpolate"
) )
func testSSHConfig() *SSHConfig { func testSSHConfig() *SSHConfig {

View File

@ -2,6 +2,7 @@ package qemu
import ( import (
"context" "context"
"github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
) )

View File

@ -2,9 +2,10 @@ package qemu
import ( import (
"context" "context"
"testing"
"github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"testing"
) )
func TestStepHTTPIPDiscover_Run(t *testing.T) { func TestStepHTTPIPDiscover_Run(t *testing.T) {

View File

@ -3,10 +3,11 @@ package common
import ( import (
"context" "context"
"fmt" "fmt"
"log"
"github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
"log"
) )
// Step to discover the http ip // Step to discover the http ip

View File

@ -3,9 +3,10 @@ package common
import ( import (
"context" "context"
"errors" "errors"
"testing"
"github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"testing"
) )
func TestStepHTTPIPDiscover_Run(t *testing.T) { func TestStepHTTPIPDiscover_Run(t *testing.T) {

View File

@ -2,6 +2,7 @@ package clone
import ( import (
"context" "context"
"github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/hcl/v2/hcldec"
"github.com/hashicorp/packer/builder/vsphere/common" "github.com/hashicorp/packer/builder/vsphere/common"
"github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/builder/vsphere/driver"

View File

@ -1,13 +1,14 @@
package clone package clone
import ( import (
"os"
"testing"
"github.com/hashicorp/packer/builder/vsphere/common" "github.com/hashicorp/packer/builder/vsphere/common"
commonT "github.com/hashicorp/packer/builder/vsphere/common/testing" commonT "github.com/hashicorp/packer/builder/vsphere/common/testing"
builderT "github.com/hashicorp/packer/helper/builder/testing" builderT "github.com/hashicorp/packer/helper/builder/testing"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
"github.com/vmware/govmomi/vim25/types" "github.com/vmware/govmomi/vim25/types"
"os"
"testing"
) )
func TestCloneBuilderAcc_default(t *testing.T) { func TestCloneBuilderAcc_default(t *testing.T) {

View File

@ -1,8 +1,9 @@
package clone package clone
import ( import (
"github.com/hashicorp/packer/packer"
"testing" "testing"
"github.com/hashicorp/packer/packer"
) )
func TestCloneBuilder_ImplementsBuilder(t *testing.T) { func TestCloneBuilder_ImplementsBuilder(t *testing.T) {

View File

@ -6,6 +6,7 @@ package clone
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/hashicorp/packer/builder/vsphere/common" "github.com/hashicorp/packer/builder/vsphere/common"
"github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"

View File

@ -6,6 +6,7 @@ package common
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"

View File

@ -6,6 +6,7 @@ package common
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
) )

View File

@ -6,6 +6,7 @@ package common
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"

View File

@ -5,10 +5,11 @@ package common
import ( import (
"context" "context"
"strings"
"github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
"strings"
) )
type RunConfig struct { type RunConfig struct {

View File

@ -7,11 +7,12 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"log"
"time"
"github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
"log"
"time"
) )
type ShutdownConfig struct { type ShutdownConfig struct {

View File

@ -2,6 +2,7 @@ package common
import ( import (
"context" "context"
"github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"

View File

@ -2,6 +2,7 @@ package common
import ( import (
"context" "context"
"github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"

View File

@ -6,11 +6,12 @@ package common
import ( import (
"context" "context"
"fmt" "fmt"
"log"
"time"
"github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
"log"
"time"
) )
type WaitIpConfig struct { type WaitIpConfig struct {

View File

@ -3,13 +3,14 @@ package testing
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/hashicorp/packer/builder/vsphere/common"
"github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/packer"
"math/rand" "math/rand"
"os" "os"
"testing" "testing"
"time" "time"
"github.com/hashicorp/packer/builder/vsphere/common"
"github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/packer"
) )
func NewVMName() string { func NewVMName() string {

View File

@ -2,6 +2,7 @@ package driver
import ( import (
"fmt" "fmt"
"github.com/vmware/govmomi/object" "github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/mo" "github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/soap" "github.com/vmware/govmomi/vim25/soap"

View File

@ -3,14 +3,15 @@ package driver
import ( import (
"context" "context"
"fmt" "fmt"
"net/url"
"time"
"github.com/vmware/govmomi" "github.com/vmware/govmomi"
"github.com/vmware/govmomi/find" "github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/object" "github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/session" "github.com/vmware/govmomi/session"
"github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/soap" "github.com/vmware/govmomi/vim25/soap"
"net/url"
"time"
) )
type Driver struct { type Driver struct {

View File

@ -2,6 +2,7 @@ package driver
import ( import (
"fmt" "fmt"
"github.com/vmware/govmomi/object" "github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/mo" "github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types" "github.com/vmware/govmomi/vim25/types"

View File

@ -2,6 +2,7 @@ package driver
import ( import (
"fmt" "fmt"
"github.com/vmware/govmomi/object" "github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/mo" "github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types" "github.com/vmware/govmomi/vim25/types"

View File

@ -4,12 +4,13 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types"
"log" "log"
"strings" "strings"
"time" "time"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types"
) )
type VirtualMachine struct { type VirtualMachine struct {

View File

@ -2,6 +2,7 @@ package driver
import ( import (
"errors" "errors"
"github.com/vmware/govmomi/vim25/types" "github.com/vmware/govmomi/vim25/types"
) )

View File

@ -1,11 +1,12 @@
package driver package driver
import ( import (
"strings"
"unicode"
"github.com/vmware/govmomi/vim25/methods" "github.com/vmware/govmomi/vim25/methods"
"github.com/vmware/govmomi/vim25/types" "github.com/vmware/govmomi/vim25/types"
"golang.org/x/mobile/event/key" "golang.org/x/mobile/event/key"
"strings"
"unicode"
) )
type KeyInput struct { type KeyInput struct {

View File

@ -2,6 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/builder/vsphere/driver"
) )

View File

@ -2,13 +2,14 @@ package iso
import ( import (
"fmt" "fmt"
"io/ioutil"
"os"
"testing"
commonT "github.com/hashicorp/packer/builder/vsphere/common/testing" commonT "github.com/hashicorp/packer/builder/vsphere/common/testing"
builderT "github.com/hashicorp/packer/helper/builder/testing" builderT "github.com/hashicorp/packer/helper/builder/testing"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
"github.com/vmware/govmomi/vim25/types" "github.com/vmware/govmomi/vim25/types"
"io/ioutil"
"os"
"testing"
) )
func TestISOBuilderAcc_default(t *testing.T) { func TestISOBuilderAcc_default(t *testing.T) {

View File

@ -6,6 +6,7 @@ package iso
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"

View File

@ -6,6 +6,7 @@ package iso
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"

View File

@ -3,18 +3,19 @@ package iso
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/hashicorp/packer/builder/vsphere/driver"
packerCommon "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"golang.org/x/mobile/event/key"
"log" "log"
"net" "net"
"os" "os"
"strings" "strings"
"time" "time"
"unicode/utf8" "unicode/utf8"
"github.com/hashicorp/packer/builder/vsphere/driver"
packerCommon "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"golang.org/x/mobile/event/key"
) )
type BootConfig struct { type BootConfig struct {

View File

@ -3,10 +3,11 @@ package iso
import ( import (
"context" "context"
"fmt" "fmt"
"path/filepath"
"github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
"path/filepath"
) )
type StepRemoteUpload struct { type StepRemoteUpload struct {

View File

@ -5,6 +5,7 @@ package iso
import ( import (
"context" "context"
"github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"

View File

@ -2,6 +2,7 @@ package iso
import ( import (
"context" "context"
"github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/builder/vsphere/driver"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"

View File

@ -4,11 +4,12 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"github.com/hashicorp/hcl/v2/hcldec"
"path/filepath" "path/filepath"
"sync" "sync"
"testing" "testing"
"github.com/hashicorp/hcl/v2/hcldec"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
"github.com/hashicorp/packer/builder/file" "github.com/hashicorp/packer/builder/file"

View File

@ -5,7 +5,6 @@ package shell_local
import ( import (
"errors" "errors"
"fmt" "fmt"
// "log"
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"

View File

@ -1,8 +1,9 @@
package fix package fix
import ( import (
"github.com/mitchellh/mapstructure"
"strings" "strings"
"github.com/mitchellh/mapstructure"
) )
type FixerAmazonTemporarySecurityCIDRs struct{} type FixerAmazonTemporarySecurityCIDRs struct{}

View File

@ -1,8 +1,9 @@
package ssh package ssh
import ( import (
"github.com/hashicorp/packer/communicator/ssh"
"testing" "testing"
"github.com/hashicorp/packer/communicator/ssh"
) )
const ( const (

View File

@ -17,7 +17,7 @@ package main
import ( import (
"github.com/hashicorp/packer/builder/amazon/chroot" "github.com/hashicorp/packer/builder/amazon/chroot"
"github.com/hashicorp/packer/packer/plugin" "github.com/hashicorp/packer/packer/plugin"
"github.com/hashicorp/packer/post-processor/docker-push" dockerpush "github.com/hashicorp/packer/post-processor/docker-push"
"github.com/hashicorp/packer/provisioner/powershell" "github.com/hashicorp/packer/provisioner/powershell"
) )

View File

@ -5,7 +5,6 @@ import (
"compress/flate" "compress/flate"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/hashicorp/packer/packer/tmp"
"io" "io"
"log" "log"
"os" "os"
@ -13,6 +12,7 @@ import (
"runtime" "runtime"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer/tmp"
"github.com/klauspost/pgzip" "github.com/klauspost/pgzip"
) )

View File

@ -2,10 +2,11 @@ package interpolate
import ( import (
"bytes" "bytes"
"github.com/google/uuid"
"regexp" "regexp"
"strings" "strings"
"text/template" "text/template"
"github.com/google/uuid"
) )
// Context is the context that an interpolation is done in. This defines // Context is the context that an interpolation is done in. This defines