Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nextchanges/bundles/windows-forward-slash-paths.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Print paths with forward slashes in bundle and `fs` error messages on Windows. ([#7377](https://github.com/databricks/cli/pull/7377))
5 changes: 0 additions & 5 deletions acceptance/apps/init/auth-mode/test.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
Cloud = false

[[Repls]]
# Fix path with reverse slashes in the output for Windows.
Old = 'TEST_TMP_DIR]\\(app-[a-z-]+)'
New = 'TEST_TMP_DIR]/${1}'
5 changes: 0 additions & 5 deletions acceptance/apps/init/binding-values/test.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
Cloud = false

[[Repls]]
# Fix path with reverse slashes in the output for Windows.
Old = 'TEST_TMP_DIR]\\(app-[a-z-]+)'
New = 'TEST_TMP_DIR]/${1}'
8 changes: 4 additions & 4 deletions acceptance/bin/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def main():
patterns = compile_repls()

if d1.is_dir() and d2.is_dir():
files1 = [str(p.relative_to(d1)) for p in d1.rglob("*") if p.is_file() and not p.name.startswith("LOG")]
files2 = [str(p.relative_to(d2)) for p in d2.rglob("*") if p.is_file() and not p.name.startswith("LOG")]
files1 = [p.relative_to(d1).as_posix() for p in d1.rglob("*") if p.is_file() and not p.name.startswith("LOG")]
files2 = [p.relative_to(d2).as_posix() for p in d2.rglob("*") if p.is_file() and not p.name.startswith("LOG")]
else:
assert d1.is_file(), d1
assert d2.is_file(), d2
Expand All @@ -31,9 +31,9 @@ def main():
p1 = d1 / f
p2 = d2 / f
if f not in set2:
print(f"Only in {d1}: {f}")
print(f"Only in {d1.as_posix()}: {f}")
elif f not in set1:
print(f"Only in {d2}: {f}")
print(f"Only in {d2.as_posix()}: {f}")
else:
diff_files(patterns, p1, p2)

Expand Down
4 changes: 0 additions & 4 deletions acceptance/bundle/artifacts/globs_in_files/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,3 @@ RecordRequests = false
[[Repls]]
Old = '\\\\'
New = '/'

[[Repls]]
Old = '\\'
New = '/'
4 changes: 0 additions & 4 deletions acceptance/bundle/artifacts/globs_invalid/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,3 @@ RecordRequests = false
[[Repls]]
Old = '\\\\'
New = '/'

[[Repls]]
Old = '\\'
New = '/'
4 changes: 0 additions & 4 deletions acceptance/bundle/artifacts/nil_artifacts/test.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
RecordRequests = false

[[Repls]]
Old = '\\\\'
New = '/'
4 changes: 0 additions & 4 deletions acceptance/bundle/artifacts/same_name_libraries/test.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
RecordRequests = false

[[Repls]]
Old = '\\'
New = '/'
3 changes: 1 addition & 2 deletions acceptance/bundle/deploy/mlops-stacks/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Ignore = [
Old = "aws|azure|gcp"
New = "[CLOUD_ENV_BASE]"

# $TESTDIR uses backslashes on Windows, hence the either-separator match.
[[Repls]]
Old = 'bundle init .*[\\/]mlops-stacks/template'
Old = 'bundle init .*/mlops-stacks/template'
New = "bundle init mlops-stacks"
4 changes: 0 additions & 4 deletions acceptance/bundle/generate/genie_space/test.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
Env.MSYS_NO_PATHCONV = "1"

[[Repls]]
Old = '\\\\'
New = '/'

[[Repls]]
Old = "[0-9a-f]{32}"
New = "[GENIE_SPACE_ID]"
3 changes: 0 additions & 3 deletions acceptance/bundle/includes/glob_in_root_path/test.toml

This file was deleted.

4 changes: 0 additions & 4 deletions acceptance/bundle/integration_whl/serverless/test.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
CloudSlow = true
# serverless is only enabled if UC is enabled

[[Repls]]
Old = '\\'
New = '/'

This file was deleted.

3 changes: 0 additions & 3 deletions acceptance/bundle/paths/outside_root_no_sync/test.toml

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions acceptance/bundle/syncroot/dotdot-git/test.toml

This file was deleted.

4 changes: 0 additions & 4 deletions acceptance/bundle/templates-machinery/wrong-url/test.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[[Repls]]
Old = '\\'
New = '/'

[[Repls]]
Old = '/world-[0-9]+'
New = '/world-123456'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ To get started, refer to the project README.md file and the documentation at htt
--- [TESTROOT]/bundle/templates/default-python/serverless-customcatalog/../serverless/output/my_default_python/src/my_default_python_etl/explorations/sample_exploration.ipynb
+++ output/my_default_python/src/my_default_python_etl/explorations/sample_exploration.ipynb
@@ -38,5 +38,5 @@
"# !!! Before performing any data analysis, make sure to run the pipeline to materialize the sample datasets. The tables referenced in this notebook depend on that step./n",
"/n",
- "display(spark.sql(/"SELECT * FROM hive_metastore.[USERNAME].sample_trips_my_default_python/"))"
+ "display(spark.sql(/"SELECT * FROM customcatalog.[USERNAME].sample_trips_my_default_python/"))"
"# !!! Before performing any data analysis, make sure to run the pipeline to materialize the sample datasets. The tables referenced in this notebook depend on that step.\n",
"\n",
- "display(spark.sql(\"SELECT * FROM hive_metastore.[USERNAME].sample_trips_my_default_python\"))"
+ "display(spark.sql(\"SELECT * FROM customcatalog.[USERNAME].sample_trips_my_default_python\"))"
]
}
--- [TESTROOT]/bundle/templates/default-python/serverless-customcatalog/../serverless/output/my_default_python/src/sample_notebook.ipynb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,3 @@ Phase = 1
[[Server]]
Pattern = "GET /api/2.1/unity-catalog/current-metastore-assignment"
Response.Body = '{"default_catalog_name": "customcatalog"}'

[[Repls]]
# windows fix
Old = '\\'
New = '/'
4 changes: 0 additions & 4 deletions acceptance/bundle/validate/targets/test.toml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
Badness = "Relative paths in variable-overrides.json resolve inconsistently: task files are resolved against the bundle root (with an error), libraries relative to the overrides file."

[[Repls]]
Old = '\\'
New = '/'

This file was deleted.

4 changes: 0 additions & 4 deletions acceptance/bundle/validate/yaml_anchors/test.toml

This file was deleted.

4 changes: 0 additions & 4 deletions acceptance/bundle/validate/yaml_duplicate_keys/test.toml

This file was deleted.

4 changes: 0 additions & 4 deletions acceptance/bundle/variables/file-defaults/test.toml

This file was deleted.

3 changes: 0 additions & 3 deletions acceptance/cmd/auth/docker/host/test.toml

This file was deleted.

5 changes: 0 additions & 5 deletions acceptance/cmd/fs/cp/file-to-nonexistent-dir/test.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
Cloud = true

# Local paths in errors use the OS separator.
[[Repls]]
Old = 'local\\nonexistent\\mydir'
New = 'local/nonexistent/mydir'
3 changes: 0 additions & 3 deletions acceptance/selftest/diff/test.toml

This file was deleted.

2 changes: 1 addition & 1 deletion bundle/artifacts/expand_globs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func createGlobError(v dyn.Value, p dyn.Path, message string) diag.Diagnostic {

return diag.Diagnostic{
Severity: diag.Error,
Summary: fmt.Sprintf("%s: %s", source, message),
Summary: fmt.Sprintf("%s: %s", filepath.ToSlash(source), message),
Locations: []diag.Location{v.Location()},
Paths: dyn.ToStructPaths(p),
}
Expand Down
2 changes: 1 addition & 1 deletion bundle/config/loader/process_root_includes.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (m *processRootIncludes) Apply(ctx context.Context, b *bundle.Bundle) diag.
diags = diags.Append(diag.Diagnostic{
Severity: diag.Error,
Summary: "Bundle root path contains glob pattern characters",
Detail: fmt.Sprintf("The path to the bundle root %s contains glob pattern character %q. Please remove the character from this path to use bundle commands.", b.BundleRootPath, char),
Detail: fmt.Sprintf("The path to the bundle root %s contains glob pattern character %q. Please remove the character from this path to use bundle commands.", filepath.ToSlash(b.BundleRootPath), char),
})

return diags
Expand Down
4 changes: 2 additions & 2 deletions bundle/config/mutator/set_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ func readVariablesFromFile(b *bundle.Bundle) (dyn.Value, diag.Diagnostics) {

val, err := jsonloader.LoadJSON(f, filePath)
if err != nil {
return dyn.InvalidValue, diag.FromErr(fmt.Errorf("failed to parse variables file %s: %w", filePath, err))
return dyn.InvalidValue, diag.FromErr(fmt.Errorf("failed to parse variables file %s: %w", filepath.ToSlash(filePath), err))
}

if val.Kind() != dyn.KindMap {
return dyn.InvalidValue, diags.Append(diag.Diagnostic{
Severity: diag.Error,
Summary: fmt.Sprintf("failed to parse variables file %s: invalid format", filePath),
Summary: fmt.Sprintf("failed to parse variables file %s: invalid format", filepath.ToSlash(filePath)),
Detail: "Variables file must be a JSON object with the following format:\n{\"var1\": \"value1\", \"var2\": \"value2\"}",
})
}
Expand Down
2 changes: 1 addition & 1 deletion bundle/config/mutator/translate_paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (t *translateContext) rewritePath(
return "", err
}
if !opts.AllowPathOutsideSyncRoot && !filepath.IsLocal(localRelPath) {
return "", fmt.Errorf("path %s is not contained in sync root path", localPath)
return "", fmt.Errorf("path %s is not contained in sync root path", filepath.ToSlash(localPath))
}

// Normalize paths to separated by forward slashes.
Expand Down
7 changes: 4 additions & 3 deletions bundle/config/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"os"
"path/filepath"
"reflect"
"strings"

Expand Down Expand Up @@ -122,13 +123,13 @@ func LoadFromBytes(path string, raw []byte) (*Root, diag.Diagnostics) {
Locations: []diag.Location{le.Loc},
}}
}
return nil, diag.Errorf("failed to load %s: %v", path, err)
return nil, diag.Errorf("failed to load %s: %v", filepath.ToSlash(path), err)
}

