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

25 lines
486 B
Go
Raw Normal View History

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