@@ -64,10 +64,9 @@ func (m *terranovaApplyMutator) Apply(ctx context.Context, b *bundle.Bundle) dia
6464 }
6565
6666 d := Deployer {
67- client : client ,
68- db : & b .ResourceDatabase ,
69- // TODO: rename section to Group
70- section : node .Group ,
67+ client : client ,
68+ db : & b .ResourceDatabase ,
69+ group : node .Group ,
7170 resourceName : node .Name ,
7271 }
7372
@@ -93,34 +92,34 @@ func (m *terranovaApplyMutator) Apply(ctx context.Context, b *bundle.Bundle) dia
9392type Deployer struct {
9493 client * databricks.WorkspaceClient
9594 db * tnstate.TerranovaState
96- section string
95+ group string
9796 resourceName string
9897}
9998
10099func (d * Deployer ) Deploy (ctx context.Context , inputConfig any , actionType deployplan.ActionType ) error {
101100 if actionType == deployplan .ActionTypeDelete {
102101 err := d .destroy (ctx , inputConfig )
103102 if err != nil {
104- return fmt .Errorf ("destroying %s.%s: %w" , d .section , d .resourceName , err )
103+ return fmt .Errorf ("destroying %s.%s: %w" , d .group , d .resourceName , err )
105104 }
106105 return nil
107106 }
108107
109108 err := d .deploy (ctx , inputConfig , actionType )
110109 if err != nil {
111- return fmt .Errorf ("deploying %s.%s: %w" , d .section , d .resourceName , err )
110+ return fmt .Errorf ("deploying %s.%s: %w" , d .group , d .resourceName , err )
112111 }
113112 return nil
114113}
115114
116115func (d * Deployer ) destroy (ctx context.Context , inputConfig any ) error {
117- entry , hasEntry := d .db .GetResourceEntry (d .section , d .resourceName )
116+ entry , hasEntry := d .db .GetResourceEntry (d .group , d .resourceName )
118117 if ! hasEntry {
119- log .Infof (ctx , "%s.%s: Cannot delete, missing from state" , d .section , d .resourceName )
118+ log .Infof (ctx , "%s.%s: Cannot delete, missing from state" , d .group , d .resourceName )
120119 return nil
121120 }
122121
123- resource , _ , err := tnresources .New (d .client , d .section , d .resourceName , inputConfig )
122+ resource , _ , err := tnresources .New (d .client , d .group , d .resourceName , inputConfig )
124123 if err != nil {
125124 return err
126125 }
@@ -138,9 +137,9 @@ func (d *Deployer) destroy(ctx context.Context, inputConfig any) error {
138137}
139138
140139func (d * Deployer ) deploy (ctx context.Context , inputConfig any , actionType deployplan.ActionType ) error {
141- entry , hasEntry := d .db .GetResourceEntry (d .section , d .resourceName )
140+ entry , hasEntry := d .db .GetResourceEntry (d .group , d .resourceName )
142141
143- resource , cfgType , err := tnresources .New (d .client , d .section , d .resourceName , inputConfig )
142+ resource , cfgType , err := tnresources .New (d .client , d .group , d .resourceName , inputConfig )
144143 if err != nil {
145144 return err
146145 }
@@ -182,7 +181,7 @@ func (d *Deployer) deploy(ctx context.Context, inputConfig any, actionType deplo
182181
183182 // localDiffType is either None or Partial: we should proceed to fetching remote state and calculate local+remote diff
184183
185- log .Debugf (ctx , "Unchanged %s.%s id=%#v" , d .section , d .resourceName , oldID )
184+ log .Debugf (ctx , "Unchanged %s.%s id=%#v" , d .group , d .resourceName , oldID )
186185 return nil
187186}
188187
@@ -192,9 +191,9 @@ func (d *Deployer) Create(ctx context.Context, resource tnresources.IResource, c
192191 return fmt .Errorf ("creating: %w" , err )
193192 }
194193
195- log .Infof (ctx , "Created %s.%s id=%#v" , d .section , d .resourceName , newID )
194+ log .Infof (ctx , "Created %s.%s id=%#v" , d .group , d .resourceName , newID )
196195
197- err = d .db .SaveState (d .section , d .resourceName , newID , config )
196+ err = d .db .SaveState (d .group , d .resourceName , newID , config )
198197 if err != nil {
199198 return fmt .Errorf ("saving state after creating id=%s: %w" , newID , err )
200199 }
@@ -213,12 +212,12 @@ func (d *Deployer) Recreate(ctx context.Context, oldResource tnresources.IResour
213212 return fmt .Errorf ("deleting old id=%s: %w" , oldID , err )
214213 }
215214
216- err = d .db .SaveState (d .section , d .resourceName , "" , nil )
215+ err = d .db .SaveState (d .group , d .resourceName , "" , nil )
217216 if err != nil {
218217 return fmt .Errorf ("deleting state: %w" , err )
219218 }
220219
221- newResource , _ , err := tnresources .New (d .client , d .section , d .resourceName , config )
220+ newResource , _ , err := tnresources .New (d .client , d .group , d .resourceName , config )
222221 if err != nil {
223222 return fmt .Errorf ("initializing: %w" , err )
224223 }
@@ -228,8 +227,8 @@ func (d *Deployer) Recreate(ctx context.Context, oldResource tnresources.IResour
228227 return fmt .Errorf ("re-creating: %w" , err )
229228 }
230229
231- log .Warnf (ctx , "Re-created %s.%s id=%#v (previously %#v)" , d .section , d .resourceName , newID , oldID )
232- err = d .db .SaveState (d .section , d .resourceName , newID , config )
230+ log .Warnf (ctx , "Re-created %s.%s id=%#v (previously %#v)" , d .group , d .resourceName , newID , oldID )
231+ err = d .db .SaveState (d .group , d .resourceName , newID , config )
233232 if err != nil {
234233 return fmt .Errorf ("saving state for id=%s: %w" , newID , err )
235234 }
@@ -249,12 +248,12 @@ func (d *Deployer) Update(ctx context.Context, resource tnresources.IResource, o
249248 }
250249
251250 if oldID != newID {
252- log .Infof (ctx , "Updated %s.%s id=%#v (previously %#v)" , d .section , d .resourceName , newID , oldID )
251+ log .Infof (ctx , "Updated %s.%s id=%#v (previously %#v)" , d .group , d .resourceName , newID , oldID )
253252 } else {
254- log .Infof (ctx , "Updated %s.%s id=%#v" , d .section , d .resourceName , newID )
253+ log .Infof (ctx , "Updated %s.%s id=%#v" , d .group , d .resourceName , newID )
255254 }
256255
257- err = d .db .SaveState (d .section , d .resourceName , newID , config )
256+ err = d .db .SaveState (d .group , d .resourceName , newID , config )
258257 if err != nil {
259258 return fmt .Errorf ("saving state id=%s: %w" , oldID , err )
260259 }
@@ -273,7 +272,7 @@ func (d *Deployer) Delete(ctx context.Context, resource tnresources.IResource, o
273272 return fmt .Errorf ("deleting id=%s: %w" , oldID , err )
274273 }
275274
276- err = d .db .DeleteState (d .section , d .resourceName )
275+ err = d .db .DeleteState (d .group , d .resourceName )
277276 if err != nil {
278277 return fmt .Errorf ("deleting state id=%s: %w" , oldID , err )
279278 }
0 commit comments