Skip to content

Commit 1e97ca1

Browse files
dsa0xSarahFrench
andcommitted
Apply suggestions from code review
Co-authored-by: Sarah French <15078782+SarahFrench@users.noreply.github.com>
1 parent 6216d80 commit 1e97ca1

4 files changed

Lines changed: 14 additions & 7 deletions

File tree

internal/plans/plan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ type Plan struct {
171171
FunctionResults []lang.FunctionResultHash
172172

173173
// PolicyResults stores the results of policy evaluations that were performed
174-
// while making this plan.
174+
// while making this plan. These policy results will not be serialized in the plan file.
175175
PolicyResults *PolicyResults
176176
}
177177

internal/terraform/context_apply.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ type ApplyOpts struct {
5050
AllowRootEphemeralOutputs bool
5151

5252
// Locks is a read-only snapshot of provider locks (from the dependency lock
53-
// file).
53+
// file). This is required by policy evaluations against providers to access version information.
5454
Locks map[addrs.Provider]*depsfile.ProviderLock
5555

56-
// Optional policy client to enable live policy evaluations.
56+
// Optional policy client.
57+
// When set, policy evaluation logic will be executed in the graph.
58+
// When nil, that logic will be skipped.
5759
PolicyClient policy.Client
5860
PolicyResults *plans.PolicyResults
5961
}

internal/terraform/context_plan_policy_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,16 +958,21 @@ func TestContext2Plan_PolicyEvaluation(t *testing.T) {
958958
default = "default"
959959
}
960960
961+
variable "input2" {
962+
type = string
963+
default = "default"
964+
}
965+
961966
resource "test_instance" "test" {
962967
value = var.input
963968
}
964969
965970
resource "test_instance" "test2" {
966-
value = resource.test_instance.test.id
971+
value = var.input2
967972
}
968973
969974
output "output" {
970-
value = test_instance.test2.value
975+
value = resource.test_instance.test.value
971976
}
972977
`,
973978
prepareExpectations: func(t *testing.T, data *data) {

internal/terraform/node_module_expand.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,10 @@ func (n *nodeExpandModule) EvalPolicy(ctx EvalContext, op walkOperation) tfdiags
347347
// value = var.input
348348
// }
349349
// resource "test_instance" "test2" {
350-
// value = resource.test_instance.test.id
350+
// value = var.input2
351351
// }
352352
// output "output" {
353-
// value = test_instance.test2.value
353+
// value = resource.test_instance.test.value
354354
// }
355355
//
356356
// This is a valid terraform module call, but the input2 value depends on the module's output,

0 commit comments

Comments
 (0)