Fix dashboard command by adding service format template

pull/776/head
Jimmi Dyson 2016-10-29 09:00:16 +01:00
parent 7323fa0421
commit 0bbcce5786
No known key found for this signature in database
GPG Key ID: 978CD4AF4C1E87F5
2 changed files with 5 additions and 2 deletions

View File

@ -19,6 +19,7 @@ package cmd
import (
"fmt"
"os"
"text/template"
"time"
"github.com/docker/machine/libmachine"
@ -53,7 +54,7 @@ var dashboardCmd = &cobra.Command{
os.Exit(1)
}
urls, err := cluster.GetServiceURLsForService(api, namespace, service, nil)
urls, err := cluster.GetServiceURLsForService(api, namespace, service, template.Must(template.New("dashboardServiceFormat").Parse(defaultServiceFormatTemplate)))
if err != nil {
fmt.Fprintln(os.Stderr, err)
fmt.Fprintln(os.Stderr, "Check that minikube is running.")

View File

@ -96,12 +96,14 @@ var serviceCmd = &cobra.Command{
},
}
const defaultServiceFormatTemplate = "http://{{.IP}}:{{.Port}}"
func init() {
serviceCmd.Flags().StringVarP(&namespace, "namespace", "n", "default", "The service namespace")
serviceCmd.Flags().BoolVar(&serviceURLMode, "url", false, "Display the kubernetes service URL in the CLI instead of opening it in the default browser")
serviceCmd.Flags().BoolVar(&https, "https", false, "Open the service URL with https instead of http")
serviceCmd.PersistentFlags().StringVar(&serviceURLFormat, "format", "http://{{.IP}}:{{.Port}}", "Format to output service URL in. This format will be applied to each url individually and they will be printed one at a time.")
serviceCmd.PersistentFlags().StringVar(&serviceURLFormat, "format", defaultServiceFormatTemplate, "Format to output service URL in. This format will be applied to each url individually and they will be printed one at a time.")
RootCmd.AddCommand(serviceCmd)
}