Skip to content

Commit

Permalink
Go 1.19 (#527)
Browse files Browse the repository at this point in the history
* Bump golang to 1.19

* Bump golangci-lint for 1.19 support

* Lint/Format

* Ignore tfproviderlint until bflad/tfproviderlint#255 is fixed

* Bump golang in CI
  • Loading branch information
tobio authored Aug 29, 2022
1 parent ef227ba commit 2ee0f61
Show file tree
Hide file tree
Showing 20 changed files with 97 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .ci/pipelines/acceptance.Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env groovy

node('docker && gobld/machineType:n1-highcpu-8') {
String DOCKER_IMAGE = "golang:1.17"
String DOCKER_IMAGE = "golang:1.19"
String APP_PATH = "/go/src/github.com/elastic/terraform-provider-ec"

stage('Checkout from GitHub') {
Expand Down
2 changes: 1 addition & 1 deletion .ci/pipelines/release.Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env groovy

node('docker && gobld/machineType:n1-highcpu-8') {
String DOCKER_IMAGE = "golang:1.17"
String DOCKER_IMAGE = "golang:1.19"
String APP_PATH = "/go/src/github.com/elastic/terraform-provider-ec"

stage('Checkout from GitHub') {
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version: 1.19
id: go

- name: Bump main version
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version: 1.19
id: go

- name: Bump main version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/changelog_generation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version: 1.19
id: go

- run: make changelog vendor
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version: 1.19
id: go

- name: Check out code into the Go module directory
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Linters
run: make lint
id: lint

- name: Run unit tests
run: make unit
id: unit
Expand Down
3 changes: 0 additions & 3 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
linters:
disable-all: true
enable:
- deadcode
- errcheck
- gofmt
- gosimple
- ineffassign
- misspell
- staticcheck
- structcheck
- unconvert
- unused
- varcheck
- vet

linters-settings:
Expand Down
2 changes: 1 addition & 1 deletion build/Makefile.deps
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ VERSION_DIR:=$(GOBIN)/versions

VERSION_GOLINT:=v0.0.0-20191125180803-fdd1cda4f05f
VERSION_GOLICENSER:=v0.3.0
VERSION_GOLANGCILINT:=v1.40.1
VERSION_GOLANGCILINT:=v1.49.0
VERSION_GORELEASER:=v1.2.5
VERSION_GOCHANGELOG:=v0.0.0-20201005170154-56335215ce3a
VERSION_VERSIONBUMP:=v1.1.0
Expand Down
7 changes: 4 additions & 3 deletions build/Makefile.lint
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ lint: golint golangci-lint check-license tfproviderlint tfproviderdocs terrafmt

.PHONY: tfproviderlint
tfproviderlint: tools
@ echo "-> Checking source code against terraform provider linters..."
@ $(GOBIN)/tfproviderlint ./...
@ echo '-> Ignoring tfproviderlint until https://github.com/bflad/tfproviderlint/issues/255 is fixed...'
#@ echo "-> Checking source code against terraform provider linters..."
#@ $(GOBIN)/tfproviderlint ./...

.PHONY: tfproviderdocs
tfproviderdocs: tools
Expand Down Expand Up @@ -39,4 +40,4 @@ validate-examples:
## Formats all the terraform ".tf" files in the repository
fmt:
@ echo "-> Checking that the terraform .tf files are formatted..."
@ terraform fmt -write=false -recursive -check
@ terraform fmt -write=false -recursive -check
2 changes: 1 addition & 1 deletion build/Makefile.tools
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

VERSION_TFPROVIDERDOCS:=v0.6.0
VERSION_TERRAFMT:=12db38d
VERSION_TFPROVIDERLINT:=v0.14.0
VERSION_TFPROVIDERLINT:=v0.28.1

## Installs the required static checks for terraform.
tools: $(GOBIN)/tfproviderdocs $(GOBIN)/terrafmt $(GOBIN)/tfproviderlint
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_failed_upgrade_retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"regexp"
"testing"

"github.com/blang/semver/v4"
semver "github.com/blang/semver/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)
Expand Down
3 changes: 2 additions & 1 deletion ec/acc/deployment_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ func readEsCredentials(t *testing.T, esCreds *creds) resource.TestCheckFunc {
}
}

// nolint, remove comment after the test is unskipped.
// remove comment after the test is unskipped.
// nolint
func triggerSnapshot(t *testing.T, esCreds *creds) func() {
t.Helper()
return func() {
Expand Down
4 changes: 2 additions & 2 deletions ec/ecresource/deploymentresource/expanders.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"sort"

"github.com/blang/semver/v4"
semver "github.com/blang/semver/v4"
"github.com/elastic/cloud-sdk-go/pkg/api"
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/deptemplateapi"
"github.com/elastic/cloud-sdk-go/pkg/models"
Expand Down Expand Up @@ -307,7 +307,7 @@ func ensurePartialSnapshotStrategy(ess []*models.ElasticsearchPayload) {
// migrated over to node_roles. Which will be true when:
// * The version field doesn't change.
// * The version field changes but:
// * The Elasticsearch.0.toplogy doesn't have any node_type_* set.
// - The Elasticsearch.0.toplogy doesn't have any node_type_* set.
func legacyToNodeRoles(d *schema.ResourceData) (bool, error) {
if !d.HasChange("version") {
return true, nil
Expand Down
3 changes: 1 addition & 2 deletions ec/ecresource/deploymentresource/expanders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"bytes"
"errors"
"io"
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -50,7 +49,7 @@ func fileAsResponseBody(t *testing.T, name string) io.ReadCloser {
}
buf.WriteString("\n")

return ioutil.NopCloser(buf)
return io.NopCloser(buf)
}

func Test_createResourceToModel(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion ec/ecresource/deploymentresource/flatteners.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"fmt"
"strings"

"github.com/blang/semver/v4"
semver "github.com/blang/semver/v4"
"github.com/elastic/cloud-sdk-go/pkg/models"
"github.com/elastic/cloud-sdk-go/pkg/multierror"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down
2 changes: 1 addition & 1 deletion ec/ecresource/deploymentresource/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"errors"
"fmt"

"github.com/blang/semver/v4"
semver "github.com/blang/semver/v4"
"github.com/elastic/cloud-sdk-go/pkg/api"
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi"
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/deputil"
Expand Down
6 changes: 3 additions & 3 deletions ec/ecresource/deploymentresource/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ func mapSelfToDeploymentID(value string, deploymentID string) string {
}

// suppressMissingOptionalConfigurationBlock handles configuration block attributes in the following scenario:
// * The resource schema includes an optional configuration block with defaults
// * The API response includes those defaults to refresh into the Terraform state
// * The operator's configuration omits the optional configuration block
// - The resource schema includes an optional configuration block with defaults
// - The API response includes those defaults to refresh into the Terraform state
// - The operator's configuration omits the optional configuration block
func suppressMissingOptionalConfigurationBlock(k, old, new string, d *schema.ResourceData) bool {
return old == "1" && new == "0"
}
5 changes: 2 additions & 3 deletions ec/ecresource/deploymentresource/testutil_func_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package deploymentresource

import (
"io/ioutil"
"os"
"testing"

Expand All @@ -28,13 +27,13 @@ import (
)

func Test_parseDeploymentTemplate(t *testing.T) {
var contents = `{"id": "deployment-template-name","deployment_template":
var contents = `{"id": "deployment-template-name","deployment_template":
{"resources": {
"elasticsearch": [{
"plan": { "deployment_template": {}}
}]
}}}`
if err := ioutil.WriteFile("test.json", []byte(contents), 0660); err != nil {
if err := os.WriteFile("test.json", []byte(contents), 0660); err != nil {
t.Fatal(err)
}
defer os.Remove("test.json")
Expand Down
5 changes: 2 additions & 3 deletions ec/provider_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package ec
import (
"errors"
"fmt"
"io/ioutil"
"net/http"
"os"
"path/filepath"
Expand All @@ -37,7 +36,7 @@ import (
)

func Test_verboseSettings(t *testing.T) {
f, err := ioutil.TempFile("", "request")
f, err := os.CreateTemp("", "request")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -161,7 +160,7 @@ func Test_newAPIConfig(t *testing.T) {
os.Remove("request.log")
}()

customFile, err := ioutil.TempFile("", "request-custom-verbose")
customFile, err := os.CreateTemp("", "request-custom-verbose")
if err != nil {
t.Fatal(err)
}
Expand Down
70 changes: 69 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/elastic/terraform-provider-ec

go 1.16
go 1.19

require (
github.com/blang/semver/v4 v4.0.0
Expand All @@ -10,3 +10,71 @@ require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.20.0
github.com/stretchr/testify v1.8.0
)

require (
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-cidr v1.1.0 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/go-openapi/analysis v0.21.2 // indirect
github.com/go-openapi/errors v0.20.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/loads v0.21.1 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/go-openapi/validate v0.21.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.2.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.4.4 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hc-install v0.4.0 // indirect
github.com/hashicorp/hcl/v2 v2.13.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.17.2 // indirect
github.com/hashicorp/terraform-json v0.14.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.12.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.7.0 // indirect
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
github.com/vmihailenco/tagparser v0.1.1 // indirect
github.com/zclconf/go-cty v1.10.0 // indirect
go.mongodb.org/mongo-driver v1.10.0 // indirect
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/genproto v0.0.0-20200711021454-869866162049 // indirect
google.golang.org/grpc v1.48.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 2ee0f61

Please sign in to comment.