Skip to content

Commit

Permalink
Merge branch 'master' into kustomize
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinbunney authored Dec 9, 2024
2 parents a8775dd + cb35f13 commit a0aaa5a
Show file tree
Hide file tree
Showing 55 changed files with 1,508 additions and 1,412 deletions.
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: "weekly"
groups:
gomod-deps:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
actions-deps:
patterns:
- "*"
107 changes: 82 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,88 +5,145 @@ on:
branches: [master]
pull_request:
branches: [master]

permissions:
contents: read
pull-requests: read

env:
GO_VERSION: 1.23

jobs:

build:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- uses: actions/checkout@v2
- name: Set up GO 1.16.x
uses: actions/setup-go@v1
- uses: actions/checkout@v4
- name: Set up GO ${{env.GO_VERSION}}.x
uses: actions/setup-go@v5
with:
go-version: '1.16'
go-version: ${{env.GO_VERSION}}
check-latest: true

- run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Setup Environment
run: make ci-build-setup
- name: Build
run: make build

test:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- uses: actions/checkout@v2
- name: Set up GO 1.16.x
uses: actions/setup-go@v1
- uses: actions/checkout@v4
- name: Set up GO ${{env.GO_VERSION}}.x
uses: actions/setup-go@v5
with:
go-version: '1.16'
go-version: ${{env.GO_VERSION}}
check-latest: true

- run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Setup Environment
run: make ci-build-setup
- name: Run unit tests
run: make test
- name: Archive code coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: test-code-coverage-report
path: build/test-coverage.html

testacc:
strategy:
matrix:
k3s_version:
- v1.31.2-k3s1
- v1.30.6-k3s1
- v1.29.10-k3s1
- v1.28.15-k3s1
- v1.27.16-k3s1
- v1.26.15-k3s1
- v1.25.16-k3s4
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- uses: actions/checkout@v2
- name: Set up GO 1.16.x
uses: actions/setup-go@v1
- uses: actions/checkout@v4
- name: Set up GO ${{env.GO_VERSION}}.x
uses: actions/setup-go@v5
with:
go-version: '1.16'
go-version: ${{env.GO_VERSION}}
check-latest: true

- run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Setup Environment
run: make ci-build-setup
- name: Start k3s
run: make k3s-start
env:
K3S_VERSION: ${{ matrix.k3s_version }}
- name: Run acceptance tests
run: make testacc
- name: Stop k3s
run: make k3s-stop
- name: Archive code coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: testacc-${{matrix.k3s_version}}-code-coverage-report
path: build/testacc-coverage.html

fmtcheck:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- uses: actions/checkout@v2
- name: Set up GO 1.16.x
uses: actions/setup-go@v1
- uses: actions/checkout@v4
- name: Set up GO ${{env.GO_VERSION}}.x
uses: actions/setup-go@v5
with:
go-version: '1.16'
go-version: ${{env.GO_VERSION}}
check-latest: true

- run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Setup Environment
run: make ci-build-setup
- name: Format check
run: make fmtcheck

vet:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- uses: actions/checkout@v2
- name: Set up GO 1.16.x
uses: actions/setup-go@v1
- uses: actions/checkout@v4
- name: Set up GO ${{env.GO_VERSION}}.x
uses: actions/setup-go@v5
with:
go-version: '1.16'
go-version: ${{env.GO_VERSION}}
check-latest: true

- run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Setup Environment
run: make ci-build-setup
- name: Run vet
run: make vet

golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up GO ${{env.GO_VERSION}}.x
uses: actions/setup-go@v5
with:
go-version: ${{env.GO_VERSION}}
check-latest: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
60 changes: 60 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Cache Images

on:
push:
paths:
- '.github/workflows/docker.yml'

jobs:
cache-images:
strategy:
matrix:
image:
- rancher/k3s:v1.31.2-k3s1
- rancher/k3s:v1.30.6-k3s1
- rancher/k3s:v1.29.10-k3s1
- rancher/k3s:v1.28.15-k3s1
- rancher/k3s:v1.27.16-k3s1
- rancher/k3s:v1.26.15-k3s1
- rancher/k3s:v1.25.16-k3s4
- registry:2
if: github.event.pull_request.user.login != 'dependabot[bot]' && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}

- name: Cache images
run: |
new_image_tag="ghcr.io/gavinbunney/terraform-provider-kubectl/testacc-$(echo '${{matrix.image}}' | sed 's/\//-/')"
echo "Caching ${{matrix.image}} as $new_image_tag"
docker rmi ${{matrix.image}} --force
docker pull ${{matrix.image}} --platform linux/amd64
docker tag ${{matrix.image}} $new_image_tag-amd64
docker push $new_image_tag-amd64
docker tag ${{matrix.image}} $new_image_tag-x86_64
docker push $new_image_tag-x86_64
docker rmi ${{matrix.image}} --force
docker pull ${{matrix.image}} --platform linux/arm64
docker tag ${{matrix.image}} $new_image_tag-arm64
docker push $new_image_tag-arm64
23 changes: 14 additions & 9 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,38 @@ on:
permissions:
contents: write

env:
GO_VERSION: 1.23

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
- name: Set up GO ${{env.GO_VERSION}}.x
uses: actions/setup-go@v5
with:
go-version: 1.16
go-version: ${{env.GO_VERSION}}
check-latest: true

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --rm-dist
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
- name: Upload assets
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
path: dist/*
34 changes: 7 additions & 27 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
*.dll
*.exe
.DS_Store
example.tf

build/
dist
scripts/kubeconfig.yaml

terraform.tfplan
terraform.tfstate
bin/
modules-dev/
/pkg/
website/.vagrant
website/.bundle
website/build
website/node_modules
.vagrant/

*.backup
./*.tfstate
/*.tfstate
.terraform/
*.log
*.bak
Expand All @@ -22,18 +17,3 @@ website/node_modules
.idea
*.iml
*.test
*.iml
dist

website/vendor

# Test exclusions
!command/test-fixtures/**/*.tfstate
!command/test-fixtures/**/.terraform/
**/terraform-provider-kubectl
k3s

node_modules/
docusaurus/website/build/
coverage.txt
scripts/kubeconfig.yaml
30 changes: 30 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
run:
timeout: 5m
output:
formats:
- format: line-number
path: stderr
- format: checkstyle
path: ./build/lint-report-checkstyle.xml
- format: html
path: ./build/lint-report.html

linters:
enable:
# default linters
#- errcheck
#- gosimple
#- govet
#- ineffassign
#- staticcheck
#- unused

# additional enabled
#- bodyclose
#- goconst
#- gosec
#- misspell
- prealloc

disable-all: true

Loading

0 comments on commit a0aaa5a

Please sign in to comment.