@@ -296,16 +296,6 @@ func BoolValueToBoolPtr(v attr.Value) *bool {
296296 return vPtr
297297}
298298
299- // BoolPtrToBoolValue accepts a bool pointer, returning a types.Bool with the dereferenced value.
300- //
301- // If the provided pointer is nil, the returned Bool type will be set as Null.
302- func BoolPtrToBoolValue (b * bool ) types.Bool {
303- if b == nil {
304- return types .BoolNull ()
305- }
306- return types .BoolValue (* b )
307- }
308-
309299// NumberValueToBigFloat accepts either a types.Number or *types.Number, returning the raw *big.Float value. This may
310300// be nil if the value was not set.
311301func NumberValueToBigFloat (v attr.Value ) * big.Float {
@@ -398,7 +388,7 @@ func StringValueToStringPtr(v attr.Value) *string {
398388 return vPtr
399389}
400390
401- // StringListToStrings accepts an instance of either types.List or *types.List where ElemType MUST be types.StringType,
391+ // StringListToStrings accepts an instance of either types.List or *types.List where ElementType MUST be types.StringType,
402392// returning a slice of strings of the value of each element
403393func StringListToStrings (v attr.Value ) []string {
404394 vt := ValueToListType (v )
@@ -409,7 +399,7 @@ func StringListToStrings(v attr.Value) []string {
409399 return out
410400}
411401
412- // StringSetToStrings accepts an instance of either types.Set or *types.Set where ElemType MUST be types.StringType,
402+ // StringSetToStrings accepts an instance of either types.Set or *types.Set where ElementType MUST be types.StringType,
413403// returning a slice of strings of the value of each element
414404func StringSetToStrings (v attr.Value ) []string {
415405 vt := ValueToSetType (v )
@@ -420,7 +410,7 @@ func StringSetToStrings(v attr.Value) []string {
420410 return out
421411}
422412
423- // Int64ListToInts accepts an instance of either types.List or *types.List where ElemType MUST be types.Int64Type,
413+ // Int64ListToInts accepts an instance of either types.List or *types.List where ElementType MUST be types.Int64Type,
424414// returning a slice of ints of the value of each element.
425415func Int64ListToInts (v attr.Value ) []int {
426416 vt := ValueToListType (v )
@@ -431,7 +421,7 @@ func Int64ListToInts(v attr.Value) []int {
431421 return out
432422}
433423
434- // Int64SetToInts accepts an instance of either types.Set or *types.set where ElemType MUST be types.Int64Type
424+ // Int64SetToInts accepts an instance of either types.Set or *types.set where ElementType MUST be types.Int64Type
435425// returning a slice of ints of the value of each element
436426func Int64SetToInts (v attr.Value ) []int {
437427 vt := ValueToSetType (v )
@@ -442,7 +432,7 @@ func Int64SetToInts(v attr.Value) []int {
442432 return out
443433}
444434
445- // NumberListToInts accepts either an instance of types.List or *types.List where ElemType MUST be types.NumberType
435+ // NumberListToInts accepts either an instance of types.List or *types.List where ElementType MUST be types.NumberType
446436// returning a slice of ints of the value of each element
447437func NumberListToInts (v attr.Value ) []int {
448438 vt := ValueToListType (v )
@@ -454,7 +444,7 @@ func NumberListToInts(v attr.Value) []int {
454444 return out
455445}
456446
457- // NumberSetToInts accepts either an instance of types.Set or *types.Set where ElemType MUST be types.NumberType
447+ // NumberSetToInts accepts either an instance of types.Set or *types.Set where ElementType MUST be types.NumberType
458448// returning a slice of ints of the value of each element
459449func NumberSetToInts (v attr.Value ) []int {
460450 vt := ValueToSetType (v )
@@ -541,11 +531,23 @@ func AttributeValueToBigFloat(v attr.Value) (*big.Float, error) {
541531}
542532
543533// BoolToBoolValue takes a bool and wraps it up as a types.Bool
534+ // DEPRECATED: use types.BoolValue() directly
544535func BoolToBoolValue (b bool ) types.Bool {
545536 return types .BoolValue (b )
546537}
547538
539+ // BoolPtrToBoolValue accepts a bool pointer, returning a types.Bool with the dereferenced value.
540+ //
541+ // If the provided pointer is nil, the returned Bool type will be set as Null.
542+ func BoolPtrToBoolValue (b * bool ) types.Bool {
543+ if b == nil {
544+ return types .BoolNull ()
545+ }
546+ return types .BoolValue (* b )
547+ }
548+
548549// Int64ToInt64Value takes an int64 and wraps it up as a types.Int64
550+ // DEPRECATED: use types.Int64Value() directly
549551func Int64ToInt64Value (i int64 ) types.Int64 {
550552 return types .Int64Value (i )
551553}
@@ -557,7 +559,7 @@ func Int64ToNumberValue(i int64) types.Number {
557559
558560// IntToInt64Value takes an int and wraps it up as a types.Int64
559561func IntToInt64Value (i int ) types.Int64 {
560- return Int64ToInt64Value (int64 (i ))
562+ return types . Int64Value (int64 (i ))
561563}
562564
563565// IntPtrToInt64Value takes an *int and wraps it up as a types.Int64
@@ -576,6 +578,7 @@ func IntToNumberValue(i int) types.Number {
576578}
577579
578580// Float64ToFloat64Value takes a float64 and wraps it up as a types.Float64
581+ // DEPRECATED: use types.Float64Value() directly
579582func Float64ToFloat64Value (f float64 ) types.Float64 {
580583 return types .Float64Value (f )
581584}
@@ -587,7 +590,7 @@ func Float64ToNumberValue(f float64) types.Number {
587590
588591// Float32ToFloat64Value takes a float32 and wraps it up as a types.Float64
589592func Float32ToFloat64Value (f float32 ) types.Float64 {
590- return Float64ToFloat64Value (float64 (f ))
593+ return types . Float64Value (float64 (f ))
591594}
592595
593596// Float32ToNumberValue takes a float32 and wraps it up as a types.Number
@@ -596,6 +599,7 @@ func Float32ToNumberValue(f float32) types.Number {
596599}
597600
598601// StringToStringValue takes a string and wraps it up as a types.String
602+ // DEPRECATED: use types.StringValue() directly
599603func StringToStringValue (s string ) types.String {
600604 return types .StringValue (s )
601605}
@@ -606,10 +610,11 @@ func BytesToStringValue(b []byte) types.String {
606610 if b == nil {
607611 return types .StringNull ()
608612 }
609- return StringToStringValue (string (b ))
613+ return types . StringValue (string (b ))
610614}
611615
612616// StringPtrToStringValue takes a *string and wraps it up as a types.String
617+ //
613618// If the go value is nil, Null will be true on the outgoing attr.Value type
614619func StringPtrToStringValue (s * string ) types.String {
615620 if s == nil {
@@ -618,29 +623,70 @@ func StringPtrToStringValue(s *string) types.String {
618623 return types .StringValue (* s )
619624}
620625
621- // IntsToInt64List takes a slice of ints and creates a typed types.List with a ElemType of types.Int64Type and each
622- // value of Elems being an instance of types.Int64
626+ // StringsToStringList takes a slice of strings and creates a typed types.List with an ElementType of types.String
627+ // and each value of Elements being an instance of types.String
623628//
624- // If nullOnEmpty parameter is `true`, sets the Null field on the returned types.List to `true`. This can be used to
629+ // If nullOnEmpty parameter is `true`, the returned types.List will be set to Null. This can be used to
630+ // avoid Terraform state inconsistencies under certain circumstances.
631+ func StringsToStringList (in []string , nullOnEmpty bool ) types.List {
632+ inLen := len (in )
633+
634+ if nullOnEmpty && inLen == 0 {
635+ return types .ListNull (types .StringType )
636+ }
637+
638+ elems := make ([]attr.Value , inLen )
639+ for i , n := range in {
640+ elems [i ] = types .StringValue (n )
641+ }
642+
643+ return types .ListValueMust (types .StringType , elems )
644+ }
645+
646+ // StringsToStringSet takes a slice of strings and creates a typed types.Set with an ElementType of types.String
647+ // and each value of Elements being an instance of types.String
648+ //
649+ // If nullOnEmpty parameter is `true`, the returned types.Set will be set to Null. This can be used to
650+ // avoid Terraform state inconsistencies under certain circumstances.
651+ func StringsToStringSet (in []string , nullOnEmpty bool ) types.Set {
652+ inLen := len (in )
653+
654+ if nullOnEmpty && inLen == 0 {
655+ return types .SetNull (types .StringType )
656+ }
657+
658+ elems := make ([]attr.Value , inLen )
659+ for i , n := range in {
660+ elems [i ] = types .StringValue (n )
661+ }
662+
663+ return types .SetValueMust (types .StringType , elems )
664+ }
665+
666+ // IntsToInt64List takes a slice of ints and creates a typed types.List with a ElementType of types.Int64Type and each
667+ // value of Elements being an instance of types.Int64
668+ //
669+ // If nullOnEmpty parameter is `true`, the returned types.List will be set to Null. This can be used to
625670// avoid Terraform state inconsistencies under certain circumstances.
626671func IntsToInt64List (in []int , nullOnEmpty bool ) types.List {
627672 inLen := len (in )
673+
628674 if nullOnEmpty && inLen == 0 {
629675 return types .ListNull (types .Int64Type )
630676 }
631677
632- elems := make ([]attr.Value , len ( in ) )
678+ elems := make ([]attr.Value , inLen )
633679 for i , n := range in {
634680 elems [i ] = IntToInt64Value (n )
635681 }
636682
637683 return types .ListValueMust (types .Int64Type , elems )
638684}
639685
640- // IntsToInt64Set takes a slice of ints and creates a typed types.Set with an ElemType of types.Int64Type and each
641- // value of Elems being an instance of types.Int64
686+ // IntsToInt64Set takes a slice of ints and creates a typed types.Set with an ElementType of types.Int64Type and each
687+ // value of Elements being an instance of types.Int64
642688//
643- // If nullOnEmpty parameter is `true`, sets the Null field on the returned types.Set to `true` . This can be used to
689+ // If nullOnEmpty parameter is `true`, the returned types.Set will be set to Null . This can be used to
644690// avoid Terraform state inconsistencies under certain circumstances.
645691func IntsToInt64Set (in []int , nullOnEmpty bool ) types.Set {
646692 inLen := len (in )
0 commit comments