This commit is contained in:
Andrew Nester 2024-09-10 14:51:01 +02:00
parent cb345b1dc7
commit c80e8984df
No known key found for this signature in database
GPG Key ID: 12BC628A44B7DA57
2 changed files with 5 additions and 5 deletions

View File

@ -44,13 +44,13 @@ func (m *rewriteWorkspacePrefix) Apply(ctx context.Context, b *bundle.Bundle) di
if strings.Contains(vv, path) { if strings.Contains(vv, path) {
diags = append(diags, diag.Diagnostic{ diags = append(diags, diag.Diagnostic{
Severity: diag.Warning, Severity: diag.Warning,
Summary: fmt.Sprintf("substring %q found in %q. Please update this to %q. For more information, please refer to: https://github.com/databricks/cli/blob/main/docs/release_notes/workspace_prefix.md", path, vv, strings.ReplaceAll(vv, "/Workspace/", "")), Summary: fmt.Sprintf("substring %q found in %q. Please update this to %q. For more information, please refer to: https://github.com/databricks/cli/blob/main/docs/release_notes/workspace_prefix.md", path, vv, strings.Replace(vv, "/Workspace/", "", 1)),
Locations: v.Locations(), Locations: v.Locations(),
Paths: []dyn.Path{p}, Paths: []dyn.Path{p},
}) })
// Remove the workspace prefix from the string. // Remove the workspace prefix from the string.
return dyn.NewValue(strings.ReplaceAll(vv, "/Workspace/", ""), v.Locations()), nil return dyn.NewValue(strings.Replace(vv, "/Workspace/", "", 1), v.Locations()), nil
} }
} }

View File

@ -65,9 +65,9 @@ func TestNoWorkspacePrefixUsed(t *testing.T) {
require.Len(t, diags, 3) require.Len(t, diags, 3)
expectedErrors := map[string]bool{ expectedErrors := map[string]bool{
"/Workspace/${workspace.root_path} used in the remote path /Workspace/${workspace.root_path}/file1.py. Please change to use ${workspace.root_path}/file1.py instead. See more details here: https://github.com/databricks/cli/blob/main/docs/release_notes/workspace_prefix.md": true, `substring "/Workspace/${workspace.root_path}" found in "/Workspace/${workspace.root_path}/file1.py". Please update this to "${workspace.root_path}/file1.py". For more information, please refer to: https://github.com/databricks/cli/blob/main/docs/release_notes/workspace_prefix.md`: true,
"/Workspace/${workspace.file_path} used in the remote path /Workspace/${workspace.file_path}/notebook1. Please change to use ${workspace.file_path}/notebook1 instead. See more details here: https://github.com/databricks/cli/blob/main/docs/release_notes/workspace_prefix.md": true, `substring "/Workspace/${workspace.file_path}" found in "/Workspace/${workspace.file_path}/notebook1". Please update this to "${workspace.file_path}/notebook1". For more information, please refer to: https://github.com/databricks/cli/blob/main/docs/release_notes/workspace_prefix.md`: true,
"/Workspace/${workspace.artifact_path} used in the remote path /Workspace/${workspace.artifact_path}/jar1.jar. Please change to use ${workspace.artifact_path}/jar1.jar instead. See more details here: https://github.com/databricks/cli/blob/main/docs/release_notes/workspace_prefix.md": true, `substring "/Workspace/${workspace.artifact_path}" found in "/Workspace/${workspace.artifact_path}/jar1.jar". Please update this to "${workspace.artifact_path}/jar1.jar". For more information, please refer to: https://github.com/databricks/cli/blob/main/docs/release_notes/workspace_prefix.md`: true,
} }
for _, d := range diags { for _, d := range diags {