// Rewrite configuration tree where necessary.
v, err = rewriteShorthands(v)
if err != nil {
return nil, diag.Errorf("failed to rewrite %s: %v", path, err)
return nil, diag.Errorf("failed to rewrite %s: %v", filepath.ToSlash(path), err)
}

// Normalize dynamic configuration tree according to configuration type.
Expand All @@ -137,7 +138,7 @@ func LoadFromBytes(path string, raw []byte) (*Root, diag.Diagnostics) {
// Convert normalized configuration tree to typed configuration.
err = r.updateWithDynamicValue(v)
if err != nil {
diags = diags.Extend(diag.Errorf("failed to load %s: %v", path, err))
diags = diags.Extend(diag.Errorf("failed to load %s: %v", filepath.ToSlash(path), err))
return nil, diags
}
return &r, diags
Expand Down
2 changes: 1 addition & 1 deletion bundle/libraries/same_name_libraries.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (c checkForSameNameLibraries) Apply(ctx context.Context, b *bundle.Bundle)
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "Duplicate local library names: " + lib,
Detail: "Local library names must be unique but found libraries with the same name: " + lv.fullPath + ", " + strings.Join(lv.otherPaths, ", "),
Detail: "Local library names must be unique but found libraries with the same name: " + filepath.ToSlash(lv.fullPath) + ", " + filepath.ToSlash(strings.Join(lv.otherPaths, ", ")),
Locations: lv.locations,
Paths: lv.paths,
})
Expand Down
3 changes: 2 additions & 1 deletion libs/diag/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package diag

