Commit 3eab8c8
authored
Validate that resource keys do not contain variable references (#5169)
## Changes
Validate that resource keys do not contain variable references
## Why
Fixes #5098
## Tests
Added an acceptance test, failed with panic before the fix
```
runtime/debug.Stack()
runtime/debug/stack.go:26 +0x5e
github.com/databricks/cli/cmd/root.Execute.func1()
github.com/databricks/cli/cmd/root/root.go:117 +0xb4
panic({0x7ff66a649480?, 0x7ff66bad51a0?})
runtime/panic.go:783 +0x132
github.com/databricks/cli/bundle/direct/dresources.(*ResourceSchema).PrepareState(0x0?, 0x0?)
github.com/databricks/cli/bundle/direct/dresources/schema.go:22
reflect.Value.call({0xc0001294a0?, 0xc000988ea8?, 0xc0006ae848?}, {0x7ff66a9b6321, 0x4}, {0xc0000d1bf0, 0x2, 0xc0006e4e18?})
reflect/value.go:581 +0xcc6
reflect.Value.Call({0xc0001294a0?, 0xc000988ea8?, 0x4?}, {0xc0000d1bf0?, 0x0?, 0x5?})
reflect/value.go:365 +0xb9
github.com/databricks/cli/libs/calladapt.(*BoundCaller).call(0xc000b93e00, {0xc0006aeab8?, 0x1, 0xc0006e4e0a?})
github.com/databricks/cli/libs/calladapt/calladapt.go:71 +0x765
github.com/databricks/cli/libs/calladapt.(*BoundCaller).Call(0xc000b93e00, {0xc0006aeab8?, 0x7ff66a9c3172?, 0xc?})
github.com/databricks/cli/libs/calladapt/calladapt.go:78 +0x2f
github.com/databricks/cli/bundle/direct/dresources.(*Adapter).PrepareState(0xc000421df8?, {0x0?, 0x0?})
github.com/databricks/cli/bundle/direct/dresources/adapter.go:374 +0x37
github.com/databricks/cli/bundle/direct.(*DeploymentBundle).makePlan(0xc000421df8, {0xc00014ea80?, 0x3e?}, 0xc000421858, 0xc000421e08)
github.com/databricks/cli/bundle/direct/bundle_plan.go:837 +0x7fd
github.com/databricks/cli/bundle/direct.(*DeploymentBundle).CalculatePlan(0xc000421df8, {0x7ff66acfa188, 0xc000b140c0}, 0xc000150908, 0xc000421858, {0xc00014ea80, 0x3e})
github.com/databricks/cli/bundle/direct/bundle_plan.go:124 +0xf0
github.com/databricks/cli/bundle/phases.RunPlan({0x7ff66acfa188, 0xc000b140c0}, 0xc000421808, {0x7ff66a9b8320?, 0x1000000000100?})
github.com/databricks/cli/bundle/phases/deploy.go:218 +0xf4
github.com/databricks/cli/cmd/bundle.newPlanCommand.func1(0xc00056cf08, {0xc000370be0?, 0x4?, 0x7ff66a9b6115?})
github.com/databricks/cli/cmd/bundle/plan.go:65 +0x1e5
github.com/spf13/cobra.(*Command).execute(0xc00056cf08, {0xc000370bc0, 0x2, 0x2})
github.com/spf13/cobra@v1.10.2/command.go:1015 +0xb02
github.com/spf13/cobra.(*Command).ExecuteC(0xc000394608)
github.com/spf13/cobra@v1.10.2/command.go:1148 +0x465
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
github.com/spf13/cobra@v1.10.2/command.go:1080
github.com/databricks/cli/cmd/root.Execute({0x7ff66acfa150, 0x7ff66bb62640}, 0xc000394608)
github.com/databricks/cli/cmd/root/root.go:149 +0x176
main.main()
github.com/databricks/cli/main.go:13 +0x3b
```1 parent 00a9f8a commit 3eab8c8
7 files changed
Lines changed: 99 additions & 2 deletions
File tree
- acceptance/bundle/variables/variable_in_resource_key
- bundle/config
- mutator
- validate
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
0 commit comments