Fix dashboard command by adding service format template
parent
7323fa0421
commit
0bbcce5786
|
@ -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.")
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue