Skip to content

Commit d34bce2

Browse files
authored
Add locations to summary --show-full-config output (#4239)
## Changes Always output location information for `bundle summary --show-full-config` ## Why Locations are needed to resolve dashboard file paths (specified relative to the YAML file they are defined in) relative to the bundle root path. ## Tests Updated acceptance test
1 parent 6b7a7f8 commit d34bce2

File tree

6 files changed

+113
-5
lines changed

6 files changed

+113
-5
lines changed

acceptance/bundle/summary/show-full-config/databricks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ bundle:
33

44
include:
55
- targets/*.yml
6+
- resources/*.yml
67

78
variables:
89
mode:

acceptance/bundle/summary/show-full-config/output.txt

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,107 @@
11

2-
>>> [CLI] bundle summary --show-full-config
2+
>>> [CLI] bundle summary --show-full-config --include-locations
33
{
4+
"__locations": {
5+
"files": [
6+
"databricks.yml",
7+
"resources/my_dashboard.dashboard.yml",
8+
"targets/default.yml",
9+
"targets/not_default.yml",
10+
"targets/variable_default.yml",
11+
"targets/variable_mode.yml"
12+
],
13+
"locations": {
14+
"bundle": [
15+
[
16+
0,
17+
2,
18+
3
19+
]
20+
],
21+
"include": [
22+
[
23+
0,
24+
5,
25+
3
26+
]
27+
],
28+
"resources": [
29+
[
30+
1,
31+
2,
32+
3
33+
]
34+
],
35+
"resources.dashboards": [
36+
[
37+
1,
38+
3,
39+
5
40+
]
41+
],
42+
"resources.dashboards.my_dashboard": [
43+
[
44+
1,
45+
4,
46+
7
47+
]
48+
],
49+
"targets": [
50+
[
51+
0,
52+
15,
53+
3
54+
],
55+
[
56+
2,
57+
2,
58+
3
59+
],
60+
[
61+
3,
62+
2,
63+
3
64+
],
65+
[
66+
4,
67+
2,
68+
3
69+
],
70+
[
71+
5,
72+
2,
73+
3
74+
]
75+
],
76+
"variables": [
77+
[
78+
0,
79+
9,
80+
3
81+
]
82+
]
83+
},
84+
"version": 1
85+
},
486
"bundle": {
587
"name": "test-bundle"
688
},
789
"include": [
890
"targets/default.yml",
991
"targets/not_default.yml",
1092
"targets/variable_default.yml",
11-
"targets/variable_mode.yml"
93+
"targets/variable_mode.yml",
94+
"resources/my_dashboard.dashboard.yml"
1295
],
96+
"resources": {
97+
"dashboards": {
98+
"my_dashboard": {
99+
"display_name": "My Dashboard",
100+
"file_path": "../src/my_dashboard.lvdash.json",
101+
"warehouse_id": "[NUMID]abcdef"
102+
}
103+
}
104+
},
13105
"targets": {
14106
"also_default": {
15107
"default": true,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
resources:
2+
dashboards:
3+
my_dashboard:
4+
display_name: My Dashboard
5+
file_path: ../src/my_dashboard.lvdash.json
6+
warehouse_id: 1234567890abcdef
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
trace $CLI bundle summary --show-full-config
1+
trace $CLI bundle summary --show-full-config --include-locations
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

cmd/bundle/summary.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Useful after deployment to see what was created and where to find it.`,
3939
cmd.SetContext(ctx)
4040
logdiag.SetSeverity(ctx, diag.Warning)
4141

42-
err = showFullConfig(ctx, cmd)
42+
err = showFullConfig(ctx, cmd, includeLocations)
4343
if err != nil {
4444
return err
4545
}
@@ -68,7 +68,7 @@ Useful after deployment to see what was created and where to find it.`,
6868
return cmd
6969
}
7070

71-
func showFullConfig(ctx context.Context, cmd *cobra.Command) error {
71+
func showFullConfig(ctx context.Context, cmd *cobra.Command, includeLocations bool) error {
7272
// call `MustLoad` directly instead of `MustConfigureBundle` because the latter does
7373
// validation that we're not interested in here
7474
b := bundle.MustLoad(ctx)
@@ -81,6 +81,14 @@ func showFullConfig(ctx context.Context, cmd *cobra.Command) error {
8181
return nil
8282
}
8383

84+
if includeLocations {
85+
// Include location information in the output
86+
bundle.ApplyContext(ctx, b, mutator.PopulateLocations())
87+
if logdiag.HasError(ctx) {
88+
return nil
89+
}
90+
}
91+
8492
err := renderJsonOutput(cmd, b)
8593
if err != nil {
8694
return err

0 commit comments

Comments
 (0)