2023-11-30 14:28:01 +00:00
|
|
|
package mutator
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/databricks/cli/bundle"
|
2024-03-25 14:18:47 +00:00
|
|
|
"github.com/databricks/cli/libs/diag"
|
2023-11-30 14:28:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type initializeWorkspaceClient struct{}
|
|
|
|
|
|
|
|
func InitializeWorkspaceClient() bundle.Mutator {
|
|
|
|
return &initializeWorkspaceClient{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *initializeWorkspaceClient) Name() string {
|
|
|
|
return "InitializeWorkspaceClient"
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply initializes the workspace client for the bundle. We do this here so
|
|
|
|
// downstream calls to b.WorkspaceClient() do not panic if there's an error in the
|
|
|
|
// auth configuration.
|
2024-03-25 14:18:47 +00:00
|
|
|
func (m *initializeWorkspaceClient) Apply(_ context.Context, b *bundle.Bundle) diag.Diagnostics {
|
2023-11-30 14:28:01 +00:00
|
|
|
_, err := b.InitializeWorkspaceClient()
|
2024-03-25 14:18:47 +00:00
|
|
|
return diag.FromErr(err)
|
2023-11-30 14:28:01 +00:00
|
|
|
}
|