From f11a882d56da0f84b3a489086e20ef66050f7041 Mon Sep 17 00:00:00 2001 From: Lax Kota Date: Mon, 1 Aug 2022 21:09:07 -0700 Subject: [PATCH] Add float64 to supported sensitve fields --- pkg/types/builder_test.go | 4 ++-- pkg/types/field.go | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/types/builder_test.go b/pkg/types/builder_test.go index cf416f6..448883f 100644 --- a/pkg/types/builder_test.go +++ b/pkg/types/builder_test.go @@ -319,7 +319,7 @@ func TestBuild(t *testing.T) { TerraformResource: &schema.Resource{ Schema: map[string]*schema.Schema{ "key_1": { - Type: schema.TypeFloat, + Type: schema.TypeInt, Sensitive: true, }, }, @@ -327,7 +327,7 @@ func TestBuild(t *testing.T) { }, }, want: want{ - err: errors.Wrapf(fmt.Errorf(`got type %q for field %q, only types "string", "*string", []string, []*string, "map[string]string" and "map[string]*string" supported as sensitive`, "*float64", "Key1"), "cannot build the Types"), + err: errors.Wrapf(fmt.Errorf(`got type %q for field %q, only types "string", "*string", []string, []*string, "map[string]string", "map[string]*string", float64 and *float64 supported as sensitive`, "*int64", "Key1"), "cannot build the Types"), }, }, "References": { diff --git a/pkg/types/field.go b/pkg/types/field.go index e5e5144..097b615 100644 --- a/pkg/types/field.go +++ b/pkg/types/field.go @@ -88,8 +88,9 @@ func NewSensitiveField(g *Builder, cfg *config.Resource, r *resource, sch *schem 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" && - f.FieldType.String() != "[]*string" && f.FieldType.String() != "map[string]string" && f.FieldType.String() != "map[string]*string" { - return nil, false, fmt.Errorf(`got type %q for field %q, only types "string", "*string", []string, []*string, "map[string]string" and "map[string]*string" supported as sensitive`, f.FieldType.String(), f.FieldNameCamel) + f.FieldType.String() != "[]*string" && f.FieldType.String() != "map[string]string" && f.FieldType.String() != "map[string]*string" && + f.FieldType.String() != "float64" && f.FieldType.String() != "*float64" { + return nil, false, fmt.Errorf(`got type %q for field %q, only types "string", "*string", []string, []*string, "map[string]string", "map[string]*string", float64 and *float64 supported as sensitive`, f.FieldType.String(), f.FieldNameCamel) } // Replace a parameter field with secretKeyRef if it is sensitive. // If it is an observation field, it will be dropped. @@ -98,7 +99,7 @@ func NewSensitiveField(g *Builder, cfg *config.Resource, r *resource, sch *schem f.TFTag = "-" switch f.FieldType.String() { - case "string", "*string": + case "string", "*string", "float64", "*float64": f.FieldType = typeSecretKeySelector case "[]string", "[]*string": f.FieldType = types.NewSlice(typeSecretKeySelector)