Skip to content

Commit

Permalink
PRODENG-2204 convert to plugin framework
Browse files Browse the repository at this point in the history
- rebase on the scaffolding project
- move mirantis/mke/client to internal/client
- rewrite provider & client-bundle resource

ALSO
- client linting fixes
- ioutil deprecation
- standard Mirantis provider Makefile targets

Signed-off-by: James Nesbitt <[email protected]>
  • Loading branch information
james-nesbitt committed Aug 8, 2023
1 parent 77cd64f commit b838335
Show file tree
Hide file tree
Showing 94 changed files with 1,696 additions and 2,632 deletions.
29 changes: 29 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
*.dll
*.exe
.DS_Store
example.tf
terraform.tfplan
terraform.tfstate
bin/
dist/
modules-dev/
/pkg/
vendor
website/.vagrant
website/.bundle
website/build
website/node_modules
.vagrant/
*.backup
.git
.github
./*.tfstate
.terraform/
*.log
*.bak
*~
.*.swp
.idea
*.iml
*.test
*.iml
5 changes: 5 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Code of Conduct

HashiCorp Community Guidelines apply to you when interacting with the community here on GitHub and contributing code.

Please read the full text at https://www.hashicorp.com/community-guidelines
6 changes: 2 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ jobs:
runs-on: ubuntu-latest
env:
GOPRIVATE: github.com/Mirantis/mcc
GH_ACCESS_TOKEN: ${{ secrets.GH_MCC_ACCESS_TOKEN }}
GH_USERNAME: ${{ secrets.GH_MCC_USERNAME }}
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version: '1.20'
- name: Setup MCC gitub repo private access
run: git config --global url."https://$GH_USERNAME:$GH_ACCESS_TOKEN@github.com/".insteadOf "https://github.com/"
run: git config --global url."https://${{ secrets.GH_MCC_USERNAME }}:${{ secrets.GH_MCC_ACCESS_TOKEN }}@github.com/".insteadOf "https://github.com/"

- name: Build
run: go build -v ./...
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ jobs:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: 'Thank you for submitting an issue to the Mirantis Terraform Provider'
pr-message: 'Thank you for contributing to the Mirantis Terraform Provider'
issue-message: 'Thank you for submitting an issue to the Mirantis Launchpad Provider'
pr-message: 'Thank you for contributing to the Mirantis Launchpad Provider'
10 changes: 3 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ permissions:
jobs:
goreleaser:
runs-on: ubuntu-latest
env:
GH_ACCESS_TOKEN: ${{ secrets.GH_MCC_ACCESS_TOKEN }}
GH_USERNAME: ${{ secrets.GH_MCC_USERNAME }}

steps:
- name: Setup MCC gitub repo private access
run: git config --global url."https://$GH_USERNAME:$GH_ACCESS_TOKEN@github.com/".insteadOf "https://github.com/"
run: git config --global url."https://${{ secrets.GH_MCC_USERNAME }}:${{ secrets.GH_MCC_ACCESS_TOKEN }}@github.com/".insteadOf "https://github.com/"
-
name: Checkout
uses: actions/checkout@v3
Expand All @@ -47,11 +43,11 @@ jobs:
passphrase: ${{ secrets.GPG_PASSPHRASE }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4.2.0
uses: goreleaser/goreleaser-action@v4.3.0
with:
version: latest
args: release --rm-dist
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
# GitHub sets this automatically
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
pull-requests: write

steps:
- uses: actions/stale@v6
- uses: actions/stale@v8
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Stale issue message'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: 'Checkout'
uses: actions/checkout@v3
- name: 'Tag'
uses: anothrNick/github-tag-action@1.61.0
uses: anothrNick/github-tag-action@1.67.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Terraform Provider testing workflow.
name: Tests

# This GitHub action runs your tests for each pull request and push.
# Optionally, you can turn it on using a schedule for regular testing.
on:
pull_request:
paths-ignore:
- 'README.md'
push:
paths-ignore:
- 'README.md'

# Testing only needs permissions to read the repository contents.
permissions:
contents: read

jobs:
# Ensure project builds before running testing matrix
build:
name: Build
runs-on: ubuntu-latest
env:
GOPRIVATE: github.com/Mirantis/mcc
timeout-minutes: 5
steps:
- name: Setup MCC gitub repo private access
run: git config --global url."https://${{ secrets.GH_MCC_USERNAME }}:${{ secrets.GH_MCC_ACCESS_TOKEN }}@github.com/".insteadOf "https://github.com/"

- uses: actions/[email protected]
- uses: actions/[email protected]
with:
go-version-file: 'go.mod'
cache: true
- run: go mod download
- run: go build -v .
- name: Run linters
uses: golangci/[email protected]
with:
version: latest

generate:
runs-on: ubuntu-latest
env:
GOPRIVATE: github.com/Mirantis/mcc
steps:
- name: Setup MCC gitub repo private access
run: git config --global url."https://${{ secrets.GH_MCC_USERNAME }}:${{ secrets.GH_MCC_ACCESS_TOKEN }}@github.com/".insteadOf "https://github.com/"

- uses: actions/[email protected]
- uses: actions/[email protected]
with:
go-version-file: 'go.mod'
cache: 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)
# Run acceptance tests in a matrix with Terraform CLI versions
test:
name: Terraform Provider Acceptance Tests
needs: build
runs-on: ubuntu-latest
env:
GOPRIVATE: github.com/Mirantis/mcc
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# list whatever Terraform versions here you would like to support
terraform:
- '1.4.*'
steps:
- name: Setup MCC gitub repo private access
run: git config --global url."https://${{ secrets.GH_MCC_USERNAME }}:${{ secrets.GH_MCC_ACCESS_TOKEN }}@github.com/".insteadOf "https://github.com/"

- uses: actions/[email protected]
- uses: actions/[email protected]
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/[email protected]
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- run: go mod download
- name: run acceptance unit tests
run: TF_ACC=1 go test -v -cover ./internal/provider/
timeout-minutes: 10
37 changes: 35 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
# Go related ignores
bin
*.dll
*.exe
.DS_Store
example.tf
terraform.tfplan
terraform.tfstate
bin/
dist/
modules-dev/
/pkg/
vendor
website/.vagrant
website/.bundle
website/build
website/node_modules
.vagrant/
*.backup
./*.tfstate
.terraform/
*.log
*.bak
*~
.*.swp
.idea
*.iml
*.test
*.iml

website/vendor

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

# Keep windows files with windows line endings
*.winfile eol=crlf
26 changes: 26 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Visit https://golangci-lint.run/ for usage documentation
# and information on other useful linters
issues:
max-per-linter: 0
max-same-issues: 0

linters:
disable-all: true
enable:
- durationcheck
- errcheck
- exportloopref
- forcetypeassert
- gofmt
- gosimple
- ineffassign
- makezero
- misspell
- nilerr
- predeclared
- staticcheck
- tenv
- unconvert
- unparam
- unused
- vet
16 changes: 7 additions & 9 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ before:
# this is just an example and not a requirement for provider building/publishing
- go mod tidy
builds:
- main: ./cmd/mirantis-mke
id: "terraform-provider-mke"
binary: "terraform-provider-mke_v{{ .Version }}"
env:
- env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
Expand All @@ -19,9 +16,9 @@ builds:
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
goos:
- linux
- freebsd
- windows
- linux
- darwin
goarch:
- amd64
Expand All @@ -31,14 +28,15 @@ builds:
ignore:
- goos: darwin
goarch: '386'
binary: '{{ .ProjectName }}_v{{ .Version }}'
archives:
- format: zip
name_template: 'terraform-provider-mke_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
checksum:
extra_files:
- glob: 'terraform-registry-manifest.json'
name_template: 'terraform-provider-mke_{{ .Version }}_manifest.json'
name_template: 'terraform-provider-mke_{{ .Version }}_SHA256SUMS'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256
signs:
- artifacts: checksum
Expand All @@ -55,7 +53,7 @@ signs:
release:
extra_files:
- glob: 'terraform-registry-manifest.json'
name_template: 'terraform-provider-mke_{{ .Version }}_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:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## 0.1.0 (Unreleased)

FEATURES:

1. Initial mke config resource.

Loading

0 comments on commit b838335

Please sign in to comment.