From 704b7fa50732d4a851d7766db0a7db8243769947 Mon Sep 17 00:00:00 2001 From: Jonathan Santerre Date: Tue, 16 Apr 2024 10:12:35 -0400 Subject: [PATCH] Fix private-cluster multiple filenames --- src/types/privatekubectl.test.ts | 7 +++++++ src/types/privatekubectl.ts | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/types/privatekubectl.test.ts b/src/types/privatekubectl.test.ts index 2d4198a57..35b87919e 100644 --- a/src/types/privatekubectl.test.ts +++ b/src/types/privatekubectl.test.ts @@ -17,6 +17,13 @@ describe('Private kubectl', () => { ) }) + it('should replace filenames with basenames correctly', () => { + const testString = `kubectl apply -f /tmp/test.yaml,/tmp/test2.yaml,/tmp/test3.yaml` + expect(mockKube.replaceFilnamesWithBasenames(testString)).toEqual( + `kubectl apply -f test.yaml,test2.yaml,test3.yaml` + ) + }) + test('Should throw well defined Error on error from Azure', async () => { const errorMsg = 'An error message' jest.spyOn(exec, 'getExecOutput').mockImplementation(async () => { diff --git a/src/types/privatekubectl.ts b/src/types/privatekubectl.ts index 19c80bb82..42d00f035 100644 --- a/src/types/privatekubectl.ts +++ b/src/types/privatekubectl.ts @@ -95,7 +95,7 @@ export class PrivateKubectl extends Kubectl { } as ExecOutput } - private replaceFilnamesWithBasenames(kubectlCmd: string) { + public replaceFilnamesWithBasenames(kubectlCmd: string) { let exFilenames = this.extractFilesnames(kubectlCmd) let filenames = exFilenames.split(' ') let filenamesArr = filenames[0].split(',') @@ -119,7 +119,7 @@ export class PrivateKubectl extends Kubectl { fileNames.push(...this.extractFilesFromMinimist(argv, fArg)) fileNames.push(...this.extractFilesFromMinimist(argv, filenameArg)) - return fileNames.join(' ') + return fileNames.join() } private extractFilesFromMinimist(argv, arg: string): string[] {