Skip to content

Commit 15804ae

Browse files
denikIsaac
andcommitted
Use structpath.NewPath for key/index paths
Co-authored-by: Isaac <no-reply@databricks.com>
1 parent 09c0030 commit 15804ae

42 files changed

Lines changed: 74 additions & 71 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎bundle/apps/validate.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func warnForAppResourcePermissions(b *bundle.Bundle, appKey string, app *resourc
167167
ref.permission,
168168
appKey,
169169
),
170-
Paths: structpath.NewStringKeysSlice("resources", "apps", appKey),
170+
Paths: structpath.NewPathSlice("resources", "apps", appKey),
171171
Locations: b.Config.GetLocations(appPath),
172172
})
173173
}

‎bundle/artifacts/expand_globs.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (e expandGlobs) Name() string {
4343
func (e expandGlobs) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
4444
// Base path for this mutator.
4545
// This path is set with the list of expanded globs when done.
46-
base := structpath.NewStringKeys(nil, "artifacts", e.name, "files")
46+
base := structpath.NewPath(nil, "artifacts", e.name, "files")
4747

4848
// Pattern to match the source key in the files sequence.
4949
pattern := structpath.NewPatternStringKey(structpath.NewPatternBracketStar(structpath.NewPatternStringKey(structpath.NewPatternStringKey(structpath.NewPatternStringKey(nil, "artifacts"), e.name), "files")), "source")
@@ -113,7 +113,7 @@ func (e expandGlobs) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnosti
113113
b.Config.UpdateSequence(base, sources)
114114
for i, locs := range locations {
115115
if locs != nil {
116-
b.Config.SetLocations(structpath.NewStringKey(structpath.NewIndex(base, i), "source"), locs)
116+
b.Config.SetLocations(structpath.NewPath(base, i, "source"), locs)
117117
}
118118
}
119119

‎bundle/config/mutator/apply_source_linked_deployment_preset.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
type applySourceLinkedDeploymentPreset struct{}
1515

1616
func targetPresetPath(target string) *structpath.PathNode {
17-
p := structpath.NewStringKeys(nil, "targets", target)
18-
return structpath.NewStringKeys(p, "presets", "source_linked_deployment")
17+
p := structpath.NewPath(nil, "targets", target)
18+
return structpath.NewPath(p, "presets", "source_linked_deployment")
1919
}
2020

2121
// Apply source-linked deployment preset

‎bundle/config/mutator/drop_empty_strings.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (m *dropEmptyStrings) Apply(ctx context.Context, b *bundle.Bundle) diag.Dia
5050
}
5151
}
5252
for _, name := range apps {
53-
err := b.Config.Set(structpath.NewStringKeys(appsPath, name, "description"), "")
53+
err := b.Config.Set(structpath.NewPath(appsPath, name, "description"), "")
5454
if err != nil {
5555
return diag.FromErr(err)
5656
}

‎bundle/config/mutator/load_dbalert_files.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (m *loadDBAlertFiles) Apply(ctx context.Context, b *bundle.Bundle) diag.Dia
5656
continue
5757
}
5858

59-
alertPath := structpath.NewStringKeys(nil, "resources", "alerts", alertKey)
59+
alertPath := structpath.NewPath(nil, "resources", "alerts", alertKey)
6060
alertV := b.Config.View().Lookup(alertPath)
6161

6262
// No other fields other than allowedInYAML should be set in the bundle YAML.

‎bundle/config/mutator/normalize_paths.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func collectGitSourcePaths(b *bundle.Bundle) []*structpath.PathNode {
7676
continue
7777
}
7878
if job.GitSource != nil {
79-
jobs = append(jobs, structpath.NewStringKeys(nil, "resources", "jobs", name))
79+
jobs = append(jobs, structpath.NewPath(nil, "resources", "jobs", name))
8080
}
8181
}
8282

‎bundle/config/mutator/paths/app_paths_visitor_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestAppPathsVisitor(t *testing.T) {
2424
}
2525

2626
actual := collectVisitedPaths(t, root, VisitAppPaths)
27-
expected := structpath.NewStringKeysSlice("resources", "apps", "app0", "source_code_path")
27+
expected := structpath.NewPathSlice("resources", "apps", "app0", "source_code_path")
2828

2929
assert.ElementsMatch(t, expected, actual)
3030
}

‎bundle/config/mutator/paths/artifact_paths_visitor_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestArtifactPathsVisitor(t *testing.T) {
1818
}
1919

2020
actual := collectVisitedPaths(t, root, VisitArtifactPaths)
21-
expected := structpath.NewStringKeysSlice("artifacts", "artifact0", "path")
21+
expected := structpath.NewPathSlice("artifacts", "artifact0", "path")
2222

2323
assert.ElementsMatch(t, expected, actual)
2424
}

‎bundle/config/mutator/paths/dashboard_paths_visitor_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestVisitDashboardPaths(t *testing.T) {
2121
}
2222

2323
actual := collectVisitedPaths(t, root, VisitDashboardPaths)
24-
expected := structpath.NewStringKeysSlice("resources", "dashboards", "dashboard0", "file_path")
24+
expected := structpath.NewPathSlice("resources", "dashboards", "dashboard0", "file_path")
2525

2626
assert.ElementsMatch(t, expected, actual)
2727
}

‎bundle/config/mutator/resolve_variable_references.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ func (m *resolveVariableReferences) resolveOnce(b *bundle.Bundle, prefixes []*st
285285
path := sp
286286
// Rewrite the shorthand path ${var.foo} into ${variables.foo.value}.
287287
if path.HasPrefix(varPath) {
288-
path = structpath.Join(structpath.NewStringKeys(nil, "variables", path.KeyAt(1), "value"), path.SkipPrefix(2).AsSlice()...)
288+
path = structpath.Join(structpath.NewPath(nil, "variables", path.KeyAt(1), "value"), path.SkipPrefix(2).AsSlice()...)
289289
}
290290

291291
// If the path starts with "artifacts", we need to add a metric to track if this reference is used.

0 commit comments

Comments
 (0)