databricks-cli/bundle/config/variable/lookup_metastore.go

25 lines
469 B
Go
Raw Normal View History

2024-11-20 21:40:33 +00:00
package variable
2024-11-20 21:40:43 +00:00
import (
"context"
"fmt"
"github.com/databricks/databricks-sdk-go"
)
type lookupMetastore struct {
name string
}
func (l *lookupMetastore) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) {
entity, err := w.Metastores.GetByName(ctx, l.name)
if err != nil {
return "", err
}
return fmt.Sprint(entity.MetastoreId), nil
}
func (l *lookupMetastore) String() string {
return fmt.Sprintf("metastore: %s", l.name)
}