Skip to content

Commit 2e3fd14

Browse files
chore: Update golang to 1.24, add tools usage, update libraries to recent versions, remove deprecated libraries and fix linting (#163)
## What ## Why ## Notes <!-- Add any notes here --> ## Checklist * [ ] _I have read [CONTRIBUTING.md](https://github.com/codefresh-io/terraform-provider-codefresh/blob/master/CONTRIBUTING.md)._ * [ ] _I have [allowed changes to my fork to be made](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork)._ * [ ] _I have added tests, assuming new tests are warranted_. * [ ] _I understand that the `/test` comment will be ignored by the CI trigger [unless it is made by a repo admin or collaborator](https://codefresh.io/docs/docs/pipelines/triggers/git-triggers/#support-for-building-pull-requests-from-forks)._
1 parent 2945191 commit 2e3fd14

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1502
-1392
lines changed

.github/workflows/pull_request.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ jobs:
1313
- name: Generate Docs
1414
run: |
1515
export PATH=$PATH:/home/runner/go/bin
16-
make docs-prepare
17-
tfplugindocs generate
16+
make docs
1817
- name: Validate No Changes
1918
run: |
2019
git diff --exit-code

GNUmakefile

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,9 @@ PKG_NAME=codefresh
66
NAMESPACE=app
77
BINARY=terraform-provider-${PKG_NAME}
88
OS_ARCH=darwin_amd64
9-
TFPLUGINDOCS_VERSION=v0.14.1
109

1110
default: build
1211

13-
tools:
14-
GO111MODULE=on go install github.com/client9/misspell/cmd/misspell
15-
GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint
16-
GO111MODULE=on go install github.com/bflad/tfproviderlint/cmd/tfproviderlint
17-
1812
build: fmtcheck
1913
go install
2014
go build -o ${BINARY}
@@ -31,7 +25,7 @@ fmtcheck:
3125

3226
lint:
3327
@echo "==> Checking source code against linters..."
34-
golangci-lint run ./...
28+
go tool golangci-lint run ./...
3529

3630
test: fmtcheck
3731
go test -i $(TEST) || exit 1
@@ -58,13 +52,8 @@ vet:
5852
exit 1; \
5953
fi
6054

61-
docs-prepare:
62-
@echo "==> Setting up tfplugindocs..."
63-
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@${TFPLUGINDOCS_VERSION}
64-
65-
docs: docs-prepare
55+
docs:
6656
@echo "==> Generating Provider Documentation..."
67-
tfplugindocs generate
68-
69-
.PHONY: build test testacc vet fmt fmtcheck lint tools test-compile docs docs-prepare
57+
go tool tfplugindocs generate
7058

59+
.PHONY: build test testacc vet fmt fmtcheck lint test-compile docs docs-prepare

codefresh.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ steps:
1515
go_fmt:
1616
title: "Formatting"
1717
stage: test
18-
image: goreleaser/goreleaser:v1.17.0
18+
image: golang:1.24.3-alpine3.21
1919
commands:
2020
- go fmt
2121

2222
go_test:
2323
title: "Run tests"
2424
stage: test
25-
image: golang:1.18.10-alpine3.17
25+
image: golang:1.24.3-alpine3.21
2626
environment:
2727
- TF_ACC="test"
2828
- CGO_ENABLED=0
@@ -39,7 +39,7 @@ steps:
3939
# The following will resolve to their latest patch version
4040
environment:
4141
- TF_VERSION=1.3.0
42-
- TF_VERSION=1.7.0
42+
- TF_VERSION=1.11.4
4343
when:
4444
condition:
4545
all:

codefresh/cfclient/account.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"errors"
55
"fmt"
66

7-
"github.com/imdario/mergo"
7+
"dario.cat/mergo"
88
)
99

1010
type DockerRegistry struct {

codefresh/cfclient/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99
"strings"
1010
)
@@ -71,7 +71,7 @@ func (client *Client) RequestAPI(opt *RequestOptions) ([]byte, error) {
7171
}
7272
defer resp.Body.Close()
7373

74-
body, err := ioutil.ReadAll(resp.Body)
74+
body, err := io.ReadAll(resp.Body)
7575
if err != nil {
7676
return nil, fmt.Errorf("Failed to read body %v %v", resp.StatusCode, resp.Status)
7777
}
@@ -103,7 +103,7 @@ func (client *Client) RequestApiXAccessToken(opt *RequestOptions) ([]byte, error
103103
}
104104
defer resp.Body.Close()
105105

106-
body, err := ioutil.ReadAll(resp.Body)
106+
body, err := io.ReadAll(resp.Body)
107107
if err != nil {
108108
return nil, fmt.Errorf("Failed to read body %v %v", resp.StatusCode, resp.Status)
109109
}

codefresh/cfclient/context.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import (
44
"fmt"
55
"log"
66
"net/url"
7-
8-
"golang.org/x/exp/slices"
7+
"slices"
98
)
109

1110
var encryptedContextTypes = []string{

codefresh/cfclient/current_account.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66

77
"github.com/stretchr/objx"
8-
"golang.org/x/exp/slices"
8+
"slices"
99
)
1010

1111
// CurrentAccountUser spec

codefresh/cfclient/gql_client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"encoding/json"
66
"errors"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99
)
1010

@@ -38,7 +38,7 @@ func (client *Client) SendGqlRequest(request GraphQLRequest) ([]byte, error) {
3838
return nil, err
3939
}
4040
if resp.StatusCode >= 400 {
41-
bodyBytes, _ := ioutil.ReadAll(resp.Body)
41+
bodyBytes, _ := io.ReadAll(resp.Body)
4242
return nil, errors.New(resp.Status + " " + string(bodyBytes))
4343
}
4444
defer resp.Body.Close()

codefresh/cfclient/idp.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cfclient
22

33
import (
4-
"errors"
54
"fmt"
65
"log"
76
"net/url"
@@ -237,7 +236,7 @@ func (client *Client) GetIdpByName(idpName string) (*IDP, error) {
237236
}
238237
}
239238

240-
return nil, errors.New(fmt.Sprintf("[ERROR] IDP with name %s isn't found.", idpName))
239+
return nil, fmt.Errorf("[ERROR] IDP with name %s isn't found.", idpName)
241240
}
242241

243242
func (client *Client) GetIdpByID(idpID string) (*IDP, error) {
@@ -253,7 +252,7 @@ func (client *Client) GetIdpByID(idpID string) (*IDP, error) {
253252
}
254253
}
255254

256-
return nil, errors.New(fmt.Sprintf("[ERROR] IDP with ID %s isn't found.", idpID))
255+
return nil, fmt.Errorf("[ERROR] IDP with ID %s isn't found.", idpID)
257256
}
258257

259258
// get account idps
@@ -293,7 +292,7 @@ func (client *Client) GetAccountIdpByID(idpID string) (*IDP, error) {
293292
}
294293
}
295294

296-
return nil, errors.New(fmt.Sprintf("[ERROR] IDP with ID %s isn't found.", idpID))
295+
return nil, fmt.Errorf("[ERROR] IDP with ID %s isn't found.", idpID)
297296
}
298297

299298
// add account to idp

codefresh/cfclient/service_user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package cfclient
22

33
import (
44
"fmt"
5-
"golang.org/x/exp/slices"
5+
"slices"
66
)
77

88
type ServiceUserTeam struct {

0 commit comments

Comments
 (0)