Skip to content

Commit

Permalink
Merge pull request #60 from cpanato/updates
Browse files Browse the repository at this point in the history
Upgrade to go1.20 and other ci updates
  • Loading branch information
imjasonh authored Mar 20, 2023
2 parents 5ee8df0 + 3d7c22e commit 66dab94
Show file tree
Hide file tree
Showing 16 changed files with 176 additions and 118 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build
on:
pull_request:
branches: ['main']
push:
branches: ['main']

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version: '1.20'
check-latest: true
- uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b # v4.2.0
with:
version: latest
args: release --clean --snapshot --skip-sign
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 7 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@ jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
- run: git fetch --prune --unshallow
- uses: actions/setup-go@v3
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version-file: 'go.mod'
go-version: '1.20'
check-latest: true
cache: true

- id: import_gpg
uses: crazy-max/ghaction-import-gpg@v5
uses: crazy-max/ghaction-import-gpg@111c56156bcc6918c056dbef52164cfa583dc549 # v5.2.0
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}

- uses: goreleaser/[email protected]
- uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b # v4.2.0
with:
version: latest
args: release --rm-dist
args: release --clean
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46 changes: 24 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.18'
- run: go generate ./...
- name: git diff
run: |
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
- uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version: '1.20'
check-latest: true
- run: go generate ./...
- name: git diff
run: |
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
test:
name: Test
Expand All @@ -26,19 +27,20 @@ jobs:
fail-fast: false
matrix:
terraform:
- '1.0.*'
- '1.1.*'
- '1.3.*'
- '1.4.*'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.18'
- uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version: '1.20'
check-latest: true

- uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false

- run: go mod download
- run: go build -v .
- run: TF_ACC=1 go test -v -cover ./internal/provider/
- run: go mod download
- run: go build -v .
- run: TF_ACC=1 go test -v -cover ./internal/provider/
24 changes: 24 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: verify

on:
pull_request:
branches: ['main']
push:
branches: ['main']


jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version: '1.20'
check-latest: true
- name: golangci-lint
uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5 # v3.4.0
with:
version: v1.51
args: --timeout=5m
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ website/vendor
*.winfile eol=crlf

terraform-provider-ko
.terraform.lock.hcl
.terraform.lock.hcl
26 changes: 26 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
run:
timeout: 5m

issues:
exclude-rules:
- path: test # Excludes /test, *_test.go etc.
linters:
- gosec

linters:
enable:
- asciicheck
- depguard
- errorlint
- gofmt
- gosec
- goimports
- importas
- prealloc
- revive
- misspell
- stylecheck
- tparallel
- unconvert
- unparam
- whitespace
58 changes: 32 additions & 26 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
before:

hooks:
- go mod tidy -compat=1.17
- go mod tidy
- /bin/bash -c 'if [ -n "$(git --no-pager diff --exit-code go.mod go.sum)" ]; then exit 1; fi'

builds:
- env:
- CGO_ENABLED=0
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
goos:
- freebsd
- windows
- linux
- darwin
goarch:
- amd64
- '386'
- arm
- arm64
ignore:
- goos: darwin
goarch: '386'
binary: '{{ .ProjectName }}_v{{ .Version }}'
- env:
- CGO_ENABLED=0
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
goos:
- freebsd
- windows
- linux
- darwin
goarch:
- amd64
- '386'
- arm
- arm64
ignore:
- goos: darwin
goarch: '386'
binary: '{{ .ProjectName }}_v{{ .Version }}'

archives:
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'

checksum:
extra_files:
- glob: 'terraform-registry-manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256

signs:
- artifacts: checksum
args:
Expand All @@ -42,11 +48,11 @@ signs:
- "${signature}"
- "--detach-sign"
- "${artifact}"

release:
extra_files:
- glob: 'terraform-registry-manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
# If you want to manually examine the release before its live, uncomment this line:
# draft: true

changelog:
skip: true
2 changes: 1 addition & 1 deletion docs/resources/resolve.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ output "manifests" {

### Required

- `filenames` (List of String) Filenames, directorys, or URLs to files to use to create the resource
- `filenames` (List of String) Filenames, directories, or URLs to files to use to create the resource

### Optional

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ko-build/terraform-provider-ko

go 1.18
go 1.20

require (
github.com/aws/aws-lambda-go v1.38.0
Expand Down
13 changes: 6 additions & 7 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

var changed = false

func init() {
// Set descriptions to support markdown syntax, this will be used in document generation
// and the language server.
Expand Down Expand Up @@ -66,7 +64,8 @@ func New(version string) func() *schema.Provider {
}

// configure initializes the global provider with sensible defaults (that mimic what ko does with cli/cobra defaults)
func configure(version string, p *schema.Provider) func(context.Context, *schema.ResourceData) (interface{}, diag.Diagnostics) {
// TODO: review input parameters
func configure(version string, p *schema.Provider) func(context.Context, *schema.ResourceData) (interface{}, diag.Diagnostics) { //nolint: revive
return func(ctx context.Context, s *schema.ResourceData) (interface{}, diag.Diagnostics) {
koDockerRepo, ok := s.Get("repo").(string)
if !ok {
Expand All @@ -93,7 +92,7 @@ func configure(version string, p *schema.Provider) func(context.Context, *schema
}
}

return &providerOpts{
return &Opts{
bo: &options.BuildOptions{},
po: &options.PublishOptions{
DockerRepo: koDockerRepo,
Expand All @@ -103,14 +102,14 @@ func configure(version string, p *schema.Provider) func(context.Context, *schema
}
}

type providerOpts struct {
type Opts struct {
bo *options.BuildOptions
po *options.PublishOptions
auth *authn.Basic
}

func NewProviderOpts(meta interface{}) (*providerOpts, error) {
opts, ok := meta.(*providerOpts)
func NewProviderOpts(meta interface{}) (*Opts, error) {
opts, ok := meta.(*Opts)
if !ok {
return nil, fmt.Errorf("parsing provider args: %v", meta)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

var providerFactories = map[string]func() (*schema.Provider, error){
"ko": func() (*schema.Provider, error) {
"ko": func() (*schema.Provider, error) { //nolint: unparam
return New("dev")(), nil
},
}
Expand Down
Loading

0 comments on commit 66dab94

Please sign in to comment.