mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-06-27 07:09:26 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user