mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-06-29 00:09:28 +08:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7362e2ee9b | |||
| 2a96bf3d2c | |||
| caa56759c2 | |||
| bae916660e | |||
| 8e795671c2 | |||
| d784fb6c4d | |||
| 534896c172 | |||
| 634370ab70 | |||
| 0e57c19ffe | |||
| 9f25026d56 | |||
| b595866809 | |||
| 00f71d4310 |
@@ -143,7 +143,7 @@ export async function annotateAndLabelResources(
|
|||||||
const workflowFilePath = await getWorkflowFilePath(githubToken)
|
const workflowFilePath = await getWorkflowFilePath(githubToken)
|
||||||
|
|
||||||
const deploymentConfig = await getDeploymentConfig()
|
const deploymentConfig = await getDeploymentConfig()
|
||||||
const annotationKeyLabel = getWorkflowAnnotationKeyLabel()
|
const annotationKeyLabel = getWorkflowAnnotationKeyLabel(workflowFilePath)
|
||||||
|
|
||||||
await annotateResources(
|
await annotateResources(
|
||||||
files,
|
files,
|
||||||
|
|||||||
@@ -1,6 +1,24 @@
|
|||||||
import {cleanLabel} from '../utilities/workflowAnnotationUtils'
|
import {
|
||||||
|
cleanLabel,
|
||||||
|
prefixObjectKeys
|
||||||
|
} from '../utilities/workflowAnnotationUtils'
|
||||||
|
|
||||||
describe('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', () => {
|
describe('cleanLabel', () => {
|
||||||
it('should clean label', () => {
|
it('should clean label', () => {
|
||||||
const alreadyClean = 'alreadyClean'
|
const alreadyClean = 'alreadyClean'
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
import {DeploymentConfig} from '../types/deploymentConfig'
|
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(
|
export function getWorkflowAnnotations(
|
||||||
lastSuccessRunSha: string,
|
lastSuccessRunSha: string,
|
||||||
@@ -24,11 +31,21 @@ export function getWorkflowAnnotations(
|
|||||||
helmChartPaths: deploymentConfig.helmChartFilePaths,
|
helmChartPaths: deploymentConfig.helmChartFilePaths,
|
||||||
provider: 'GitHub'
|
provider: 'GitHub'
|
||||||
}
|
}
|
||||||
return JSON.stringify(annotationObject)
|
const prefixedAnnotationObject = prefixObjectKeys(
|
||||||
|
annotationObject,
|
||||||
|
ANNOTATION_PREFIX
|
||||||
|
)
|
||||||
|
return JSON.stringify(prefixedAnnotationObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getWorkflowAnnotationKeyLabel(): string {
|
export function getWorkflowAnnotationKeyLabel(
|
||||||
return `${ANNOTATION_PREFIX}/k8s-deploy`
|
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