From aa58f1aaad76342a2c0cd13d3cb9aa0adb2e0f8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergen=20Yal=C3=A7=C4=B1n?= Date: Fri, 23 Feb 2024 14:29:43 +0300 Subject: [PATCH 1/2] Fix non-primitive type sensitive field generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sergen Yalçın (cherry picked from commit 8bf78e8106531c0006c18b9a395dece38ff51ca0) --- pkg/types/field.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/types/field.go b/pkg/types/field.go index 1200b90a..e7b9c143 100644 --- a/pkg/types/field.go +++ b/pkg/types/field.go @@ -268,7 +268,13 @@ func NewSensitiveField(g *Builder, cfg *config.Resource, r *resource, sch *schem return nil, true, nil } sfx := "SecretRef" - cfg.Sensitive.AddFieldPath(fieldPathWithWildcard(f.TerraformPaths), "spec.forProvider."+fieldPathWithWildcard(f.CRDPaths)+sfx) + switch f.FieldType.String() { + case "string", "*string", "map[string]string", "map[string]*string": + cfg.Sensitive.AddFieldPath(fieldPathWithWildcard(f.TerraformPaths), "spec.forProvider."+fieldPathWithWildcard(f.CRDPaths)+sfx) + case "[]string", "[]*string": + f.CRDPaths[len(f.CRDPaths)-2] = f.CRDPaths[len(f.CRDPaths)-2] + sfx + cfg.Sensitive.AddFieldPath(fieldPathWithWildcard(f.TerraformPaths), "spec.forProvider."+fieldPathWithWildcard(f.CRDPaths)) + } // todo(turkenh): do we need to support other field types as sensitive? if f.FieldType.String() != "string" && f.FieldType.String() != "*string" && f.FieldType.String() != "[]string" && f.FieldType.String() != "[]*string" && f.FieldType.String() != "map[string]string" && f.FieldType.String() != "map[string]*string" { From 404ab86cb1b741c7c719daa4a65feaf5ec10d888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergen=20Yal=C3=A7=C4=B1n?= Date: Mon, 26 Feb 2024 20:05:02 +0300 Subject: [PATCH 2/2] Change cases from string to type of FieldType MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sergen Yalçın (cherry picked from commit b63f33874c7ed7ed6e30b0429f4ef745842ad8fb) --- pkg/types/field.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/types/field.go b/pkg/types/field.go index e7b9c143..b4f04866 100644 --- a/pkg/types/field.go +++ b/pkg/types/field.go @@ -268,12 +268,12 @@ func NewSensitiveField(g *Builder, cfg *config.Resource, r *resource, sch *schem return nil, true, nil } sfx := "SecretRef" - switch f.FieldType.String() { - case "string", "*string", "map[string]string", "map[string]*string": - cfg.Sensitive.AddFieldPath(fieldPathWithWildcard(f.TerraformPaths), "spec.forProvider."+fieldPathWithWildcard(f.CRDPaths)+sfx) - case "[]string", "[]*string": + switch f.FieldType.(type) { + case *types.Slice: f.CRDPaths[len(f.CRDPaths)-2] = f.CRDPaths[len(f.CRDPaths)-2] + sfx cfg.Sensitive.AddFieldPath(fieldPathWithWildcard(f.TerraformPaths), "spec.forProvider."+fieldPathWithWildcard(f.CRDPaths)) + default: + cfg.Sensitive.AddFieldPath(fieldPathWithWildcard(f.TerraformPaths), "spec.forProvider."+fieldPathWithWildcard(f.CRDPaths)+sfx) } // todo(turkenh): do we need to support other field types as sensitive? if f.FieldType.String() != "string" && f.FieldType.String() != "*string" && f.FieldType.String() != "[]string" &&