Skip to content

Commit 75fa00f

Browse files
authored
Add provider defined functions for encoding and decoding Kubernetes manifests (#2428)
1 parent 9bafdf0 commit 75fa00f

23 files changed

+1416
-106
lines changed

.changelog/2428.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
Add provider defined functions: `manifest_encode`, `manifest_decode`, `manifest_decode_multi`
3+
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Provider Functions Unit Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "internal/framework/provider/functions/**/*.go"
9+
pull_request:
10+
branches:
11+
- main
12+
paths:
13+
- "internal/framework/provider/functions/**/*.go"
14+
workflow_dispatch:
15+
16+
jobs:
17+
unit_tests:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
22+
- name: Set up Go
23+
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
24+
with:
25+
go-version-file: 'go.mod'
26+
- name: Go mod verify
27+
run: go mod verify
28+
- name: Run unit tests
29+
env:
30+
# FIXME this needs to be changed once the 1.8 release goes out
31+
TF_ACC_TERRAFORM_VERSION: 1.8.0-rc1
32+
run: |
33+
make testfuncs

GNUmakefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ PKG_NAME := kubernetes
88
OS_ARCH := $(shell go env GOOS)_$(shell go env GOARCH)
99
TF_PROV_DOCS := $(PWD)/kubernetes/test-infra/tfproviderdocs
1010

11+
PROVIDER_FUNCTIONS_DIR := "$(PROVIDER_DIR)/internal/framework/provider/functions"
12+
1113
ifneq ($(PWD),$(PROVIDER_DIR))
1214
$(error "Makefile must be run from the provider directory")
1315
endif
@@ -75,6 +77,9 @@ test: fmtcheck vet
7577
testacc: fmtcheck vet
7678
TF_ACC=1 go test $(TEST) -v -vet=off $(TESTARGS) -parallel $(PARALLEL_RUNS) -timeout 3h
7779

80+
testfuncs: fmtcheck
81+
go test $(PROVIDER_FUNCTIONS_DIR) -v -vet=off $(TESTARGS) -parallel $(PARALLEL_RUNS)
82+
7883
test-compile:
7984
@if [ "$(TEST)" = "./..." ]; then \
8085
echo "ERROR: Set TEST to a specific package. For example,"; \
@@ -99,8 +104,8 @@ tests-lint-fix: tools
99104
tools:
100105
go install github.com/client9/misspell/cmd/[email protected]
101106
go install github.com/bflad/tfproviderlint/cmd/[email protected]
102-
go install github.com/bflad/tfproviderdocs@v0.9.1
103-
go install github.com/katbyte/[email protected].2
107+
go install github.com/bflad/tfproviderdocs@v0.12.0
108+
go install github.com/katbyte/[email protected].3
104109
go install github.com/golangci/golangci-lint/cmd/[email protected]
105110
go install github.com/hashicorp/go-changelog/cmd/changelog-build@latest
106111
go install github.com/hashicorp/go-changelog/cmd/changelog-entry@latest

go.mod

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,53 @@
11
module github.com/hashicorp/terraform-provider-kubernetes
22

3+
go 1.21
4+
35
require (
46
github.com/Masterminds/semver v1.5.0
57
github.com/getkin/kin-openapi v0.111.0
68
github.com/google/go-cmp v0.6.0
7-
github.com/hashicorp/go-hclog v1.5.0
9+
github.com/hashicorp/go-hclog v1.6.2
810
github.com/hashicorp/go-plugin v1.6.0
911
github.com/hashicorp/go-version v1.6.0
10-
github.com/hashicorp/hc-install v0.6.0
11-
github.com/hashicorp/hcl/v2 v2.18.0
12-
github.com/hashicorp/terraform-exec v0.19.0
13-
github.com/hashicorp/terraform-json v0.17.1
12+
github.com/hashicorp/hc-install v0.6.3
13+
github.com/hashicorp/hcl/v2 v2.20.0
14+
github.com/hashicorp/terraform-exec v0.20.0
15+
github.com/hashicorp/terraform-json v0.21.0
1416
github.com/hashicorp/terraform-plugin-docs v0.16.0
15-
github.com/hashicorp/terraform-plugin-framework v1.5.0
16-
github.com/hashicorp/terraform-plugin-go v0.20.0
17+
github.com/hashicorp/terraform-plugin-framework v1.7.0
18+
github.com/hashicorp/terraform-plugin-go v0.22.1
1719
github.com/hashicorp/terraform-plugin-log v0.9.0
18-
github.com/hashicorp/terraform-plugin-mux v0.12.0
19-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0
20+
github.com/hashicorp/terraform-plugin-mux v0.15.0
21+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
22+
github.com/hashicorp/terraform-plugin-testing v1.7.0
2023
github.com/jinzhu/copier v0.3.5
2124
github.com/mitchellh/go-homedir v1.1.0
2225
github.com/mitchellh/hashstructure v1.1.0
2326
github.com/robfig/cron v1.2.0
2427
github.com/stretchr/testify v1.8.2
25-
golang.org/x/mod v0.14.0
28+
golang.org/x/mod v0.15.0
2629
k8s.io/api v0.28.6
2730
k8s.io/apiextensions-apiserver v0.28.6
2831
k8s.io/apimachinery v0.28.6
2932
k8s.io/client-go v0.28.6
3033
k8s.io/kube-aggregator v0.28.6
3134
k8s.io/kubectl v0.28.6
3235
k8s.io/kubernetes v1.28.6
36+
sigs.k8s.io/yaml v1.4.0
3337
)
3438

3539
require (
3640
github.com/Masterminds/goutils v1.1.1 // indirect
37-
github.com/Masterminds/semver/v3 v3.1.1 // indirect
38-
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
39-
github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect
41+
github.com/Masterminds/semver/v3 v3.2.0 // indirect
42+
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
43+
github.com/ProtonMail/go-crypto v1.1.0-alpha.0 // indirect
4044
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
4145
github.com/armon/go-radix v1.0.0 // indirect
4246
github.com/bgentry/speakeasy v0.1.0 // indirect
4347
github.com/cloudflare/circl v1.3.7 // indirect
4448
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
4549
github.com/google/gnostic-models v0.6.8 // indirect
46-
github.com/huandu/xstrings v1.3.2 // indirect
50+
github.com/huandu/xstrings v1.3.3 // indirect
4751
github.com/invopop/yaml v0.2.0 // indirect
4852
github.com/mitchellh/cli v1.1.5 // indirect
4953
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
@@ -55,8 +59,9 @@ require (
5559
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
5660
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
5761
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect
58-
golang.org/x/sync v0.5.0 // indirect
59-
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect
62+
golang.org/x/sync v0.6.0 // indirect
63+
golang.org/x/tools v0.16.1 // indirect
64+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
6065
)
6166

6267
require (
@@ -68,7 +73,7 @@ require (
6873
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
6974
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
7075
github.com/fatih/camelcase v1.0.0 // indirect
71-
github.com/fatih/color v1.13.0 // indirect
76+
github.com/fatih/color v1.16.0 // indirect
7277
github.com/go-errors/errors v1.4.2 // indirect
7378
github.com/go-logr/logr v1.2.4 // indirect
7479
github.com/go-openapi/jsonpointer v0.19.6 // indirect
@@ -79,7 +84,7 @@ require (
7984
github.com/google/btree v1.1.2 // indirect
8085
github.com/google/gofuzz v1.2.0 // indirect
8186
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
82-
github.com/google/uuid v1.3.1 // indirect
87+
github.com/google/uuid v1.6.0 // indirect
8388
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
8489
github.com/hashicorp/errwrap v1.1.0 // indirect
8590
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
@@ -98,7 +103,7 @@ require (
98103
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
99104
github.com/mailru/easyjson v0.7.7 // indirect
100105
github.com/mattn/go-colorable v0.1.13 // indirect
101-
github.com/mattn/go-isatty v0.0.16 // indirect
106+
github.com/mattn/go-isatty v0.0.20 // indirect
102107
github.com/mitchellh/copystructure v1.2.0 // indirect
103108
github.com/mitchellh/go-testing-interface v1.14.1
104109
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
@@ -118,17 +123,17 @@ require (
118123
github.com/spf13/pflag v1.0.5 // indirect
119124
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
120125
github.com/xlab/treeprint v1.2.0 // indirect
121-
github.com/zclconf/go-cty v1.14.0
126+
github.com/zclconf/go-cty v1.14.3
122127
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
123-
golang.org/x/crypto v0.17.0 // indirect
124-
golang.org/x/net v0.19.0 // indirect
125-
golang.org/x/oauth2 v0.13.0 // indirect
126-
golang.org/x/sys v0.15.0 // indirect
127-
golang.org/x/term v0.15.0 // indirect
128+
golang.org/x/crypto v0.21.0 // indirect
129+
golang.org/x/net v0.21.0 // indirect
130+
golang.org/x/oauth2 v0.16.0 // indirect
131+
golang.org/x/sys v0.18.0 // indirect
132+
golang.org/x/term v0.18.0 // indirect
128133
golang.org/x/text v0.14.0 // indirect
129134
golang.org/x/time v0.3.0 // indirect
130135
google.golang.org/appengine v1.6.8 // indirect
131-
google.golang.org/grpc v1.60.0
136+
google.golang.org/grpc v1.62.1
132137
google.golang.org/protobuf v1.33.0 // indirect
133138
gopkg.in/inf.v0 v0.9.1 // indirect
134139
gopkg.in/yaml.v2 v2.4.0 // indirect
@@ -142,7 +147,4 @@ require (
142147
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect
143148
sigs.k8s.io/kustomize/kyaml v0.14.3-0.20230601165947-6ce0bf390ce3 // indirect
144149
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
145-
sigs.k8s.io/yaml v1.3.0 // indirect
146150
)
147-
148-
go 1.21

0 commit comments

Comments
 (0)