Skip to content

Commit

Permalink
feat: add diff tool customization (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Elyytscha authored Oct 1, 2024
1 parent 5efbdc5 commit 2879ef1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
collapse-diff: false
timezone: America/Los_Angeles
timezone-locale: en-US
diff-tool: diff -N -u

```

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ inputs:
description: 'Time zone locale to use in comment'
default: 'en-US'
required: false
diff-tool:
description: 'Diff tool to use'
default: 'diff -N -u'
required: false
runs:
using: 'node12'
main: 'dist/index.js'
3 changes: 2 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1918,6 +1918,7 @@ const PLAINTEXT = core.getInput('plaintext').toLowerCase() === "true";
const COLLAPSE_DIFF = core.getInput('collapse-diff').toLowerCase() === "true";
const TIMEZONE = core.getInput('timezone');
const TIMEZONE_LOCALE = core.getInput('timezone-locale');
const DIFF_TOOL = core.getInput('diff-tool') || 'diff -N -u';
let EXTRA_CLI_ARGS = core.getInput('argocd-extra-cli-args');
if (PLAINTEXT) {
EXTRA_CLI_ARGS += ' --plaintext';
Expand Down Expand Up @@ -1957,7 +1958,7 @@ function setupArgoCDCommand() {
fs.chmodSync(path.join(argoBinaryPath), '755');
// core.addPath(argoBinaryPath);
return (params) => __awaiter(this, void 0, void 0, function* () {
return execCommand(`${argoBinaryPath} ${params} --auth-token=${ARGOCD_TOKEN} --server=${ARGOCD_SERVER_URL} ${EXTRA_CLI_ARGS}`);
return execCommand(`KUBECTL_EXTERNAL_DIFF='${DIFF_TOOL}' ${argoBinaryPath} ${params} --auth-token=${ARGOCD_TOKEN} --server=${ARGOCD_SERVER_URL} ${EXTRA_CLI_ARGS}`);
});
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const PLAINTEXT = core.getInput('plaintext').toLowerCase() === "true";
const COLLAPSE_DIFF = core.getInput('collapse-diff').toLowerCase() === "true";
const TIMEZONE = core.getInput('timezone');
const TIMEZONE_LOCALE = core.getInput('timezone-locale');
const DIFF_TOOL = core.getInput('diff-tool') || 'diff -N -u';
let EXTRA_CLI_ARGS = core.getInput('argocd-extra-cli-args');
if (PLAINTEXT) {
EXTRA_CLI_ARGS += ' --plaintext';
Expand Down Expand Up @@ -87,7 +88,7 @@ async function setupArgoCDCommand(): Promise<(params: string) => Promise<ExecRes

return async (params: string) =>
execCommand(
`${argoBinaryPath} ${params} --auth-token=${ARGOCD_TOKEN} --server=${ARGOCD_SERVER_URL} ${EXTRA_CLI_ARGS}`
`KUBECTL_EXTERNAL_DIFF='${DIFF_TOOL}' ${argoBinaryPath} ${params} --auth-token=${ARGOCD_TOKEN} --server=${ARGOCD_SERVER_URL} ${EXTRA_CLI_ARGS}`
);
}

Expand Down

0 comments on commit 2879ef1

Please sign in to comment.