Skip to content

Commit 1444c38

Browse files
standardize on marks.Has
1 parent 2657a4d commit 1444c38

File tree

12 files changed

+23
-23
lines changed

12 files changed

+23
-23
lines changed

internal/command/format/object_id.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func ObjectValueID(obj cty.Value) (k, v string) {
3434

3535
case atys["id"] == cty.String:
3636
v := obj.GetAttr("id")
37-
if v.HasMark(marks.Sensitive) {
37+
if marks.Has(v, marks.Sensitive) {
3838
break
3939
}
4040
v, _ = v.Unmark()
@@ -47,7 +47,7 @@ func ObjectValueID(obj cty.Value) (k, v string) {
4747
// "name" isn't always globally unique, but if there isn't also an
4848
// "id" then it _often_ is, in practice.
4949
v := obj.GetAttr("name")
50-
if v.HasMark(marks.Sensitive) {
50+
if marks.Has(v, marks.Sensitive) {
5151
break
5252
}
5353
v, _ = v.Unmark()
@@ -91,7 +91,7 @@ func ObjectValueName(obj cty.Value) (k, v string) {
9191

9292
case atys["name"] == cty.String:
9393
v := obj.GetAttr("name")
94-
if v.HasMark(marks.Sensitive) {
94+
if marks.Has(v, marks.Sensitive) {
9595
break
9696
}
9797
v, _ = v.Unmark()
@@ -102,15 +102,15 @@ func ObjectValueName(obj cty.Value) (k, v string) {
102102

103103
case atys["tags"].IsMapType() && atys["tags"].ElementType() == cty.String:
104104
tags := obj.GetAttr("tags")
105-
if tags.IsNull() || !tags.IsWhollyKnown() || tags.HasMark(marks.Sensitive) {
105+
if tags.IsNull() || !tags.IsWhollyKnown() || marks.Has(tags, marks.Sensitive) {
106106
break
107107
}
108108
tags, _ = tags.Unmark()
109109

110110
switch {
111111
case tags.HasIndex(cty.StringVal("name")).RawEquals(cty.True):
112112
v := tags.Index(cty.StringVal("name"))
113-
if v.HasMark(marks.Sensitive) {
113+
if marks.Has(v, marks.Sensitive) {
114114
break
115115
}
116116
v, _ = v.Unmark()
@@ -121,7 +121,7 @@ func ObjectValueName(obj cty.Value) (k, v string) {
121121
case tags.HasIndex(cty.StringVal("Name")).RawEquals(cty.True):
122122
// AWS-style naming convention
123123
v := tags.Index(cty.StringVal("Name"))
124-
if v.HasMark(marks.Sensitive) {
124+
if marks.Has(v, marks.Sensitive) {
125125
break
126126
}
127127
v, _ = v.Unmark()

internal/command/jsonstate/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ func marshalResources(resources map[string]*states.Resource, module addrs.Module
537537
}
538538

539539
func SensitiveAsBool(val cty.Value) cty.Value {
540-
if val.HasMark(marks.Sensitive) {
540+
if marks.Has(val, marks.Sensitive) {
541541
return cty.True
542542
}
543543

internal/command/views/json/diagnostic.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ func NewDiagnostic(diag tfdiags.Diagnostic, sources map[string][]byte) *Diagnost
346346
}
347347
}
348348
switch {
349-
case val.HasMark(marks.Sensitive) && val.HasMark(marks.Ephemeral):
349+
case marks.Has(val, marks.Sensitive) && marks.Has(val, marks.Ephemeral):
350350
// We only mention the combination of sensitive and ephemeral
351351
// values if the diagnostic we're rendering is explicitly
352352
// marked as being caused by sensitive and ephemeral values,
@@ -357,7 +357,7 @@ func NewDiagnostic(diag tfdiags.Diagnostic, sources map[string][]byte) *Diagnost
357357
}
358358

359359
value.Statement = "has an ephemeral, sensitive value"
360-
case val.HasMark(marks.Sensitive):
360+
case marks.Has(val, marks.Sensitive):
361361
// We only mention a sensitive value if the diagnostic
362362
// we're rendering is explicitly marked as being
363363
// caused by sensitive values, because otherwise
@@ -370,7 +370,7 @@ func NewDiagnostic(diag tfdiags.Diagnostic, sources map[string][]byte) *Diagnost
370370
// in order to minimize the chance of giving away
371371
// whatever was sensitive about it.
372372
value.Statement = "has a sensitive value"
373-
case val.HasMark(marks.Ephemeral):
373+
case marks.Has(val, marks.Ephemeral):
374374
if !includeEphemeral {
375375
continue Traversals
376376
}

internal/lang/funcs/sensitive.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ var IssensitiveFunc = function.New(&function.Spec{
7171
},
7272
Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {
7373
switch v := args[0]; {
74-
case v.HasMark(marks.Sensitive):
74+
case marks.Has(v, marks.Sensitive):
7575
return cty.True, nil
7676
case !v.IsKnown():
7777
return cty.UnknownVal(cty.Bool), nil

internal/lang/funcs/sensitive_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func TestSensitive(t *testing.T) {
6969
t.Fatalf("unexpected error: %s", err)
7070
}
7171

72-
if !got.HasMark(marks.Sensitive) {
72+
if !marks.Has(got, marks.Sensitive) {
7373
t.Errorf("result is not marked sensitive")
7474
}
7575

@@ -152,7 +152,7 @@ func TestNonsensitive(t *testing.T) {
152152
t.Fatalf("unexpected error: %s", err)
153153
}
154154

155-
if got.HasMark(marks.Sensitive) {
155+
if marks.Has(got, marks.Sensitive) {
156156
t.Errorf("result is still marked sensitive")
157157
}
158158
wantRaw, _ := test.Input.Unmark()

internal/repl/format.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ func FormatValue(v cty.Value, indent int) string {
2020
if !v.IsKnown() {
2121
return "(known after apply)"
2222
}
23-
if v.HasMark(marks.Sensitive) {
23+
if marks.Has(v, marks.Sensitive) {
2424
return "(sensitive value)"
2525
}
26-
if v.HasMark(marks.Ephemeral) {
26+
if marks.Has(v, marks.Ephemeral) {
2727
return "(ephemeral value)"
2828
}
2929
if v.IsNull() {

internal/stacks/stackruntime/internal/stackeval/for_each.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func evaluateForEachExpr(ctx context.Context, expr hcl.Expression, phase EvalPha
4646
invalidForEachDetail := fmt.Sprintf("The for_each expression must produce either a map of any type or a set of strings. The keys of the map or the set elements will serve as unique identifiers for multiple instances of this %s.", callerDiagName)
4747
const sensitiveForEachDetail = "Sensitive values, or values derived from sensitive values, cannot be used as for_each arguments. If used, the sensitive value could be exposed as a resource instance key."
4848
switch {
49-
case result.Value.HasMark(marks.Sensitive):
49+
case marks.Has(result.Value, marks.Sensitive):
5050
// Sensitive values are not allowed as for_each arguments because
5151
// they could be exposed as resource instance keys.
5252
// TODO: This should have Extra: tdiagnosticCausedBySensitive(true),

internal/terraform/eval_count.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func evaluateCountExpression(expr hcl.Expression, ctx EvalContext, allowUnknown
5252
}
5353

5454
// Ephemeral values are not allowed in count expressions.
55-
if countVal.HasMark(marks.Ephemeral) {
55+
if marks.Has(countVal, marks.Ephemeral) {
5656
diags = diags.Append(&hcl.Diagnostic{
5757
Severity: hcl.DiagError,
5858
Summary: "Invalid count argument",
@@ -87,7 +87,7 @@ func evaluateCountExpressionValue(expr hcl.Expression, ctx EvalContext) (cty.Val
8787
return nullCount, diags
8888
}
8989

90-
if countVal.HasMark(marks.Ephemeral) {
90+
if marks.Has(countVal, marks.Ephemeral) {
9191
diags = diags.Append(&hcl.Diagnostic{
9292
Severity: hcl.DiagError,
9393
Summary: "Invalid count argument",

internal/terraform/eval_for_each.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func (ev *forEachEvaluator) ensureNotEphemeral(forEachVal cty.Value) tfdiags.Dia
263263
// Ephemeral values are not allowed because instance keys persist from
264264
// plan to apply and between plan/apply rounds, whereas ephemeral values
265265
// do not.
266-
if forEachVal.HasMark(marks.Ephemeral) {
266+
if marks.Has(forEachVal, marks.Ephemeral) {
267267
diags = diags.Append(&hcl.Diagnostic{
268268
Severity: hcl.DiagError,
269269
Summary: "Invalid for_each argument",
@@ -315,7 +315,7 @@ func (ev *forEachEvaluator) validateResourceOrActionForEach(forEachVal cty.Value
315315
if blocktype == "action" {
316316
msg = "an action"
317317
}
318-
if forEachVal.HasMark(marks.Sensitive) {
318+
if marks.Has(forEachVal, marks.Sensitive) {
319319
diags = diags.Append(&hcl.Diagnostic{
320320
Severity: hcl.DiagError,
321321
Summary: "Invalid for_each argument",

internal/terraform/eval_import.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func parseImportToKeyExpression(expr hcl.Expression, keyData instances.Repetitio
241241
return idx, diags
242242
}
243243

244-
if val.HasMark(marks.Sensitive) {
244+
if marks.Has(val, marks.Sensitive) {
245245
diags = diags.Append(&hcl.Diagnostic{
246246
Severity: hcl.DiagError,
247247
Summary: "Invalid index expression",

0 commit comments

Comments
 (0)