stack: stacks should be applyable even if no components are (#35498)

pull/35489/head^2
Liam Cervante 2 years ago committed by GitHub
parent d14e713c51
commit e704da535e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -449,13 +449,13 @@ func TestStacksPlanStackChanges(t *testing.T) {
PlannedChange: &terraform1.PlannedChange{
Raw: []*anypb.Any{
mustMarshalAnyPb(&tfstackdata1.PlanApplyable{
Applyable: false,
Applyable: true,
}),
},
Descriptions: []*terraform1.PlannedChange_ChangeDescription{
{
Description: &terraform1.PlannedChange_ChangeDescription_PlanApplyable{
PlanApplyable: false,
PlanApplyable: true,
},
},
},

@ -39,7 +39,7 @@ func Plan(ctx context.Context, req *PlanRequest, resp *PlanResponse) {
close(resp.PlannedChanges) // MUST be the last channel to close
}()
var errored, applyable bool
var errored bool
planTimestamp := time.Now().UTC()
if req.ForcePlanTimestamp != nil {
@ -58,11 +58,6 @@ func Plan(ctx context.Context, req *PlanRequest, resp *PlanResponse) {
main.PlanAll(ctx, stackeval.PlanOutput{
AnnouncePlannedChange: func(ctx context.Context, change stackplan.PlannedChange) {
resp.PlannedChanges <- change
if componentChange, ok := change.(*stackplan.PlannedChangeComponentInstance); ok {
if componentChange.PlanApplyable {
applyable = true
}
}
},
AnnounceDiagnostics: func(ctx context.Context, diags tfdiags.Diagnostics) {
for _, diag := range diags {
@ -82,9 +77,8 @@ func Plan(ctx context.Context, req *PlanRequest, resp *PlanResponse) {
resp.Diagnostics <- diag
}
// An overall stack plan is applyable if at least one of its component
// instances is applyable and we had no error diagnostics.
resp.Applyable = !errored && applyable
// An overall stack plan is applyable if it has no error diagnostics.
resp.Applyable = !errored
// Before we return we'll emit one more special planned change just to
// remember in the raw plan sequence whether we considered this plan to be

@ -359,7 +359,7 @@ func TestPlanWithVariableDefaults(t *testing.T) {
wantChanges := []stackplan.PlannedChange{
&stackplan.PlannedChangeApplyable{
Applyable: false,
Applyable: true,
},
&stackplan.PlannedChangeHeader{
TerraformVersion: version.SemVer,
@ -891,7 +891,7 @@ func TestPlanWithEphemeralInputVariables(t *testing.T) {
wantChanges := []stackplan.PlannedChange{
&stackplan.PlannedChangeApplyable{
Applyable: false,
Applyable: true,
},
&stackplan.PlannedChangeHeader{
TerraformVersion: version.SemVer,
@ -949,7 +949,7 @@ func TestPlanWithEphemeralInputVariables(t *testing.T) {
wantChanges := []stackplan.PlannedChange{
&stackplan.PlannedChangeApplyable{
Applyable: false,
Applyable: true,
},
&stackplan.PlannedChangeHeader{
TerraformVersion: version.SemVer,
@ -1008,7 +1008,7 @@ func TestPlanVariableOutputRoundtripNested(t *testing.T) {
wantChanges := []stackplan.PlannedChange{
&stackplan.PlannedChangeApplyable{
Applyable: false,
Applyable: true,
},
&stackplan.PlannedChangeHeader{
TerraformVersion: version.SemVer,
@ -2145,7 +2145,7 @@ func TestPlanWithDeferredResource(t *testing.T) {
wantChanges := []stackplan.PlannedChange{
&stackplan.PlannedChangeApplyable{
Applyable: false,
Applyable: true,
},
&stackplan.PlannedChangeComponentInstance{
Addr: stackaddrs.Absolute(
@ -2787,7 +2787,7 @@ func TestPlanWithDeferredEmbeddedStackForEach(t *testing.T) {
wantChanges := []stackplan.PlannedChange{
&stackplan.PlannedChangeApplyable{
Applyable: false,
Applyable: true,
},
&stackplan.PlannedChangeHeader{
TerraformVersion: version.SemVer,
@ -2933,7 +2933,7 @@ func TestPlanWithDeferredEmbeddedStackAndComponentForEach(t *testing.T) {
wantChanges := []stackplan.PlannedChange{
&stackplan.PlannedChangeApplyable{
Applyable: false,
Applyable: true,
},
&stackplan.PlannedChangeHeader{
TerraformVersion: version.SemVer,
@ -3140,7 +3140,7 @@ func TestPlanWithDeferredProviderForEach(t *testing.T) {
wantChanges := []stackplan.PlannedChange{
&stackplan.PlannedChangeApplyable{
Applyable: false,
Applyable: true,
},
&stackplan.PlannedChangeComponentInstance{
Addr: stackaddrs.Absolute(

Loading…
Cancel
Save