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

+910
-721
lines changed

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @tensor5

.github/dependabot.yml

+2-7
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

+11-22
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

+42-49
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

+5
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

-21
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

-1
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

-1
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

+4-5
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

+7-7
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
}

examples/digitalocean/worker.tf

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
resource "digitalocean_droplet" "worker" {
22
count = var.worker_number
33

4-
image = digitalocean_custom_image.talos.id
5-
name = "talos-worker-${count.index}"
6-
region = var.region
7-
size = var.worker_size
8-
ssh_keys = [var.ssh_key_fingerprint]
9-
user_data = talos_gen_config.config.worker_config
4+
image = digitalocean_custom_image.talos.id
5+
name = "talos-worker-${count.index}"
6+
region = var.region
7+
size = var.worker_size
8+
ssh_keys = [var.ssh_key_fingerprint]
9+
user_data = talos_gen_config.config.worker_config
1010
}

go.mod

+4-12
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ replace inet.af/tcpproxy => github.com/smira/tcpproxy v0.0.0-20201015133617-de5f
66

77
require (
88
github.com/ghodss/yaml v1.0.0
9-
github.com/google/uuid v1.3.0
109
github.com/hashicorp/terraform-plugin-docs v0.13.0
11-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.23.0
10+
github.com/hashicorp/terraform-plugin-framework v0.13.0
11+
github.com/hashicorp/terraform-plugin-go v0.14.0
12+
github.com/hashicorp/terraform-plugin-log v0.7.0
1213
github.com/talos-systems/talos v1.2.3
1314
github.com/talos-systems/talos/pkg/machinery v1.2.3
1415
google.golang.org/grpc v1.49.0
@@ -27,8 +28,6 @@ require (
2728
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
2829
github.com/Microsoft/go-winio v0.5.2 // indirect
2930
github.com/Microsoft/hcsshim v0.9.4 // indirect
30-
github.com/agext/levenshtein v1.2.3 // indirect
31-
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
3231
github.com/armon/go-radix v1.0.0 // indirect
3332
github.com/aws/aws-sdk-go v1.44.76 // indirect
3433
github.com/beorn7/perks v1.0.1 // indirect
@@ -71,14 +70,14 @@ require (
7170
github.com/google/gnostic v0.6.9 // indirect
7271
github.com/google/go-cmp v0.5.9 // indirect
7372
github.com/google/gofuzz v1.2.0 // indirect
73+
github.com/google/uuid v1.3.0 // indirect
7474
github.com/googleapis/enterprise-certificate-proxy v0.1.0 // indirect
7575
github.com/googleapis/gax-go/v2 v2.4.0 // indirect
7676
github.com/googleapis/go-type-adapters v1.0.0 // indirect
7777
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.2 // indirect
7878
github.com/hashicorp/errwrap v1.1.0 // indirect
7979
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
8080
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
81-
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
8281
github.com/hashicorp/go-getter v1.6.2 // indirect
8382
github.com/hashicorp/go-hclog v1.2.1 // indirect
8483
github.com/hashicorp/go-multierror v1.1.1 // indirect
@@ -87,12 +86,8 @@ require (
8786
github.com/hashicorp/go-uuid v1.0.3 // indirect
8887
github.com/hashicorp/go-version v1.6.0 // indirect
8988
github.com/hashicorp/hc-install v0.4.0 // indirect
90-
github.com/hashicorp/hcl/v2 v2.14.0 // indirect
91-
github.com/hashicorp/logutils v1.0.0 // indirect
9289
github.com/hashicorp/terraform-exec v0.17.3 // indirect
9390
github.com/hashicorp/terraform-json v0.14.0 // indirect
94-
github.com/hashicorp/terraform-plugin-go v0.14.0 // indirect
95-
github.com/hashicorp/terraform-plugin-log v0.7.0 // indirect
9691
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect
9792
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
9893
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect
@@ -118,8 +113,6 @@ require (
118113
github.com/mitchellh/copystructure v1.2.0 // indirect
119114
github.com/mitchellh/go-homedir v1.1.0 // indirect
120115
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
121-
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
122-
github.com/mitchellh/mapstructure v1.5.0 // indirect
123116
github.com/mitchellh/reflectwalk v1.0.2 // indirect
124117
github.com/moby/locker v1.0.1 // indirect
125118
github.com/moby/spdystream v0.2.0 // indirect
@@ -161,7 +154,6 @@ require (
161154
github.com/talos-systems/net v0.3.2 // indirect
162155
github.com/u-root/uio v0.0.0-20220204230159-dac05f7d2cb4 // indirect
163156
github.com/ulikunitz/xz v0.5.10 // indirect
164-
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
165157
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
166158
github.com/vmihailenco/tagparser v0.1.2 // indirect
167159
github.com/zclconf/go-cty v1.11.0 // indirect

0 commit comments

Comments
 (0)