Skip to content

Commit bb0278d

Browse files
authored
Swap annotation key to actions.github.com prefix (#216)
1 parent 71e93a7 commit bb0278d

File tree

3 files changed

+6
-41
lines changed

3 files changed

+6
-41
lines changed

src/strategyHelpers/deploymentHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export async function annotateAndLabelResources(
143143
const workflowFilePath = await getWorkflowFilePath(githubToken)
144144

145145
const deploymentConfig = await getDeploymentConfig()
146-
const annotationKeyLabel = getWorkflowAnnotationKeyLabel(workflowFilePath)
146+
const annotationKeyLabel = getWorkflowAnnotationKeyLabel()
147147

148148
await annotateResources(
149149
files,

src/utilities/workflowAnnotationUtils.test.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
1-
import {
2-
cleanLabel,
3-
prefixObjectKeys
4-
} from '../utilities/workflowAnnotationUtils'
1+
import {cleanLabel} from '../utilities/workflowAnnotationUtils'
52

63
describe('WorkflowAnnotationUtils', () => {
7-
describe('prefixObjectKeys', () => {
8-
it('should prefix an object with a given prefix', () => {
9-
const obj = {
10-
foo: 'bar',
11-
baz: 'qux'
12-
}
13-
const prefix = 'prefix.'
14-
const expected = {
15-
'prefix.foo': 'bar',
16-
'prefix.baz': 'qux'
17-
}
18-
expect(prefixObjectKeys(obj, prefix)).toEqual(expected)
19-
})
20-
})
21-
224
describe('cleanLabel', () => {
235
it('should clean label', () => {
246
const alreadyClean = 'alreadyClean'

src/utilities/workflowAnnotationUtils.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import {DeploymentConfig} from '../types/deploymentConfig'
22

3-
const ANNOTATION_PREFIX = 'actions.github.com/'
4-
5-
export function prefixObjectKeys(obj: any, prefix: string): any {
6-
return Object.keys(obj).reduce((newObj, key) => {
7-
newObj[prefix + key] = obj[key]
8-
return newObj
9-
}, {})
10-
}
3+
const ANNOTATION_PREFIX = 'actions.github.com'
114

125
export function getWorkflowAnnotations(
136
lastSuccessRunSha: string,
@@ -31,21 +24,11 @@ export function getWorkflowAnnotations(
3124
helmChartPaths: deploymentConfig.helmChartFilePaths,
3225
provider: 'GitHub'
3326
}
34-
const prefixedAnnotationObject = prefixObjectKeys(
35-
annotationObject,
36-
ANNOTATION_PREFIX
37-
)
38-
return JSON.stringify(prefixedAnnotationObject)
27+
return JSON.stringify(annotationObject)
3928
}
4029

41-
export function getWorkflowAnnotationKeyLabel(
42-
workflowFilePath: string
43-
): string {
44-
const hashKey = require('crypto')
45-
.createHash('MD5')
46-
.update(`${process.env.GITHUB_REPOSITORY}/${workflowFilePath}`)
47-
.digest('hex')
48-
return `githubWorkflow_${hashKey}`
30+
export function getWorkflowAnnotationKeyLabel(): string {
31+
return `${ANNOTATION_PREFIX}/k8s-deploy`
4932
}
5033

5134
/**

0 commit comments

Comments
 (0)