Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add provider defined functions for encoding and decoding Kubernetes manifests #2428

Merged
merged 42 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d8e9521
Add a new function
arybolovlev Feb 13, 2024
8d908b0
Add function definition for manifest_decode
jrhouston Feb 13, 2024
69bde1f
create specific function for manifestDecode
jrhouston Feb 13, 2024
6a9fc16
Move function to framework
arybolovlev Feb 15, 2024
9331a10
Clean up
arybolovlev Feb 16, 2024
94413ae
add support for multi doc
jrhouston Feb 20, 2024
f67dadc
wip: add TODOs
jrhouston Feb 20, 2024
31c5aeb
remove regex TODO
jrhouston Feb 20, 2024
00b2515
wip: add TODO
jrhouston Feb 20, 2024
2f8f39b
move functions folder to internal/framework/provider
jrhouston Feb 21, 2024
4f5ce88
add happy path unit test for manifest_decode
jrhouston Feb 23, 2024
ea8052c
add validation that the YAML is a manifest
jrhouston Feb 26, 2024
1abfd0d
add test cases for invalid manifests
jrhouston Feb 26, 2024
b3613ed
refactor decoder logic to be simpler
jrhouston Feb 26, 2024
c1cc39b
print value in diagnostic
jrhouston Feb 26, 2024
874eb30
add test case for multi-doc manifest
jrhouston Feb 26, 2024
8dcfb86
update documentation strings
jrhouston Feb 27, 2024
2f1cca6
add warning for empty YAML document
jrhouston Feb 27, 2024
b1797ec
add namespace to configmap test
jrhouston Feb 27, 2024
15b822e
rename some things
jrhouston Feb 28, 2024
19ccd65
manifest_decode -> manifest_decode_multi
jrhouston Feb 29, 2024
389edec
rename test functions
jrhouston Feb 29, 2024
1c677a2
add manifest_decode
jrhouston Mar 4, 2024
8ec2f14
update summary and description strings
jrhouston Mar 4, 2024
9fb653f
add manifest_encode function
jrhouston Mar 4, 2024
5b2dda8
add tests for manifest_encode
jrhouston Mar 7, 2024
bcf794d
Add GHA for testing provider functions
jrhouston Mar 26, 2024
773c717
Use latest version of plugin framework
jrhouston Mar 26, 2024
94674b1
Fix title in provider funcs GHA
jrhouston Mar 26, 2024
7c15d86
Set terraform version to 1.8.0-rc1 in provider funcs GHA
jrhouston Mar 26, 2024
a010dc6
Update tests to use ConfigStateChecks
jrhouston Mar 27, 2024
524b14c
Add docs pages
jrhouston Mar 27, 2024
ce7a28a
remove context.TODO()
jrhouston Mar 27, 2024
aeab645
add changelog entry
jrhouston Mar 27, 2024
56a89f4
Add missing copywrite headers
jrhouston Mar 27, 2024
e35572a
Fix null value crash in manifest_encode
jrhouston Mar 28, 2024
73ae108
remove superfluous encoder cases for Int64,Float64
jrhouston Mar 28, 2024
1c93920
remove unneeded comment
jrhouston Mar 28, 2024
2ff8993
Fix docs linters
arybolovlev Apr 2, 2024
596ad79
Bump tfproviderdocs to 0.12.0
arybolovlev Apr 2, 2024
4915eaa
Add layout and move functions docs from f to functions dir
arybolovlev Apr 2, 2024
5134a60
remove dead link
jrhouston Apr 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/2428.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
Add provider defined functions: `manifest_encode`, `manifest_decode`, `manifest_decode_multi`
```
33 changes: 33 additions & 0 deletions .github/workflows/provider_functions_unit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Provider Functions Unit Tests

on:
push:
branches:
- main
paths:
- "internal/framework/provider/functions/**/*.go"
pull_request:
branches:
- main
paths:
- "internal/framework/provider/functions/**/*.go"
workflow_dispatch:

jobs:
unit_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Set up Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
- name: Go mod verify
run: go mod verify
- name: Run unit tests
env:
# FIXME this needs to be changed once the 1.8 release goes out
TF_ACC_TERRAFORM_VERSION: 1.8.0-rc1
run: |
make testfuncs
9 changes: 7 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ PKG_NAME := kubernetes
OS_ARCH := $(shell go env GOOS)_$(shell go env GOARCH)
TF_PROV_DOCS := $(PWD)/kubernetes/test-infra/tfproviderdocs

PROVIDER_FUNCTIONS_DIR := "$(PROVIDER_DIR)/internal/framework/provider/functions"

ifneq ($(PWD),$(PROVIDER_DIR))
$(error "Makefile must be run from the provider directory")
endif
Expand Down Expand Up @@ -75,6 +77,9 @@ test: fmtcheck vet
testacc: fmtcheck vet
TF_ACC=1 go test $(TEST) -v -vet=off $(TESTARGS) -parallel $(PARALLEL_RUNS) -timeout 3h

testfuncs: fmtcheck
go test $(PROVIDER_FUNCTIONS_DIR) -v -vet=off $(TESTARGS) -parallel $(PARALLEL_RUNS)

test-compile:
@if [ "$(TEST)" = "./..." ]; then \
echo "ERROR: Set TEST to a specific package. For example,"; \
Expand All @@ -99,8 +104,8 @@ tests-lint-fix: tools
tools:
go install github.com/client9/misspell/cmd/misspell@v0.3.4
go install github.com/bflad/tfproviderlint/cmd/tfproviderlint@v0.28.1
go install github.com/bflad/tfproviderdocs@v0.9.1
go install github.com/katbyte/terrafmt@v0.5.2
go install github.com/bflad/tfproviderdocs@v0.12.0
go install github.com/katbyte/terrafmt@v0.5.3
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2
go install github.com/hashicorp/go-changelog/cmd/changelog-build@latest
go install github.com/hashicorp/go-changelog/cmd/changelog-entry@latest
Expand Down
60 changes: 31 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
module github.com/hashicorp/terraform-provider-kubernetes

go 1.21

require (
github.com/Masterminds/semver v1.5.0
github.com/getkin/kin-openapi v0.111.0
github.com/google/go-cmp v0.6.0
github.com/hashicorp/go-hclog v1.5.0
github.com/hashicorp/go-hclog v1.6.2
github.com/hashicorp/go-plugin v1.6.0
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/hc-install v0.6.0
github.com/hashicorp/hcl/v2 v2.18.0
github.com/hashicorp/terraform-exec v0.19.0
github.com/hashicorp/terraform-json v0.17.1
github.com/hashicorp/hc-install v0.6.3
github.com/hashicorp/hcl/v2 v2.20.0
github.com/hashicorp/terraform-exec v0.20.0
github.com/hashicorp/terraform-json v0.21.0
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/hashicorp/terraform-plugin-framework v1.5.0
github.com/hashicorp/terraform-plugin-go v0.20.0
github.com/hashicorp/terraform-plugin-framework v1.7.0
github.com/hashicorp/terraform-plugin-go v0.22.1
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-mux v0.12.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0
github.com/hashicorp/terraform-plugin-mux v0.15.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
github.com/hashicorp/terraform-plugin-testing v1.7.0
github.com/jinzhu/copier v0.3.5
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/hashstructure v1.1.0
github.com/robfig/cron v1.2.0
github.com/stretchr/testify v1.8.2
golang.org/x/mod v0.14.0
golang.org/x/mod v0.15.0
k8s.io/api v0.28.6
k8s.io/apiextensions-apiserver v0.28.6
k8s.io/apimachinery v0.28.6
k8s.io/client-go v0.28.6
k8s.io/kube-aggregator v0.28.6
k8s.io/kubectl v0.28.6
k8s.io/kubernetes v1.28.6
sigs.k8s.io/yaml v1.4.0
)

require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.0 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/invopop/yaml v0.2.0 // indirect
github.com/mitchellh/cli v1.1.5 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
Expand All @@ -55,8 +59,9 @@ require (
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect
golang.org/x/sync v0.5.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/tools v0.16.1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
)

require (
Expand All @@ -68,7 +73,7 @@ require (
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
github.com/fatih/camelcase v1.0.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
Expand All @@ -79,7 +84,7 @@ require (
github.com/google/btree v1.1.2 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
Expand All @@ -98,7 +103,7 @@ require (
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
Expand All @@ -118,17 +123,17 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/xlab/treeprint v1.2.0 // indirect
github.com/zclconf/go-cty v1.14.0
github.com/zclconf/go-cty v1.14.3
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/grpc v1.60.0
google.golang.org/grpc v1.62.1
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand All @@ -142,7 +147,4 @@ require (
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect
sigs.k8s.io/kustomize/kyaml v0.14.3-0.20230601165947-6ce0bf390ce3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

go 1.21
Loading
Loading