| 50 | ` |
| 51 | |
| 52 | func localCmd() *cobra.Command { |
| 53 | diff := local{ |
| 54 | release: "release", |
| 55 | } |
| 56 | |
| 57 | localCmd := &cobra.Command{ |
| 58 | Use: "local [flags] CHART1 CHART2", |
| 59 | Short: "Shows diff between two local chart directories", |
| 60 | Long: localCmdLongUsage, |
| 61 | Example: strings.Join([]string{ |
| 62 | " helm diff local ./chart-v1 ./chart-v2", |
| 63 | " helm diff local ./chart-v1 ./chart-v2 -f values.yaml", |
| 64 | " helm diff local /path/to/chart-a /path/to/chart-b --set replicas=3", |
| 65 | }, "\n"), |
| 66 | RunE: func(cmd *cobra.Command, args []string) error { |
| 67 | cmd.SilenceUsage = true |
| 68 | |
| 69 | if err := checkArgsLength(len(args), "chart1 path", "chart2 path"); err != nil { |
| 70 | return err |
| 71 | } |
| 72 | |
| 73 | ProcessDiffOptions(cmd.Flags(), &diff.Options) |
| 74 | |
| 75 | diff.chart1 = args[0] |
| 76 | diff.chart2 = args[1] |
| 77 | |
| 78 | if diff.namespace == "" { |
| 79 | diff.namespace = os.Getenv("HELM_NAMESPACE") |
| 80 | } |
| 81 | |
| 82 | return diff.run() |
| 83 | }, |
| 84 | } |
| 85 | |
| 86 | localCmd.Flags().StringVar(&diff.release, "release", "release", "release name to use for template rendering") |
| 87 | localCmd.Flags().StringVar(&diff.namespace, "namespace", "", "namespace to use for template rendering") |
| 88 | localCmd.Flags().BoolVar(&diff.detailedExitCode, "detailed-exitcode", false, "return a non-zero exit code when there are changes") |
| 89 | localCmd.Flags().BoolVar(&diff.includeTests, "include-tests", false, "enable the diffing of the helm test hooks") |
| 90 | localCmd.Flags().BoolVar(&diff.includeCRDs, "include-crds", false, "include CRDs in the diffing") |
| 91 | localCmd.Flags().BoolVar(&diff.normalizeManifests, "normalize-manifests", false, "normalize manifests before running diff to exclude style differences from the output") |
| 92 | localCmd.Flags().BoolVar(&diff.enableDNS, "enable-dns", false, "enable DNS lookups when rendering templates") |
| 93 | localCmd.Flags().VarP(&diff.valueFiles, "values", "f", "specify values in a YAML file (can specify multiple)") |
| 94 | localCmd.Flags().StringArrayVar(&diff.values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") |
| 95 | localCmd.Flags().StringArrayVar(&diff.stringValues, "set-string", []string{}, "set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") |
| 96 | localCmd.Flags().StringArrayVar(&diff.stringLiteralValues, "set-literal", []string{}, "set STRING literal values on the command line") |
| 97 | localCmd.Flags().StringArrayVar(&diff.jsonValues, "set-json", []string{}, "set JSON values on the command line (can specify multiple or separate values with commas: key1=jsonval1,key2=jsonval2)") |
| 98 | localCmd.Flags().StringArrayVar(&diff.fileValues, "set-file", []string{}, "set values from respective files specified via the command line (can specify multiple or separate values with commas: key1=path1,key2=path2)") |
| 99 | localCmd.Flags().StringVar(&diff.postRenderer, "post-renderer", "", "the path to an executable to be used for post rendering. If it exists in $PATH, the binary will be used, otherwise it will try to look for the executable at the given path") |
| 100 | localCmd.Flags().StringArrayVar(&diff.postRendererArgs, "post-renderer-args", []string{}, "an argument to the post-renderer (can specify multiple)") |
| 101 | localCmd.Flags().StringArrayVarP(&diff.extraAPIs, "api-versions", "a", []string{}, "Kubernetes api versions used for Capabilities.APIVersions") |
| 102 | localCmd.Flags().StringVar(&diff.kubeVersion, "kube-version", "", "Kubernetes version used for Capabilities.KubeVersion") |
| 103 | |
| 104 | AddDiffOptions(localCmd.Flags(), &diff.Options) |
| 105 | |
| 106 | localCmd.SuggestionsMinimumDistance = 1 |
| 107 | |
| 108 | return localCmd |
| 109 | } |