Skip to content

Commit

Permalink
fix(plugins/plugin-kubectl): plugin-kubectl's fetch-file, when using …
Browse files Browse the repository at this point in the history
…electron, does not have error handling

Fixes #6426
  • Loading branch information
starpit committed Dec 21, 2020
1 parent 5737ed9 commit 5dd00d4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions plugins/plugin-kubectl/src/lib/util/fetch-file.ts
Expand Up @@ -72,6 +72,8 @@ async function _needle({ qexec }: REPL, method: 'get', url: string): Promise<{ s
redirect: 'follow'
})

request.on('error', reject)

request.on('response', response => {
const statusCode = response.statusCode
debug('got response', statusCode)
Expand Down Expand Up @@ -103,7 +105,7 @@ async function _needle({ qexec }: REPL, method: 'get', url: string): Promise<{ s
}
}

async function fetchRemote (repl: REPL, url: string) {
async function fetchRemote(repl: REPL, url: string) {
const fetchOnce = () => _needle(repl, 'get', url).then(_ => _.body)

const retry = (delay: number) => async (err: Error) => {
Expand Down Expand Up @@ -172,7 +174,7 @@ export async function fetchRawFiles(args: Arguments<KubeOptions>, filepath: stri
await args.REPL.rexec<{ data?: string; isDirectory?: boolean }>(`vfs fstat ${path} --with-data`)
).content

if (resourceStats.isDirectory) {
if (resourceStats.isDirectory) {
return args.REPL.rexec<{ path: string }[]>(
`vfs ls ${join(path, isRecursive(args) ? '/**/*.yaml' : '/*.yaml')} --with-data`
)
Expand Down

0 comments on commit 5dd00d4

Please sign in to comment.