Compare commits

..

12 Commits

Author SHA1 Message Date
Vidya Reddy 7362e2ee9b Spelling correction 2022-07-25 10:32:04 +05:30
Vidya Reddy 2a96bf3d2c Updated Readme and action.yml 2022-07-25 09:08:38 +05:30
Vidya Reddy caa56759c2 Create annotation object 2022-07-22 10:52:37 +05:30
Vidya Reddy bae916660e Clean code 2022-07-20 21:59:33 +05:30
Vidya Reddy 8e795671c2 Clean code 2022-07-20 21:55:47 +05:30
Vidya Reddy d784fb6c4d clean code 2022-07-20 12:54:17 +05:30
Vidya Reddy 534896c172 Traffic split - canary deployment 2022-07-20 12:34:31 +05:30
Vidya Reddy 634370ab70 updated Readme and action.yml 2022-07-19 11:37:26 +05:30
Vidya Reddy 0e57c19ffe Traffic split annotations - canary deployment 2022-07-18 16:20:06 +05:30
Vidya Reddy 9f25026d56 traffic split - canary deployment 2022-07-15 00:20:56 +05:30
Vidya Reddy b595866809 traffic split - blueGreen deployment 2022-07-14 14:59:47 +05:30
Vidya Reddy 00f71d4310 Added Traffic split annotations 2022-07-11 21:20:36 -07:00
3 changed files with 41 additions and 6 deletions
+1 -1
View File
@@ -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,
+19 -1
View File
@@ -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'
+21 -4
View File
@@ -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}`
}
/**