github.com/simonferquel/app@v0.6.1-0.20181012141724-68b7cccf26ac/cmd/docker-app/helm.go (about) 1 package main 2 3 import ( 4 "fmt" 5 6 "github.com/docker/app/internal" 7 "github.com/docker/app/internal/helm" 8 "github.com/docker/app/internal/packager" 9 "github.com/docker/app/types" 10 "github.com/docker/cli/cli" 11 cliopts "github.com/docker/cli/opts" 12 "github.com/spf13/cobra" 13 ) 14 15 var ( 16 helmComposeFiles []string 17 helmSettingsFile []string 18 helmEnv []string 19 helmRender bool 20 stackVersion string 21 ) 22 23 func helmCmd() *cobra.Command { 24 cmd := &cobra.Command{ 25 Use: "helm [<app-name>] [-s key=value...] [-f settings-file...]", 26 Short: "Generate a Helm chart", 27 Long: `Generate a Helm chart for the application.`, 28 Args: cli.RequiresMaxArgs(1), 29 RunE: func(cmd *cobra.Command, args []string) error { 30 app, err := packager.Extract(firstOrEmpty(args), 31 types.WithSettingsFiles(helmSettingsFile...), 32 types.WithComposeFiles(helmComposeFiles...), 33 ) 34 if err != nil { 35 return err 36 } 37 defer app.Cleanup() 38 d := cliopts.ConvertKVStringsToMap(helmEnv) 39 if stackVersion != helm.V1Beta1 && stackVersion != helm.V1Beta2 { 40 return fmt.Errorf("invalid stack version %q (accepted values: %s, %s)", stackVersion, helm.V1Beta1, helm.V1Beta2) 41 } 42 return helm.Helm(app, d, helmRender, stackVersion) 43 }, 44 } 45 if internal.Experimental == "on" { 46 cmd.Flags().StringArrayVarP(&helmComposeFiles, "compose-files", "c", []string{}, "Override Compose files") 47 cmd.Use += " [-c <compose-files>...]" 48 cmd.Flags().BoolVarP(&helmRender, "render", "r", false, "Render the template instead of exporting it") 49 cmd.Long += ` If the --render option is used, the docker-compose.yml will 50 be rendered instead of exported as a template.` 51 } 52 cmd.Flags().StringArrayVarP(&helmSettingsFile, "settings-files", "f", []string{}, "Override settings files") 53 cmd.Flags().StringArrayVarP(&helmEnv, "set", "s", []string{}, "Override settings values") 54 cmd.Flags().StringVarP(&stackVersion, "stack-version", "", helm.V1Beta2, "Version of the stack specification for the produced helm chart (v1beta1 / v1beta2)") 55 return cmd 56 }