mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-06-24 13:39:27 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ce6bc40bc4 | |||
| 36041268eb | |||
| 36b55e389b | |||
| 6e560d48e7 |
@@ -143,7 +143,7 @@ export async function annotateAndLabelResources(
|
||||
const workflowFilePath = await getWorkflowFilePath(githubToken)
|
||||
|
||||
const deploymentConfig = await getDeploymentConfig()
|
||||
const annotationKeyLabel = getWorkflowAnnotationKeyLabel()
|
||||
const annotationKeyLabel = getWorkflowAnnotationKeyLabel(workflowFilePath)
|
||||
|
||||
await annotateResources(
|
||||
files,
|
||||
|
||||
@@ -23,7 +23,12 @@ export async function getDeploymentConfig(): Promise<DeploymentConfig> {
|
||||
)
|
||||
}
|
||||
|
||||
const imageNames = core.getInput('images').split('\n') || []
|
||||
let imageNames = core.getInput('images').split('\n') || []
|
||||
imageNames.forEach((element) => {
|
||||
if (element === null || '/^s+$/') {
|
||||
imageNames.pop()
|
||||
}
|
||||
})
|
||||
const imageDockerfilePathMap: {[id: string]: string} = {}
|
||||
|
||||
const pullImages = !(core.getInput('pull-images').toLowerCase() === 'false')
|
||||
|
||||
@@ -1,6 +1,24 @@
|
||||
import {cleanLabel} from '../utilities/workflowAnnotationUtils'
|
||||
import {
|
||||
cleanLabel,
|
||||
prefixObjectKeys
|
||||
} from '../utilities/workflowAnnotationUtils'
|
||||
|
||||
describe('WorkflowAnnotationUtils', () => {
|
||||
describe('prefixObjectKeys', () => {
|
||||
it('should prefix an object with a given prefix', () => {
|
||||
const obj = {
|
||||
foo: 'bar',
|
||||
baz: 'qux'
|
||||
}
|
||||
const prefix = 'prefix.'
|
||||
const expected = {
|
||||
'prefix.foo': 'bar',
|
||||
'prefix.baz': 'qux'
|
||||
}
|
||||
expect(prefixObjectKeys(obj, prefix)).toEqual(expected)
|
||||
})
|
||||
})
|
||||
|
||||
describe('cleanLabel', () => {
|
||||
it('should clean label', () => {
|
||||
const alreadyClean = 'alreadyClean'
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import {DeploymentConfig} from '../types/deploymentConfig'
|
||||
|
||||
const ANNOTATION_PREFIX = 'actions.github.com'
|
||||
const ANNOTATION_PREFIX = 'actions.github.com/'
|
||||
|
||||
export function prefixObjectKeys(obj: any, prefix: string): any {
|
||||
return Object.keys(obj).reduce((newObj, key) => {
|
||||
newObj[prefix + key] = obj[key]
|
||||
return newObj
|
||||
}, {})
|
||||
}
|
||||
|
||||
export function getWorkflowAnnotations(
|
||||
lastSuccessRunSha: string,
|
||||
@@ -24,11 +31,21 @@ export function getWorkflowAnnotations(
|
||||
helmChartPaths: deploymentConfig.helmChartFilePaths,
|
||||
provider: 'GitHub'
|
||||
}
|
||||
return JSON.stringify(annotationObject)
|
||||
const prefixedAnnotationObject = prefixObjectKeys(
|
||||
annotationObject,
|
||||
ANNOTATION_PREFIX
|
||||
)
|
||||
return JSON.stringify(prefixedAnnotationObject)
|
||||
}
|
||||
|
||||
export function getWorkflowAnnotationKeyLabel(): string {
|
||||
return `${ANNOTATION_PREFIX}/k8s-deploy`
|
||||
export function getWorkflowAnnotationKeyLabel(
|
||||
workflowFilePath: string
|
||||
): string {
|
||||
const hashKey = require('crypto')
|
||||
.createHash('MD5')
|
||||
.update(`${process.env.GITHUB_REPOSITORY}/${workflowFilePath}`)
|
||||
.digest('hex')
|
||||
return `githubWorkflow_${hashKey}`
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user