Skip to content

Commit aa31904

Browse files
Fix lakeview publish to default embed_credentials to false
2 parents 145f48f + 7a84cf1 commit aa31904

File tree

12 files changed

+56
-36
lines changed

12 files changed

+56
-36
lines changed

acceptance/bundle/deploy/fail-on-active-runs/out.test.toml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

acceptance/bundle/deploy/fail-on-active-runs/test.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
RecordRequests = true
22

3-
# --fail-on-active-runs not implemented yet
4-
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["terraform"]
5-
63
[[Server]]
74
Pattern = "GET /api/2.2/jobs/runs/list"
85
Response.Body = '''

acceptance/pipelines/deploy/fail-on-active-runs/out.test.toml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

acceptance/pipelines/deploy/fail-on-active-runs/test.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Deploy relies on terraform.CheckRunningResource()
2-
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["terraform"]
3-
41
# Cycling between states not implemented yet
52
# spec to avoid "pipeline spec is nil" error
63

acceptance/workspace/lakeview/publish/out.requests.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
{
22
"method": "POST",
3-
"path": "/api/2.0/lakeview/dashboards/dashboard-id-123/published",
3+
"path": "/api/2.0/workspace/mkdirs",
4+
"body": {
5+
"path": "/Users/[USERNAME]"
6+
}
7+
}
8+
{
9+
"method": "POST",
10+
"path": "/api/2.0/lakeview/dashboards",
11+
"body": {
12+
"display_name": "Test Dashboard",
13+
"parent_path": "/Users/[USERNAME]",
14+
"warehouse_id": "test-warehouse"
15+
}
16+
}
17+
{
18+
"method": "POST",
19+
"path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]/published",
420
"body": {
521
"embed_credentials": false
622
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11

2-
>>> [CLI] lakeview publish dashboard-id-123
2+
>>> [CLI] lakeview publish [DASHBOARD_ID]
33
{
4-
"display_name":"My Dashboard",
4+
"display_name":"Test Dashboard",
55
"embed_credentials":false,
6-
"revision_create_time":"[TIMESTAMP]",
7-
"warehouse_id":"warehouse-123"
6+
"warehouse_id":"test-warehouse"
87
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
# Test that embed_credentials defaults to false when --embed-credentials flag is not provided
2-
trace $CLI lakeview publish dashboard-id-123
1+
$CLI workspace mkdirs /Users/[email protected]
2+
3+
dashboard_id=$($CLI lakeview create --json '{"display_name": "Test Dashboard", "parent_path": "/Users/[email protected]", "warehouse_id": "test-warehouse"}' -o json | jq -r '.dashboard_id')
4+
5+
trace $CLI lakeview publish $dashboard_id
Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
RecordRequests = true
22

3-
[[Server]]
4-
Pattern = "POST /api/2.0/lakeview/dashboards/dashboard-id-123/published"
5-
Response.Body = '''
6-
{
7-
"dashboard_id": "dashboard-id-123",
8-
"display_name": "My Dashboard",
9-
"warehouse_id": "warehouse-123",
10-
"embed_credentials": false,
11-
"revision_create_time": "2025-01-01T00:00:00.000Z"
12-
}
13-
'''
3+
[[Repls]]
4+
Old = "[a-f0-9]{32}"
5+
New = "[DASHBOARD_ID]"

bundle/phases/plan.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/databricks/cli/bundle/deploy/terraform"
1313
"github.com/databricks/cli/bundle/deployplan"
1414
"github.com/databricks/cli/bundle/libraries"
15+
"github.com/databricks/cli/bundle/statemgmt"
1516
"github.com/databricks/cli/bundle/trampoline"
1617
"github.com/databricks/cli/libs/dyn"
1718
"github.com/databricks/cli/libs/logdiag"
@@ -24,7 +25,7 @@ func DeployPrepare(ctx context.Context, b *bundle.Bundle, isPlan bool, engine en
2425
terraform.CheckDashboardsModifiedRemotely(isPlan, engine),
2526
deploy.StatePull(),
2627
mutator.ValidateGitDetails(),
27-
terraform.CheckRunningResource(),
28+
statemgmt.CheckRunningResource(engine),
2829

2930
// libraries.CheckForSameNameLibraries() needs to be run after we expand glob references so we
3031
// know what are the actual library paths.

bundle/deploy/terraform/check_running_resources.go renamed to bundle/statemgmt/check_running_resources.go

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package terraform
1+
package statemgmt
22

33
import (
44
"context"
@@ -7,6 +7,8 @@ import (
77

88
"github.com/databricks/cli/bundle"
99
"github.com/databricks/cli/bundle/config"
10+
"github.com/databricks/cli/bundle/config/engine"
11+
"github.com/databricks/cli/bundle/deploy/terraform"
1012
"github.com/databricks/cli/libs/diag"
1113
"github.com/databricks/databricks-sdk-go"
1214
"github.com/databricks/databricks-sdk-go/service/jobs"
@@ -23,7 +25,9 @@ func (e ErrResourceIsRunning) Error() string {
2325
return fmt.Sprintf("%s %s is running", e.resourceType, e.resourceId)
2426
}
2527

26-
type checkRunningResources struct{}
28+
type checkRunningResources struct {
29+
engine engine.EngineType
30+
}
2731

2832
func (l *checkRunningResources) Name() string {
2933
return "check-running-resources"
@@ -34,9 +38,20 @@ func (l *checkRunningResources) Apply(ctx context.Context, b *bundle.Bundle) dia
3438
return nil
3539
}
3640

37-
state, err := ParseResourcesState(ctx, b)
38-
if err != nil && state == nil {
39-
return diag.FromErr(err)
41+
var err error
42+
var state ExportedResourcesMap
43+
44+
if l.engine.IsDirect() {
45+
_, fullPathDirect := b.StateFilenameDirect(ctx)
46+
state, err = b.DeploymentBundle.ExportState(ctx, fullPathDirect)
47+
if err != nil {
48+
return diag.FromErr(err)
49+
}
50+
} else {
51+
state, err = terraform.ParseResourcesState(ctx, b)
52+
if err != nil {
53+
return diag.FromErr(err)
54+
}
4055
}
4156

4257
w := b.WorkspaceClient()
@@ -47,8 +62,8 @@ func (l *checkRunningResources) Apply(ctx context.Context, b *bundle.Bundle) dia
4762
return nil
4863
}
4964

50-
func CheckRunningResource() *checkRunningResources {
51-
return &checkRunningResources{}
65+
func CheckRunningResource(engine engine.EngineType) bundle.Mutator {
66+
return &checkRunningResources{engine: engine}
5267
}
5368

5469
func checkAnyResourceRunning(ctx context.Context, w *databricks.WorkspaceClient, state ExportedResourcesMap) error {

0 commit comments

Comments
 (0)