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

25 lines
448 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"
)
2024-11-20 22:12:16 +00:00
type resolveAlert struct {
2024-11-20 21:40:33 +00:00
name string
}
2024-11-20 22:12:16 +00:00
func (l resolveAlert) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) {
2024-11-20 21:40:33 +00:00
entity, err := w.Alerts.GetByDisplayName(ctx, l.name)
if err != nil {
return "", err
}
return fmt.Sprint(entity.Id), nil
}
2024-11-20 22:12:16 +00:00
func (l resolveAlert) String() string {
2024-11-20 21:40:33 +00:00
return fmt.Sprintf("alert: %s", l.name)
}