Merge pull request #12380 from hashicorp/bump-go-1.20

Bump Go tooling to version 1.20
pull/12390/head
Wilken Rivera 3 years ago committed by Wilken Rivera
parent 3bdf7d3bde
commit c12c47f09d

@ -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@v2
- uses: actions/setup-go@v2
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@v2
- uses: actions/setup-go@v2
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@v2
- uses: actions/setup-go@v2
with:
go-version: '1.18'
go-version: ${{ needs.get-go-version.outputs.go-version }}
- run: go test ./... -coverprofile=coverage.txt -covermode=atomic

@ -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@v2
- uses: actions/setup-go@v2
- 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@v2
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@v2
- uses: actions/setup-go@v2
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@v2
- uses: actions/setup-go@v2
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

@ -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 \

@ -50,6 +50,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 (

@ -185,7 +185,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().

@ -255,4 +255,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)
go 1.18
go 1.20

@ -94,9 +94,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: "",

@ -4,5 +4,4 @@
//
// Checkout the files in testdata/complete/ to see what a packer config could
// look like.
//
package hcl2template

@ -24,7 +24,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{

@ -64,11 +64,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}

@ -13,9 +13,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
@ -36,9 +36,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),

@ -97,12 +97,12 @@ func GetGitFingerprint(opts IterationOptions) (string, error) {
return ref.Hash().String(), 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 {
@ -117,7 +117,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 (

@ -383,8 +383,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 (

@ -25,7 +25,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 {

@ -96,10 +96,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…
Cancel
Save