mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
5d7cb81c0c
Some function errors include values derived from arguments. This commit is the result of a manual audit of these errors, which resulted in: - Adding a helper function to redact sensitive values; - Applying that helper function where errors include values derived from possibly-sensitive arguments; - Cleaning up other errors which need not include those values, or were otherwise incorrect.
21 lines
420 B
Go
21 lines
420 B
Go
package funcs
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hashicorp/terraform/internal/lang/marks"
|
|
"github.com/zclconf/go-cty/cty"
|
|
)
|
|
|
|
func redactIfSensitive(value interface{}, markses ...cty.ValueMarks) string {
|
|
if marks.Has(cty.DynamicVal.WithMarks(markses...), marks.Sensitive) {
|
|
return "(sensitive value)"
|
|
}
|
|
switch v := value.(type) {
|
|
case string:
|
|
return fmt.Sprintf("%q", v)
|
|
default:
|
|
return fmt.Sprintf("%v", v)
|
|
}
|
|
}
|