Skip to content

Commit

Permalink
Make helm diff color optional (#383)
Browse files Browse the repository at this point in the history
* Add helm-diff-color option to action
  • Loading branch information
Dermah authored Nov 11, 2024
1 parent 0f0a6e1 commit d816691
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This action works on Linux, macOS and Windows
- `helm-plugins` : Comma separated list of Helm plugins to install. Default `https://github.com/databus23/helm-diff`
- `helmfile-auto-init` : Whether to run `helmfile init` before running helmfile command. Default `"false"`
- `helmfile-kubeconfig-context` : Kubeconfig context. Default `""`, if not empty, it will be written to `$HOME/.kube/config`
- `helm-diff-color`: Enable helm diff plugin color output. Default `"true"`.

Example with optional inputs

Expand Down
4 changes: 4 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ inputs:
required: false
description: 'kubeconfig context, it not empty, it will be written to the kubeconfig file'
default: ''
helm-diff-color:
required: false
description: 'Enable helm diff plugin color output'
default: 'true'
outputs:
exit-code:
description: 'Exit code of helmfile. Useful to handle diff --detailed-exitcode'
Expand Down
6 changes: 4 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ async function run(): Promise<void> {
const helmfileKubeconfigContext = core.getInput(
'helmfile-kubeconfig-context'
);
const helmDiffColor = core.getInput('helm-diff-color');

core.debug(`helmfile-args: ${helmfileArgs}`);
core.debug(`helmfile-version: ${helmfileVersion}`);
core.debug(`helmfile-workdirectory: ${helmfileWorkDirectory}`);
core.debug(`helm-version: ${helmVersion}`);
core.debug(`helm-plugins: ${helmPlugins}`);
core.debug(`helmfile-auto-init: ${helmfileAutoInit}`);
core.debug(`helm-diff-color: ${helmDiffColor}`);

core.startGroup('Install helmfile');
await Promise.all([installHelmfile(helmfileVersion)]);
Expand Down Expand Up @@ -99,10 +101,10 @@ async function run(): Promise<void> {

options.ignoreReturnCode = true;

// set HELM_DIFF_COLOR=true into the environment
// set HELM_DIFF_COLOR=true into the helmfile command's environment
options.env = {
...process.env,
HELM_DIFF_COLOR: 'true'
HELM_DIFF_COLOR: helmDiffColor,
...process.env
};

const processExitCode = await exec.exec(
Expand Down

0 comments on commit d816691

Please sign in to comment.