mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-03-24 14:42:17 +08:00
prefix for annotations (#191)
This commit is contained in:
parent
06a06b13b9
commit
507f2d4fc7
18
src/utilities/workflowAnnotationUtils.test.ts
Normal file
18
src/utilities/workflowAnnotationUtils.test.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { 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);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -1,5 +1,14 @@
|
||||
import { DeploymentConfig } from "../types/deploymentConfig";
|
||||
|
||||
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,
|
||||
workflowFilePath: string,
|
||||
@ -22,7 +31,8 @@ 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(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user