mirror of https://github.com/databricks/cli.git
fixes
This commit is contained in:
parent
87b1c7a402
commit
9675aa7294
|
@ -22,8 +22,8 @@ func (m *prependWorkspacePrefix) Name() string {
|
|||
}
|
||||
|
||||
var skipPrefixes = []string{
|
||||
"/Workspace",
|
||||
"/Volumes",
|
||||
"/Workspace/",
|
||||
"/Volumes/",
|
||||
}
|
||||
|
||||
func (m *prependWorkspacePrefix) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
|
||||
|
|
|
@ -23,24 +23,26 @@ func (m *noWorkspacePrefixUsed) Name() string {
|
|||
|
||||
func (m *noWorkspacePrefixUsed) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
|
||||
diags := diag.Diagnostics{}
|
||||
prefixes := []string{
|
||||
paths := []string{
|
||||
"/Workspace/${workspace.root_path}",
|
||||
"/Workspace/${workspace.file_path}",
|
||||
"/Workspace/${workspace.artifact_path}",
|
||||
"/Workspace/${workspace.state_path}",
|
||||
}
|
||||
|
||||
// Walk through the bundle configuration, check all the string leaves and
|
||||
// see if any of the prefixes are used in the remote path.
|
||||
_, err := dyn.Walk(b.Config.Value(), func(p dyn.Path, v dyn.Value) (dyn.Value, error) {
|
||||
vv, ok := v.AsString()
|
||||
if !ok {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
for _, prefix := range prefixes {
|
||||
if strings.HasPrefix(vv, prefix) {
|
||||
for _, path := range paths {
|
||||
if strings.Contains(vv, path) {
|
||||
diags = append(diags, diag.Diagnostic{
|
||||
Severity: diag.Error,
|
||||
Summary: fmt.Sprintf("%s used in the remote path %s. Please change to use %s instead", prefix, vv, strings.ReplaceAll(vv, "/Workspace/", "")),
|
||||
Summary: fmt.Sprintf("%s used in the remote path %s. Please change to use %s instead", path, vv, strings.ReplaceAll(vv, "/Workspace/", "")),
|
||||
Locations: v.Locations(),
|
||||
Paths: []dyn.Path{p},
|
||||
})
|
||||
|
|
|
@ -45,6 +45,8 @@ func Initialize() bundle.Mutator {
|
|||
mutator.DefineDefaultWorkspacePaths(),
|
||||
mutator.PrependWorkspacePrefix(),
|
||||
|
||||
// This mutator needs to be run before variable interpolation because it
|
||||
// searches for strings with variable references in them.
|
||||
validate.NoWorkspacePrefixUsed(),
|
||||
|
||||
mutator.SetVariables(),
|
||||
|
|
Loading…
Reference in New Issue