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

Commit

Permalink
Revised print routines to not print blanks, added --links and supress…
Browse files Browse the repository at this point in the history
…ed link blocks by default
  • Loading branch information
codepope committed Jun 29, 2017
1 parent a42e9ee commit 1d22713
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
46 changes: 33 additions & 13 deletions cmd/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,40 @@ func printDeployment(deployment composeAPI.Deployment) {
fmt.Printf("%15s: %s... (Use --fullca for certificate)\n", "CA Certificate", deployment.CACertificateBase64[0:32])
}
}
fmt.Printf("%15s: %s\n", "Web UI Link", getLink(deployment.Links.ComposeWebUILink))
fmt.Printf("%15s: %s\n", "Health", deployment.Connection.Health)
fmt.Printf("%15s: %s\n", "SSH", deployment.Connection.SSH)
fmt.Printf("%15s: %s\n", "Admin", deployment.Connection.Admin)
fmt.Printf("%15s: %s\n", "SSHAdmin", deployment.Connection.SSHAdmin)
fmt.Printf("%15s: %s\n", "CLI Connect", deployment.Connection.CLI)
fmt.Printf("%15s: %s\n", "Direct Connect", deployment.Connection.Direct)

// Format the Misc connection as a JSON object
miscbuf, err := json.MarshalIndent(deployment.Connection.Misc, "", " ")
if err != nil {
fmt.Printf("%15s: %#v\n", "Misc Error", err)
} else {
fmt.Printf("%15s: %s\n", "Misc", string(miscbuf))
if showLinks {
fmt.Printf("%15s: %s\n", "Web UI Link", getLink(deployment.Links.ComposeWebUILink))
fmt.Printf("%15s: %s\n", "Alerts Link", getLink(deployment.Links.AlertsLink))
fmt.Printf("%15s: %s\n", "Cluster Link", getLink(deployment.Links.ClusterLink))
fmt.Printf("%15s: %s\n", "Scalings Link", getLink(deployment.Links.ScalingsLink))
}

if len(deployment.Connection.Health) > 0 {
fmt.Printf("%15s: %s\n", "Health", deployment.Connection.Health)
}
if len(deployment.Connection.SSH) > 0 {
fmt.Printf("%15s: %s\n", "SSH", deployment.Connection.SSH)
}
if len(deployment.Connection.Admin) > 0 {
fmt.Printf("%15s: %s\n", "Admin", deployment.Connection.Admin)
}
if len(deployment.Connection.SSHAdmin) > 0 {
fmt.Printf("%15s: %s\n", "SSHAdmin", deployment.Connection.SSHAdmin)
}
if len(deployment.Connection.CLI) > 0 {
fmt.Printf("%15s: %s\n", "CLI Connect", deployment.Connection.CLI)
}
if len(deployment.Connection.Direct) > 0 {
fmt.Printf("%15s: %s\n", "Direct Connect", deployment.Connection.Direct)
}
if len(deployment.Connection.Misc.(map[string]interface{})) > 0 {
// Format the Misc connection as a JSON object
miscbuf, err := json.MarshalIndent(deployment.Connection.Misc, "", " ")
if err != nil {
fmt.Printf("%15s: %#v\n", "Misc Error", err)
} else {
fmt.Printf("%15s: %s\n", "Misc", string(miscbuf))
}
}

}
Expand Down
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var noDecodeCA bool
var caEscaped bool
var recipewatch bool
var recipewait bool
var showLinks bool

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

}

Expand Down

0 comments on commit 1d22713

Please sign in to comment.