@@ -55,13 +55,8 @@ func (m *terranovaDeployMutator) Apply(ctx context.Context, b *bundle.Bundle) di
5555 countDeployed := 0
5656
5757 err = g .Run (maxPoolSize , func (node tnstate.ResourceNode ) {
58- // TODO func(node string) bool
59- // If function returns false, downstream callers are not called
60- // g.Run() should return list of not executed nodes
61- // log.Warnf(ctx, "Processing node=%s", node)
62-
63- // TODO: resolve all resource references inside this resource. It should be possible, if graph was constructed correctly.
64- // If it is not possible, return error (and fail this and dependent resources)
58+ // TODO: if a given node fails, all downstream nodes should not be run. We should report those nodes.
59+ // TODO: ensure that config for this node is fully resolved at this point.
6560
6661 config , ok := b .GetResourceConfig (node .Section , node .Name )
6762 if ! ok {
@@ -81,7 +76,6 @@ func (m *terranovaDeployMutator) Apply(ctx context.Context, b *bundle.Bundle) di
8176 diags .AppendError (err )
8277 return
8378 }
84- // TODO handle error; count stats
8579
8680 countDeployed = countDeployed + 1
8781 })
@@ -94,8 +88,10 @@ func (m *terranovaDeployMutator) Apply(ctx context.Context, b *bundle.Bundle) di
9488 cmdio .LogString (ctx , "Updating deployment state..." )
9589 }
9690
97- _ = b .ResourceDatabase .Finalize ()
98- // TODO: handle errors
91+ err = b .ResourceDatabase .Finalize ()
92+ if err != nil {
93+ diags .AppendError (err )
94+ }
9995
10096 return diags .Diags
10197}
@@ -128,7 +124,7 @@ func (d *Deployer) deploy(ctx context.Context, inputConfig any) error {
128124
129125 config := resource .Config ()
130126
131- // presence of id in the state file implies that the resource was created by us
127+ // Presence of id in the state file implies that the resource was created by us
132128
133129 if oldID == "" {
134130 newID , err := resource .DoCreate (ctx )
@@ -150,11 +146,11 @@ func (d *Deployer) deploy(ctx context.Context, inputConfig any) error {
150146 if err != nil {
151147 return fmt .Errorf ("reading state: %w" , err )
152148 }
149+
153150 localDiff , err := structdiff .GetStructDiff (savedState , config )
154151 if err != nil {
155152 return fmt .Errorf ("state error: %w" , err )
156153 }
157- // log.Warnf(ctx, "localDiff: %#v", localDiff)
158154
159155 localDiffType := tnresources .ChangeTypeNone
160156 if len (localDiff ) > 0 {
@@ -169,12 +165,7 @@ func (d *Deployer) deploy(ctx context.Context, inputConfig any) error {
169165 return d .Update (ctx , resource , oldID , config )
170166 }
171167
172- // localDiffType is either None or Partial: we should proceed to remote diff
173-
174- // remoteState := DoRead()
175- // compare config and remoteState
176- // OR compare config and state + config and remoteState separately
177- // decide what to do for this: config=X state=Y remoteState=X; should this trigger deploy? probably not.
168+ // localDiffType is either None or Partial: we should proceed to fetching remote state and calculate local+remote diff
178169
179170 log .Warnf (ctx , "Unchanged %s.%s id=%#v" , d .section , d .resourceName , oldID )
180171 return nil
0 commit comments