Rebase from master

reviewable/pr2557/r10
Justin Scott 8 years ago
parent d4224af1f1
commit 2889f97b5c

@ -21,7 +21,6 @@ import (
"fmt" "fmt"
"io" "io"
"os" "os"
"strings"
"github.com/spf13/cobra" "github.com/spf13/cobra"
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
@ -123,7 +122,7 @@ func newInitCmd(out io.Writer) *cobra.Command {
f.StringVar(&i.serviceAccount, "service-account", "", "name of service account") f.StringVar(&i.serviceAccount, "service-account", "", "name of service account")
f.StringVar(&i.opts.NodeSelectors, "node-selectors", "", "labels to specify the node on which Tiller is installed (app=tiller,helm=rocks)") f.StringVar(&i.opts.NodeSelectors, "node-selectors", "", "labels to specify the node on which Tiller is installed (app=tiller,helm=rocks)")
f.StringVarP(&i.opts.Output, "output", "o", "", "skip installation and output Tiller's manifest in specified format (json or yaml)") f.VarP(&i.opts.Output, "output", "o", "skip installation and output Tiller's manifest in specified format (json or yaml)")
f.StringArrayVar(&i.opts.Values, "set", []string{}, "set values for the Tiller Deployment manifest (can specify multiple or separate values with commas: key1=val1,key2=val2)") f.StringArrayVar(&i.opts.Values, "set", []string{}, "set values for the Tiller Deployment manifest (can specify multiple or separate values with commas: key1=val1,key2=val2)")
return cmd return cmd
@ -195,7 +194,7 @@ func (i *initCmd) run() error {
if body, err = installer.DeploymentManifest(&i.opts); err != nil { if body, err = installer.DeploymentManifest(&i.opts); err != nil {
return err return err
} }
switch strings.ToLower(i.opts.Output) { switch i.opts.Output.String() {
case "json": case "json":
jsonb, err := yaml.ToJSON([]byte(body)) jsonb, err := yaml.ToJSON([]byte(body))
if err != nil { if err != nil {

@ -78,7 +78,7 @@ type Options struct {
NodeSelectors string NodeSelectors string
// Output dumps the Tiller manifest in the specified format (e.g. JSON) but skips Helm/Tiller installation // Output dumps the Tiller manifest in the specified format (e.g. JSON) but skips Helm/Tiller installation
Output string Output outputFormat
// Set merges additional values into the Tiller Deployment manifest // Set merges additional values into the Tiller Deployment manifest
Values []string Values []string
@ -113,3 +113,28 @@ func (opts *Options) valuesMap(m map[string]interface{}) (map[string]interface{}
} }
return m, nil return m, nil
} }
type outputFormat string
func (f *outputFormat) String() string {
return string(*f)
}
func (f *outputFormat) Type() string {
return "outputFormat"
}
const (
fmtJSON outputFormat = "json"
fmtYAML = "yaml"
)
func (f *outputFormat) Set(s string) error {
for _, of := range []outputFormat{fmtJSON, fmtYAML} {
if s == string(of) {
*f = of
return nil
}
}
return fmt.Errorf("unknown output format %q", s)
}

@ -39,7 +39,7 @@ helm init
--local-repo-url string URL for local repository (default "http://127.0.0.1:8879/charts") --local-repo-url string URL for local repository (default "http://127.0.0.1:8879/charts")
--net-host install Tiller with net=host --net-host install Tiller with net=host
--node-selectors string labels to specify the node on which Tiller is installed (app=tiller,helm=rocks) --node-selectors string labels to specify the node on which Tiller is installed (app=tiller,helm=rocks)
-o, --output string skip installation and output Tiller's manifest in specified format (json or yaml) -o, --output outputFormat skip installation and output Tiller's manifest in specified format (json or yaml)
--service-account string name of service account --service-account string name of service account
--set stringArray set values for the Tiller Deployment manifest (can specify multiple or separate values with commas: key1=val1,key2=val2) --set stringArray set values for the Tiller Deployment manifest (can specify multiple or separate values with commas: key1=val1,key2=val2)
--skip-refresh do not refresh (download) the local repository cache --skip-refresh do not refresh (download) the local repository cache

Loading…
Cancel
Save