@@ -2,6 +2,7 @@ package blueprint
22
33import (
44 "context"
5+
56 "github.com/hashicorp/terraform-plugin-framework/attr"
67 "github.com/hashicorp/terraform-plugin-framework/types"
78 "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
@@ -59,6 +60,26 @@ func arrayPropResourceToBody(ctx context.Context, state *PropertiesModel, props
5960
6061 property .Default = defaultList
6162 }
63+ if ! prop .StringItems .Enum .IsNull () {
64+ enumList , err := utils .TerraformListToGoArray (ctx , prop .StringItems .Enum , "string" )
65+ if err != nil {
66+ return err
67+ }
68+ items ["enum" ] = enumList
69+ }
70+ if ! prop .StringItems .EnumColors .IsNull () {
71+ enumColors := map [string ]string {}
72+ for k , v := range prop .StringItems .EnumColors .Elements () {
73+ value , _ := v .ToTerraformValue (ctx )
74+ var keyValue string
75+ err := value .As (& keyValue )
76+ if err != nil {
77+ return err
78+ }
79+ enumColors [k ] = keyValue
80+ }
81+ items ["enumColors" ] = enumColors
82+ }
6283 property .Items = items
6384 }
6485
@@ -112,7 +133,7 @@ func arrayPropResourceToBody(ctx context.Context, state *PropertiesModel, props
112133 return nil
113134}
114135
115- func AddArrayPropertiesToState (v * cli.BlueprintProperty , jsonEscapeHTML bool ) * ArrayPropModel {
136+ func AddArrayPropertiesToState (ctx context. Context , v * cli.BlueprintProperty , jsonEscapeHTML bool ) * ArrayPropModel {
116137 arrayProp := & ArrayPropModel {
117138 MinItems : flex .GoInt64ToFramework (v .MinItems ),
118139 MaxItems : flex .GoInt64ToFramework (v .MaxItems ),
@@ -142,6 +163,20 @@ func AddArrayPropertiesToState(v *cli.BlueprintProperty, jsonEscapeHTML bool) *A
142163 if value , ok := v .Items ["pattern" ]; ok && value != nil {
143164 arrayProp .StringItems .Pattern = types .StringValue (v .Items ["pattern" ].(string ))
144165 }
166+ if value , ok := v .Items ["enum" ]; ok && value != nil {
167+ attrs := make ([]attr.Value , 0 , len (value .([]interface {})))
168+ for _ , enumValue := range value .([]interface {}) {
169+ attrs = append (attrs , basetypes .NewStringValue (enumValue .(string )))
170+ }
171+ arrayProp .StringItems .Enum , _ = types .ListValue (types .StringType , attrs )
172+ } else {
173+ arrayProp .StringItems .Enum = types .ListNull (types .StringType )
174+ }
175+ if value , ok := v .Items ["enumColors" ]; ok && value != nil {
176+ arrayProp .StringItems .EnumColors , _ = types .MapValueFrom (ctx , types .StringType , value )
177+ } else {
178+ arrayProp .StringItems .EnumColors = types .MapNull (types .StringType )
179+ }
145180 case "number" :
146181 arrayProp .NumberItems = & NumberItems {}
147182 if v .Default != nil {
0 commit comments