@linzjs/cdk-tags 1.0.3 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/build/src/build.d.ts +30 -0
- package/build/src/build.js +24 -0
- package/build/src/build.js.map +1 -0
- package/build/src/data.d.ts +28 -0
- package/build/src/data.js +9 -0
- package/build/src/data.js.map +1 -0
- package/build/src/index.d.ts +3 -0
- package/build/src/index.js +11 -0
- package/build/src/index.js.map +1 -0
- package/build/src/security.d.ts +13 -0
- package/build/src/security.js +18 -0
- package/build/src/security.js.map +1 -0
- package/build/src/tags.d.ts +63 -0
- package/build/src/tags.js +49 -0
- package/build/src/tags.js.map +1 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
interface GitBuildInfo {
|
|
2
|
+
/**
|
|
3
|
+
* Last git version tag
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* "v6.45.0"
|
|
7
|
+
*/
|
|
8
|
+
version: string;
|
|
9
|
+
/**
|
|
10
|
+
* Current git commit hash
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* "e460a1bf611b9464f4c2c3feb48e4823277f14a4"
|
|
14
|
+
*/
|
|
15
|
+
hash: string;
|
|
16
|
+
/**
|
|
17
|
+
* Github actions run id and attempt if it exists, otherwise ""
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* "6228679664-1"
|
|
21
|
+
*/
|
|
22
|
+
buildId: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Attempt to guess build information from the currently checked out version of the source code
|
|
26
|
+
*
|
|
27
|
+
* @returns Basic Git/Github build information
|
|
28
|
+
*/
|
|
29
|
+
export declare function getGitBuildInfo(): GitBuildInfo;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGitBuildInfo = void 0;
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
let buildInfo;
|
|
6
|
+
/**
|
|
7
|
+
* Attempt to guess build information from the currently checked out version of the source code
|
|
8
|
+
*
|
|
9
|
+
* @returns Basic Git/Github build information
|
|
10
|
+
*/
|
|
11
|
+
function getGitBuildInfo() {
|
|
12
|
+
if (buildInfo == null) {
|
|
13
|
+
buildInfo = {
|
|
14
|
+
version: (0, node_child_process_1.execFileSync)('git', ['describe', '--tags', '--always', '--match', 'v*']).toString().trim(),
|
|
15
|
+
hash: (0, node_child_process_1.execFileSync)('git', ['rev-parse', 'HEAD']).toString().trim(),
|
|
16
|
+
buildId: process.env['GITHUB_RUN_ID']
|
|
17
|
+
? `${process.env['GITHUB_RUN_ID']}-${process.env['GITHUB_RUN_ATTEMPT']}`
|
|
18
|
+
: '',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return buildInfo;
|
|
22
|
+
}
|
|
23
|
+
exports.getGitBuildInfo = getGitBuildInfo;
|
|
24
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/build.ts"],"names":[],"mappings":";;;AAAA,2DAAkD;AA0BlD,IAAI,SAAmC,CAAC;AAExC;;;;GAIG;AACH,SAAgB,eAAe;IAC7B,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QACtB,SAAS,GAAG;YACV,OAAO,EAAE,IAAA,iCAAY,EAAC,KAAK,EAAE,CAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE;YACnG,IAAI,EAAE,IAAA,iCAAY,EAAC,KAAK,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE;YAClE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;gBACnC,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE;gBACxE,CAAC,CAAC,EAAE;SACP,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAXD,0CAWC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface TagsData {
|
|
2
|
+
/**
|
|
3
|
+
* What is the highest importance data in this storage location
|
|
4
|
+
*
|
|
5
|
+
* For example a public master data archive s3://nz-imagery is `archive`
|
|
6
|
+
*/
|
|
7
|
+
role: TagDataRole;
|
|
8
|
+
/**
|
|
9
|
+
* Is this data public,
|
|
10
|
+
*
|
|
11
|
+
* For example a public bucket such as `s3://nz-imagery`
|
|
12
|
+
*
|
|
13
|
+
* @defaultValue false
|
|
14
|
+
*/
|
|
15
|
+
isPublic: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Does this construct contain the master source of data
|
|
18
|
+
*
|
|
19
|
+
* for example the public imagery archive `s3://nz-imagery`
|
|
20
|
+
*
|
|
21
|
+
* @defaultValue false
|
|
22
|
+
*/
|
|
23
|
+
isMaster: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare enum TagDataRole {
|
|
26
|
+
Primary = "primary",
|
|
27
|
+
Archive = "archive"
|
|
28
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TagDataRole = void 0;
|
|
4
|
+
var TagDataRole;
|
|
5
|
+
(function (TagDataRole) {
|
|
6
|
+
TagDataRole["Primary"] = "primary";
|
|
7
|
+
TagDataRole["Archive"] = "archive";
|
|
8
|
+
})(TagDataRole || (exports.TagDataRole = TagDataRole = {}));
|
|
9
|
+
//# sourceMappingURL=data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/data.ts"],"names":[],"mappings":";;;AA0BA,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,kCAAmB,CAAA;AACrB,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyTagsData = exports.applyTags = exports.SecurityClassification = exports.getGitBuildInfo = void 0;
|
|
4
|
+
var build_js_1 = require("./build.js");
|
|
5
|
+
Object.defineProperty(exports, "getGitBuildInfo", { enumerable: true, get: function () { return build_js_1.getGitBuildInfo; } });
|
|
6
|
+
var security_js_1 = require("./security.js");
|
|
7
|
+
Object.defineProperty(exports, "SecurityClassification", { enumerable: true, get: function () { return security_js_1.SecurityClassification; } });
|
|
8
|
+
var tags_js_1 = require("./tags.js");
|
|
9
|
+
Object.defineProperty(exports, "applyTags", { enumerable: true, get: function () { return tags_js_1.applyTags; } });
|
|
10
|
+
Object.defineProperty(exports, "applyTagsData", { enumerable: true, get: function () { return tags_js_1.applyTagsData; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAA6C;AAApC,2GAAA,eAAe,OAAA;AACxB,6CAAuD;AAA9C,qHAAA,sBAAsB,OAAA;AAC/B,qCAAqD;AAA5C,oGAAA,SAAS,OAAA;AAAE,wGAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NZ Security classification
|
|
3
|
+
* @see https://www.digital.govt.nz/standards-and-guidance/governance/managing-online-channels/security-and-privacy-for-websites/foundations/classify-information/
|
|
4
|
+
*/
|
|
5
|
+
export declare enum SecurityClassification {
|
|
6
|
+
Unclassified = "unclassified",
|
|
7
|
+
InConfidence = "in-confidence",
|
|
8
|
+
Sensitive = "sensitive",
|
|
9
|
+
Restricted = "restricted",
|
|
10
|
+
Confidential = "confidential",
|
|
11
|
+
Secret = "secret",
|
|
12
|
+
TopSecret = "top-secret"
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SecurityClassification = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* NZ Security classification
|
|
6
|
+
* @see https://www.digital.govt.nz/standards-and-guidance/governance/managing-online-channels/security-and-privacy-for-websites/foundations/classify-information/
|
|
7
|
+
*/
|
|
8
|
+
var SecurityClassification;
|
|
9
|
+
(function (SecurityClassification) {
|
|
10
|
+
SecurityClassification["Unclassified"] = "unclassified";
|
|
11
|
+
SecurityClassification["InConfidence"] = "in-confidence";
|
|
12
|
+
SecurityClassification["Sensitive"] = "sensitive";
|
|
13
|
+
SecurityClassification["Restricted"] = "restricted";
|
|
14
|
+
SecurityClassification["Confidential"] = "confidential";
|
|
15
|
+
SecurityClassification["Secret"] = "secret";
|
|
16
|
+
SecurityClassification["TopSecret"] = "top-secret";
|
|
17
|
+
})(SecurityClassification || (exports.SecurityClassification = SecurityClassification = {}));
|
|
18
|
+
//# sourceMappingURL=security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.js","sourceRoot":"","sources":["../../src/security.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAY,sBAQX;AARD,WAAY,sBAAsB;IAChC,uDAA6B,CAAA;IAC7B,wDAA8B,CAAA;IAC9B,iDAAuB,CAAA;IACvB,mDAAyB,CAAA;IACzB,uDAA6B,CAAA;IAC7B,2CAAiB,CAAA;IACjB,kDAAwB,CAAA;AAC1B,CAAC,EARW,sBAAsB,sCAAtB,sBAAsB,QAQjC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { IConstruct } from 'constructs';
|
|
2
|
+
import { TagsData } from './data.js';
|
|
3
|
+
import { SecurityClassification } from './security.js';
|
|
4
|
+
export interface TagsBase {
|
|
5
|
+
/**
|
|
6
|
+
* Environment of the resource
|
|
7
|
+
*
|
|
8
|
+
* @example 'prod'
|
|
9
|
+
*
|
|
10
|
+
* @see AwsEnv in @linz/accounts
|
|
11
|
+
*/
|
|
12
|
+
environment: 'nonprod' | 'preprod' | 'prod';
|
|
13
|
+
/**
|
|
14
|
+
* Application name
|
|
15
|
+
*
|
|
16
|
+
* @example "basemaps"
|
|
17
|
+
*/
|
|
18
|
+
application: string;
|
|
19
|
+
/**
|
|
20
|
+
* Human friendly name for LINZ group that the resources belong to
|
|
21
|
+
*
|
|
22
|
+
* @example "step" or "li"
|
|
23
|
+
*/
|
|
24
|
+
group: string;
|
|
25
|
+
/**
|
|
26
|
+
* Git repository that this construct belongs to
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* "linz/basemaps"
|
|
31
|
+
* "linz/lds-cache"
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* Uses the $GITHUB_REPOSITORY env var by default
|
|
35
|
+
*
|
|
36
|
+
* @default "$GITHUB_REPOSITORY"
|
|
37
|
+
*/
|
|
38
|
+
repository?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Security classification of the construct
|
|
41
|
+
*
|
|
42
|
+
* @see https://www.digital.govt.nz/standards-and-guidance/governance/managing-online-channels/security-and-privacy-for-websites/foundations/classify-information/
|
|
43
|
+
*/
|
|
44
|
+
classification: SecurityClassification;
|
|
45
|
+
/**
|
|
46
|
+
* Criticality of the resources
|
|
47
|
+
*/
|
|
48
|
+
criticality: 'critical' | 'high' | 'medium' | 'low';
|
|
49
|
+
/**
|
|
50
|
+
* THe responder team listed in OpsGenie.
|
|
51
|
+
* @see https://toitutewhenua.app.opsgenie.com/teams/list
|
|
52
|
+
*/
|
|
53
|
+
responderTeam?: string;
|
|
54
|
+
/**
|
|
55
|
+
* skip collection of git info, commit, version etc
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
skipGitInfo?: boolean;
|
|
59
|
+
/** Data classification tags */
|
|
60
|
+
data?: TagsData;
|
|
61
|
+
}
|
|
62
|
+
export declare function applyTags(construct: IConstruct, ctx: TagsBase): void;
|
|
63
|
+
export declare function applyTagsData(construct: IConstruct, tags: TagsData): void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyTagsData = exports.applyTags = void 0;
|
|
4
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
|
+
const build_js_1 = require("./build.js");
|
|
6
|
+
const security_js_1 = require("./security.js");
|
|
7
|
+
// Apply a tag but skip application of tag if the value is undefined or empty
|
|
8
|
+
function tag(construct, key, value) {
|
|
9
|
+
if (value == null)
|
|
10
|
+
return;
|
|
11
|
+
if (value === '')
|
|
12
|
+
return;
|
|
13
|
+
aws_cdk_lib_1.Tags.of(construct).add(key, value);
|
|
14
|
+
}
|
|
15
|
+
function applyTags(construct, ctx) {
|
|
16
|
+
// TODO is this check valid here?
|
|
17
|
+
if (ctx.data?.isPublic && ctx.classification !== security_js_1.SecurityClassification.Unclassified) {
|
|
18
|
+
throw new Error('Only unclassified constructs can be made public');
|
|
19
|
+
}
|
|
20
|
+
const buildInfo = ctx.skipGitInfo ? undefined : (0, build_js_1.getGitBuildInfo)();
|
|
21
|
+
// applications tags
|
|
22
|
+
tag(construct, 'linz.app.name', ctx.application);
|
|
23
|
+
if (buildInfo)
|
|
24
|
+
tag(construct, 'linz.app.version', buildInfo.version);
|
|
25
|
+
tag(construct, 'linz.environment', ctx.environment);
|
|
26
|
+
// Ownership tags
|
|
27
|
+
tag(construct, 'linz.group', ctx.group);
|
|
28
|
+
tag(construct, 'linz.responder.team', ctx.responderTeam ?? 'NotSet');
|
|
29
|
+
tag(construct, 'linz.app.criticality', ctx.criticality);
|
|
30
|
+
// Git Tags
|
|
31
|
+
if (buildInfo)
|
|
32
|
+
tag(construct, 'linz.git.hash', buildInfo.hash);
|
|
33
|
+
tag(construct, 'linz.git.repository', process.env['GITHUB_REPOSITORY'] ?? ctx.repository);
|
|
34
|
+
// Github actions build information
|
|
35
|
+
if (buildInfo)
|
|
36
|
+
tag(construct, 'linz.build.id', buildInfo.buildId);
|
|
37
|
+
// Security
|
|
38
|
+
tag(construct, 'linz.security.classification', ctx.classification);
|
|
39
|
+
if (ctx.data)
|
|
40
|
+
applyTagsData(construct, ctx.data);
|
|
41
|
+
}
|
|
42
|
+
exports.applyTags = applyTags;
|
|
43
|
+
function applyTagsData(construct, tags) {
|
|
44
|
+
tag(construct, 'linz.data.role', tags.role);
|
|
45
|
+
tag(construct, 'linz.data.is-master', String(tags.isMaster ?? false));
|
|
46
|
+
tag(construct, 'linz.data.is-public', String(tags.isPublic ?? false));
|
|
47
|
+
}
|
|
48
|
+
exports.applyTagsData = applyTagsData;
|
|
49
|
+
//# sourceMappingURL=tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../../src/tags.ts"],"names":[],"mappings":";;;AAAA,6CAAmC;AAGnC,yCAA6C;AAE7C,+CAAuD;AAoEvD,6EAA6E;AAC7E,SAAS,GAAG,CAAC,SAAqB,EAAE,GAAW,EAAE,KAAgC;IAC/E,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO;IAC1B,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO;IAEzB,kBAAI,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACrC,CAAC;AAED,SAAgB,SAAS,CAAC,SAAqB,EAAE,GAAa;IAC5D,iCAAiC;IACjC,IAAI,GAAG,CAAC,IAAI,EAAE,QAAQ,IAAI,GAAG,CAAC,cAAc,KAAK,oCAAsB,CAAC,YAAY,EA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,CAAC,SAAqB,EAAE,IAAc;IACjE,GAAG,CAAC,SAAS,EAAE,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,GAAG,CAAC,SAAS,EAAE,qBAAqB,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC;IACtE,GAAG,CAAC,SAAS,EAAE,qBAAqB,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC;AACxE,CAAC;AAJD,sCAIC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linzjs/cdk-tags",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"main": "
|
|
5
|
-
"types": "
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"main": "build/src/index.js",
|
|
5
|
+
"types": "build/src/index.d.ts",
|
|
6
6
|
"files": [
|
|
7
|
-
"
|
|
7
|
+
"build/src"
|
|
8
8
|
],
|
|
9
9
|
"author": {
|
|
10
10
|
"name": "Land Information New Zealand",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"repository": {
|
|
26
|
-
"url": "git://github.com/linz/cdk-
|
|
26
|
+
"url": "git://github.com/linz/cdk-tags.git",
|
|
27
27
|
"type": "git"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@linzjs/style": "^5.2.0",
|
|
35
|
-
"@types/node": "^20.
|
|
35
|
+
"@types/node": "^20.12.8"
|
|
36
36
|
}
|
|
37
37
|
}
|