From 331313ea5f5d7c387183e5735185a13cc0cc0f1e Mon Sep 17 00:00:00 2001 From: shreyas-goenka <88374338+shreyas-goenka@users.noreply.github.com> Date: Fri, 19 Apr 2024 17:13:50 +0530 Subject: [PATCH] Print host in `bundle validate` when passed via profile or environment variables (#1378) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Changes Fixes to get host from the workspace client rather than only printing the host when it's configured in the bundle config. ## Tests Manually. When a profile was specified for auth. Before: ``` ➜ bundle-playground git:(master) ✗ cli bundle validate Name: bundle-playground Target: default Workspace: Host: User: shreyas.goenka@databricks.com Path: /Users/shreyas.goenka@databricks.com/.bundle/bundle-playground/default ``` After: ``` ➜ bundle-playground git:(master) ✗ cli bundle validate Name: bundle-playground Target: default Workspace: Host: https://e2-dogfood.staging.cloud.databricks.com User: shreyas.goenka@databricks.com Path: /Users/shreyas.goenka@databricks.com/.bundle/bundle-playground/default ``` --- cmd/bundle/validate.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/bundle/validate.go b/cmd/bundle/validate.go index 0472df47..8d49ec96 100644 --- a/cmd/bundle/validate.go +++ b/cmd/bundle/validate.go @@ -48,7 +48,7 @@ const warningTemplate = `{{ "Warning" | yellow }}: {{ .Summary }} const summaryTemplate = `Name: {{ .Config.Bundle.Name | bold }} Target: {{ .Config.Bundle.Target | bold }} Workspace: - Host: {{ .Config.Workspace.Host | bold }} + Host: {{ .WorkspaceClient.Config.Host | bold }} User: {{ .Config.Workspace.CurrentUser.UserName | bold }} Path: {{ .Config.Workspace.RootPath | bold }} @@ -107,8 +107,9 @@ func renderTextOutput(cmd *cobra.Command, b *bundle.Bundle, diags diag.Diagnosti // Print validation summary. t := template.Must(template.New("summary").Funcs(validateFuncMap).Parse(summaryTemplate)) err := t.Execute(cmd.OutOrStdout(), map[string]any{ - "Config": b.Config, - "Trailer": buildTrailer(diags), + "Config": b.Config, + "Trailer": buildTrailer(diags), + "WorkspaceClient": b.WorkspaceClient(), }) if err != nil { return err