|
6 | 6 | "fmt" |
7 | 7 | "log" |
8 | 8 | "os" |
| 9 | + "strconv" |
9 | 10 | "strings" |
10 | 11 |
|
11 | 12 | jsoniterator "github.com/json-iterator/go" |
@@ -112,6 +113,11 @@ func newChartCommand() *cobra.Command { |
112 | 113 | " # This is equivalent to specifying the --normalize-manifests flag.", |
113 | 114 | " # Read the flag usage below for more information on --normalize-manifests.", |
114 | 115 | " HELM_DIFF_NORMALIZE_MANIFESTS=true helm diff upgrade my-release datadog/datadog", |
| 116 | + "", |
| 117 | + "# Set HELM_DIFF_OUTPUT_CONTEXT=n to configure the output context to n lines.", |
| 118 | + "# This is equivalent to specifying the --context flag.", |
| 119 | + "# Read the flag usage below for more information on --context.", |
| 120 | + "HELM_DIFF_OUTPUT_CONTEXT=5 helm diff upgrade my-release datadog/datadog", |
115 | 121 | }, "\n"), |
116 | 122 | Args: func(cmd *cobra.Command, args []string) error { |
117 | 123 | return checkArgsLength(len(args), "release name", "chart path") |
@@ -144,6 +150,16 @@ func newChartCommand() *cobra.Command { |
144 | 150 | } |
145 | 151 | } |
146 | 152 |
|
| 153 | + if diff.OutputContext == -1 && !cmd.Flags().Changed("context") { |
| 154 | + contextEnvVar := os.Getenv("HELM_DIFF_OUTPUT_CONTEXT") |
| 155 | + if contextEnvVar != "" { |
| 156 | + context, err := strconv.Atoi(contextEnvVar) |
| 157 | + if err == nil { |
| 158 | + diff.OutputContext = context |
| 159 | + } |
| 160 | + } |
| 161 | + } |
| 162 | + |
147 | 163 | ProcessDiffOptions(cmd.Flags(), &diff.Options) |
148 | 164 |
|
149 | 165 | diff.release = args[0] |
|
0 commit comments