@@ -632,34 +632,21 @@ func extractEnvbuilderFromImage(ctx context.Context, imgRef, destPath string) er
632
632
return fmt .Errorf ("extract envbuilder binary from image %q: %w" , imgRef , os .ErrNotExist )
633
633
}
634
634
635
- // The below interfaces are to handle converting Terraform types can be converted to a string.
636
- // The String() method on an attr.Value creates a 'human-readable' version of the type, which
637
- // leads to quotes, escaped characters, and other assorted sadness.
638
- type valuestringer interface {
639
- ValueString () string
640
- }
641
-
642
- type valuebooler interface {
643
- ValueBool () bool
644
- }
645
-
646
- type valueint64er interface {
647
- ValueInt64 () int64
648
- }
649
-
650
635
// tfValueToString converts an attr.Value to its string representation
651
- // based on its implementation of the above interfaces.
636
+ // based on its Terraform type. This is needed because the String()
637
+ // method on an attr.Value creates a 'human-readable' version of the type, which
638
+ // leads to quotes, escaped characters, and other assorted sadness.
652
639
func tfValueToString (val attr.Value ) string {
653
640
if val .IsUnknown () || val .IsNull () {
654
641
return ""
655
642
}
656
- if vs , ok := val .(valuestringer ); ok {
643
+ if vs , ok := val .(interface { ValueString () string } ); ok {
657
644
return vs .ValueString ()
658
645
}
659
- if vb , ok := val .(valuebooler ); ok {
646
+ if vb , ok := val .(interface { ValueBool () bool } ); ok {
660
647
return fmt .Sprintf ("%t" , vb .ValueBool ())
661
648
}
662
- if vi , ok := val .(valueint64er ); ok {
649
+ if vi , ok := val .(interface { ValueInt64 () int64 } ); ok {
663
650
return fmt .Sprintf ("%d" , vi .ValueInt64 ())
664
651
}
665
652
panic (fmt .Errorf ("tfValueToString: value %T is not a supported type" , val ))
0 commit comments