Skip to content

Commit

Permalink
add support for initializeUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-goenka committed Nov 18, 2024
1 parent f5ea8da commit ea6906e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bundle/config/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}

Expand Down Expand Up @@ -184,5 +185,11 @@ func SupportedResources() map[string]ResourceDescription {
SingularTitle: "Dashboard",
PluralTitle: "Dashboards",
},
"volumes": {
SingularName: "volume",
PluralName: "volumes",
SingularTitle: "Volume",
PluralTitle: "Volumes",
},
}
}
31 changes: 31 additions & 0 deletions bundle/config/resources/volume.go
Original file line number Diff line number Diff line change
@@ -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"
)
Expand All @@ -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 {
Expand All @@ -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
}

0 comments on commit ea6906e

Please sign in to comment.