mirror of https://github.com/databricks/cli.git
Add workspace host mismatch check
This commit is contained in:
parent
61cb0f2695
commit
153510bfbf
|
@ -0,0 +1,30 @@
|
||||||
|
package mutator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/databricks/cli/bundle"
|
||||||
|
"github.com/databricks/cli/bundle/env"
|
||||||
|
"github.com/databricks/cli/libs/diag"
|
||||||
|
)
|
||||||
|
|
||||||
|
type validateWorkspaceHost struct{}
|
||||||
|
|
||||||
|
func ValidateWorkspaceHost() *validateWorkspaceHost {
|
||||||
|
return &validateWorkspaceHost{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *validateWorkspaceHost) Name() string {
|
||||||
|
return "ValidateWorkspaceHost"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *validateWorkspaceHost) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
|
||||||
|
env_host, _ := env.Host(ctx)
|
||||||
|
target_host := b.Config.Workspace.Host
|
||||||
|
|
||||||
|
if env_host != "" && target_host != "" && env_host != target_host {
|
||||||
|
return diag.Errorf("Target host and DATABRICKS_HOST environment variable mismatch")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package env
|
||||||
|
|
||||||
|
import "context"
|
||||||
|
|
||||||
|
const HostVariable = "DATABRICKS_HOST"
|
||||||
|
|
||||||
|
func Host(ctx context.Context) (string, bool) {
|
||||||
|
return get(ctx, []string{
|
||||||
|
HostVariable,
|
||||||
|
})
|
||||||
|
}
|
|
@ -25,6 +25,7 @@ func Deploy() bundle.Mutator {
|
||||||
bundle.Seq(
|
bundle.Seq(
|
||||||
terraform.StatePull(),
|
terraform.StatePull(),
|
||||||
deploy.StatePull(),
|
deploy.StatePull(),
|
||||||
|
mutator.ValidateWorkspaceHost(),
|
||||||
mutator.ValidateGitDetails(),
|
mutator.ValidateGitDetails(),
|
||||||
libraries.ValidateLocalLibrariesExist(),
|
libraries.ValidateLocalLibrariesExist(),
|
||||||
artifacts.CleanUp(),
|
artifacts.CleanUp(),
|
||||||
|
|
Loading…
Reference in New Issue