Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundle/apps/interpolate_variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestAppInterpolateVariables(t *testing.T) {
},
Jobs: map[string]*resources.Job{
"my_job": {
ID: "123",
BaseResource: resources.BaseResource{ID: "123"},
},
},
},
Expand Down
26 changes: 13 additions & 13 deletions bundle/config/mutator/initialize_urls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,39 @@ func TestInitializeURLs(t *testing.T) {
Resources: config.Resources{
Jobs: map[string]*resources.Job{
"job1": {
ID: "1",
JobSettings: jobs.JobSettings{Name: "job1"},
BaseResource: resources.BaseResource{ID: "1"},
JobSettings: jobs.JobSettings{Name: "job1"},
},
},
Pipelines: map[string]*resources.Pipeline{
"pipeline1": {
ID: "3",
BaseResource: resources.BaseResource{ID: "3"},
CreatePipeline: pipelines.CreatePipeline{Name: "pipeline1"},
},
},
Experiments: map[string]*resources.MlflowExperiment{
"experiment1": {
ID: "4",
Experiment: ml.Experiment{Name: "experiment1"},
BaseResource: resources.BaseResource{ID: "4"},
Experiment: ml.Experiment{Name: "experiment1"},
},
},
Models: map[string]*resources.MlflowModel{
"model1": {
ID: "a model uses its name for identifier",
BaseResource: resources.BaseResource{ID: "a model uses its name for identifier"},
CreateModelRequest: ml.CreateModelRequest{Name: "a model uses its name for identifier"},
},
},
ModelServingEndpoints: map[string]*resources.ModelServingEndpoint{
"servingendpoint1": {
ID: "my_serving_endpoint",
BaseResource: resources.BaseResource{ID: "my_serving_endpoint"},
CreateServingEndpoint: serving.CreateServingEndpoint{
Name: "my_serving_endpoint",
},
},
},
RegisteredModels: map[string]*resources.RegisteredModel{
"registeredmodel1": {
ID: "8",
BaseResource: resources.BaseResource{ID: "8"},
CreateRegisteredModelRequest: catalog.CreateRegisteredModelRequest{
Name: "my_registered_model",
},
Expand All @@ -71,23 +71,23 @@ func TestInitializeURLs(t *testing.T) {
},
Schemas: map[string]*resources.Schema{
"schema1": {
ID: "catalog.schema",
BaseResource: resources.BaseResource{ID: "catalog.schema"},
CreateSchema: catalog.CreateSchema{
Name: "schema",
},
},
},
Clusters: map[string]*resources.Cluster{
"cluster1": {
ID: "1017-103929-vlr7jzcf",
BaseResource: resources.BaseResource{ID: "1017-103929-vlr7jzcf"},
ClusterSpec: compute.ClusterSpec{
ClusterName: "cluster1",
},
},
},
Dashboards: map[string]*resources.Dashboard{
"dashboard1": {
ID: "01ef8d56871e1d50ae30ce7375e42478",
BaseResource: resources.BaseResource{ID: "01ef8d56871e1d50ae30ce7375e42478"},
DashboardConfig: resources.DashboardConfig{
Dashboard: dashboards.Dashboard{
DisplayName: "My special dashboard",
Expand Down Expand Up @@ -128,8 +128,8 @@ func TestInitializeURLsWithoutOrgId(t *testing.T) {
Resources: config.Resources{
Jobs: map[string]*resources.Job{
"job1": {
ID: "1",
JobSettings: jobs.JobSettings{Name: "job1"},
BaseResource: resources.BaseResource{ID: "1"},
JobSettings: jobs.JobSettings{Name: "job1"},
},
},
},
Expand Down
12 changes: 4 additions & 8 deletions bundle/config/resources/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ type AppPermission struct {
}

type App struct {
// This is app's name pulled from the state. Usually the same as Name but may be different if Name in the config
// was changed but the app was not re-deployed yet.
ID string `json:"id,omitempty" bundle:"readonly"`
BaseResource

// SourceCodePath is a required field used by DABs to point to Databricks app source code
// on local disk and to the corresponding workspace path during app deployment.
Expand All @@ -34,14 +32,12 @@ type App struct {
// Config is an optional field which allows configuring the app following Databricks app configuration format like in app.yml.
// When this field is set, DABs read the configuration set in this field and write
// it to app.yml in the root of the source code folder in Databricks workspace.
// If theres app.yml defined locally, DABs will raise an error.
// If there's app.yml defined locally, DABs will raise an error.
Config map[string]any `json:"config,omitempty"`

Permissions []AppPermission `json:"permissions,omitempty"`
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
URL string `json:"url,omitempty" bundle:"internal"`
Permissions []AppPermission `json:"permissions,omitempty"`

apps.App
apps.App // nolint App struct also defines Id and URL field with the same json tag "id" and "url"
}

func (a *App) UnmarshalJSON(b []byte) error {
Expand Down
8 changes: 8 additions & 0 deletions bundle/config/resources/base.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package resources

// BaseResource is a struct that contains the base settings for a resource.
type BaseResource struct {
ID string `json:"id,omitempty" bundle:"readonly"`
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
URL string `json:"url,omitempty" bundle:"internal"`
}
7 changes: 3 additions & 4 deletions bundle/config/resources/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ type ClusterPermission struct {
}

type Cluster struct {
ID string `json:"id,omitempty" bundle:"readonly"`
Permissions []ClusterPermission `json:"permissions,omitempty"`
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
URL string `json:"url,omitempty" bundle:"internal"`
BaseResource

Permissions []ClusterPermission `json:"permissions,omitempty"`

compute.ClusterSpec
}
Expand Down
6 changes: 2 additions & 4 deletions bundle/config/resources/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ type DashboardConfig struct {
}

type Dashboard struct {
ID string `json:"id,omitempty" bundle:"readonly"`
Permissions []DashboardPermission `json:"permissions,omitempty"`
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
URL string `json:"url,omitempty" bundle:"internal"`
BaseResource
Permissions []DashboardPermission `json:"permissions,omitempty"`

DashboardConfig

Expand Down
4 changes: 1 addition & 3 deletions bundle/config/resources/database_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import (
)

type DatabaseCatalog struct {
ID string `json:"id,omitempty" bundle:"readonly"`
URL string `json:"url,omitempty" bundle:"internal"`
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
BaseResource

database.DatabaseCatalog
}
Expand Down
7 changes: 3 additions & 4 deletions bundle/config/resources/database_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ type DatabaseInstancePermission struct {
}

type DatabaseInstance struct {
ID string `json:"id,omitempty" bundle:"readonly"`
URL string `json:"url,omitempty" bundle:"internal"`
Permissions []DatabaseInstancePermission `json:"permissions,omitempty"`
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
BaseResource

Permissions []DatabaseInstancePermission `json:"permissions,omitempty"`

database.DatabaseInstance
}
Expand Down
7 changes: 3 additions & 4 deletions bundle/config/resources/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ type JobPermission struct {
}

type Job struct {
ID string `json:"id,omitempty" bundle:"readonly"`
Permissions []JobPermission `json:"permissions,omitempty"`
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
URL string `json:"url,omitempty" bundle:"internal"`
BaseResource

Permissions []JobPermission `json:"permissions,omitempty"`

jobs.JobSettings
}
Expand Down
7 changes: 3 additions & 4 deletions bundle/config/resources/mlflow_experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ type MlflowExperimentPermission struct {
}

type MlflowExperiment struct {
ID string `json:"id,omitempty" bundle:"readonly"`
Permissions []MlflowExperimentPermission `json:"permissions,omitempty"`
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
URL string `json:"url,omitempty" bundle:"internal"`
BaseResource

Permissions []MlflowExperimentPermission `json:"permissions,omitempty"`

ml.Experiment
}
Expand Down
7 changes: 3 additions & 4 deletions bundle/config/resources/mlflow_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ type MlflowModelPermission struct {
}

type MlflowModel struct {
ID string `json:"id,omitempty" bundle:"readonly"`
Permissions []MlflowModelPermission `json:"permissions,omitempty"`
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
URL string `json:"url,omitempty" bundle:"internal"`
BaseResource

Permissions []MlflowModelPermission `json:"permissions,omitempty"`

ml.CreateModelRequest
}
Expand Down
13 changes: 4 additions & 9 deletions bundle/config/resources/model_serving_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,15 @@ type ModelServingEndpointPermission struct {
}

type ModelServingEndpoint struct {
// This represents the input args for terraform, and will get converted
// to a HCL representation for CRUD
serving.CreateServingEndpoint

// This represents the id (ie serving_endpoint_id) that can be used
// as a reference in other resources. This value is returned by terraform.
ID string `json:"id,omitempty" bundle:"readonly"`
BaseResource

// This is a resource agnostic implementation of permissions for ACLs.
// Implementation could be different based on the resource type.
Permissions []ModelServingEndpointPermission `json:"permissions,omitempty"`

ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
URL string `json:"url,omitempty" bundle:"internal"`
// This represents the input args for terraform, and will get converted
// to a HCL representation for CRUD
serving.CreateServingEndpoint
}

func (s *ModelServingEndpoint) UnmarshalJSON(b []byte) error {
Expand Down
8 changes: 3 additions & 5 deletions bundle/config/resources/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ type PipelinePermission struct {
}

type Pipeline struct {
ID string `json:"id,omitempty" bundle:"readonly"`
Permissions []PipelinePermission `json:"permissions,omitempty"`
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
URL string `json:"url,omitempty" bundle:"internal"`
BaseResource
Permissions []PipelinePermission `json:"permissions,omitempty"`

pipelines.CreatePipeline
pipelines.CreatePipeline //nolint CreatePipeline also defines Id field with the same json tag "id"
}

func (p *Pipeline) UnmarshalJSON(b []byte) error {
Expand Down
4 changes: 1 addition & 3 deletions bundle/config/resources/quality_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import (
)

type QualityMonitor struct {
ID string `json:"id,omitempty" bundle:"readonly"`
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
URL string `json:"url,omitempty" bundle:"internal"`
BaseResource

// The table name is a required field but not included as a JSON field in [catalog.CreateMonitor].
TableName string `json:"table_name"`
Expand Down
10 changes: 2 additions & 8 deletions bundle/config/resources/registered_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,15 @@ import (
)

type RegisteredModel struct {
BaseResource

// This is a resource agnostic implementation of grants.
// Implementation could be different based on the resource type.
Grants []Grant `json:"grants,omitempty"`

// This represents the id which is the full name of the model
// (catalog_name.schema_name.model_name) that can be used
// as a reference in other resources. This value is returned by terraform.
ID string `json:"id,omitempty" bundle:"readonly"`

// This represents the input args for terraform, and will get converted
// to a HCL representation for CRUD
catalog.CreateRegisteredModelRequest

ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
URL string `json:"url,omitempty" bundle:"internal"`
}

func (s *RegisteredModel) UnmarshalJSON(b []byte) error {
Expand Down
9 changes: 2 additions & 7 deletions bundle/config/resources/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,12 @@ type SchemaGrant struct {
}

type Schema struct {
BaseResource

// List of grants to apply on this schema.
Grants []SchemaGrant `json:"grants,omitempty"`

// Full name of the schema (catalog_name.schema_name). This value is read from
// the terraform state after deployment succeeds.
ID string `json:"id,omitempty" bundle:"readonly"`

catalog.CreateSchema

ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
URL string `json:"url,omitempty" bundle:"internal"`
}

func (s *Schema) Exists(ctx context.Context, w *databricks.WorkspaceClient, fullName string) (bool, error) {
Expand Down
6 changes: 2 additions & 4 deletions bundle/config/resources/secret_scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ type SecretScopePermission struct {
}

type SecretScope struct {
// ID is Name that is stored in resources state, usually the same as Name unless re-deployment is pending.
ID string `json:"id,omitempty" bundle:"readonly"`
BaseResource

// A unique name to identify the secret scope.
Name string `json:"name"`

Permissions []SecretScopePermission `json:"permissions,omitempty"`
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
Permissions []SecretScopePermission `json:"permissions,omitempty"`

// Secret scope configuration is explicitly defined here with individual fields
// to maintain API stability and prevent unintended configuration changes.
Expand Down
6 changes: 2 additions & 4 deletions bundle/config/resources/sql_warehouses.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ type SqlWarehousePermission struct {
}

type SqlWarehouse struct {
ID string `json:"id,omitempty" bundle:"readonly"`
BaseResource

Permissions []SqlWarehousePermission `json:"permissions,omitempty"`
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
URL string `json:"url,omitempty" bundle:"internal"`
Permissions []SqlWarehousePermission `json:"permissions,omitempty"`

sql.CreateWarehouseRequest
}
Expand Down
4 changes: 1 addition & 3 deletions bundle/config/resources/synced_database_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import (
)

type SyncedDatabaseTable struct {
ID string `json:"id,omitempty" bundle:"readonly"`
URL string `json:"url,omitempty" bundle:"internal"`
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
BaseResource

database.SyncedDatabaseTable
}
Expand Down
9 changes: 2 additions & 7 deletions bundle/config/resources/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,12 @@ type VolumeGrant struct {
}

type Volume struct {
BaseResource

// List of grants to apply on this volume.
Grants []VolumeGrant `json:"grants,omitempty"`

// Full name of the volume (catalog_name.schema_name.volume_name). This value is read from
// the terraform state after deployment succeeds.
ID string `json:"id,omitempty" bundle:"readonly"`

catalog.CreateVolumeRequestContent

ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
URL string `json:"url,omitempty" bundle:"internal"`
}

func (v *Volume) UnmarshalJSON(b []byte) error {
Expand Down
Loading
Loading