diff --git a/bundle/config/resources.go b/bundle/config/resources.go index 2e3f4dbf4..f44e7e9de 100644 --- a/bundle/config/resources.go +++ b/bundle/config/resources.go @@ -80,6 +80,7 @@ func (r *Resources) AllResources() []ResourceGroup { collectResourceMap(descriptions["schemas"], r.Schemas), collectResourceMap(descriptions["clusters"], r.Clusters), collectResourceMap(descriptions["dashboards"], r.Dashboards), + collectResourceMap(descriptions["volumes"], r.Volumes), } } @@ -184,5 +185,11 @@ func SupportedResources() map[string]ResourceDescription { SingularTitle: "Dashboard", PluralTitle: "Dashboards", }, + "volumes": { + SingularName: "volume", + PluralName: "volumes", + SingularTitle: "Volume", + PluralTitle: "Volumes", + }, } } diff --git a/bundle/config/resources/volume.go b/bundle/config/resources/volume.go index f7af05bda..d459f9e13 100644 --- a/bundle/config/resources/volume.go +++ b/bundle/config/resources/volume.go @@ -1,6 +1,11 @@ package resources import ( + "context" + "fmt" + "net/url" + + "github.com/databricks/databricks-sdk-go" "github.com/databricks/databricks-sdk-go/marshal" "github.com/databricks/databricks-sdk-go/service/catalog" ) @@ -16,6 +21,7 @@ type Volume struct { *catalog.CreateVolumeRequestContent ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"` + URL string `json:"url,omitempty" bundle:"internal"` } func (v *Volume) UnmarshalJSON(b []byte) error { @@ -25,3 +31,28 @@ func (v *Volume) UnmarshalJSON(b []byte) error { func (v Volume) MarshalJSON() ([]byte, error) { return marshal.Marshal(v) } + +func (v *Volume) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { + return false, fmt.Errorf("volume.Exists() is not supported") +} + +func (v *Volume) TerraformResourceName() string { + return "databricks_volume" +} + +// TODO: Test unit and manually. Maybe just manually. +func (v *Volume) InitializeURL(baseURL url.URL) { + if v.ID == "" { + return + } + baseURL.Path = fmt.Sprintf("explore/data/volumes/%s", v.ID) + v.URL = baseURL.String() +} + +func (v *Volume) GetURL() string { + return v.URL +} + +func (v *Volume) GetName() string { + return v.Name +}