Skip to content
Merged
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
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ import "github.com/databricks/cli/libs/cmdio"
cmdio.LogString(ctx, "...")
```

Always output file path with forward slashes, even on Windows, so that acceptance test output is stable between OSes. Use filepath.ToSlash for this.

# Specific File Guides

## databricks_template_schema.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@ Ignore = [
# C:/Program Files/Git/Users/$username/UNIQUE_NAME before passing it to the CLI
# Setting this environment variable prevents that conversion on windows.
MSYS_NO_PATHCONV = "1"

[[Repls]]
Old = '\\'
New = '/'
4 changes: 0 additions & 4 deletions acceptance/bundle/generate/app_subfolders/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,3 @@ Pattern = "GET /api/2.0/workspace/export"
Response.Body = '''
print("Hello, World!")
'''

[[Repls]]
Old = '\\'
New = '/'
4 changes: 0 additions & 4 deletions acceptance/bundle/generate/auto-bind/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,3 @@ Ignore = [
# C:/Program Files/Git/Users/$username/UNIQUE_NAME before passing it to the CLI
# Setting this environment variable prevents that conversion on windows.
MSYS_NO_PATHCONV = "1"

[[Repls]]
Old = '\\'
New = '/'
2 changes: 1 addition & 1 deletion acceptance/bundle/generate/dashboard-inplace/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Deployment complete!

=== update the dashboard file using bundle generate
>>> [CLI] bundle generate dashboard --resource test_dashboard --force
Writing dashboard to "dash.lvdash.json"
Writing dashboard to dash.lvdash.json

>>> cat dash.lvdash.json
{
Expand Down
4 changes: 2 additions & 2 deletions acceptance/bundle/generate/dashboard/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
>>> [CLI] workspace mkdirs /Workspace/test-[UNIQUE_NAME]

>>> [CLI] bundle generate dashboard --existing-id [DASHBOARD_ID] --dashboard-dir out/dashboard --resource-dir out/resource
Writing dashboard to "out/dashboard/test_dashboard.lvdash.json"
Writing configuration to "out/resource/test_dashboard.dashboard.yml"
Writing dashboard to out/dashboard/test_dashboard.lvdash.json
Writing configuration to out/resource/test_dashboard.dashboard.yml
4 changes: 0 additions & 4 deletions acceptance/bundle/generate/dashboard/test.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[[Repls]]
Old = '\\\\'
New = '/'

[[Repls]]
Old = "[0-9a-f]{32}"
New = "[DASHBOARD_ID]"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

>>> [CLI] bundle generate dashboard --existing-path /path/to/dashboard --dashboard-dir out/dashboard --resource-dir out/resource
Writing dashboard to "out/dashboard/this_is_a_test_dashboard.lvdash.json"
Writing configuration to "out/resource/this_is_a_test_dashboard.dashboard.yml"
Writing dashboard to out/dashboard/this_is_a_test_dashboard.lvdash.json
Writing configuration to out/resource/this_is_a_test_dashboard.dashboard.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[[Repls]]
Old = '\\\\'
New = '/'

[[Server]]
Pattern = "GET /api/2.0/workspace/get-status"
Response.Body = '''
Expand Down
4 changes: 0 additions & 4 deletions acceptance/bundle/generate/lakeflow_pipelines/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ Response.Body = '''
print("Hello, World!")
'''

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

[[Server]]
Pattern = "GET /api/2.0/workspace/list"
Response.Body = '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Exit code: 1
}

>>> [CLI] bundle generate dashboard --resource already_exists --force
Writing dashboard to "dashboard.lvdash.json"
Writing dashboard to dashboard.lvdash.json

>>> cat dashboard.lvdash.json
{}
Expand Down
6 changes: 3 additions & 3 deletions bundle/generate/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ func (n *Downloader) FlushToDisk(ctx context.Context, force bool) error {
info, err := os.Stat(targetPath)
if err == nil {
if info.IsDir() {
return fmt.Errorf("%s is a directory", targetPath)
return fmt.Errorf("%s is a directory", filepath.ToSlash(targetPath))
}
if !force {
return fmt.Errorf("%s already exists. Use --force to overwrite", targetPath)
return fmt.Errorf("%s already exists. Use --force to overwrite", filepath.ToSlash(targetPath))
}
}
}
Expand Down Expand Up @@ -261,7 +261,7 @@ func (n *Downloader) FlushToDisk(ctx context.Context, force bool) error {
return err
}

cmdio.LogString(errCtx, "File successfully saved to "+targetPath)
cmdio.LogString(errCtx, "File successfully saved to "+filepath.ToSlash(targetPath))
return reader.Close()
})
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/bundle/generate/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ After generation, you can deploy this alert to other targets using:

// Check if file exists and force flag
if _, err := os.Stat(alertPath); err == nil && !force {
return fmt.Errorf("%s already exists. Use --force to overwrite", alertPath)
return fmt.Errorf("%s already exists. Use --force to overwrite", filepath.ToSlash(alertPath))
}

// Write alert definition file
Expand Down Expand Up @@ -170,8 +170,8 @@ After generation, you can deploy this alert to other targets using:
return err
}

cmdio.LogString(ctx, "Alert configuration successfully saved to "+configPath)
cmdio.LogString(ctx, "Serialized alert definition to "+alertPath)
cmdio.LogString(ctx, "Alert configuration successfully saved to "+filepath.ToSlash(configPath))
cmdio.LogString(ctx, "Serialized alert definition to "+filepath.ToSlash(alertPath))

return nil
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/bundle/generate/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ func (d *dashboard) saveSerializedDashboard(ctx context.Context, b *bundle.Bundl
info, err := os.Stat(filename)
if err == nil {
if info.IsDir() {
return fmt.Errorf("%s is a directory", rel)
return fmt.Errorf("%s is a directory", filepath.ToSlash(rel))
}
if !d.force {
return fmt.Errorf("%s already exists. Use --force to overwrite", rel)
return fmt.Errorf("%s already exists. Use --force to overwrite", filepath.ToSlash(rel))
}
}

cmdio.LogString(ctx, fmt.Sprintf("Writing dashboard to %q", rel))
cmdio.LogString(ctx, "Writing dashboard to "+filepath.ToSlash(rel))
return os.WriteFile(filename, data, 0o644)
}

Expand Down Expand Up @@ -242,7 +242,7 @@ func (d *dashboard) saveConfiguration(ctx context.Context, b *bundle.Bundle, das
rel = resourcePath
}

cmdio.LogString(ctx, fmt.Sprintf("Writing configuration to %q", rel))
cmdio.LogString(ctx, "Writing configuration to "+filepath.ToSlash(rel))
err = saver.SaveAsYAML(result, resourcePath, d.force)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/bundle/generate/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ After generation, you can deploy this job to other targets using:
return err
}

cmdio.LogString(ctx, "Job configuration successfully saved to "+filename)
cmdio.LogString(ctx, "Job configuration successfully saved to "+filepath.ToSlash(filename))

if bind {
return deployment.BindResource(cmd, jobKey, strconv.FormatInt(jobId, 10), true, false, true)
Expand Down
2 changes: 1 addition & 1 deletion cmd/bundle/generate/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ like catalogs, schemas, and compute configurations per target.`,
return err
}

cmdio.LogString(ctx, "Pipeline configuration successfully saved to "+filename)
cmdio.LogString(ctx, "Pipeline configuration successfully saved to "+filepath.ToSlash(filename))

if bind {
return deployment.BindResource(cmd, pipelineKey, pipelineId, true, false, true)
Expand Down