diff --git a/.nextchanges/cli/7638.md b/.nextchanges/cli/7638.md new file mode 100644 index 00000000000..f22a5dce736 --- /dev/null +++ b/.nextchanges/cli/7638.md @@ -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)) diff --git a/acceptance/cmd/auth/profiles/output.txt b/acceptance/cmd/auth/profiles/output.txt index df472a2fd5e..7287b6cacc0 100644 --- a/acceptance/cmd/auth/profiles/output.txt +++ b/acceptance/cmd/auth/profiles/output.txt @@ -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 diff --git a/acceptance/cmd/auth/profiles/script b/acceptance/cmd/auth/profiles/script index 61ba384c9fb..779c006d5f9 100644 --- a/acceptance/cmd/auth/profiles/script +++ b/acceptance/cmd/auth/profiles/script @@ -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 diff --git a/acceptance/cmd/auth/switch/nominal/output.txt b/acceptance/cmd/auth/switch/nominal/output.txt index 00f83abfaa5..d1e15395009 100644 --- a/acceptance/cmd/auth/switch/nominal/output.txt +++ b/acceptance/cmd/auth/switch/nominal/output.txt @@ -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 @@ -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] diff --git a/cmd/auth/profiles.go b/cmd/auth/profiles.go index e65b11371b7..56998266a76 100644 --- a/cmd/auth/profiles.go +++ b/cmd/auth/profiles.go @@ -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 @@ -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