diff --git a/bundle/config/resources/dashboard.go b/bundle/config/resources/dashboard.go index d46402717..20acc9b07 100644 --- a/bundle/config/resources/dashboard.go +++ b/bundle/config/resources/dashboard.go @@ -18,21 +18,37 @@ type Dashboard struct { // === BEGIN OF API FIELDS === // =========================== - // DisplayName is the name of the dashboard (both as title and as basename in the workspace). - DisplayName string `json:"display_name,omitempty"` + // DisplayName is the display name of the dashboard (both as title and as basename in the workspace). + DisplayName string `json:"display_name"` - // ParentPath is the path to the parent directory of the dashboard. + // WarehouseID is the ID of the SQL Warehouse used to run the dashboard's queries. + WarehouseID string `json:"warehouse_id"` + + // SerializedDashboard is the contents of the dashboard in serialized JSON form. + // Note: its type is any and not string such that it can be inlined as YAML. + // If it is not a string, its contents will be marshalled as JSON. + SerializedDashboard any `json:"serialized_dashboard,omitempty"` + + // ParentPath is the workspace path of the folder containing the dashboard. + // Includes leading slash and no trailing slash. + // + // Defaults to ${workspace.resource_path} if not set. ParentPath string `json:"parent_path,omitempty"` - // WarehouseID is the ID of the warehouse to use for the dashboard. - WarehouseID string `json:"warehouse_id,omitempty"` + // EmbedCredentials is a flag to indicate if the publisher's credentials should + // be embedded in the published dashboard. These embedded credentials will be used + // to execute the published dashboard's queries. + // + // Defaults to false if not set. + EmbedCredentials bool `json:"embed_credentials,omitempty"` // =========================== // ==== END OF API FIELDS ==== // =========================== - // DefinitionPath points to the local `.lvdash.json` file containing the dashboard definition. - DefinitionPath string `json:"definition_path,omitempty"` + // FilePath points to the local `.lvdash.json` file containing the dashboard definition. + // If specified, it will populate the `SerializedDashboard` field. + FilePath string `json:"file_path,omitempty"` } func (s *Dashboard) UnmarshalJSON(b []byte) error { @@ -43,7 +59,7 @@ func (s Dashboard) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -func (_ *Dashboard) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { +func (*Dashboard) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { _, err := w.Lakeview.Get(ctx, dashboards.GetDashboardRequest{ DashboardId: id, }) @@ -54,6 +70,6 @@ func (_ *Dashboard) Exists(ctx context.Context, w *databricks.WorkspaceClient, i return true, nil } -func (_ *Dashboard) TerraformResourceName() string { +func (*Dashboard) TerraformResourceName() string { return "databricks_dashboard" } diff --git a/bundle/deploy/terraform/convert_test.go b/bundle/deploy/terraform/convert_test.go index 4c6866d9d..cc5073423 100644 --- a/bundle/deploy/terraform/convert_test.go +++ b/bundle/deploy/terraform/convert_test.go @@ -58,9 +58,12 @@ func TestBundleToTerraformJob(t *testing.T) { }, } - out := BundleToTerraform(&config) - resource := out.Resource.Job["my_job"].(*schema.ResourceJob) + vin, err := convert.FromTyped(config, dyn.NilValue) + require.NoError(t, err) + out, err := BundleToTerraformWithDynValue(context.Background(), vin) + require.NoError(t, err) + resource := out.Resource.Job["my_job"].(*schema.ResourceJob) assert.Equal(t, "my job", resource.Name) assert.Len(t, resource.JobCluster, 1) assert.Equal(t, "https://github.com/foo/bar", resource.GitSource.Url) diff --git a/cmd/bundle/generate/dashboard.go b/cmd/bundle/generate/dashboard.go index d0726ba63..12a23b3f5 100644 --- a/cmd/bundle/generate/dashboard.go +++ b/cmd/bundle/generate/dashboard.go @@ -175,7 +175,7 @@ func (d *dashboard) watchForChanges(ctx context.Context, b *bundle.Bundle) error return err } - relPath, err := filepath.Rel(cwd, dash.DefinitionPath) + relPath, err := filepath.Rel(cwd, dash.FilePath) if err != nil { return err } @@ -199,7 +199,7 @@ func (d *dashboard) watchForChanges(ctx context.Context, b *bundle.Bundle) error if etag != dashboard.Etag { fmt.Printf("[%s]: Updating dashboard at %s\n", dashboard.UpdateTime, relPath) - d.saveSerializedDashboard(ctx, dashboard, dash.DefinitionPath) + d.saveSerializedDashboard(ctx, dashboard, dash.FilePath) } etag = dashboard.Etag