From 4db62a75ecc1435ca3bfacb171517796ef8cffd0 Mon Sep 17 00:00:00 2001 From: Mauricio Alvarez Leon <65101411+BBBmau@users.noreply.github.com> Date: Thu, 25 Jan 2024 11:03:57 -0800 Subject: [PATCH] `kubernetes_manifest` schema refactor (#2408) * refactor of manifest schema and getMetadata * gh test * use keys from GetProvider functions for GetMetadata schema * update terraform versions to latest in check_examples yaml --- .github/workflows/check_examples.yaml | 4 ++-- manifest/provider/server.go | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/check_examples.yaml b/.github/workflows/check_examples.yaml index 9746ce09dc..5f2a50d6aa 100644 --- a/.github/workflows/check_examples.yaml +++ b/.github/workflows/check_examples.yaml @@ -24,11 +24,11 @@ jobs: strategy: matrix: terraform_version: - - "1.0.11" - - "1.1.9" - "1.2.9" - "1.3.9" - "1.4.0" + - "1.6.0" + - "1.7.0" env: TF_X_KUBERNETES_MANIFEST_RESOURCE: 1 TERM: linux diff --git a/manifest/provider/server.go b/manifest/provider/server.go index 69560e9d48..cc7e8e9cb9 100644 --- a/manifest/provider/server.go +++ b/manifest/provider/server.go @@ -55,18 +55,21 @@ func (s *RawProviderServer) PrepareProviderConfig(ctx context.Context, req *tfpr func (s *RawProviderServer) GetMetadata(ctx context.Context, req *tfprotov5.GetMetadataRequest) (*tfprotov5.GetMetadataResponse, error) { s.logger.Trace("[GetMetadata][Request]\n%s\n", dump(*req)) + sch := GetProviderResourceSchema() + rs := make([]tfprotov5.ResourceMetadata, 0, len(sch)) + for k := range sch { + rs = append(rs, tfprotov5.ResourceMetadata{TypeName: k}) + } + + sch = GetProviderDataSourceSchema() + ds := make([]tfprotov5.DataSourceMetadata, 0, len(sch)) + for k := range sch { + ds = append(ds, tfprotov5.DataSourceMetadata{TypeName: k}) + } + resp := &tfprotov5.GetMetadataResponse{ - Resources: []tfprotov5.ResourceMetadata{{ - TypeName: "kubernetes_manifest", - }}, - DataSources: []tfprotov5.DataSourceMetadata{ - { - TypeName: "kubernetes_resource", - }, - { - TypeName: "kubernetes_resources", - }, - }, + Resources: rs, + DataSources: ds, } return resp, nil }