codify-plugin-lib 1.0.39 → 1.0.40
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.
|
@@ -32,20 +32,19 @@ export class Resource {
|
|
|
32
32
|
.filter((sp) => desiredParameters[sp.name] !== undefined);
|
|
33
33
|
const keysToRefresh = new Set(Object.keys(resourceParameters));
|
|
34
34
|
const currentParameters = await this.refresh(keysToRefresh);
|
|
35
|
-
if (currentParameters == null
|
|
35
|
+
if (currentParameters == null) {
|
|
36
36
|
return Plan.create(desiredConfig, null, planConfiguration);
|
|
37
37
|
}
|
|
38
38
|
this.validateRefreshResults(currentParameters, keysToRefresh);
|
|
39
|
-
const currentStatefulParameters = {};
|
|
40
39
|
for (const statefulParameter of statefulParameters) {
|
|
41
40
|
const desiredValue = desiredParameters[statefulParameter.name];
|
|
42
41
|
let currentValue = await statefulParameter.refresh(desiredValue ?? null) ?? undefined;
|
|
43
42
|
if (Array.isArray(currentValue) && Array.isArray(desiredValue) && !planConfiguration.statefulMode) {
|
|
44
43
|
currentValue = currentValue.filter((p) => desiredValue?.includes(p));
|
|
45
44
|
}
|
|
46
|
-
|
|
45
|
+
currentParameters[statefulParameter.name] = currentValue;
|
|
47
46
|
}
|
|
48
|
-
return Plan.create(desiredConfig, { ...currentParameters, ...
|
|
47
|
+
return Plan.create(desiredConfig, { ...currentParameters, ...resourceMetadata }, planConfiguration);
|
|
49
48
|
}
|
|
50
49
|
async apply(plan) {
|
|
51
50
|
if (plan.getResourceType() !== this.typeId) {
|
package/package.json
CHANGED
|
@@ -113,7 +113,7 @@ describe('Resource parameters tests', () => {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
async refresh(): Promise<Partial<TestConfig> | null> {
|
|
116
|
-
return
|
|
116
|
+
return {};
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -144,7 +144,7 @@ describe('Resource parameters tests', () => {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
async refresh(): Promise<Partial<TestConfig> | null> {
|
|
147
|
-
return
|
|
147
|
+
return {};
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
package/src/entities/resource.ts
CHANGED
|
@@ -64,7 +64,8 @@ export abstract class Resource<T extends StringIndexedObject> {
|
|
|
64
64
|
const keysToRefresh = new Set(Object.keys(resourceParameters));
|
|
65
65
|
const currentParameters = await this.refresh(keysToRefresh);
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
// Short circuit here. If resource is non-existent, then there's no point checking stateful parameters
|
|
68
|
+
if (currentParameters == null) {
|
|
68
69
|
return Plan.create(desiredConfig, null, planConfiguration);
|
|
69
70
|
}
|
|
70
71
|
|
|
@@ -72,8 +73,6 @@ export abstract class Resource<T extends StringIndexedObject> {
|
|
|
72
73
|
|
|
73
74
|
// Refresh stateful parameters
|
|
74
75
|
// This refreshes parameters that are stateful (they can be added, deleted separately from the resource)
|
|
75
|
-
const currentStatefulParameters = {} as Partial<T>;
|
|
76
|
-
|
|
77
76
|
for(const statefulParameter of statefulParameters) {
|
|
78
77
|
const desiredValue = desiredParameters[statefulParameter.name];
|
|
79
78
|
|
|
@@ -84,12 +83,12 @@ export abstract class Resource<T extends StringIndexedObject> {
|
|
|
84
83
|
currentValue = currentValue.filter((p) => desiredValue?.includes(p)) as any;
|
|
85
84
|
}
|
|
86
85
|
|
|
87
|
-
|
|
86
|
+
currentParameters[statefulParameter.name] = currentValue;
|
|
88
87
|
}
|
|
89
88
|
|
|
90
89
|
return Plan.create(
|
|
91
90
|
desiredConfig,
|
|
92
|
-
{ ...currentParameters, ...
|
|
91
|
+
{ ...currentParameters, ...resourceMetadata } as Partial<T> & ResourceConfig,
|
|
93
92
|
planConfiguration,
|
|
94
93
|
)
|
|
95
94
|
}
|