Skip to content

Commit

Permalink
Porting changes for kubectl path fix (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ganeshrockz authored Sep 2, 2021
1 parent fe0e722 commit 773b614
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion __tests__/kubectl-util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ describe('Testing all funcitons in kubectl-util file.', () => {
jest.spyOn(toolCache, 'find').mockReturnValue('pathToKubectl');
jest.spyOn(os, 'type').mockReturnValue('Windows_NT');

expect(await kubectlUtil.getKubectlPath()).toBe('pathToKubectl');
expect(await kubectlUtil.getKubectlPath()).toBe(path.join('pathToKubectl', 'kubectl.exe'));
expect(core.getInput).toBeCalledWith('kubectl-version', {required: false});
expect(toolCache.find).toBeCalledWith('kubectl', 'v2.0.0');
});
Expand Down
3 changes: 2 additions & 1 deletion lib/kubectl-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ function getKubectlPath() {
if (core.getInput('kubectl-version', { required: false })) {
var version = core.getInput('kubectl-version', { required: false });
if (!!version && version != "latest") {
kubectlPath = toolCache.find('kubectl', version);
const cachedToolPath = toolCache.find('kubectl', version);
kubectlPath = path.join(cachedToolPath, kubectlToolName + utilities_1.getExecutableExtension());
}
if (!kubectlPath) {
kubectlPath = yield installKubectl(version);
Expand Down
3 changes: 2 additions & 1 deletion src/kubectl-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export async function getKubectlPath() {
if (core.getInput('kubectl-version', { required: false })) {
var version = core.getInput('kubectl-version', { required: false });
if ( !!version && version != "latest" ){
kubectlPath = toolCache.find('kubectl', version);
const cachedToolPath = toolCache.find('kubectl', version);
kubectlPath = path.join(cachedToolPath, kubectlToolName + getExecutableExtension())
}

if (!kubectlPath) {
Expand Down

0 comments on commit 773b614

Please sign in to comment.