Skip to content

Commit f969bed

Browse files
committed
clean up; do not ignore errors
1 parent 6d24059 commit f969bed

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

bundle/config/resources_types.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ import (
99
// ResourcesTypes maps the configuration key of each Databricks resource section (for example
1010
// "jobs" or "pipelines") to the Go type that represents a single resource instance inside
1111
// that section (for example `resources.Job`).
12-
//
13-
// The map is populated at package‐initialisation time by inspecting the `Resources` struct with
14-
// reflection, so it automatically stays up-to-date when new resource kinds are added.
1512
var ResourcesTypes = func() map[string]reflect.Type {
1613
var r Resources
1714
rt := reflect.TypeOf(r)

bundle/terranova/deploy_mutator.go

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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

bundle/terranova/destroy_mutator.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ func (m *terranovaDestroyMutator) Apply(ctx context.Context, b *bundle.Bundle) d
5252
diags.AppendError(err)
5353
}
5454

55-
_ = b.ResourceDatabase.Finalize()
55+
err = b.ResourceDatabase.Finalize()
56+
if err != nil {
57+
diags.AppendError(err)
58+
}
5659

5760
return diags.Diags
5861
}

0 commit comments

Comments
 (0)