mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-04-11 00:40:08 +08:00
Create annotation object
This commit is contained in:
parent
bae916660e
commit
caa56759c2
28
src/run.ts
28
src/run.ts
@ -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
8
src/types/annotations.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
export function parseAnnotations(str: string) {
|
||||||
|
if (str == '') {
|
||||||
|
return {}
|
||||||
|
} else {
|
||||||
|
const annotaion = JSON.parse(str)
|
||||||
|
return new Map(annotaion)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user