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

25 lines
514 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 lookupServicePrincipal struct {
name string
}
func (l *lookupServicePrincipal) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) {
entity, err := w.ServicePrincipals.GetByDisplayName(ctx, l.name)
if err != nil {
return "", err
}
return fmt.Sprint(entity.ApplicationId), nil
}
func (l *lookupServicePrincipal) String() string {
return fmt.Sprintf("service-principal: %s", l.name)
}