Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Add float64 to supported sensitve fields
Browse files Browse the repository at this point in the history
Signed-off-by: Lax Kota <[email protected]>
  • Loading branch information
Lax77 authored and Lax Kota committed Aug 4, 2022
1 parent 6e78c04 commit 75dc677
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/types/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,15 @@ func TestBuild(t *testing.T) {
TerraformResource: &schema.Resource{
Schema: map[string]*schema.Schema{
"key_1": {
Type: schema.TypeFloat,
Type: schema.TypeInt,
Sensitive: true,
},
},
},
},
},
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": {
Expand Down
7 changes: 4 additions & 3 deletions pkg/types/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down

0 comments on commit 75dc677

Please sign in to comment.