From 29a4f15346b8ab31967371cc21c0ee51682bbacf Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Mon, 9 Jun 2025 14:29:14 +0200 Subject: [PATCH 1/8] Fix dashboard generation for already imported dashboard --- acceptance/acceptance_test.go | 2 +- .../dashboard-inplace/dash.lvdash.json | 1 + .../generate/dashboard-inplace/databricks.yml | 9 +++ .../generate/dashboard-inplace/output.txt | 25 ++++++ .../bundle/generate/dashboard-inplace/script | 13 +++ .../bundle/generate/dashboard/dashboard.json | 5 ++ .../bundle/generate/dashboard/databricks.yml | 2 + .../out/dashboard/test_dashboard.lvdash.json | 1 + .../out/resource/test_dashboard.dashboard.yml | 6 ++ .../bundle/generate/dashboard/output.txt | 2 + acceptance/bundle/generate/dashboard/script | 4 + acceptance/internal/handlers.go | 14 ++++ ...nfigure_dashboards_serialized_dashboard.go | 8 +- bundle/config/resources/dashboard.go | 2 + .../terraform/tfdyn/convert_dashboard.go | 7 ++ cmd/workspace/lakeview/lakeview.go | 16 ++-- libs/testserver/dashboards.go | 81 +++++++++++++++++++ libs/testserver/fake_workspace.go | 11 ++- 18 files changed, 189 insertions(+), 20 deletions(-) create mode 100644 acceptance/bundle/generate/dashboard-inplace/dash.lvdash.json create mode 100644 acceptance/bundle/generate/dashboard-inplace/databricks.yml create mode 100644 acceptance/bundle/generate/dashboard-inplace/output.txt create mode 100644 acceptance/bundle/generate/dashboard-inplace/script create mode 100644 acceptance/bundle/generate/dashboard/dashboard.json create mode 100644 acceptance/bundle/generate/dashboard/databricks.yml create mode 100644 acceptance/bundle/generate/dashboard/out/dashboard/test_dashboard.lvdash.json create mode 100644 acceptance/bundle/generate/dashboard/out/resource/test_dashboard.dashboard.yml create mode 100644 acceptance/bundle/generate/dashboard/output.txt create mode 100644 acceptance/bundle/generate/dashboard/script create mode 100644 libs/testserver/dashboards.go diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index 3c09fe772d1..da356c7273c 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -92,7 +92,7 @@ var Ignored = map[string]bool{ } func TestAccept(t *testing.T) { - testAccept(t, InprocessMode, "") + testAccept(t, true, "") } func TestInprocessMode(t *testing.T) { diff --git a/acceptance/bundle/generate/dashboard-inplace/dash.lvdash.json b/acceptance/bundle/generate/dashboard-inplace/dash.lvdash.json new file mode 100644 index 00000000000..0967ef424bc --- /dev/null +++ b/acceptance/bundle/generate/dashboard-inplace/dash.lvdash.json @@ -0,0 +1 @@ +{} diff --git a/acceptance/bundle/generate/dashboard-inplace/databricks.yml b/acceptance/bundle/generate/dashboard-inplace/databricks.yml new file mode 100644 index 00000000000..5bbe24529b6 --- /dev/null +++ b/acceptance/bundle/generate/dashboard-inplace/databricks.yml @@ -0,0 +1,9 @@ +bundle: + name: dashboard update inplace + +resources: + dashboards: + test_dashboard: + display_name: "test dashboard" + warehouse_id: "" + file_path: ./dash.lvdash.json diff --git a/acceptance/bundle/generate/dashboard-inplace/output.txt b/acceptance/bundle/generate/dashboard-inplace/output.txt new file mode 100644 index 00000000000..a1fe3c9a160 --- /dev/null +++ b/acceptance/bundle/generate/dashboard-inplace/output.txt @@ -0,0 +1,25 @@ + +>>> cat dash.lvdash.json +{} + +=== deploy initial dashboard +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/dashboard update inplace/default/files... +Deploying resources... +Updating deployment state... +Deployment complete! + +=== update the dashboard +>>> [CLI] lakeview update [UUID] --serialized-dashboard {"a":"b"} +{ + "etag":"[UUID]", + "serialized_dashboard":"{\"a\":\"b\"}" +} + +=== update the dashboard file using bundle generate +>>> [CLI] bundle generate dashboard --resource test_dashboard --force + +>>> cat dash.lvdash.json +{ + "a": "b" +} diff --git a/acceptance/bundle/generate/dashboard-inplace/script b/acceptance/bundle/generate/dashboard-inplace/script new file mode 100644 index 00000000000..f11a56da3cf --- /dev/null +++ b/acceptance/bundle/generate/dashboard-inplace/script @@ -0,0 +1,13 @@ +trace cat dash.lvdash.json + +title "deploy initial dashboard" +trace $CLI bundle deploy +dashboard_id=$($CLI bundle summary --output json | jq -r '.resources.dashboards.test_dashboard.id') + +title "update the dashboard" +trace $CLI lakeview update $dashboard_id --serialized-dashboard '{"a":"b"}' + +title "update the dashboard file using bundle generate" +trace $CLI bundle generate dashboard --resource test_dashboard --force + +trace cat dash.lvdash.json diff --git a/acceptance/bundle/generate/dashboard/dashboard.json b/acceptance/bundle/generate/dashboard/dashboard.json new file mode 100644 index 00000000000..502787ac8b3 --- /dev/null +++ b/acceptance/bundle/generate/dashboard/dashboard.json @@ -0,0 +1,5 @@ +{ + "display_name": "test dashboard", + "parent_path": "/test", + "serialized_dashboard": "{}" +} diff --git a/acceptance/bundle/generate/dashboard/databricks.yml b/acceptance/bundle/generate/dashboard/databricks.yml new file mode 100644 index 00000000000..726ee8a43a1 --- /dev/null +++ b/acceptance/bundle/generate/dashboard/databricks.yml @@ -0,0 +1,2 @@ +bundle: + name: dashboard-generate diff --git a/acceptance/bundle/generate/dashboard/out/dashboard/test_dashboard.lvdash.json b/acceptance/bundle/generate/dashboard/out/dashboard/test_dashboard.lvdash.json new file mode 100644 index 00000000000..0967ef424bc --- /dev/null +++ b/acceptance/bundle/generate/dashboard/out/dashboard/test_dashboard.lvdash.json @@ -0,0 +1 @@ +{} diff --git a/acceptance/bundle/generate/dashboard/out/resource/test_dashboard.dashboard.yml b/acceptance/bundle/generate/dashboard/out/resource/test_dashboard.dashboard.yml new file mode 100644 index 00000000000..d282c46e69b --- /dev/null +++ b/acceptance/bundle/generate/dashboard/out/resource/test_dashboard.dashboard.yml @@ -0,0 +1,6 @@ +resources: + dashboards: + test_dashboard: + display_name: "test dashboard" + warehouse_id: "" + file_path: ../dashboard/test_dashboard.lvdash.json diff --git a/acceptance/bundle/generate/dashboard/output.txt b/acceptance/bundle/generate/dashboard/output.txt new file mode 100644 index 00000000000..7f3eb39198d --- /dev/null +++ b/acceptance/bundle/generate/dashboard/output.txt @@ -0,0 +1,2 @@ + +>>> [CLI] bundle generate dashboard --existing-id [UUID] --dashboard-dir out/dashboard --resource-dir out/resource diff --git a/acceptance/bundle/generate/dashboard/script b/acceptance/bundle/generate/dashboard/script new file mode 100644 index 00000000000..2f3abe2db29 --- /dev/null +++ b/acceptance/bundle/generate/dashboard/script @@ -0,0 +1,4 @@ +# create a dashboard to import +dashboard_id=$($CLI lakeview create --json @dashboard.json | jq -r '.dashboard_id') + +trace $CLI bundle generate dashboard --existing-id $dashboard_id --dashboard-dir out1/dashboard --resource-dir out1/resource diff --git a/acceptance/internal/handlers.go b/acceptance/internal/handlers.go index 3cf95165e1c..e0200a1e4fb 100644 --- a/acceptance/internal/handlers.go +++ b/acceptance/internal/handlers.go @@ -252,6 +252,20 @@ func addDefaultHandlers(server *testserver.Server) { } }) + // Dashboards: + server.Handle("GET", "/api/2.0/lakeview/dashboards/{dashboard_id}", func(req testserver.Request) any { + return req.Workspace.DashboardGet(req.Vars["dashboard_id"]) + }) + server.Handle("POST", "/api/2.0/lakeview/dashboards", func(req testserver.Request) any { + return req.Workspace.DashboardCreate(req) + }) + server.Handle("POST", "/api/2.0/lakeview/dashboards/{dashboard_id}/published", func(req testserver.Request) any { + return req.Workspace.DashboardPublish(req) + }) + server.Handle("PATCH", "/api/2.0/lakeview/dashboards/{dashboard_id}", func(req testserver.Request) any { + return req.Workspace.DashboardUpdate(req) + }) + // Pipelines: server.Handle("GET", "/api/2.0/pipelines/{pipeline_id}", func(req testserver.Request) any { diff --git a/bundle/config/mutator/resourcemutator/configure_dashboards_serialized_dashboard.go b/bundle/config/mutator/resourcemutator/configure_dashboards_serialized_dashboard.go index 92d12ed8939..27b55403d88 100644 --- a/bundle/config/mutator/resourcemutator/configure_dashboards_serialized_dashboard.go +++ b/bundle/config/mutator/resourcemutator/configure_dashboards_serialized_dashboard.go @@ -49,13 +49,7 @@ func (c configureDashboardSerializedDashboard) Apply(_ context.Context, b *bundl return dyn.InvalidValue, fmt.Errorf("failed to read serialized dashboard from file_path %s: %w", path, err) } - v, err = dyn.Set(v, serializedDashboardFieldName, dyn.V(string(contents))) - if err != nil { - return dyn.InvalidValue, fmt.Errorf("failed to set serialized_dashboard: %w", err) - } - - // Drop the "file_path" field. It is mutually exclusive with "serialized_dashboard". - return dyn.DropKeys(v, []string{filePathFieldName}) + return dyn.Set(v, serializedDashboardFieldName, dyn.V(string(contents))) }) }) diff --git a/bundle/config/resources/dashboard.go b/bundle/config/resources/dashboard.go index 572217baae7..39b5a59abb5 100644 --- a/bundle/config/resources/dashboard.go +++ b/bundle/config/resources/dashboard.go @@ -49,6 +49,8 @@ type Dashboard struct { EmbedCredentials bool `json:"embed_credentials,omitempty"` // FilePath points to the local `.lvdash.json` file containing the dashboard definition. + // This is inlined into serialized_dashboard during deployment. The file_path is kept around + // as metadata which is needed for `databricks bundle generate dashboard --resource ` to work. FilePath string `json:"file_path,omitempty"` } diff --git a/bundle/deploy/terraform/tfdyn/convert_dashboard.go b/bundle/deploy/terraform/tfdyn/convert_dashboard.go index 8734565999f..ea1afec13be 100644 --- a/bundle/deploy/terraform/tfdyn/convert_dashboard.go +++ b/bundle/deploy/terraform/tfdyn/convert_dashboard.go @@ -53,6 +53,13 @@ func convertDashboardResource(ctx context.Context, vin dyn.Value) (dyn.Value, er return dyn.InvalidValue, err } + // Drop the "file_path" field. It's always inlined into "serialized_dashboard". + // TODO: Add unit test for this. + vout, err = dyn.DropKeys(vout, []string{"file_path"}) + if err != nil { + return dyn.InvalidValue, err + } + return vout, nil } diff --git a/cmd/workspace/lakeview/lakeview.go b/cmd/workspace/lakeview/lakeview.go index 54fcd4e1065..5a0a1f57977 100755 --- a/cmd/workspace/lakeview/lakeview.go +++ b/cmd/workspace/lakeview/lakeview.go @@ -85,7 +85,7 @@ func newCreate() *cobra.Command { cmd.Use = "create" cmd.Short = `Create dashboard.` cmd.Long = `Create dashboard. - + Create a draft dashboard.` cmd.Annotations = make(map[string]string) @@ -425,7 +425,7 @@ func newGet() *cobra.Command { cmd.Use = "get DASHBOARD_ID" cmd.Short = `Get dashboard.` cmd.Long = `Get dashboard. - + Get a draft dashboard. Arguments: @@ -483,7 +483,7 @@ func newGetPublished() *cobra.Command { cmd.Use = "get-published DASHBOARD_ID" cmd.Short = `Get published dashboard.` cmd.Long = `Get published dashboard. - + Get the current published dashboard. Arguments: @@ -832,7 +832,7 @@ func newMigrate() *cobra.Command { cmd.Use = "migrate SOURCE_DASHBOARD_ID" cmd.Short = `Migrate dashboard.` cmd.Long = `Migrate dashboard. - + Migrates a classic SQL dashboard to Lakeview. Arguments: @@ -916,7 +916,7 @@ func newPublish() *cobra.Command { cmd.Use = "publish DASHBOARD_ID" cmd.Short = `Publish dashboard.` cmd.Long = `Publish dashboard. - + Publish the current draft dashboard. Arguments: @@ -986,7 +986,7 @@ func newTrash() *cobra.Command { cmd.Use = "trash DASHBOARD_ID" cmd.Short = `Trash dashboard.` cmd.Long = `Trash dashboard. - + Trash a dashboard. Arguments: @@ -1044,7 +1044,7 @@ func newUnpublish() *cobra.Command { cmd.Use = "unpublish DASHBOARD_ID" cmd.Short = `Unpublish dashboard.` cmd.Long = `Unpublish dashboard. - + Unpublish the dashboard. Arguments: @@ -1109,7 +1109,7 @@ func newUpdate() *cobra.Command { cmd.Use = "update DASHBOARD_ID" cmd.Short = `Update dashboard.` cmd.Long = `Update dashboard. - + Update a draft dashboard. Arguments: diff --git a/libs/testserver/dashboards.go b/libs/testserver/dashboards.go new file mode 100644 index 00000000000..76491efb72d --- /dev/null +++ b/libs/testserver/dashboards.go @@ -0,0 +1,81 @@ +package testserver + +import ( + "encoding/json" + + "github.com/databricks/databricks-sdk-go/service/dashboards" + "github.com/google/uuid" +) + +func (s *FakeWorkspace) DashboardGet(dashboardId string) Response { + defer s.LockUnlock()() + + value, ok := s.Dashboards[dashboardId] + if !ok { + return Response{ + StatusCode: 404, + } + } + return Response{ + Body: value, + } +} + +func (s *FakeWorkspace) DashboardCreate(req Request) Response { + defer s.LockUnlock()() + + var dashboard dashboards.Dashboard + if err := json.Unmarshal(req.Body, &dashboard); err != nil { + return Response{ + StatusCode: 400, + } + } + + dashboard.DashboardId = uuid.New().String() + s.Dashboards[dashboard.DashboardId] = dashboard + + return Response{ + Body: dashboards.Dashboard{ + DashboardId: dashboard.DashboardId, + Etag: uuid.New().String(), + }, + } +} + +func (s *FakeWorkspace) DashboardUpdate(req Request) Response { + defer s.LockUnlock()() + + var dashboard dashboards.Dashboard + if err := json.Unmarshal(req.Body, &dashboard); err != nil { + return Response{ + StatusCode: 400, + } + } + + // Update the etag for the dashboard. + dashboard.Etag = uuid.New().String() + + dashboardId := req.Vars["dashboard_id"] + s.Dashboards[dashboardId] = dashboard + + return Response{ + Body: dashboard, + } +} + +func (s *FakeWorkspace) DashboardPublish(req Request) Response { + defer s.LockUnlock()() + + var dashboard dashboards.Dashboard + if err := json.Unmarshal(req.Body, &dashboard); err != nil { + return Response{ + StatusCode: 400, + } + } + + return Response{ + Body: dashboards.PublishedDashboard{ + WarehouseId: dashboard.WarehouseId, + }, + } +} diff --git a/libs/testserver/fake_workspace.go b/libs/testserver/fake_workspace.go index 3b2baf9d55b..68e872b7940 100644 --- a/libs/testserver/fake_workspace.go +++ b/libs/testserver/fake_workspace.go @@ -12,6 +12,7 @@ import ( "github.com/databricks/databricks-sdk-go/service/apps" "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/databricks-sdk-go/service/dashboards" "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/databricks/databricks-sdk-go/service/pipelines" "github.com/databricks/databricks-sdk-go/service/workspace" @@ -40,10 +41,11 @@ type FakeWorkspace struct { Jobs map[int64]jobs.Job JobRuns map[int64]jobs.Run - Pipelines map[string]pipelines.GetPipelineResponse - Monitors map[string]catalog.MonitorInfo - Apps map[string]apps.App - Schemas map[string]catalog.SchemaInfo + Pipelines map[string]pipelines.GetPipelineResponse + Monitors map[string]catalog.MonitorInfo + Apps map[string]apps.App + Schemas map[string]catalog.SchemaInfo + Dashboards map[string]dashboards.Dashboard } func (w *FakeWorkspace) LockUnlock() func() { @@ -116,6 +118,7 @@ func NewFakeWorkspace(url string) *FakeWorkspace { Monitors: map[string]catalog.MonitorInfo{}, Apps: map[string]apps.App{}, Schemas: map[string]catalog.SchemaInfo{}, + Dashboards: map[string]dashboards.Dashboard{}, } } From d673059304f8df5bfa732b1041d8b6bed21e5824 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Mon, 9 Jun 2025 14:36:00 +0200 Subject: [PATCH 2/8] cleanup --- acceptance/acceptance_test.go | 2 +- .../deploy/terraform/tfdyn/convert_dashboard.go | 1 - .../terraform/tfdyn/convert_dashboard_test.go | 4 ++++ cmd/workspace/lakeview/lakeview.go | 16 ++++++++-------- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index da356c7273c..3c09fe772d1 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -92,7 +92,7 @@ var Ignored = map[string]bool{ } func TestAccept(t *testing.T) { - testAccept(t, true, "") + testAccept(t, InprocessMode, "") } func TestInprocessMode(t *testing.T) { diff --git a/bundle/deploy/terraform/tfdyn/convert_dashboard.go b/bundle/deploy/terraform/tfdyn/convert_dashboard.go index ea1afec13be..b51f6ae445e 100644 --- a/bundle/deploy/terraform/tfdyn/convert_dashboard.go +++ b/bundle/deploy/terraform/tfdyn/convert_dashboard.go @@ -54,7 +54,6 @@ func convertDashboardResource(ctx context.Context, vin dyn.Value) (dyn.Value, er } // Drop the "file_path" field. It's always inlined into "serialized_dashboard". - // TODO: Add unit test for this. vout, err = dyn.DropKeys(vout, []string{"file_path"}) if err != nil { return dyn.InvalidValue, err diff --git a/bundle/deploy/terraform/tfdyn/convert_dashboard_test.go b/bundle/deploy/terraform/tfdyn/convert_dashboard_test.go index 5d84949092a..39b6f44714f 100644 --- a/bundle/deploy/terraform/tfdyn/convert_dashboard_test.go +++ b/bundle/deploy/terraform/tfdyn/convert_dashboard_test.go @@ -88,6 +88,7 @@ func TestConvertDashboardSerializedDashboardAny(t *testing.T) { }, }, }, + FilePath: "some/path/to/dashboard.lvdash.json", } vin, err := convert.FromTyped(src, dyn.NilValue) @@ -102,4 +103,7 @@ func TestConvertDashboardSerializedDashboardAny(t *testing.T) { assert.Subset(t, out.Dashboard["my_dashboard"], map[string]any{ "serialized_dashboard": `{"pages":[{"displayName":"New Page","layout":[]}]}`, }) + + // Assert that the "file_path" is dropped. + assert.NotContains(t, out.Dashboard["my_dashboard"], "file_path") } diff --git a/cmd/workspace/lakeview/lakeview.go b/cmd/workspace/lakeview/lakeview.go index 5a0a1f57977..54fcd4e1065 100755 --- a/cmd/workspace/lakeview/lakeview.go +++ b/cmd/workspace/lakeview/lakeview.go @@ -85,7 +85,7 @@ func newCreate() *cobra.Command { cmd.Use = "create" cmd.Short = `Create dashboard.` cmd.Long = `Create dashboard. - + Create a draft dashboard.` cmd.Annotations = make(map[string]string) @@ -425,7 +425,7 @@ func newGet() *cobra.Command { cmd.Use = "get DASHBOARD_ID" cmd.Short = `Get dashboard.` cmd.Long = `Get dashboard. - + Get a draft dashboard. Arguments: @@ -483,7 +483,7 @@ func newGetPublished() *cobra.Command { cmd.Use = "get-published DASHBOARD_ID" cmd.Short = `Get published dashboard.` cmd.Long = `Get published dashboard. - + Get the current published dashboard. Arguments: @@ -832,7 +832,7 @@ func newMigrate() *cobra.Command { cmd.Use = "migrate SOURCE_DASHBOARD_ID" cmd.Short = `Migrate dashboard.` cmd.Long = `Migrate dashboard. - + Migrates a classic SQL dashboard to Lakeview. Arguments: @@ -916,7 +916,7 @@ func newPublish() *cobra.Command { cmd.Use = "publish DASHBOARD_ID" cmd.Short = `Publish dashboard.` cmd.Long = `Publish dashboard. - + Publish the current draft dashboard. Arguments: @@ -986,7 +986,7 @@ func newTrash() *cobra.Command { cmd.Use = "trash DASHBOARD_ID" cmd.Short = `Trash dashboard.` cmd.Long = `Trash dashboard. - + Trash a dashboard. Arguments: @@ -1044,7 +1044,7 @@ func newUnpublish() *cobra.Command { cmd.Use = "unpublish DASHBOARD_ID" cmd.Short = `Unpublish dashboard.` cmd.Long = `Unpublish dashboard. - + Unpublish the dashboard. Arguments: @@ -1109,7 +1109,7 @@ func newUpdate() *cobra.Command { cmd.Use = "update DASHBOARD_ID" cmd.Short = `Update dashboard.` cmd.Long = `Update dashboard. - + Update a draft dashboard. Arguments: From 992792874f543315296c631b538ebbd15b683925 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Mon, 9 Jun 2025 14:43:05 +0200 Subject: [PATCH 3/8] fix test --- .../{out => out1}/dashboard/test_dashboard.lvdash.json | 0 .../{out => out1}/resource/test_dashboard.dashboard.yml | 0 acceptance/bundle/generate/dashboard/output.txt | 4 +++- 3 files changed, 3 insertions(+), 1 deletion(-) rename acceptance/bundle/generate/dashboard/{out => out1}/dashboard/test_dashboard.lvdash.json (100%) rename acceptance/bundle/generate/dashboard/{out => out1}/resource/test_dashboard.dashboard.yml (100%) diff --git a/acceptance/bundle/generate/dashboard/out/dashboard/test_dashboard.lvdash.json b/acceptance/bundle/generate/dashboard/out1/dashboard/test_dashboard.lvdash.json similarity index 100% rename from acceptance/bundle/generate/dashboard/out/dashboard/test_dashboard.lvdash.json rename to acceptance/bundle/generate/dashboard/out1/dashboard/test_dashboard.lvdash.json diff --git a/acceptance/bundle/generate/dashboard/out/resource/test_dashboard.dashboard.yml b/acceptance/bundle/generate/dashboard/out1/resource/test_dashboard.dashboard.yml similarity index 100% rename from acceptance/bundle/generate/dashboard/out/resource/test_dashboard.dashboard.yml rename to acceptance/bundle/generate/dashboard/out1/resource/test_dashboard.dashboard.yml diff --git a/acceptance/bundle/generate/dashboard/output.txt b/acceptance/bundle/generate/dashboard/output.txt index 7f3eb39198d..54bd6b1fbf9 100644 --- a/acceptance/bundle/generate/dashboard/output.txt +++ b/acceptance/bundle/generate/dashboard/output.txt @@ -1,2 +1,4 @@ ->>> [CLI] bundle generate dashboard --existing-id [UUID] --dashboard-dir out/dashboard --resource-dir out/resource +>>> [CLI] bundle generate dashboard --existing-id [UUID] --dashboard-dir out1/dashboard --resource-dir out1/resource +Writing dashboard to "out1/dashboard/test_dashboard.lvdash.json" +Writing configuration to "out1/resource/test_dashboard.dashboard.yml" From 5f4f4efa4cf6f2f9e63c38fcd5f887aeacbd3aa3 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Mon, 9 Jun 2025 14:44:05 +0200 Subject: [PATCH 4/8] out1 -> out --- .../{out1 => out}/dashboard/test_dashboard.lvdash.json | 0 .../{out1 => out}/resource/test_dashboard.dashboard.yml | 0 acceptance/bundle/generate/dashboard/output.txt | 6 +++--- acceptance/bundle/generate/dashboard/script | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename acceptance/bundle/generate/dashboard/{out1 => out}/dashboard/test_dashboard.lvdash.json (100%) rename acceptance/bundle/generate/dashboard/{out1 => out}/resource/test_dashboard.dashboard.yml (100%) diff --git a/acceptance/bundle/generate/dashboard/out1/dashboard/test_dashboard.lvdash.json b/acceptance/bundle/generate/dashboard/out/dashboard/test_dashboard.lvdash.json similarity index 100% rename from acceptance/bundle/generate/dashboard/out1/dashboard/test_dashboard.lvdash.json rename to acceptance/bundle/generate/dashboard/out/dashboard/test_dashboard.lvdash.json diff --git a/acceptance/bundle/generate/dashboard/out1/resource/test_dashboard.dashboard.yml b/acceptance/bundle/generate/dashboard/out/resource/test_dashboard.dashboard.yml similarity index 100% rename from acceptance/bundle/generate/dashboard/out1/resource/test_dashboard.dashboard.yml rename to acceptance/bundle/generate/dashboard/out/resource/test_dashboard.dashboard.yml diff --git a/acceptance/bundle/generate/dashboard/output.txt b/acceptance/bundle/generate/dashboard/output.txt index 54bd6b1fbf9..342ca8566c9 100644 --- a/acceptance/bundle/generate/dashboard/output.txt +++ b/acceptance/bundle/generate/dashboard/output.txt @@ -1,4 +1,4 @@ ->>> [CLI] bundle generate dashboard --existing-id [UUID] --dashboard-dir out1/dashboard --resource-dir out1/resource -Writing dashboard to "out1/dashboard/test_dashboard.lvdash.json" -Writing configuration to "out1/resource/test_dashboard.dashboard.yml" +>>> [CLI] bundle generate dashboard --existing-id [UUID] --dashboard-dir out/dashboard --resource-dir out/resource +Writing dashboard to "out/dashboard/test_dashboard.lvdash.json" +Writing configuration to "out/resource/test_dashboard.dashboard.yml" diff --git a/acceptance/bundle/generate/dashboard/script b/acceptance/bundle/generate/dashboard/script index 2f3abe2db29..7a6616f57ee 100644 --- a/acceptance/bundle/generate/dashboard/script +++ b/acceptance/bundle/generate/dashboard/script @@ -1,4 +1,4 @@ # create a dashboard to import dashboard_id=$($CLI lakeview create --json @dashboard.json | jq -r '.dashboard_id') -trace $CLI bundle generate dashboard --existing-id $dashboard_id --dashboard-dir out1/dashboard --resource-dir out1/resource +trace $CLI bundle generate dashboard --existing-id $dashboard_id --dashboard-dir out/dashboard --resource-dir out/resource From a2fb2db397ec5c29efcd3aa44ea9ea95d4ea85c3 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Mon, 9 Jun 2025 14:50:46 +0200 Subject: [PATCH 5/8] fix test --- acceptance/bundle/generate/dashboard-inplace/output.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/acceptance/bundle/generate/dashboard-inplace/output.txt b/acceptance/bundle/generate/dashboard-inplace/output.txt index a1fe3c9a160..38880046b53 100644 --- a/acceptance/bundle/generate/dashboard-inplace/output.txt +++ b/acceptance/bundle/generate/dashboard-inplace/output.txt @@ -18,6 +18,7 @@ Deployment complete! === update the dashboard file using bundle generate >>> [CLI] bundle generate dashboard --resource test_dashboard --force +Writing dashboard to "dash.lvdash.json" >>> cat dash.lvdash.json { From eb88149527fb325d7707d594d47058f63c685413 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Tue, 10 Jun 2025 09:18:51 +0200 Subject: [PATCH 6/8] fix test --- acceptance/bundle/generate/dashboard/test.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 acceptance/bundle/generate/dashboard/test.toml diff --git a/acceptance/bundle/generate/dashboard/test.toml b/acceptance/bundle/generate/dashboard/test.toml new file mode 100644 index 00000000000..a298217f218 --- /dev/null +++ b/acceptance/bundle/generate/dashboard/test.toml @@ -0,0 +1,3 @@ +[[Repls]] +Old = '\\' +New = '/' From 8f5ee6fea401e329e28beaef98b010ad3c07ab55 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Tue, 10 Jun 2025 09:57:57 +0200 Subject: [PATCH 7/8] - --- acceptance/bundle/generate/dashboard/test.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance/bundle/generate/dashboard/test.toml b/acceptance/bundle/generate/dashboard/test.toml index a298217f218..9cf9b33ecab 100644 --- a/acceptance/bundle/generate/dashboard/test.toml +++ b/acceptance/bundle/generate/dashboard/test.toml @@ -1,3 +1,3 @@ [[Repls]] -Old = '\\' +Old = '\\\\' New = '/' From d2042e18c7e4aad239b2174da084b08b8a921802 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Tue, 10 Jun 2025 14:10:15 +0200 Subject: [PATCH 8/8] use MapGet --- acceptance/internal/handlers.go | 2 +- libs/testserver/dashboards.go | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/acceptance/internal/handlers.go b/acceptance/internal/handlers.go index e0200a1e4fb..07f0e013982 100644 --- a/acceptance/internal/handlers.go +++ b/acceptance/internal/handlers.go @@ -254,7 +254,7 @@ func addDefaultHandlers(server *testserver.Server) { // Dashboards: server.Handle("GET", "/api/2.0/lakeview/dashboards/{dashboard_id}", func(req testserver.Request) any { - return req.Workspace.DashboardGet(req.Vars["dashboard_id"]) + return testserver.MapGet(req.Workspace, req.Workspace.Dashboards, req.Vars["dashboard_id"]) }) server.Handle("POST", "/api/2.0/lakeview/dashboards", func(req testserver.Request) any { return req.Workspace.DashboardCreate(req) diff --git a/libs/testserver/dashboards.go b/libs/testserver/dashboards.go index 76491efb72d..6e5c26863ce 100644 --- a/libs/testserver/dashboards.go +++ b/libs/testserver/dashboards.go @@ -7,20 +7,6 @@ import ( "github.com/google/uuid" ) -func (s *FakeWorkspace) DashboardGet(dashboardId string) Response { - defer s.LockUnlock()() - - value, ok := s.Dashboards[dashboardId] - if !ok { - return Response{ - StatusCode: 404, - } - } - return Response{ - Body: value, - } -} - func (s *FakeWorkspace) DashboardCreate(req Request) Response { defer s.LockUnlock()()