Beispiel #1
0
func newVersionCmd(c helm.Interface, out io.Writer) *cobra.Command {
	version := &versionCmd{
		client: c,
		out:    out,
	}

	cmd := &cobra.Command{
		Use:   "version",
		Short: "print the client/server version information",
		Long:  versionDesc,
		RunE: func(cmd *cobra.Command, args []string) error {
			// If neither is explicitly set, show both.
			if !version.showClient && !version.showServer {
				version.showClient, version.showServer = true, true
			}
			if version.showServer {
				// We do this manually instead of in PreRun because we only
				// need a tunnel if server version is requested.
				setupConnection(cmd, args)
			}
			version.client = ensureHelmClient(version.client)
			return version.run()
		},
	}
	f := cmd.Flags()
	f.BoolVarP(&version.showClient, "client", "c", false, "client version only")
	f.BoolVarP(&version.showServer, "server", "s", false, "server version only")
	f.BoolVar(&version.short, "short", false, "print the version number")

	return cmd
}
Beispiel #2
0
func newVersionCmd(c helm.Interface, out io.Writer) *cobra.Command {
	version := &versionCmd{
		client: c,
		out:    out,
	}
	cmd := &cobra.Command{
		Use:               "version",
		Short:             "print the client/server version information",
		PersistentPreRunE: setupConnection,
		RunE: func(cmd *cobra.Command, args []string) error {
			version.client = ensureHelmClient(version.client)
			return version.run()
		},
	}
	return cmd
}