mirror of
https://github.com/hashicorp/packer.git
synced 2026-05-28 04:35:38 -04:00
Merge pull request #12380 from hashicorp/bump-go-1.20
Bump Go tooling to version 1.20
This commit is contained in:
commit
06fe087097
19 changed files with 76 additions and 40 deletions
23
.github/workflows/go-test.yml
vendored
23
.github/workflows/go-test.yml
vendored
|
|
@ -18,30 +18,47 @@ permissions:
|
|||
contents: read
|
||||
|
||||
jobs:
|
||||
get-go-version:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
go-version: ${{ steps.get-go-version.outputs.go-version }}
|
||||
steps:
|
||||
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
|
||||
- name: 'Determine Go version'
|
||||
id: get-go-version
|
||||
run: |
|
||||
echo "Found Go $(cat .go-version)"
|
||||
echo "go-version=$(cat .go-version)" >> $GITHUB_OUTPUT
|
||||
linux-go-tests:
|
||||
needs:
|
||||
- get-go-version
|
||||
runs-on: ubuntu-latest
|
||||
name: Linux go tests
|
||||
steps:
|
||||
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
|
||||
with:
|
||||
go-version: '1.18'
|
||||
go-version: ${{ needs.get-go-version.outputs.go-version }}
|
||||
- run: TESTARGS="-coverprofile=coverage.txt -covermode=atomic" make ci
|
||||
darwin-go-tests:
|
||||
needs:
|
||||
- get-go-version
|
||||
runs-on: macos-latest
|
||||
name: Darwin go tests
|
||||
steps:
|
||||
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
|
||||
with:
|
||||
go-version: '1.18'
|
||||
go-version: ${{ needs.get-go-version.outputs.go-version }}
|
||||
- run: go test ./... -coverprofile=coverage.txt -covermode=atomic
|
||||
windows-go-tests:
|
||||
needs:
|
||||
- get-go-version
|
||||
runs-on: windows-latest
|
||||
name: Windows go tests
|
||||
steps:
|
||||
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
|
||||
with:
|
||||
go-version: '1.18'
|
||||
go-version: ${{ needs.get-go-version.outputs.go-version }}
|
||||
- run: go test ./... -coverprofile=coverage.txt -covermode=atomic
|
||||
|
|
|
|||
29
.github/workflows/go-validate.yml
vendored
29
.github/workflows/go-validate.yml
vendored
|
|
@ -14,16 +14,31 @@ permissions:
|
|||
contents: read
|
||||
|
||||
jobs:
|
||||
get-go-version:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
go-version: ${{ steps.get-go-version.outputs.go-version }}
|
||||
steps:
|
||||
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
|
||||
- name: 'Determine Go version'
|
||||
id: get-go-version
|
||||
run: |
|
||||
echo "Found Go $(cat .go-version)"
|
||||
echo "go-version=$(cat .go-version)" >> $GITHUB_OUTPUT
|
||||
check-mod-tidy:
|
||||
needs:
|
||||
- get-go-version
|
||||
runs-on: ubuntu-latest
|
||||
name: Go Mod Tidy
|
||||
steps:
|
||||
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
|
||||
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
|
||||
with:
|
||||
go-version: '1.18'
|
||||
go-version: ${{ needs.get-go-version.outputs.go-version }}
|
||||
- run: go mod tidy
|
||||
check-lint:
|
||||
needs:
|
||||
- get-go-version
|
||||
runs-on: ubuntu-latest
|
||||
name: Lint
|
||||
steps:
|
||||
|
|
@ -32,26 +47,30 @@ jobs:
|
|||
fetch-depth: 0
|
||||
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
|
||||
with:
|
||||
go-version: '1.18'
|
||||
go-version: ${{ needs.get-go-version.outputs.go-version }}
|
||||
- run: echo "$GITHUB_SHA"
|
||||
- run: git fetch --all
|
||||
- run: echo $(git merge-base origin/main $GITHUB_SHA)
|
||||
- run: make ci-lint
|
||||
check-fmt:
|
||||
needs:
|
||||
- get-go-version
|
||||
runs-on: ubuntu-latest
|
||||
name: Fmt check
|
||||
steps:
|
||||
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
|
||||
with:
|
||||
go-version: '1.18'
|
||||
go-version: ${{ needs.get-go-version.outputs.go-version }}
|
||||
- run: make fmt-check
|
||||
check-generate:
|
||||
needs:
|
||||
- get-go-version
|
||||
runs-on: ubuntu-latest
|
||||
name: Generate check
|
||||
steps:
|
||||
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
|
||||
with:
|
||||
go-version: '1.18'
|
||||
go-version: ${{ needs.get-go-version.outputs.go-version }}
|
||||
- run: make generate-check
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
1.18.9
|
||||
1.20.3
|
||||
|
|
|
|||
2
Makefile
2
Makefile
|
|
@ -57,7 +57,7 @@ install-gen-deps: ## Install dependencies for code generation
|
|||
|
||||
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.46.0
|
||||
@curl -sSfL -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.52.0
|
||||
|
||||
dev: ## Build and install a development build
|
||||
@grep 'const VersionPrerelease = ""' version/version.go > /dev/null ; if [ $$? -eq 0 ]; then \
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ func TestBuildCommand_RunContext_CtxCancel(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
b := NewParallelTestBuilder(tt.parallelPassingTests)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Code generated by "enumer -type configType -trimprefix ConfigType -transform snake"; DO NOT EDIT.
|
||||
|
||||
//
|
||||
package command
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -188,7 +188,9 @@ func generateFakePlugins(dirname string, pluginNames []string) (string, []string
|
|||
return dir, plugins, cleanUpFunc, nil
|
||||
}
|
||||
|
||||
/* generateFakePackerConfigData creates a collection of mock plugins along with a basic packerconfig.
|
||||
/*
|
||||
generateFakePackerConfigData creates a collection of mock plugins along with a basic packerconfig.
|
||||
|
||||
The return packerConfigData is a valid packerconfig file that can be used for configuring external plugins, cleanUpFunc is a function that should be called for cleaning up any generated mock data.
|
||||
This function will only clean up if there is an error, on successful runs the caller
|
||||
is responsible for cleaning up the data via cleanUpFunc().
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -250,4 +250,4 @@ require (
|
|||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
go 1.18
|
||||
go 1.20
|
||||
|
|
|
|||
|
|
@ -97,9 +97,10 @@ func IsPluginPartNormalized(str string) (bool, error) {
|
|||
// This is intended primarily to parse the FQN-like strings
|
||||
//
|
||||
// The following are valid source string formats:
|
||||
// name
|
||||
// namespace/name
|
||||
// hostname/namespace/name
|
||||
//
|
||||
// name
|
||||
// namespace/name
|
||||
// hostname/namespace/name
|
||||
func ParsePluginSourceString(str string) (*Plugin, hcl.Diagnostics) {
|
||||
ret := &Plugin{
|
||||
Hostname: "",
|
||||
|
|
|
|||
|
|
@ -7,5 +7,4 @@
|
|||
//
|
||||
// Checkout the files in testdata/complete/ to see what a packer config could
|
||||
// look like.
|
||||
//
|
||||
package hcl2template
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import (
|
|||
// basedir is used with file functions and allows a user to reference a file
|
||||
// using local path. Usually basedir is the directory in which the config file
|
||||
// is located
|
||||
//
|
||||
func Functions(basedir string) map[string]function.Function {
|
||||
|
||||
funcs := map[string]function.Function{
|
||||
|
|
|
|||
|
|
@ -67,11 +67,12 @@ func (b *SourceUseBlock) ctyValues() map[string]cty.Value {
|
|||
}
|
||||
|
||||
// decodeBuildSource reads a used source block from a build:
|
||||
// build {
|
||||
// source "type.example" {
|
||||
// name = "local_name"
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// build {
|
||||
// source "type.example" {
|
||||
// name = "local_name"
|
||||
// }
|
||||
// }
|
||||
func (p *Parser) decodeBuildSource(block *hcl.Block) (SourceUseBlock, hcl.Diagnostics) {
|
||||
ref := sourceRefFromString(block.Labels[0])
|
||||
out := SourceUseBlock{SourceRef: ref}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ import (
|
|||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
//MockPackerClientService represents a basic mock of the Cloud Packer Service.
|
||||
//Upon calling a service method a boolean is set to true to indicate that a method has been called.
|
||||
//To skip the setting of these booleans set TrackCalledServiceMethods to false; defaults to true in NewMockPackerClientService().
|
||||
// MockPackerClientService represents a basic mock of the Cloud Packer Service.
|
||||
// Upon calling a service method a boolean is set to true to indicate that a method has been called.
|
||||
// To skip the setting of these booleans set TrackCalledServiceMethods to false; defaults to true in NewMockPackerClientService().
|
||||
type MockPackerClientService struct {
|
||||
CreateBucketCalled, UpdateBucketCalled, BucketAlreadyExist bool
|
||||
CreateIterationCalled, GetIterationCalled, IterationAlreadyExist, IterationCompleted bool
|
||||
|
|
@ -39,9 +39,9 @@ type MockPackerClientService struct {
|
|||
packerSvc.ClientService
|
||||
}
|
||||
|
||||
//NewMockPackerClientService returns a basic mock of the Cloud Packer Service.
|
||||
//Upon calling a service method a boolean is set to true to indicate that a method has been called.
|
||||
//To skip the setting of these booleans set TrackCalledServiceMethods to false. By default it is true.
|
||||
// NewMockPackerClientService returns a basic mock of the Cloud Packer Service.
|
||||
// Upon calling a service method a boolean is set to true to indicate that a method has been called.
|
||||
// To skip the setting of these booleans set TrackCalledServiceMethods to false. By default it is true.
|
||||
func NewMockPackerClientService() *MockPackerClientService {
|
||||
m := MockPackerClientService{
|
||||
ExistingBuilds: make([]string, 0),
|
||||
|
|
|
|||
|
|
@ -64,12 +64,12 @@ func (i *Iteration) Initialize() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
//StoreBuild stores a build for buildName to an active iteration.
|
||||
// StoreBuild stores a build for buildName to an active iteration.
|
||||
func (i *Iteration) StoreBuild(buildName string, build *Build) {
|
||||
i.builds.Store(buildName, build)
|
||||
}
|
||||
|
||||
//Build gets the store build associated with buildName in the active iteration.
|
||||
// Build gets the store build associated with buildName in the active iteration.
|
||||
func (i *Iteration) Build(buildName string) (*Build, error) {
|
||||
build, ok := i.builds.Load(buildName)
|
||||
if !ok {
|
||||
|
|
@ -84,7 +84,7 @@ func (i *Iteration) Build(buildName string) (*Build, error) {
|
|||
return b, nil
|
||||
}
|
||||
|
||||
//HasBuild checks if iteration has a stored build associated with buildName.
|
||||
// HasBuild checks if iteration has a stored build associated with buildName.
|
||||
func (i *Iteration) HasBuild(buildName string) bool {
|
||||
_, ok := i.builds.Load(buildName)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Code generated by "enumer -type FixConfigMode"; DO NOT EDIT.
|
||||
|
||||
//
|
||||
package packer
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -386,8 +386,8 @@ func (e ChecksumFileEntry) Os() string { return e.os }
|
|||
func (e ChecksumFileEntry) Arch() string { return e.arch }
|
||||
|
||||
// a file inside will look like so:
|
||||
// packer-plugin-comment_v0.2.12_x5.0_freebsd_amd64.zip
|
||||
//
|
||||
// packer-plugin-comment_v0.2.12_x5.0_freebsd_amd64.zip
|
||||
func (e *ChecksumFileEntry) init(req *Requirement) (err error) {
|
||||
filename := e.Filename
|
||||
res := strings.TrimPrefix(filename, req.FilenamePrefix())
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// Code generated by "enumer -transform snake -trimprefix ExecutionPolicy -type ExecutionPolicy"; DO NOT EDIT.
|
||||
|
||||
//
|
||||
package powershell
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import (
|
|||
"github.com/hashicorp/packer-plugin-sdk/tmp"
|
||||
)
|
||||
|
||||
//FIXME query remote host or use %SYSTEMROOT%, %TEMP% and more creative filename
|
||||
// FIXME query remote host or use %SYSTEMROOT%, %TEMP% and more creative filename
|
||||
const DefaultRemotePath = "c:/Windows/Temp/script.bat"
|
||||
|
||||
type Config struct {
|
||||
|
|
|
|||
|
|
@ -99,10 +99,10 @@ type plugin struct {
|
|||
// makeMap creates a map named Name with type packer.Name that looks something
|
||||
// like this:
|
||||
//
|
||||
// var Builders = map[string]packersdk.Builder{
|
||||
// "amazon-chroot": new(chroot.Builder),
|
||||
// "amazon-ebs": new(ebs.Builder),
|
||||
// "amazon-instance": new(instance.Builder),
|
||||
// var Builders = map[string]packersdk.Builder{
|
||||
// "amazon-chroot": new(chroot.Builder),
|
||||
// "amazon-ebs": new(ebs.Builder),
|
||||
// "amazon-instance": new(instance.Builder),
|
||||
func makeMap(varName, varType string, items []plugin) string {
|
||||
output := ""
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue