Skip to content

Commit 51ead6c

Browse files
committed
feat!: migrate to Terraform Plugin Framework
Follow the provider scaffolding https://github.com/hashicorp/terraform-provider-scaffolding-framework.
1 parent d61eee1 commit 51ead6c

25 files changed

Lines changed: 910 additions & 721 deletions

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @tensor5

.github/dependabot.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
# See GitHub's docs for more information on this file:
2-
# https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates
1+
# See GitHub's documentation for more information on this file:
2+
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
33
version: 2
44
updates:
5-
# Maintain dependencies for GitHub Actions
65
- package-ecosystem: "github-actions"
76
directory: "/"
87
schedule:
9-
# Check for updates to GitHub Actions every weekday
108
interval: "daily"
11-
12-
# Maintain dependencies for Go modules
139
- package-ecosystem: "gomod"
1410
directory: "/"
1511
schedule:
16-
# Check for updates to Go modules every weekday
1712
interval: "daily"

.github/workflows/release.yml

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
# This GitHub action can publish assets for release when a tag is created.
2-
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
3-
#
4-
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
5-
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
6-
# secret. If you would rather own your own GPG handling, please fork this action
7-
# or use an alternative one for key handling.
8-
#
9-
# You will need to pass the `--batch` flag to `gpg` in your signing step
10-
# in `goreleaser` to indicate this is being used in a non-interactive mode.
11-
#
1+
# Terraform Provider release workflow.
122
name: Release
133

144
on:
@@ -37,27 +27,26 @@ jobs:
3727
needs: release-please
3828
runs-on: ubuntu-22.04
3929
steps:
40-
- name: Checkout
41-
uses: actions/checkout@v3
42-
- name: Unshallow
43-
run: git fetch --prune --unshallow
44-
- name: Set up Go
45-
uses: actions/setup-go@v3
30+
- uses: actions/checkout@v3
4631
with:
32+
# Allow goreleaser to access older tag information.
33+
fetch-depth: 0
34+
- uses: actions/setup-go@v3
35+
with:
36+
cache: true
4737
go-version-file: go.mod
4838
- name: Import GPG key
4939
uses: crazy-max/ghaction-import-gpg@v5
5040
id: import_gpg
5141
with:
42+
fingerprint: ${{ secrets.GPG_FINGERPRINT }}
5243
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
5344
passphrase: ${{ secrets.GPG_PASSPHRASE }}
54-
fingerprint: ${{ secrets.GPG_FINGERPRINT }}
5545
- name: Run GoReleaser
56-
uses: goreleaser/goreleaser-action@v3.1.0
46+
uses: goreleaser/goreleaser-action@v3
5747
with:
58-
version: latest
5948
args: release --rm-dist
6049
env:
61-
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
62-
# GitHub sets this automatically
50+
# GitHub sets the GITHUB_TOKEN secret automatically.
6351
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

.github/workflows/test.yml

Lines changed: 42 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,52 @@
1-
# This GitHub action runs your tests for each commit push and/or PR. Optionally
2-
# you can turn it on using a cron schedule for regular testing.
3-
#
1+
# Terraform Provider testing workflow.
42
name: Tests
3+
4+
# This GitHub action runs your tests for each pull request and push.
5+
# Optionally, you can turn it on using a schedule for regular testing.
56
on:
67
pull_request:
78
paths-ignore:
89
- "README.md"
910
push:
1011
paths-ignore:
1112
- "README.md"
12-
# For systems with an upstream API that could drift unexpectedly (like most SaaS systems, etc.),
13-
# we recommend testing at a regular interval not necessarily tied to code changes. This will
14-
# ensure you are alerted to something breaking due to an API change, even if the code did not
15-
# change.
16-
# schedule:
17-
# - cron: '0 13 * * *'
13+
14+
# Testing only needs permissions to read the repository contents.
15+
permissions:
16+
contents: read
17+
1818
jobs:
19-
# ensure the code builds...
19+
# Ensure project builds before running testing matrix
2020
build:
2121
name: Build
2222
runs-on: ubuntu-latest
2323
timeout-minutes: 5
2424
steps:
25-
- name: Check out code into the Go module directory
26-
uses: actions/checkout@v3
27-
28-
- name: Set up Go
29-
uses: actions/setup-go@v3
25+
- uses: actions/checkout@v3
26+
- uses: actions/setup-go@v3
3027
with:
31-
go-version-file: go.mod
32-
id: go
33-
34-
- name: Get dependencies
35-
run: |
36-
go mod download
28+
go-version-file: "go.mod"
29+
cache: true
30+
- run: go mod download
31+
- run: go build -v .
3732

38-
- name: Build
33+
generate:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v3
37+
- uses: actions/setup-go@v3
38+
with:
39+
go-version-file: "go.mod"
40+
cache: true
41+
- run: go generate ./...
42+
- name: git diff
3943
run: |
40-
go build -v .
44+
git diff --compact-summary --exit-code || \
45+
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
4146
42-
# run acceptance tests in a matrix with Terraform core versions
47+
# Run acceptance tests in a matrix with Terraform CLI versions
4348
test:
44-
name: Matrix Test
49+
name: Terraform Provider Acceptance Tests
4550
needs: build
4651
runs-on: ubuntu-latest
4752
timeout-minutes: 15
@@ -54,29 +59,17 @@ jobs:
5459
- "1.1.*"
5560
- "1.2.*"
5661
steps:
57-
- name: Check out code into the Go module directory
58-
uses: actions/checkout@v3
59-
60-
- name: Set up Go
61-
uses: actions/setup-go@v3
62+
- uses: actions/checkout@v3
63+
- uses: actions/setup-go@v3
6264
with:
63-
go-version-file: go.mod
64-
id: go
65-
66-
- name: Get dependencies
67-
run: |
68-
go mod download
69-
70-
- name: TF acceptance tests
71-
timeout-minutes: 10
72-
env:
65+
go-version-file: "go.mod"
66+
cache: true
67+
- uses: hashicorp/setup-terraform@v2
68+
with:
69+
terraform_version: ${{ matrix.terraform }}
70+
terraform_wrapper: false
71+
- run: go mod download
72+
- env:
7373
TF_ACC: "1"
74-
TF_ACC_TERRAFORM_VERSION: ${{ matrix.terraform }}
75-
76-
# Set whatever additional acceptance test env vars here. You can
77-
# optionally use data from your repository secrets using the
78-
# following syntax:
79-
# SOME_VAR: ${{ secrets.SOME_VAR }}
80-
81-
run: |
82-
go test -v -cover ./internal/provider/
74+
run: go test -v -cover ./internal/provider/
75+
timeout-minutes: 10

