add marks.Raw

This commit is contained in:
James Bardin 2021-06-25 14:27:43 -04:00
parent 55ebb2708c
commit 80ef795cbf
3 changed files with 6 additions and 2 deletions

View File

@ -109,7 +109,7 @@ var TypeFunc = function.New(&function.Spec{
}, },
Type: function.StaticReturnType(cty.String), Type: function.StaticReturnType(cty.String),
Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) { Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {
return cty.StringVal(TypeString(args[0].Type())).Mark("raw"), nil return cty.StringVal(TypeString(args[0].Type())).Mark(marks.Raw), nil
}, },
}) })

View File

@ -37,3 +37,7 @@ func Contains(val cty.Value, mark valueMark) bool {
// Sensitive indicates that this value is marked as sensitive in the context of // Sensitive indicates that this value is marked as sensitive in the context of
// Terraform. // Terraform.
var Sensitive = valueMark("sensitive") var Sensitive = valueMark("sensitive")
// Raw is used to indicate to the repl that the value should be written without
// any formatting.
var Raw = valueMark("raw")

View File

@ -17,7 +17,7 @@ func FormatValue(v cty.Value, indent int) string {
if !v.IsKnown() { if !v.IsKnown() {
return "(known after apply)" return "(known after apply)"
} }
if v.Type().Equals(cty.String) && v.HasMark("raw") { if v.Type().Equals(cty.String) && v.HasMark(marks.Raw) {
raw, _ := v.Unmark() raw, _ := v.Unmark()
return raw.AsString() return raw.AsString()
} }