Skip to content

Commit 1e3f1e9

Browse files
committed
feat: Add resource level isSensitive
1 parent 98de986 commit 1e3f1e9

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codify-plugin-lib",
3-
"version": "1.0.177",
3+
"version": "1.0.180",
44
"description": "Library plugin library",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",

src/plugin/plugin.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,24 @@ export class Plugin {
5959

6060
return {
6161
resourceDefinitions: [...this.resourceControllers.values()]
62-
.map((r) => ({
63-
dependencies: r.dependencies,
64-
type: r.typeId,
65-
sensitiveParameters: Object.entries(r.settings.parameterSettings ?? {})
62+
.map((r) => {
63+
const sensitiveParameters = Object.entries(r.settings.parameterSettings ?? {})
6664
.filter(([, v]) => v?.isSensitive)
67-
.map(([k]) => k),
68-
}))
65+
.map(([k]) => k);
66+
67+
// Here we add '*' if the resource is sensitive but no sensitive parameters are found. This works because the import
68+
// sensitivity check only checks for the existance of a sensitive parameter whereas the parameter blocking one blocks
69+
// on a specific sensitive parameter.
70+
if (r.settings.isSensitive && sensitiveParameters.length === 0) {
71+
sensitiveParameters.push('*');
72+
}
73+
74+
return {
75+
dependencies: r.dependencies,
76+
type: r.typeId,
77+
sensitiveParameters,
78+
}
79+
})
6980
}
7081
}
7182

@@ -87,10 +98,17 @@ export class Plugin {
8798
const allowMultiple = resource.settings.allowMultiple !== undefined
8899
&& resource.settings.allowMultiple !== false;
89100

101+
// Here we add '*' if the resource is sensitive but no sensitive parameters are found. This works because the import
102+
// sensitivity check only checks for the existance of a sensitive parameter whereas the parameter blocking one blocks
103+
// on a specific sensitive parameter.
90104
const sensitiveParameters = Object.entries(resource.settings.parameterSettings ?? {})
91105
.filter(([, v]) => v?.isSensitive)
92106
.map(([k]) => k);
93107

108+
if (resource.settings.isSensitive && sensitiveParameters.length === 0) {
109+
sensitiveParameters.push('*');
110+
}
111+
94112
return {
95113
plugin: this.name,
96114
type: data.type,

src/resource/resource-settings.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ export interface ResourceSettings<T extends StringIndexedObject> {
2727
*/
2828
schema?: Partial<JSONSchemaType<T | any>>;
2929

30+
/**
31+
* Mark the resource as sensitive. Defaults to false. This prevents the resource from automatically being imported by init and import.
32+
* This differs from the parameter level sensitivity which also prevents the parameter value from being displayed in the plan.
33+
*/
34+
isSensitive?: boolean;
35+
3036
/**
3137
* Allow multiple of the same resource to unique. Set truthy if
3238
* multiples are allowed, for example for applications, there can be multiple copy of the same application installed

0 commit comments

Comments
 (0)