.goreleaser.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ builds:
1616
ldflags:
1717
- "-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}"
1818
goos:
19+
- freebsd
1920
- windows
2021
- linux
2122
- darwin
@@ -53,3 +54,7 @@ release:
5354
extra_files:
5455
- glob: "terraform-registry-manifest.json"
5556
name_template: "{{ .ProjectName }}_{{ .Version }}_manifest.json"
57+
# If you want to manually examine the release before its live, uncomment this line:
58+
# draft: true
59+
changelog:
60+
skip: true

GNUmakefile

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,5 @@
1-
2-
GIT_VERSION ?= $(shell git describe --tags --always --dirty 2> /dev/null)
3-
VERSION = $(shell echo $(GIT_VERSION) | sed 's/^v//' | sed 's/-.*//')
4-
5-
PROVIDER_HOSTNAME=github.com
6-
PROVIDER_NAMESPACE=tensor5
7-
PROVIDER_TYPE=talos
8-
PROVIDER_TARGET=$(shell go env GOOS)_$(shell go env GOARCH)
9-
PROVIDER_PATH=~/.terraform.d/plugins/$(PROVIDER_HOSTNAME)/$(PROVIDER_NAMESPACE)/$(PROVIDER_TYPE)/$(VERSION)/$(PROVIDER_TARGET)
10-
111
default: testacc
122

13-
build:
14-
@mkdir -p $(PROVIDER_PATH)
15-
go build \
16-
-tags release \
17-
-ldflags '-X $(MODULE)/internal/config.Version=$(GIT_VERSION)' \
18-
-o $(PROVIDER_PATH)/terraform-provider-$(PROVIDER_TYPE)_v$(VERSION)
19-
20-
.PHONY: docs
21-
docs:
22-
go generate
23-
243
# Run acceptance tests
254
.PHONY: testacc
265
testacc:

docs/data-sources/kubeconfig.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ Download the kubeconfig information from a Talos node.
2727
- `client_certificate` (String) PEM-encoded client certificate for TLS authentication.
2828
- `client_key` (String) PEM-encoded client certificate key for TLS authentication.
2929
- `cluster_ca_certificate` (String) PEM-encoded root certificates bundle for TLS authentication.
30-
- `id` (String) The ID of this resource.
3130
- `raw` (String) Content of kubeconfig file.
3231

3332

docs/resources/bootstrap.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ Bootstrap a Talos cluster and download kubeconfig.
2727
- `client_certificate` (String) PEM-encoded client certificate for TLS authentication.
2828
- `client_key` (String) PEM-encoded client certificate key for TLS authentication.
2929
- `cluster_ca_certificate` (String) PEM-encoded root certificates bundle for TLS authentication.
30-
- `id` (String) The ID of this resource.
3130
- `raw` (String) Content of kubeconfig file.
3231

3332

docs/resources/gen_config.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Generates a configuration for Talos cluster.
2929
- `dns_domain` (String) The dns domain to use for cluster.
3030
- `install_disk` (String) The disk to install to.
3131
- `install_image` (String) The image used to perform an installation.
32-
- `kubernetes_version` (String) Desired kubernetes version to run (default "1.24.3").
32+
- `kubernetes_version` (String) Desired kubernetes version to run (default "1.25.1").
3333
- `persist` (Boolean) The desired persist value for configs.
3434
- `registry_mirrors` (Map of String) List of registry mirrors to use in format: <registry host>=<mirror URL>.
3535
- `talos_version` (String) The desired Talos version to generate config for (backwards compatibility, e.g. v0.8).
@@ -38,9 +38,8 @@ Generates a configuration for Talos cluster.
3838

3939
### Read-Only
4040

41-
- `control_plane_config` (String)
42-
- `id` (String) The ID of this resource.
43-
- `talos_config` (String)
44-
- `worker_config` (String)
41+
- `control_plane_config` (String, Sensitive)
42+
- `talos_config` (String, Sensitive)
43+
- `worker_config` (String, Sensitive)
4544

4645

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
resource "digitalocean_droplet" "control_plane" {
22
count = var.control_plane_number
33

4-
image = digitalocean_custom_image.talos.id
5-
name = "talos-control-plane-${count.index}"
6-
region = var.region
7-
size = var.control_plane_size
8-
ssh_keys = [var.ssh_key_fingerprint]
9-
tags = [var.control_plane_tag]
10-
user_data = talos_gen_config.config.control_plane_config
4+
image = digitalocean_custom_image.talos.id
5+
name = "talos-control-plane-${count.index}"
6+
region = var.region
7+
size = var.control_plane_size
8+
ssh_keys = [var.ssh_key_fingerprint]
9+
tags = [var.control_plane_tag]
10+
user_data = talos_gen_config.config.control_plane_config
1111
}

0 commit comments

Comments
 (0)