import (
"fmt"
"path/filepath"
)

type Location struct {
Expand All @@ -11,5 +12,5 @@ type Location struct {
}

func (l Location) String() string {
return fmt.Sprintf("%s:%d:%d", l.File, l.Line, l.Column)
return fmt.Sprintf("%s:%d:%d", filepath.ToSlash(l.File), l.Line, l.Column)
}
19 changes: 11 additions & 8 deletions libs/filer/errors.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package filer

import "io/fs"
import (
"io/fs"
"path/filepath"
)

// fileAlreadyExistsError is returned when attempting to write a file at a path
// that already exists, without using the OverwriteIfExists WriteMode flag.
Expand All @@ -9,7 +12,7 @@ type fileAlreadyExistsError struct {
}

func (err fileAlreadyExistsError) Error() string {
return "file already exists: " + err.path
return "file already exists: " + filepath.ToSlash(err.path)
}

func (err fileAlreadyExistsError) Is(other error) bool {
Expand All @@ -28,7 +31,7 @@ func (err fileDoesNotExistError) Is(other error) bool {
}

func (err fileDoesNotExistError) Error() string {
return "file does not exist: " + err.path
return "file does not exist: " + filepath.ToSlash(err.path)
}

// noSuchDirectoryError is returned when attempting to write a file to a path
Expand All @@ -39,7 +42,7 @@ type noSuchDirectoryError struct {
}

func (err noSuchDirectoryError) Error() string {
return "no such directory: " + err.path
return "no such directory: " + filepath.ToSlash(err.path)
}

func (err noSuchDirectoryError) Is(other error) bool {
Expand All @@ -53,7 +56,7 @@ type notADirectory struct {
}

func (err notADirectory) Error() string {
return "not a directory: " + err.path
return "not a directory: " + filepath.ToSlash(err.path)
}

func (err notADirectory) Is(other error) bool {
Expand All @@ -67,7 +70,7 @@ type notAFile struct {
}

func (err notAFile) Error() string {
return "not a file: " + err.path
return "not a file: " + filepath.ToSlash(err.path)
}

func (err notAFile) Is(other error) bool {
Expand All @@ -82,7 +85,7 @@ type directoryNotEmptyError struct {
}

func (err directoryNotEmptyError) Error() string {
return "directory not empty: " + err.path
return "directory not empty: " + filepath.ToSlash(err.path)
}

func (err directoryNotEmptyError) Is(other error) bool {
Expand Down Expand Up @@ -113,7 +116,7 @@ type permissionError struct {
}

func (err permissionError) Error() string {
return "access denied: " + err.path
return "access denied: " + filepath.ToSlash(err.path)
}

func (err permissionError) Is(other error) bool {
Expand Down
2 changes: 1 addition & 1 deletion libs/git/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func NewView(ctx context.Context, worktreeRoot, root vfs.Path) (*View, error) {
target := root.Native()
prefix := repo.rootDir.Native()
if !strings.HasPrefix(target, prefix) {
return nil, fmt.Errorf("path %q is not within repository root %q", root.Native(), prefix)
return nil, fmt.Errorf("path %q is not within repository root %q", filepath.ToSlash(root.Native()), filepath.ToSlash(prefix))
}

// Make target a relative path.
Expand Down
Loading