add private cluster exitCode check

This commit is contained in:
Oliver King 2022-10-18 10:35:38 -04:00
parent 57d0489e1f
commit e4d3021456
No known key found for this signature in database
GPG Key ID: 8C02F0B0B4671B24

View File

@ -10,7 +10,7 @@ export class PrivateKubectl extends Kubectl {
args.unshift('kubectl')
let kubectlCmd = args.join(' ')
let addFileFlag = false
let eo = <ExecOptions>{silent}
let eo = <ExecOptions>{silent: true}
if (this.containsFilenames(kubectlCmd)) {
// For private clusters, files will referenced solely by their basename
@ -52,7 +52,26 @@ export class PrivateKubectl extends Kubectl {
core.debug(
`private cluster Kubectl run with invoke command: ${kubectlCmd}`
)
return await getExecOutput('az', privateClusterArgs, eo)
const runOutput = await getExecOutput(
'az',
[...privateClusterArgs, '-o', 'json'],
eo
)
const runObj: {logs: string; exitCode: number} = JSON.parse(
runOutput.stdout
)
if (!silent) core.info(runObj.logs)
if (runObj.exitCode !== 0) {
throw Error(`failed private cluster Kubectl command: ${kubectlCmd}`)
}
const output: ExecOutput = {
exitCode: 0,
stdout: '',
stderr: ''
}
return output
}
private replaceFilnamesWithBasenames(kubectlCmd: string) {