codify-plugin-lib 1.0.86 → 1.0.87
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/plugin/plugin.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Plan } from '../plan/plan.js';
|
|
2
2
|
import { ResourceController } from '../resource/resource-controller.js';
|
|
3
|
-
import { splitUserConfig } from '../utils/utils.js';
|
|
4
3
|
export class Plugin {
|
|
5
4
|
name;
|
|
6
5
|
resourceControllers;
|
|
@@ -34,10 +33,9 @@ export class Plugin {
|
|
|
34
33
|
if (!this.resourceControllers.has(config.type)) {
|
|
35
34
|
throw new Error(`Resource type not found: ${config.type}`);
|
|
36
35
|
}
|
|
37
|
-
const { parameters, coreParameters } = splitUserConfig(config);
|
|
38
36
|
const validation = await this.resourceControllers
|
|
39
37
|
.get(config.type)
|
|
40
|
-
.validate(
|
|
38
|
+
.validate(config);
|
|
41
39
|
validationResults.push(validation);
|
|
42
40
|
}
|
|
43
41
|
await this.crossValidateResources(data.configs);
|
|
@@ -14,7 +14,7 @@ export declare class ResourceController<T extends StringIndexedObject> {
|
|
|
14
14
|
protected schemaValidator?: ValidateFunction;
|
|
15
15
|
constructor(resource: Resource<T>);
|
|
16
16
|
initialize(): Promise<void>;
|
|
17
|
-
validate(
|
|
17
|
+
validate(desiredConfig: Partial<T> & ResourceConfig): Promise<ValidateResponseData['resourceValidations'][0]>;
|
|
18
18
|
plan(desiredConfig: Partial<T> & ResourceConfig | null, stateConfig?: Partial<T> & ResourceConfig | null, statefulMode?: boolean): Promise<Plan<T>>;
|
|
19
19
|
apply(plan: Plan<T>): Promise<void>;
|
|
20
20
|
private applyCreate;
|
|
@@ -31,14 +31,18 @@ export class ResourceController {
|
|
|
31
31
|
async initialize() {
|
|
32
32
|
return this.resource.initialize();
|
|
33
33
|
}
|
|
34
|
-
async validate(
|
|
34
|
+
async validate(desiredConfig) {
|
|
35
|
+
const configToValidate = { ...desiredConfig };
|
|
36
|
+
await this.applyTransformParameters(configToValidate);
|
|
37
|
+
const { parameters, coreParameters } = splitUserConfig(configToValidate);
|
|
38
|
+
this.addDefaultValues(parameters);
|
|
35
39
|
if (this.schemaValidator) {
|
|
36
40
|
const isValid = this.schemaValidator(parameters);
|
|
37
41
|
if (!isValid) {
|
|
38
42
|
return {
|
|
39
43
|
isValid: false,
|
|
40
|
-
resourceName:
|
|
41
|
-
resourceType:
|
|
44
|
+
resourceName: coreParameters.name,
|
|
45
|
+
resourceType: coreParameters.type,
|
|
42
46
|
schemaValidationErrors: this.schemaValidator?.errors ?? [],
|
|
43
47
|
};
|
|
44
48
|
}
|
|
@@ -56,15 +60,15 @@ export class ResourceController {
|
|
|
56
60
|
return {
|
|
57
61
|
customValidationErrorMessage,
|
|
58
62
|
isValid: false,
|
|
59
|
-
resourceName:
|
|
60
|
-
resourceType:
|
|
63
|
+
resourceName: coreParameters.name,
|
|
64
|
+
resourceType: coreParameters.type,
|
|
61
65
|
schemaValidationErrors: this.schemaValidator?.errors ?? [],
|
|
62
66
|
};
|
|
63
67
|
}
|
|
64
68
|
return {
|
|
65
69
|
isValid: true,
|
|
66
|
-
resourceName:
|
|
67
|
-
resourceType:
|
|
70
|
+
resourceName: coreParameters.name,
|
|
71
|
+
resourceType: coreParameters.type,
|
|
68
72
|
schemaValidationErrors: [],
|
|
69
73
|
};
|
|
70
74
|
}
|
package/package.json
CHANGED
|
@@ -57,10 +57,10 @@ export class ResourceController<T extends StringIndexedObject> {
|
|
|
57
57
|
desiredConfig: Partial<T> & ResourceConfig,
|
|
58
58
|
): Promise<ValidateResponseData['resourceValidations'][0]> {
|
|
59
59
|
const configToValidate = { ...desiredConfig };
|
|
60
|
-
|
|
60
|
+
await this.applyTransformParameters(configToValidate);
|
|
61
61
|
|
|
62
|
+
const { parameters, coreParameters } = splitUserConfig(configToValidate);
|
|
62
63
|
this.addDefaultValues(parameters);
|
|
63
|
-
await this.applyTransformParameters(configToValidate);
|
|
64
64
|
|
|
65
65
|
if (this.schemaValidator) {
|
|
66
66
|
const isValid = this.schemaValidator(parameters);
|