Create annotation object

This commit is contained in:
Vidya Reddy 2022-07-22 10:52:37 +05:30
parent bae916660e
commit caa56759c2
2 changed files with 15 additions and 21 deletions

View File

@ -6,7 +6,7 @@ import {reject} from './actions/reject'
import {Action, parseAction} from './types/action' import {Action, parseAction} from './types/action'
import {parseDeploymentStrategy} from './types/deploymentStrategy' import {parseDeploymentStrategy} from './types/deploymentStrategy'
import {getFilesFromDirectories} from './utilities/fileUtils' import {getFilesFromDirectories} from './utilities/fileUtils'
import {stringify} from 'querystring' import {parseAnnotations} from './types/annotations'
export async function run() { export async function run() {
// verify kubeconfig is set // verify kubeconfig is set
@ -19,8 +19,9 @@ export async function run() {
const action: Action | undefined = parseAction( const action: Action | undefined = parseAction(
core.getInput('action', {required: true}) core.getInput('action', {required: true})
) )
const annotation: {[key: string]: string} = {} const annotations = parseAnnotations(
const annotations = core.getInput(stringify(annotation), {required: true}) core.getInput('annotations', {required: false})
)
const strategy = parseDeploymentStrategy(core.getInput('strategy')) const strategy = parseDeploymentStrategy(core.getInput('strategy'))
const manifestsInput = core.getInput('manifests', {required: true}) const manifestsInput = core.getInput('manifests', {required: true})
const manifestFilePaths = manifestsInput const manifestFilePaths = manifestsInput
@ -37,30 +38,15 @@ export async function run() {
// run action // run action
switch (action) { switch (action) {
case Action.DEPLOY: { case Action.DEPLOY: {
await deploy( await deploy(kubectl, fullManifestFilePaths, strategy, annotations)
kubectl,
fullManifestFilePaths,
strategy,
JSON.parse(annotations)
)
break break
} }
case Action.PROMOTE: { case Action.PROMOTE: {
await promote( await promote(kubectl, fullManifestFilePaths, strategy, annotations)
kubectl,
fullManifestFilePaths,
strategy,
JSON.parse(annotations)
)
break break
} }
case Action.REJECT: { case Action.REJECT: {
await reject( await reject(kubectl, fullManifestFilePaths, strategy, annotations)
kubectl,
fullManifestFilePaths,
strategy,
JSON.parse(annotations)
)
break break
} }
default: { default: {

8
src/types/annotations.ts Normal file
View File

@ -0,0 +1,8 @@
export function parseAnnotations(str: string) {
if (str == '') {
return {}
} else {
const annotaion = JSON.parse(str)
return new Map(annotaion)
}
}