Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix kubectl command with multiple filenames in private cluster #321

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/types/privatekubectl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
4 changes: 2 additions & 2 deletions src/types/privatekubectl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(',')
Expand All @@ -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[] {
Expand Down