Fixes multiple namespaces bug (#276)

* fix ns bug

* add tests

* rename some variables

* rename ns to namespace

* fix delete + correctly type

* add typing to input obj parser
This commit is contained in:
Oliver King
2023-02-06 13:42:55 -05:00
committed by GitHub
parent 756cc0a511
commit ecb488266d
14 changed files with 326 additions and 81 deletions
+12 -3
View File
@@ -2,6 +2,8 @@ import * as core from '@actions/core'
import {ExecOutput} from '@actions/exec'
import {Kubectl} from '../types/kubectl'
const NAMESPACE = 'namespace'
export function checkForErrors(
execResults: ExecOutput[],
warnIfError?: boolean
@@ -30,7 +32,12 @@ export async function getLastSuccessfulRunSha(
annotationKey: string
): Promise<string> {
try {
const result = await kubectl.getResource('namespace', namespaceName)
const result = await kubectl.getResource(
NAMESPACE,
namespaceName,
false,
namespaceName
)
if (result?.stderr) {
core.warning(result.stderr)
return process.env.GITHUB_SHA
@@ -53,12 +60,13 @@ export async function annotateChildPods(
kubectl: Kubectl,
resourceType: string,
resourceName: string,
namespace: string | undefined,
annotationKeyValStr: string,
allPods
): Promise<ExecOutput[]> {
let owner = resourceName
if (resourceType.toLowerCase().indexOf('deployment') > -1) {
owner = await kubectl.getNewReplicaSet(resourceName)
owner = await kubectl.getNewReplicaSet(resourceName, namespace)
}
const commandExecutionResults = []
@@ -72,7 +80,8 @@ export async function annotateChildPods(
kubectl.annotate(
'pod',
pod.metadata.name,
annotationKeyValStr
annotationKeyValStr,
namespace
)
)
break