Skip to content

Conversation

@sergeimonakhov
Copy link

@sergeimonakhov sergeimonakhov commented Aug 5, 2025

Rollback Plan

If a change needs to be reverted, we will publish an updated version of the library.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

Description

Fix error handling in TFTypeFromOpenAPI to correctly fallback to OpenAPI schema when CRD schema lookup fails. This prevents premature failure and improves robustness of type generation for Kubernetes resources.

Acceptance tests

  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccTFTypeFromOpenAPIFallback'
==> Checking that code complies with gofmt requirements...
go vet ./...
go: downloading github.com/hashicorp/terraform-plugin-framework v1.15.0
go: downloading github.com/hashicorp/terraform-plugin-go v0.27.0
go: downloading github.com/hashicorp/terraform-plugin-log v0.9.0
go: downloading github.com/hashicorp/terraform-plugin-mux v0.19.0
go: downloading github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0
go: downloading github.com/mitchellh/go-testing-interface v1.14.1
go: downloading k8s.io/api v0.28.6
go: downloading k8s.io/apimachinery v0.28.6
go: downloading github.com/hashicorp/go-version v1.7.0
go: downloading github.com/hashicorp/hc-install v0.9.2
go: downloading github.com/getkin/kin-openapi v0.111.0
go: downloading github.com/hashicorp/terraform-exec v0.23.0
go: downloading github.com/hashicorp/go-hclog v1.6.3
go: downloading github.com/hashicorp/terraform-json v0.25.0
go: downloading github.com/hashicorp/go-plugin v1.6.3
go: downloading github.com/mitchellh/hashstructure v1.1.0
go: downloading github.com/hashicorp/hcl/v2 v2.23.0
go: downloading k8s.io/client-go v0.28.6
go: downloading github.com/hashicorp/go-cty v1.5.0
go: downloading sigs.k8s.io/yaml v1.4.0
go: downloading github.com/mitchellh/go-homedir v1.1.0
go: downloading github.com/zclconf/go-cty v1.16.2
go: downloading golang.org/x/mod v0.24.0
go: downloading github.com/jinzhu/copier v0.3.5
go: downloading google.golang.org/grpc v1.72.1
go: downloading github.com/robfig/cron v1.2.0
go: downloading k8s.io/apiextensions-apiserver v0.28.6
go: downloading k8s.io/kubectl v0.28.6
go: downloading k8s.io/kube-aggregator v0.28.6
go: downloading k8s.io/utils v0.0.0-20231127182322-b307cd553661
go: downloading github.com/gogo/protobuf v1.3.2
go: downloading github.com/google/gofuzz v1.2.0
go: downloading github.com/google/go-cmp v0.7.0
go: downloading github.com/vmihailenco/msgpack/v5 v5.4.1
go: downloading github.com/hashicorp/go-uuid v1.0.3
go: downloading github.com/hashicorp/logutils v1.0.0
go: downloading github.com/vmihailenco/msgpack v4.0.4+incompatible
go: downloading github.com/fatih/color v1.16.0
go: downloading github.com/mattn/go-isatty v0.0.20
go: downloading github.com/golang/protobuf v1.5.4
go: downloading github.com/hashicorp/yamux v0.1.1
go: downloading github.com/oklog/run v1.1.0
go: downloading github.com/apparentlymart/go-textseg/v15 v15.0.0
go: downloading github.com/mitchellh/go-wordwrap v1.0.1
go: downloading github.com/agext/levenshtein v1.2.3
go: downloading github.com/mitchellh/copystructure v1.2.0
go: downloading github.com/mitchellh/mapstructure v1.5.0
go: downloading golang.org/x/text v0.25.0
go: downloading github.com/go-openapi/jsonpointer v0.19.6
go: downloading github.com/invopop/yaml v0.2.0
go: downloading github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
go: downloading k8s.io/klog/v2 v2.100.1
go: downloading sigs.k8s.io/structured-merge-diff/v4 v4.2.3
go: downloading github.com/google/gnostic-models v0.6.8
go: downloading golang.org/x/net v0.39.0
go: downloading github.com/imdario/mergo v0.3.15
go: downloading github.com/spf13/pflag v1.0.5
go: downloading golang.org/x/term v0.32.0
go: downloading gopkg.in/inf.v0 v0.9.1
go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a
go: downloading github.com/hashicorp/go-multierror v1.1.1
go: downloading github.com/hashicorp/go-checkpoint v0.5.0
go: downloading google.golang.org/protobuf v1.36.6
go: downloading github.com/vmihailenco/tagparser/v2 v2.0.0
go: downloading github.com/hashicorp/terraform-registry-address v0.2.5
go: downloading github.com/mitchellh/reflectwalk v1.0.2
go: downloading golang.org/x/sys v0.33.0
go: downloading github.com/mattn/go-colorable v0.1.13
go: downloading sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd
go: downloading k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9
go: downloading golang.org/x/oauth2 v0.26.0
go: downloading golang.org/x/time v0.3.0
go: downloading github.com/go-openapi/swag v0.22.3
go: downloading k8s.io/cli-runtime v0.28.6
go: downloading github.com/go-logr/logr v1.4.2
go: downloading github.com/ProtonMail/go-crypto v1.1.6
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/json-iterator/go v1.1.12
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/hashicorp/errwrap v1.1.0
go: downloading github.com/hashicorp/go-cleanhttp v0.5.2
go: downloading github.com/hashicorp/terraform-svchost v0.1.1
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/evanphx/json-patch v5.6.0+incompatible
go: downloading github.com/spf13/cobra v1.7.0
go: downloading k8s.io/component-base v0.28.6
go: downloading github.com/fatih/camelcase v1.0.0
go: downloading github.com/hashicorp/go-retryablehttp v0.7.7
go: downloading github.com/mailru/easyjson v0.7.7
go: downloading golang.org/x/crypto v0.38.0
go: downloading github.com/google/uuid v1.6.0
go: downloading github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
go: downloading github.com/chai2010/gettext-go v1.0.2
go: downloading github.com/MakeNowJust/heredoc v1.0.0
go: downloading github.com/russross/blackfriday/v2 v2.1.0
go: downloading github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f
go: downloading github.com/go-openapi/jsonreference v0.20.2
go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: downloading github.com/modern-go/reflect2 v1.0.2
go: downloading github.com/cloudflare/circl v1.6.0
go: downloading github.com/russross/blackfriday v1.6.0
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/emicklei/go-restful/v3 v3.10.1
go: downloading github.com/josharian/intern v1.0.0
go: downloading github.com/moby/term v0.0.0-20221205130635-1aeaba878587
go: downloading golang.org/x/sync v0.14.0
go: downloading sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3
go: downloading sigs.k8s.io/kustomize/kyaml v0.14.3-0.20230601165947-6ce0bf390ce3
go: downloading github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de
go: downloading github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79
go: downloading github.com/peterbourgon/diskv v2.0.1+incompatible
go: downloading github.com/moby/spdystream v0.2.0
go: downloading github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
go: downloading github.com/google/btree v1.1.2
go: downloading github.com/go-errors/errors v1.4.2
go: downloading go.starlark.net v0.0.0-20230525235612-a134d8f9ddca
go: downloading github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00
go: downloading github.com/xlab/treeprint v1.2.0
go: downloading github.com/hashicorp/terraform-plugin-testing v1.13.0
go: downloading k8s.io/kubernetes v1.28.6
TF_ACC=1 go test "/workspaces/terraform-provider-kubernetes/kubernetes" -v -vet=off -run=TestAccTFTypeFromOpenAPIFallback -parallel 8 -timeout 3h
testing: warning: no tests to run
PASS
ok      github.com/hashicorp/terraform-provider-kubernetes/kubernetes   0.019s [no tests to run]

Release Note

Release note for CHANGELOG:

Fix TFTypeFromOpenAPI to fallback properly to OpenAPI spec when CRD schema lookup fails, improving stability.

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

@sergeimonakhov sergeimonakhov requested a review from a team as a code owner August 5, 2025 10:54
@hashicorp-cla-app
Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

1 similar comment
@hashicorp-cla-app
Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant