helmfile: Missing colors in diff

After upgrading helm-diff to 3.2.0 or newer, running helmfile diff produces output with no colors when running in regular terminal (not CI, TERM=xterm-256color). In the same time running helm diff in the same terminal produces colors as expected.

My guess is that after https://github.com/databus23/helm-diff/pull/240, there is check https://github.com/databus23/helm-diff/blob/master/cmd/root.go#L47-L50 which always true due to how helmfile executes helm-diff. helm-diff’s stdout is captured/redirected in separate file descriptor which isn’t considered as terminal.

I tried passing running helmfile --no-color=false diff, but it didn’t enable color in diff output. Only way to enforce colors I found was helmfile diff --args="--no-color=false", but it’s problematic in way where this arg passed to helm list execution and fails there.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 7
  • Comments: 23 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Merged https://github.com/databus23/helm-diff/issues/344 on helm-diff. The next action item would be to enhance helmfile to set HELM_DIFF_COLOR appropriately.

the latest helm-diff release should work well with helmfile --color

I don’t see this.

% helm diff version
3.4.0

% helmfile version
helmfile version v0.143.0

Running helmfile diff produces output without colors.

Running helmfile --color diff produces error Incorrect Usage. flag provided but not defined: -color and shows helmfile usage help.

Running helmfile diff --color produces error Incorrect Usage. flag provided but not defined: -color and shows helmfile diff usage help.

Running HELM_DIFF_COLOR=true helmfile diff produces colored output.

Is this expected resolution?


Additionally is it possible to make patch release of helmfile docker image, which includes updated helm-diff?

Turns out I forgot the fact that it only has --no-color but --color https://github.com/roboll/helmfile/blob/debd3c0eeac2cd40c8a1227a3d0424f5944c3b81/pkg/state/state.go#L1710-L1712

That said, HELM_DIFF_COLOR=true helmfile diff might be the right way to force color! Thanks for pointing it out.

As @frank-berlin has kindly shared, the latest helm-diff release should work well with helmfile --color. Closing as resolved but please feel free to reopen if necessary. Thanks everyone for your cooperation!

I agree, the colors are very useful in CI. I personally use them to reduce the output of diff to only changed lines (after creating the full diff). It used to work beautifully before.

See example output here (gitlab CI): image

@mumoshu proposed logic look correct, just need to take into account helmfile’s own --no-colors argument.