mirror of https://github.com/databricks/cli.git
Comments
This commit is contained in:
parent
ff15a046fc
commit
3a1d92c75c
|
@ -18,21 +18,37 @@ type Dashboard struct {
|
||||||
// === BEGIN OF API FIELDS ===
|
// === BEGIN OF API FIELDS ===
|
||||||
// ===========================
|
// ===========================
|
||||||
|
|
||||||
// DisplayName is the name of the dashboard (both as title and as basename in the workspace).
|
// DisplayName is the display name of the dashboard (both as title and as basename in the workspace).
|
||||||
DisplayName string `json:"display_name,omitempty"`
|
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"`
|
ParentPath string `json:"parent_path,omitempty"`
|
||||||
|
|
||||||
// WarehouseID is the ID of the warehouse to use for the dashboard.
|
// EmbedCredentials is a flag to indicate if the publisher's credentials should
|
||||||
WarehouseID string `json:"warehouse_id,omitempty"`
|
// 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 ====
|
// ==== END OF API FIELDS ====
|
||||||
// ===========================
|
// ===========================
|
||||||
|
|
||||||
// DefinitionPath points to the local `.lvdash.json` file containing the dashboard definition.
|
// FilePath points to the local `.lvdash.json` file containing the dashboard definition.
|
||||||
DefinitionPath string `json:"definition_path,omitempty"`
|
// If specified, it will populate the `SerializedDashboard` field.
|
||||||
|
FilePath string `json:"file_path,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Dashboard) UnmarshalJSON(b []byte) error {
|
func (s *Dashboard) UnmarshalJSON(b []byte) error {
|
||||||
|
@ -43,7 +59,7 @@ func (s Dashboard) MarshalJSON() ([]byte, error) {
|
||||||
return marshal.Marshal(s)
|
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{
|
_, err := w.Lakeview.Get(ctx, dashboards.GetDashboardRequest{
|
||||||
DashboardId: id,
|
DashboardId: id,
|
||||||
})
|
})
|
||||||
|
@ -54,6 +70,6 @@ func (_ *Dashboard) Exists(ctx context.Context, w *databricks.WorkspaceClient, i
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ *Dashboard) TerraformResourceName() string {
|
func (*Dashboard) TerraformResourceName() string {
|
||||||
return "databricks_dashboard"
|
return "databricks_dashboard"
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,9 +58,12 @@ func TestBundleToTerraformJob(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := BundleToTerraform(&config)
|
vin, err := convert.FromTyped(config, dyn.NilValue)
|
||||||
resource := out.Resource.Job["my_job"].(*schema.ResourceJob)
|
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.Equal(t, "my job", resource.Name)
|
||||||
assert.Len(t, resource.JobCluster, 1)
|
assert.Len(t, resource.JobCluster, 1)
|
||||||
assert.Equal(t, "https://github.com/foo/bar", resource.GitSource.Url)
|
assert.Equal(t, "https://github.com/foo/bar", resource.GitSource.Url)
|
||||||
|
|
|
@ -175,7 +175,7 @@ func (d *dashboard) watchForChanges(ctx context.Context, b *bundle.Bundle) error
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
relPath, err := filepath.Rel(cwd, dash.DefinitionPath)
|
relPath, err := filepath.Rel(cwd, dash.FilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ func (d *dashboard) watchForChanges(ctx context.Context, b *bundle.Bundle) error
|
||||||
|
|
||||||
if etag != dashboard.Etag {
|
if etag != dashboard.Etag {
|
||||||
fmt.Printf("[%s]: Updating dashboard at %s\n", dashboard.UpdateTime, relPath)
|
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
|
etag = dashboard.Etag
|
||||||
|
|
Loading…
Reference in New Issue