Skip to content

Commit 2be1048

Browse files
committed
rename to override_during
1 parent 2f014ac commit 2be1048

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

internal/command/test_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func TestTest_Runs(t *testing.T) {
225225
"mocking-invalid": {
226226
expectedErr: []string{
227227
"Invalid outputs attribute",
228-
"The override_target attribute must be a value of plan or apply.",
228+
"The override_during attribute must be a value of plan or apply.",
229229
},
230230
initCode: 1,
231231
},
@@ -1763,7 +1763,7 @@ condition depended on is not known until after the plan has been applied.
17631763
Either remove this value from your condition, or execute an %s command
17641764
from this %s block. Alternatively, if there is an override for this value,
17651765
you can make it available during the plan phase by setting %s in the %s block.
1766-
`, "`run`", "`command = plan`", "`apply`", "`run`", "`override_target\n= plan`", "`override_`"),
1766+
`, "`run`", "`command = plan`", "`apply`", "`run`", "`override_during\n= plan`", "`override_`"),
17671767
},
17681768
"unknown_value_in_vars": {
17691769
code: 1,

internal/command/testdata/test/mocking-error/tests/plan_mocked_provider.tftest.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ run "test" {
1919

2020
assert {
2121
condition = test_resource.secondary[0].id == "ffff"
22-
error_message = "plan should use the mocked provider value when override_target is plan"
22+
error_message = "plan should use the mocked provider value when override_during is plan"
2323
}
2424

2525
}

internal/command/testdata/test/mocking-invalid/tests/override_computed_invalid_boolean.tftest.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mock_provider "test" {
22
alias = "primary"
3-
override_target = baz // This should either be plan or apply, therefore this test should fail
3+
override_during = baz // This should either be plan or apply, therefore this test should fail
44

55
mock_resource "test_resource" {
66
defaults = {

internal/command/testdata/test/mocking/tests/plan_mocked_overridden.tftest.hcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mock_provider "test" {
99

1010
override_resource {
1111
target = test_resource.primary
12-
override_target = plan
12+
override_during = plan
1313
values = {
1414
id = "bbbb"
1515
}
@@ -26,7 +26,7 @@ run "test" {
2626

2727
assert {
2828
condition = test_resource.primary[0].id == "bbbb"
29-
error_message = "plan should override the value when override_target is plan"
29+
error_message = "plan should override the value when override_during is plan"
3030
}
3131

3232
}

internal/command/testdata/test/mocking/tests/plan_mocked_provider.tftest.hcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mock_provider "test" {
22
alias = "secondary"
3-
override_target = plan
3+
override_during = plan
44

55
mock_resource "test_resource" {
66
defaults = {
@@ -20,7 +20,7 @@ run "test" {
2020

2121
assert {
2222
condition = test_resource.secondary[0].id == "ffff"
23-
error_message = "plan should use the mocked provider value when override_target is plan"
23+
error_message = "plan should use the mocked provider value when override_during is plan"
2424
}
2525

2626
}

internal/command/testdata/test/mocking/tests/plan_mocked_provider_overridden.tftest.hcl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mock_provider "test" {
22
alias = "primary"
3-
override_target = plan
3+
override_during = plan
44

55
mock_resource "test_resource" {
66
defaults = {
@@ -17,7 +17,7 @@ mock_provider "test" {
1717

1818
override_resource {
1919
target = test_resource.primary[1]
20-
override_target = apply // this should take precedence over the provider-level override_target
20+
override_during = apply // this should take precedence over the provider-level override_during
2121
values = {
2222
id = "bbbb"
2323
}
@@ -27,7 +27,7 @@ mock_provider "test" {
2727

2828
override_resource {
2929
target = test_resource.secondary[0]
30-
override_target = plan
30+
override_during = plan
3131
values = {
3232
id = "ssss"
3333
}
@@ -44,12 +44,12 @@ run "test" {
4444

4545
assert {
4646
condition = test_resource.primary[0].id == "bbbb"
47-
error_message = "plan should override the value when override_target is plan"
47+
error_message = "plan should override the value when override_during is plan"
4848
}
4949

5050
assert {
5151
condition = test_resource.secondary[0].id == "ssss"
52-
error_message = "plan should override the value when override_target is plan"
52+
error_message = "plan should override the value when override_during is plan"
5353
}
5454

5555
}

internal/configs/mock_provider.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var (
1616
// When this attribute is set to plan, the values specified in the override
1717
// block will be used for computed attributes even when planning. It defaults
1818
// to apply, meaning that the values will only be used during apply.
19-
overrideTargetCommand = "override_target"
19+
overrideDuringCommand = "override_during"
2020
)
2121

2222
func decodeMockProviderBlock(block *hcl.Block) (*Provider, hcl.Diagnostics) {
@@ -72,16 +72,16 @@ func decodeMockProviderBlock(block *hcl.Block) (*Provider, hcl.Diagnostics) {
7272
return provider, diags
7373
}
7474

75-
func extractOverrideComputed(content *hcl.BodyContent) (*string, hcl.Diagnostics) {
75+
func extractOverrideDuring(content *hcl.BodyContent) (*string, hcl.Diagnostics) {
7676
var diags hcl.Diagnostics
7777

78-
if attr, exists := content.Attributes[overrideTargetCommand]; exists {
78+
if attr, exists := content.Attributes[overrideDuringCommand]; exists {
7979
overrideComputedStr := hcl.ExprAsKeyword(attr.Expr)
8080
if overrideComputedStr != "plan" && overrideComputedStr != "apply" {
8181
diags = diags.Append(&hcl.Diagnostic{
8282
Severity: hcl.DiagError,
83-
Summary: fmt.Sprintf("Invalid %s value", overrideTargetCommand),
84-
Detail: fmt.Sprintf("The %s attribute must be a value of plan or apply.", overrideTargetCommand),
83+
Summary: fmt.Sprintf("Invalid %s value", overrideDuringCommand),
84+
Detail: fmt.Sprintf("The %s attribute must be a value of plan or apply.", overrideDuringCommand),
8585
Subject: attr.Range.Ptr(),
8686
})
8787
}
@@ -235,7 +235,7 @@ func decodeMockDataBody(body hcl.Body, source OverrideSource) (*MockData, hcl.Di
235235
diags = append(diags, contentDiags...)
236236

237237
// provider-level setting for overrideComputed
238-
providerOverrideComputed, valueDiags := extractOverrideComputed(content)
238+
providerOverrideComputed, valueDiags := extractOverrideDuring(content)
239239
diags = append(diags, valueDiags...)
240240
useForPlan := providerOverrideComputed != nil && *providerOverrideComputed == "plan"
241241
data := &MockData{
@@ -460,7 +460,7 @@ func decodeOverrideBlock(block *hcl.Block, attributeName string, blockName strin
460460
content, contentDiags := block.Body.Content(&hcl.BodySchema{
461461
Attributes: []hcl.AttributeSchema{
462462
{Name: "target"},
463-
{Name: overrideTargetCommand},
463+
{Name: overrideDuringCommand},
464464
{Name: attributeName},
465465
},
466466
})
@@ -502,8 +502,8 @@ func decodeOverrideBlock(block *hcl.Block, attributeName string, blockName strin
502502
override.Values = cty.EmptyObjectVal
503503
}
504504

505-
// Override computed values during planning if override_target is plan.
506-
overrideComputedStr, valueDiags := extractOverrideComputed(content)
505+
// Override computed values during planning if override_during is plan.
506+
overrideComputedStr, valueDiags := extractOverrideDuring(content)
507507
diags = append(diags, valueDiags...)
508508
if overrideComputedStr != nil {
509509
useForPlan := *overrideComputedStr == "plan"
@@ -544,7 +544,7 @@ var mockProviderSchema = &hcl.BodySchema{
544544

545545
var mockDataSchema = &hcl.BodySchema{
546546
Attributes: []hcl.AttributeSchema{
547-
{Name: overrideTargetCommand},
547+
{Name: overrideDuringCommand},
548548
},
549549
Blocks: []hcl.BlockHeaderSchema{
550550
{Type: "mock_resource", LabelNames: []string{"type"}},

internal/moduletest/eval_context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func (ec *EvalContext) Evaluate() (Status, cty.Value, tfdiags.Diagnostics) {
141141
diags = diags.Append(&hcl.Diagnostic{
142142
Severity: hcl.DiagError,
143143
Summary: "Unknown condition value",
144-
Detail: "Condition expression could not be evaluated at this time. This means you have executed a `run` block with `command = plan` and one of the values your condition depended on is not known until after the plan has been applied. Either remove this value from your condition, or execute an `apply` command from this `run` block. Alternatively, if there is an override for this value, you can make it available during the plan phase by setting `override_target = plan` in the `override_` block.",
144+
Detail: "Condition expression could not be evaluated at this time. This means you have executed a `run` block with `command = plan` and one of the values your condition depended on is not known until after the plan has been applied. Either remove this value from your condition, or execute an `apply` command from this `run` block. Alternatively, if there is an override for this value, you can make it available during the plan phase by setting `override_during = plan` in the `override_` block.",
145145
Subject: rule.Condition.Range().Ptr(),
146146
Expression: rule.Condition,
147147
EvalContext: hclCtx,

0 commit comments

Comments
 (0)