@@ -92,27 +92,27 @@ func approvalForDeploy(ctx context.Context, b *bundle.Bundle, plan *deployplan.P
9292 return approved , nil
9393}
9494
95- func deployCore (ctx context.Context , b * bundle.Bundle , plan * deployplan.Plan ) {
95+ func deployCore (ctx context.Context , b * bundle.Bundle , plan * deployplan.Plan , directDeployment bool ) {
9696 // Core mutators that CRUD resources and modify deployment state. These
9797 // mutators need informed consent if they are potentially destructive.
9898 cmdio .LogString (ctx , "Deploying resources..." )
9999
100- if * b . DirectDeployment {
100+ if directDeployment {
101101 b .DeploymentBundle .Apply (ctx , b .WorkspaceClient (), & b .Config , plan )
102102 } else {
103103 bundle .ApplyContext (ctx , b , terraform .Apply ())
104104 }
105105
106106 // Even if deployment failed, there might be updates in states that we need to upload
107107 bundle .ApplyContext (ctx , b ,
108- statemgmt .StatePush (),
108+ statemgmt .StatePush (directDeployment ),
109109 )
110110 if logdiag .HasError (ctx ) {
111111 return
112112 }
113113
114114 bundle .ApplySeqContext (ctx , b ,
115- statemgmt .Load (),
115+ statemgmt .Load (directDeployment ),
116116 metadata .Compute (),
117117 metadata .Upload (),
118118 )
@@ -133,7 +133,7 @@ func uploadLibraries(ctx context.Context, b *bundle.Bundle, libs map[string][]li
133133}
134134
135135// The deploy phase deploys artifacts and resources.
136- func Deploy (ctx context.Context , b * bundle.Bundle , outputHandler sync.OutputHandler ) {
136+ func Deploy (ctx context.Context , b * bundle.Bundle , outputHandler sync.OutputHandler , directDeployment bool ) {
137137 log .Info (ctx , "Phase: deploy" )
138138
139139 // Core mutators that CRUD resources and modify deployment state. These
@@ -153,7 +153,7 @@ func Deploy(ctx context.Context, b *bundle.Bundle, outputHandler sync.OutputHand
153153 bundle .ApplyContext (ctx , b , lock .Release (lock .GoalDeploy ))
154154 }()
155155
156- libs := deployPrepare (ctx , b , false )
156+ libs := deployPrepare (ctx , b , false , directDeployment )
157157 if logdiag .HasError (ctx ) {
158158 return
159159 }
@@ -176,7 +176,7 @@ func Deploy(ctx context.Context, b *bundle.Bundle, outputHandler sync.OutputHand
176176 return
177177 }
178178
179- plan := planWithoutPrepare (ctx , b )
179+ plan := planWithoutPrepare (ctx , b , directDeployment )
180180 if logdiag .HasError (ctx ) {
181181 return
182182 }
@@ -187,7 +187,7 @@ func Deploy(ctx context.Context, b *bundle.Bundle, outputHandler sync.OutputHand
187187 return
188188 }
189189 if haveApproval {
190- deployCore (ctx , b , plan )
190+ deployCore (ctx , b , plan , directDeployment )
191191 } else {
192192 cmdio .LogString (ctx , "Deployment cancelled!" )
193193 return
@@ -203,8 +203,8 @@ func Deploy(ctx context.Context, b *bundle.Bundle, outputHandler sync.OutputHand
203203
204204// planWithoutPrepare builds a deployment plan without running deployPrepare.
205205// This is used when deployPrepare has already been called.
206- func planWithoutPrepare (ctx context.Context , b * bundle.Bundle ) * deployplan.Plan {
207- if * b . DirectDeployment {
206+ func planWithoutPrepare (ctx context.Context , b * bundle.Bundle , directDeployment bool ) * deployplan.Plan {
207+ if directDeployment {
208208 _ , localPath := b .StateFilenameDirect (ctx )
209209 plan , err := b .DeploymentBundle .CalculatePlan (ctx , b .WorkspaceClient (), & b .Config , localPath )
210210 if err != nil {
@@ -236,16 +236,27 @@ func planWithoutPrepare(ctx context.Context, b *bundle.Bundle) *deployplan.Plan
236236 return nil
237237 }
238238
239+ for _ , group := range b .Config .Resources .AllResources () {
240+ for rKey := range group .Resources {
241+ resourceKey := "resources." + group .Description .PluralName + "." + rKey
242+ if _ , ok := plan .Plan [resourceKey ]; ! ok {
243+ plan .Plan [resourceKey ] = & deployplan.PlanEntry {
244+ Action : deployplan .ActionTypeSkip .String (),
245+ }
246+ }
247+ }
248+ }
249+
239250 return plan
240251}
241252
242- func Plan (ctx context.Context , b * bundle.Bundle ) * deployplan.Plan {
243- deployPrepare (ctx , b , true )
253+ func Plan (ctx context.Context , b * bundle.Bundle , directDeployment bool ) * deployplan.Plan {
254+ deployPrepare (ctx , b , true , directDeployment )
244255 if logdiag .HasError (ctx ) {
245256 return nil
246257 }
247258
248- return planWithoutPrepare (ctx , b )
259+ return planWithoutPrepare (ctx , b , directDeployment )
249260}
250261
251262// If there are more than 1 thousand of a resource type, do not
0 commit comments