Skip to content
Draft
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/cli/7638.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* `databricks auth profiles --skip-validate` now omits the `Valid` column instead of reporting `NO` for every profile. ([#7638](https://github.com/databricks/cli/pull/7638))
8 changes: 8 additions & 0 deletions acceptance/cmd/auth/profiles/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@
}
]
}

=== Profiles with workspace_id (text output)

>>> [CLI] auth profiles --skip-validate
Name Host
workspace-profile https://workspace.cloud.databricks.test
account-profile https://accounts.cloud.databricks.test
unified-profile https://unified.databricks.test
3 changes: 3 additions & 0 deletions acceptance/cmd/auth/profiles/script
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ sethome "./home"
# home/.databrickscfg is a checked-in input with profiles including one with workspace_id.
title "Profiles with workspace_id (JSON output)"
$CLI auth profiles --skip-validate --output json

title "Profiles with workspace_id (text output)"
trace $CLI auth profiles --skip-validate
12 changes: 6 additions & 6 deletions acceptance/cmd/auth/switch/nominal/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ default_profile = profile-a
=== Profiles after first switch

>>> [CLI] auth profiles --skip-validate
Name Host Valid
profile-a (Default) [DATABRICKS_URL] NO
profile-b [DATABRICKS_URL] NO
Name Host
profile-a (Default) [DATABRICKS_URL]
profile-b [DATABRICKS_URL]

=== Switch to profile-b

Expand All @@ -27,6 +27,6 @@ default_profile = profile-b
=== Profiles after second switch

>>> [CLI] auth profiles --skip-validate
Name Host Valid
profile-a [DATABRICKS_URL] NO
profile-b (Default) [DATABRICKS_URL] NO
Name Host
profile-a [DATABRICKS_URL]
profile-b (Default) [DATABRICKS_URL]
12 changes: 8 additions & 4 deletions cmd/auth/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,17 @@ func newProfilesCommand() *cobra.Command {
Use: "profiles",
Short: "Lists profiles from ~/.databrickscfg",
Annotations: map[string]string{
// With --skip-validate nothing is validated, so the Valid column is
// omitted instead of reporting NO for every profile.
"template": cmdio.Heredoc(`
{{header "Name"}} {{header "Host"}} {{header "Valid"}}
{{range .Profiles}}{{.Name | green}}{{if .Default}} (Default){{end}} {{.Host|cyan}} {{bool .Valid}}
{{header "Name"}} {{header "Host"}}{{if not .SkipValidate}} {{header "Valid"}}{{end}}
{{range .Profiles}}{{.Name | green}}{{if .Default}} (Default){{end}} {{.Host|cyan}}{{if not $.SkipValidate}} {{bool .Valid}}{{end}}
{{end}}`),
},
}

var skipValidate bool
cmd.Flags().BoolVar(&skipValidate, "skip-validate", false, "Whether to skip validating the profiles")
cmd.Flags().BoolVar(&skipValidate, "skip-validate", false, "Skip validating the profiles (the Valid column is omitted and JSON \"valid\" is always false)")

cmd.RunE = func(cmd *cobra.Command, args []string) error {
var profiles []*profileMetadata
Expand Down Expand Up @@ -176,7 +178,9 @@ func newProfilesCommand() *cobra.Command {
wg.Wait()
return cmdio.Render(cmd.Context(), struct {
Profiles []*profileMetadata `json:"profiles"`
}{profiles})
// Used only by the text template; kept out of JSON so its shape stays stable.
SkipValidate bool `json:"-"`
}{profiles, skipValidate})
}

return cmd
Expand Down
Loading