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"
|
|
|
|
)
|
|
|
|
|
2024-11-20 22:12:16 +00:00
|
|
|
type resolveServicePrincipal struct {
|
2024-11-20 21:40:43 +00:00
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
2024-11-20 22:12:16 +00:00
|
|
|
func (l resolveServicePrincipal) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) {
|
2024-11-20 21:40:43 +00:00
|
|
|
entity, err := w.ServicePrincipals.GetByDisplayName(ctx, l.name)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
return fmt.Sprint(entity.ApplicationId), nil
|
|
|
|
}
|
|
|
|
|
2024-11-20 22:12:16 +00:00
|
|
|
func (l resolveServicePrincipal) String() string {
|
2024-11-20 21:40:43 +00:00
|
|
|
return fmt.Sprintf("service-principal: %s", l.name)
|
|
|
|
}
|