Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 1d22713

Browse files
committed
Revised print routines to not print blanks, added --links and supressed link blocks by default
1 parent a42e9ee commit 1d22713

2 files changed

Lines changed: 35 additions & 13 deletions

File tree

cmd/print.go

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,40 @@ func printDeployment(deployment composeAPI.Deployment) {
9797
fmt.Printf("%15s: %s... (Use --fullca for certificate)\n", "CA Certificate", deployment.CACertificateBase64[0:32])
9898
}
9999
}
100-
fmt.Printf("%15s: %s\n", "Web UI Link", getLink(deployment.Links.ComposeWebUILink))
101-
fmt.Printf("%15s: %s\n", "Health", deployment.Connection.Health)
102-
fmt.Printf("%15s: %s\n", "SSH", deployment.Connection.SSH)
103-
fmt.Printf("%15s: %s\n", "Admin", deployment.Connection.Admin)
104-
fmt.Printf("%15s: %s\n", "SSHAdmin", deployment.Connection.SSHAdmin)
105-
fmt.Printf("%15s: %s\n", "CLI Connect", deployment.Connection.CLI)
106-
fmt.Printf("%15s: %s\n", "Direct Connect", deployment.Connection.Direct)
107100

108-
// Format the Misc connection as a JSON object
109-
miscbuf, err := json.MarshalIndent(deployment.Connection.Misc, "", " ")
110-
if err != nil {
111-
fmt.Printf("%15s: %#v\n", "Misc Error", err)
112-
} else {
113-
fmt.Printf("%15s: %s\n", "Misc", string(miscbuf))
101+
if showLinks {
102+
fmt.Printf("%15s: %s\n", "Web UI Link", getLink(deployment.Links.ComposeWebUILink))
103+
fmt.Printf("%15s: %s\n", "Alerts Link", getLink(deployment.Links.AlertsLink))
104+
fmt.Printf("%15s: %s\n", "Cluster Link", getLink(deployment.Links.ClusterLink))
105+
fmt.Printf("%15s: %s\n", "Scalings Link", getLink(deployment.Links.ScalingsLink))
106+
}
107+
108+
if len(deployment.Connection.Health) > 0 {
109+
fmt.Printf("%15s: %s\n", "Health", deployment.Connection.Health)
110+
}
111+
if len(deployment.Connection.SSH) > 0 {
112+
fmt.Printf("%15s: %s\n", "SSH", deployment.Connection.SSH)
113+
}
114+
if len(deployment.Connection.Admin) > 0 {
115+
fmt.Printf("%15s: %s\n", "Admin", deployment.Connection.Admin)
116+
}
117+
if len(deployment.Connection.SSHAdmin) > 0 {
118+
fmt.Printf("%15s: %s\n", "SSHAdmin", deployment.Connection.SSHAdmin)
119+
}
120+
if len(deployment.Connection.CLI) > 0 {
121+
fmt.Printf("%15s: %s\n", "CLI Connect", deployment.Connection.CLI)
122+
}
123+
if len(deployment.Connection.Direct) > 0 {
124+
fmt.Printf("%15s: %s\n", "Direct Connect", deployment.Connection.Direct)
125+
}
126+
if len(deployment.Connection.Misc.(map[string]interface{})) > 0 {
127+
// Format the Misc connection as a JSON object
128+
miscbuf, err := json.MarshalIndent(deployment.Connection.Misc, "", " ")
129+
if err != nil {
130+
fmt.Printf("%15s: %#v\n", "Misc Error", err)
131+
} else {
132+
fmt.Printf("%15s: %s\n", "Misc", string(miscbuf))
133+
}
114134
}
115135

116136
}

cmd/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var noDecodeCA bool
3131
var caEscaped bool
3232
var recipewatch bool
3333
var recipewait bool
34+
var showLinks bool
3435

3536
// RootCmd represents the base command when called without any subcommands
3637
var RootCmd = &cobra.Command{
@@ -59,6 +60,7 @@ func init() {
5960
RootCmd.PersistentFlags().BoolVar(&caEscaped, "caescaped", false, "Display full CAs as escaped strings")
6061
RootCmd.PersistentFlags().BoolVar(&recipewatch, "watch", false, "Automatically watch a resulting recipe")
6162
RootCmd.PersistentFlags().BoolVar(&recipewait, "wait", false, "Automatically silently wait for a resulting recipe to finish")
63+
RootCmd.PersistentFlags().BoolVar(&showLinks, "links", false, "Show HATEOS links")
6264

6365
}
6466

0 commit comments

Comments
 (0)