codify-plugin-lib 1.0.56 → 1.0.57
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/dist/entities/plan-types.d.ts +1 -2
- package/dist/entities/plan.js +2 -2
- package/dist/entities/resource-types.d.ts +1 -2
- package/dist/entities/resource.d.ts +2 -1
- package/dist/entities/resource.js +2 -2
- package/package.json +1 -1
- package/src/entities/plan-types.ts +2 -4
- package/src/entities/plan.ts +2 -2
- package/src/entities/resource-parameters.test.ts +1 -1
- package/src/entities/resource-types.ts +3 -5
- package/src/entities/resource.test.ts +4 -4
- package/src/entities/resource.ts +2 -2
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ResourceOperation } from 'codify-schemas';
|
|
2
1
|
export interface ParameterOptions {
|
|
3
|
-
|
|
2
|
+
canModify?: boolean;
|
|
4
3
|
isEqual?: (desired: any, current: any) => boolean;
|
|
5
4
|
isElementEqual?: (desired: any, current: any) => boolean;
|
|
6
5
|
default?: unknown;
|
package/dist/entities/plan.js
CHANGED
|
@@ -31,8 +31,8 @@ export class Plan {
|
|
|
31
31
|
if (statefulParameterNames.has(curr.name)) {
|
|
32
32
|
newOperation = ResourceOperation.MODIFY;
|
|
33
33
|
}
|
|
34
|
-
else if (parameterOptions[curr.name]?.
|
|
35
|
-
newOperation = parameterOptions[curr.name].
|
|
34
|
+
else if (parameterOptions[curr.name]?.canModify) {
|
|
35
|
+
newOperation = parameterOptions[curr.name].canModify ? ResourceOperation.MODIFY : ResourceOperation.RECREATE;
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
38
38
|
newOperation = ResourceOperation.RECREATE;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ResourceOperation } from 'codify-schemas';
|
|
2
1
|
export type ErrorMessage = string;
|
|
3
2
|
export interface ResourceParameterOptions {
|
|
4
|
-
|
|
3
|
+
canModify?: boolean;
|
|
5
4
|
isEqual?: (desired: any, current: any) => boolean;
|
|
6
5
|
default?: unknown;
|
|
7
6
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ResourceConfig, StringIndexedObject } from 'codify-schemas';
|
|
2
|
+
import { ParameterChange } from './change-set.js';
|
|
2
3
|
import { Plan } from './plan.js';
|
|
3
4
|
import { StatefulParameter } from './stateful-parameter.js';
|
|
4
5
|
import { ResourceParameterOptions, ValidationResult } from './resource-types.js';
|
|
@@ -36,6 +37,6 @@ export declare abstract class Resource<T extends StringIndexedObject> {
|
|
|
36
37
|
validate(parameters: unknown): Promise<ValidationResult>;
|
|
37
38
|
abstract refresh(keys: Map<keyof T, T[keyof T]>): Promise<Partial<T> | null>;
|
|
38
39
|
abstract applyCreate(plan: Plan<T>): Promise<void>;
|
|
39
|
-
applyModify(
|
|
40
|
+
applyModify(pc: ParameterChange<T>, plan: Plan<T>): Promise<void>;
|
|
40
41
|
abstract applyDestroy(plan: Plan<T>): Promise<void>;
|
|
41
42
|
}
|
|
@@ -103,7 +103,7 @@ export class Resource {
|
|
|
103
103
|
const statelessParameterChanges = parameterChanges
|
|
104
104
|
.filter((pc) => !this.statefulParameters.has(pc.name));
|
|
105
105
|
for (const pc of statelessParameterChanges) {
|
|
106
|
-
await this.applyModify(pc
|
|
106
|
+
await this.applyModify(pc, plan);
|
|
107
107
|
}
|
|
108
108
|
const statefulParameterChanges = parameterChanges
|
|
109
109
|
.filter((pc) => this.statefulParameters.has(pc.name))
|
|
@@ -210,7 +210,7 @@ Additional: ${[...refreshKeys].filter(k => !desiredKeys.has(k))};`);
|
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
212
|
;
|
|
213
|
-
async applyModify(
|
|
213
|
+
async applyModify(pc, plan) { }
|
|
214
214
|
;
|
|
215
215
|
}
|
|
216
216
|
class ConfigParser {
|
package/package.json
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { ResourceOperation } from 'codify-schemas';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Customize properties for specific parameters. This will alter the way the library process changes to the parameter.
|
|
5
3
|
*/
|
|
6
4
|
export interface ParameterOptions {
|
|
7
5
|
/**
|
|
8
|
-
* Chose if the resource should be re-created or modified if this parameter is changed. Defaults to re-
|
|
6
|
+
* Chose if the resource should be re-created or modified if this parameter is changed. Defaults to false (re-creates resource on change).
|
|
9
7
|
*/
|
|
10
|
-
|
|
8
|
+
canModify?: boolean;
|
|
11
9
|
/**
|
|
12
10
|
* Customize the equality comparison for a parameter.
|
|
13
11
|
* @param a
|
package/src/entities/plan.ts
CHANGED
|
@@ -55,8 +55,8 @@ export class Plan<T extends StringIndexedObject> {
|
|
|
55
55
|
let newOperation: ResourceOperation;
|
|
56
56
|
if (statefulParameterNames.has(curr.name)) {
|
|
57
57
|
newOperation = ResourceOperation.MODIFY // All stateful parameters are modify only
|
|
58
|
-
} else if (parameterOptions[curr.name]?.
|
|
59
|
-
newOperation = parameterOptions[curr.name].
|
|
58
|
+
} else if (parameterOptions[curr.name]?.canModify) {
|
|
59
|
+
newOperation = parameterOptions[curr.name].canModify ? ResourceOperation.MODIFY : ResourceOperation.RECREATE;
|
|
60
60
|
} else {
|
|
61
61
|
newOperation = ResourceOperation.RECREATE; // Default to Re-create. Should handle the majority of use cases
|
|
62
62
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ResourceOperation } from 'codify-schemas';
|
|
2
|
-
|
|
3
1
|
export type ErrorMessage = string;
|
|
4
2
|
|
|
5
3
|
/**
|
|
@@ -7,9 +5,9 @@ export type ErrorMessage = string;
|
|
|
7
5
|
*/
|
|
8
6
|
export interface ResourceParameterOptions {
|
|
9
7
|
/**
|
|
10
|
-
* Chose if the resource should be re-created or modified if this parameter is changed. Defaults to re-create.
|
|
8
|
+
* Chose if the resource should be re-created or modified if this parameter is changed. Defaults to false (re-create).
|
|
11
9
|
*/
|
|
12
|
-
|
|
10
|
+
canModify?: boolean;
|
|
13
11
|
/**
|
|
14
12
|
* Customize the equality comparison for a parameter.
|
|
15
13
|
* @param desired
|
|
@@ -19,7 +17,7 @@ export interface ResourceParameterOptions {
|
|
|
19
17
|
/**
|
|
20
18
|
* Default value for the parameter. If a value is not provided in the config, the library will use this value.
|
|
21
19
|
*/
|
|
22
|
-
default?: unknown
|
|
20
|
+
default?: unknown;
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
/**
|
|
@@ -195,8 +195,8 @@ describe('Resource tests', () => {
|
|
|
195
195
|
super({
|
|
196
196
|
type: 'resource',
|
|
197
197
|
parameterOptions: {
|
|
198
|
-
propA: {
|
|
199
|
-
propB: {
|
|
198
|
+
propA: { canModify: true },
|
|
199
|
+
propB: { canModify: true },
|
|
200
200
|
}
|
|
201
201
|
});
|
|
202
202
|
}
|
|
@@ -244,7 +244,7 @@ describe('Resource tests', () => {
|
|
|
244
244
|
type: 'type',
|
|
245
245
|
dependencies: ['homebrew', 'python'],
|
|
246
246
|
parameterOptions: {
|
|
247
|
-
propA: {
|
|
247
|
+
propA: { canModify: true },
|
|
248
248
|
propB: { statefulParameter },
|
|
249
249
|
propC: { isEqual: (a, b) => true },
|
|
250
250
|
}
|
|
@@ -281,7 +281,7 @@ describe('Resource tests', () => {
|
|
|
281
281
|
type: 'type',
|
|
282
282
|
dependencies: ['homebrew', 'python'],
|
|
283
283
|
parameterOptions: {
|
|
284
|
-
propA: {
|
|
284
|
+
propA: { canModify: true },
|
|
285
285
|
propB: { statefulParameter },
|
|
286
286
|
propC: { isEqual: (a, b) => true },
|
|
287
287
|
}
|
package/src/entities/resource.ts
CHANGED
|
@@ -161,7 +161,7 @@ export abstract class Resource<T extends StringIndexedObject> {
|
|
|
161
161
|
|
|
162
162
|
for (const pc of statelessParameterChanges) {
|
|
163
163
|
// TODO: When stateful mode is added in the future. Dynamically choose if deletes are allowed
|
|
164
|
-
await this.applyModify(pc
|
|
164
|
+
await this.applyModify(pc, plan);
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
const statefulParameterChanges = parameterChanges
|
|
@@ -310,7 +310,7 @@ Additional: ${[...refreshKeys].filter(k => !desiredKeys.has(k))};`
|
|
|
310
310
|
|
|
311
311
|
abstract applyCreate(plan: Plan<T>): Promise<void>;
|
|
312
312
|
|
|
313
|
-
async applyModify(
|
|
313
|
+
async applyModify(pc: ParameterChange<T>, plan: Plan<T>): Promise<void> {};
|
|
314
314
|
|
|
315
315
|
abstract applyDestroy(plan: Plan<T>): Promise<void>;
|
|
316
316
|
}
|