codify-plugin-lib 1.0.129 → 1.0.131

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.
@@ -38,16 +38,19 @@ describe('Resource parameter tests', () => {
38
38
  }
39
39
 
40
40
  const controller = new ResourceController(resource);
41
- const plan = await controller.plan({
42
- type: 'type',
43
- propA: 'a',
44
- propB: 10
45
- })
41
+ const plan = await controller.plan(
42
+ { type: 'type' },
43
+ {
44
+ propA: 'a',
45
+ propB: 10
46
+ },
47
+ null,
48
+ false
49
+ )
46
50
 
47
51
  expect(statefulParameter.refresh.notCalled).to.be.true;
48
52
  expect(plan.currentConfig).to.be.null;
49
53
  expect(plan.desiredConfig).toMatchObject({
50
- type: 'type',
51
54
  propA: 'a',
52
55
  propB: 10
53
56
  })
@@ -116,7 +119,12 @@ describe('Resource parameter tests', () => {
116
119
 
117
120
  const controller = new ResourceController(resource);
118
121
 
119
- const plan = await controller.plan({ type: 'type', propA: 'a', propB: 0, propC: 'b' })
122
+ const plan = await controller.plan(
123
+ { type: 'type' },
124
+ { propA: 'a', propB: 0, propC: 'b' },
125
+ null,
126
+ false
127
+ )
120
128
 
121
129
  const resourceSpy = spy(resource);
122
130
  await controller.apply(plan);
@@ -156,12 +164,11 @@ describe('Resource parameter tests', () => {
156
164
  const controller = new ResourceController(resource);
157
165
  const plan = await controller.plan({
158
166
  type: 'type',
159
- })
167
+ }, {}, null, false)
160
168
 
161
169
  expect(statefulParameter.refresh.notCalled).to.be.true;
162
170
  expect(plan.currentConfig).to.be.null;
163
171
  expect(plan.desiredConfig).toMatchObject({
164
- type: 'type',
165
172
  propA: 'abc',
166
173
  })
167
174
  expect(plan.changeSet.operation).to.eq(ResourceOperation.CREATE);
@@ -196,7 +203,7 @@ describe('Resource parameter tests', () => {
196
203
  }
197
204
 
198
205
  const controller = new ResourceController(resource);
199
- const plan = await controller.plan({ type: 'type', propA: ['a', 'b'] } as any)
206
+ const plan = await controller.plan({ type: 'type' }, { propA: ['a', 'b'] } as any, null, false)
200
207
 
201
208
  expect(plan).toMatchObject({
202
209
  changeSet: {
@@ -230,7 +237,7 @@ describe('Resource parameter tests', () => {
230
237
  }
231
238
 
232
239
  const controller = new ResourceController(resource);
233
- const plan = await controller.plan({ type: 'type', propA: ['a', 'b', 'c', 'd'] } as any)
240
+ const plan = await controller.plan({ type: 'type' }, { propA: ['a', 'b', 'c', 'd'] } as any, null, false)
234
241
 
235
242
  expect(plan).toMatchObject({
236
243
  changeSet: {
@@ -277,21 +284,25 @@ describe('Resource parameter tests', () => {
277
284
  }
278
285
 
279
286
  const controller = new ResourceController(resource);
280
- const plan = await controller.plan({
281
- type: 'type',
282
- hosts: [
283
- {
284
- Host: 'new.com',
285
- AddKeysToAgent: 'yes',
286
- IdentityFile: '~/.ssh/id_ed25519'
287
- },
288
- {
289
- Host: 'github.com',
290
- AddKeysToAgent: 'yes',
291
- UseKeychain: 'yes',
292
- }
293
- ]
294
- });
287
+ const plan = await controller.plan(
288
+ { type: 'type' },
289
+ {
290
+ hosts: [
291
+ {
292
+ Host: 'new.com',
293
+ AddKeysToAgent: 'yes',
294
+ IdentityFile: '~/.ssh/id_ed25519'
295
+ },
296
+ {
297
+ Host: 'github.com',
298
+ AddKeysToAgent: 'yes',
299
+ UseKeychain: 'yes',
300
+ }
301
+ ]
302
+ },
303
+ null,
304
+ false
305
+ );
295
306
 
296
307
  expect(plan).toMatchObject({
297
308
  'changeSet': {
@@ -361,7 +372,7 @@ describe('Resource parameter tests', () => {
361
372
  }
362
373
 
363
374
  const controller = new ResourceController(resource);
364
- const plan = await controller.plan({ type: 'type', propA: ['3.11'] } as any)
375
+ const plan = await controller.plan({ type: 'type' }, { propA: ['3.11'] } as any, null, false)
365
376
 
366
377
  expect(plan).toMatchObject({
367
378
  changeSet: {
@@ -421,14 +432,17 @@ describe('Resource parameter tests', () => {
421
432
  });
422
433
 
423
434
  const controller = new ResourceController(resource)
424
- const plan = await controller.plan({
425
- type: 'resourceType',
426
- propA: 'propA',
427
- propB: 10,
428
- propC: 'propC',
429
- propD: 'propD',
430
- propE: 'propE',
431
- });
435
+ const plan = await controller.plan(
436
+ { type: 'resourceType' },
437
+ {
438
+ propA: 'propA',
439
+ propB: 10,
440
+ propC: 'propC',
441
+ propD: 'propD',
442
+ propE: 'propE',
443
+ }, null,
444
+ false
445
+ );
432
446
 
433
447
  expect(plan.currentConfig?.propB).to.be.lessThan(plan.currentConfig?.propC as any);
434
448
  expect(plan.currentConfig?.propC).to.be.lessThan(plan.currentConfig?.propA as any);
@@ -571,7 +585,7 @@ describe('Resource parameter tests', () => {
571
585
  });
572
586
 
573
587
  const controller = new ResourceController(resource);
574
- const plan = await controller.plan({ type: 'resourceType', propC: 'abc' } as any);
588
+ const plan = await controller.plan({ type: 'resourceType' }, { propC: 'abc' } as any, null, false);
575
589
 
576
590
  expect(resource.refresh.called).to.be.true;
577
591
  expect(resource.refresh.getCall(0).firstArg['propA']).to.exist;
@@ -606,7 +620,7 @@ describe('Resource parameter tests', () => {
606
620
  });
607
621
 
608
622
  const controller = new ResourceController(resource);
609
- const plan = await controller.plan(null, { type: 'resourceType', propC: 'abc' } as any, true);
623
+ const plan = await controller.plan({ type: 'resourceType' }, null, { propC: 'abc' }, true);
610
624
 
611
625
  expect(resource.refresh.called).to.be.true;
612
626
  expect(resource.refresh.getCall(0).firstArg['propA']).to.exist;
@@ -654,7 +668,7 @@ describe('Resource parameter tests', () => {
654
668
  };
655
669
 
656
670
  const controller = new ResourceController(resource);
657
- const plan = await controller.plan({ type: 'resourceType', propA: '~/test/folder' } as any);
671
+ const plan = await controller.plan({ type: 'resourceType' }, { propA: '~/test/folder' } as any, null, false);
658
672
 
659
673
  expect(plan.changeSet.parameterChanges[0]).toMatchObject({
660
674
  operation: ParameterOperation.NOOP,
@@ -682,7 +696,7 @@ describe('Resource parameter tests', () => {
682
696
  };
683
697
 
684
698
  const controller = new ResourceController(resource);
685
- const plan = await controller.plan({ type: 'resourceType', propA: 'setting', propB: 64 } as any);
699
+ const plan = await controller.plan({ type: 'resourceType' }, { propA: 'setting', propB: 64 } as any, null, false);
686
700
 
687
701
  expect(plan.changeSet.parameterChanges).toMatchObject(
688
702
  expect.arrayContaining([
@@ -741,7 +755,7 @@ describe('Resource parameter tests', () => {
741
755
 
742
756
  const controller = new ResourceController(resource);
743
757
 
744
- const result = await controller.plan({ type: 'resourceType', propA: '10.0' });
758
+ const result = await controller.plan({ type: 'resourceType' }, { propA: '10.0' }, null, false);
745
759
  expect(result.changeSet).toMatchObject({
746
760
  operation: ResourceOperation.NOOP,
747
761
  })
@@ -771,14 +785,18 @@ describe('Resource parameter tests', () => {
771
785
 
772
786
  const controller = new ResourceController(resource);
773
787
 
774
- const result = await controller.plan({
775
- type: 'resourceType',
776
- propD: {
777
- testC: 10,
778
- testA: 'a',
779
- testB: 'b',
780
- }
781
- });
788
+ const result = await controller.plan(
789
+ { type: 'resourceType' },
790
+ {
791
+ propD: {
792
+ testC: 10,
793
+ testA: 'a',
794
+ testB: 'b',
795
+ }
796
+ },
797
+ null,
798
+ false
799
+ );
782
800
 
783
801
  expect(result.changeSet).toMatchObject({
784
802
  operation: ResourceOperation.NOOP,
@@ -808,14 +826,18 @@ describe('Resource parameter tests', () => {
808
826
 
809
827
  const controller = new ResourceController(resource);
810
828
 
811
- const result = await controller.plan({
812
- type: 'resourceType',
813
- propD: {
814
- testC: 10,
815
- testA: 'a',
816
- testB: 'b',
817
- }
818
- });
829
+ const result = await controller.plan(
830
+ { type: 'resourceType' },
831
+ {
832
+ propD: {
833
+ testC: 10,
834
+ testA: 'a',
835
+ testB: 'b',
836
+ }
837
+ },
838
+ null,
839
+ false
840
+ );
819
841
 
820
842
  expect(result.changeSet).toMatchObject({
821
843
  operation: ResourceOperation.RECREATE,
@@ -856,8 +878,9 @@ describe('Resource parameter tests', () => {
856
878
  }
857
879
 
858
880
  const controller = new ResourceController(resource);
859
- await controller.plan({
860
- type: 'resourceType',
881
+ await controller.plan(
882
+ { type: 'resourceType' },
883
+ {
861
884
  propD: [
862
885
  {
863
886
  Host: 'new.com',
@@ -874,13 +897,16 @@ describe('Resource parameter tests', () => {
874
897
  PasswordAuthentication: true,
875
898
  }
876
899
  ]
877
- });
900
+ },
901
+ null,
902
+ false
903
+ );
878
904
 
879
905
  })
880
906
 
881
907
  it('Transforms input parameters for stateful parameters', async () => {
882
908
  const sp = new class extends TestStatefulParameter {
883
- getSettings(): ResourceSettings<TestConfig> {
909
+ getSettings(): any {
884
910
  return {
885
911
  type: 'array',
886
912
  inputTransformation: (hosts: Record<string, unknown>[]) => hosts.map((h) => Object.fromEntries(
@@ -896,7 +922,7 @@ describe('Resource parameter tests', () => {
896
922
  }
897
923
  }
898
924
 
899
- async refresh(desired: any): Promise<Partial<TestConfig> | null> {
925
+ async refresh(desired: any): Promise<any | null> {
900
926
  expect(desired[0].AddKeysToAgent).to.eq('yes')
901
927
  expect(desired[1].AddKeysToAgent).to.eq('yes')
902
928
  expect(desired[1].UseKeychain).to.eq('yes')
@@ -918,25 +944,29 @@ describe('Resource parameter tests', () => {
918
944
  }
919
945
 
920
946
  const controller = new ResourceController(resource);
921
- await controller.plan({
922
- type: 'resourceType',
923
- propD: [
924
- {
925
- Host: 'new.com',
926
- AddKeysToAgent: true,
927
- IdentityFile: 'id_ed25519'
928
- },
929
- {
930
- Host: 'github.com',
931
- AddKeysToAgent: true,
932
- UseKeychain: true,
933
- },
934
- {
935
- Match: 'User bob,joe,phil',
936
- PasswordAuthentication: true,
937
- }
938
- ]
939
- });
947
+ await controller.plan(
948
+ { type: 'resourceType' },
949
+ {
950
+ propD: [
951
+ {
952
+ Host: 'new.com',
953
+ AddKeysToAgent: true,
954
+ IdentityFile: 'id_ed25519'
955
+ },
956
+ {
957
+ Host: 'github.com',
958
+ AddKeysToAgent: true,
959
+ UseKeychain: true,
960
+ },
961
+ {
962
+ Match: 'User bob,joe,phil',
963
+ PasswordAuthentication: true,
964
+ }
965
+ ]
966
+ },
967
+ null,
968
+ false
969
+ );
940
970
 
941
971
  })
942
972
  })
@@ -153,9 +153,12 @@ describe('Stateful parameter tests', () => {
153
153
  }
154
154
 
155
155
  const controller = new ResourceController(resource);
156
- const plan = await controller.plan({
157
- nodeVersions: ['20.15'],
158
- } as any)
156
+ const plan = await controller.plan(
157
+ { type: 'type' },
158
+ { nodeVersions: ['20.15'] } as any,
159
+ null,
160
+ false
161
+ )
159
162
 
160
163
  expect(plan.changeSet.operation).to.eq(ResourceOperation.NOOP);
161
164
  })
@@ -188,9 +191,12 @@ describe('Stateful parameter tests', () => {
188
191
  }
189
192
 
190
193
  const controller = new ResourceController(resource);
191
- const plan = await controller.plan({
192
- propA: '20.15',
193
- } as any)
194
+ const plan = await controller.plan(
195
+ { type: 'type' },
196
+ { propA: '20.15', } as any,
197
+ null,
198
+ false
199
+ )
194
200
 
195
201
  expect(plan.changeSet.operation).to.eq(ResourceOperation.NOOP);
196
202
  })
@@ -226,9 +232,12 @@ describe('Stateful parameter tests', () => {
226
232
  }
227
233
 
228
234
  const controller = new ResourceController(resource);
229
- const plan = await controller.plan({
230
- propA: ['20.15', '20.18'],
231
- } as any)
235
+ const plan = await controller.plan(
236
+ { type: 'type' },
237
+ { propA: ['20.15', '20.18'] } as any,
238
+ null,
239
+ false
240
+ )
232
241
 
233
242
  expect(plan.changeSet.operation).to.eq(ResourceOperation.NOOP);
234
243
  })
@@ -15,10 +15,10 @@ export function testPlan<T extends StringIndexedObject>(params: {
15
15
  isStateful?: boolean;
16
16
  }) {
17
17
  return Plan.calculate({
18
- desiredParameters: params.desired ?? null,
19
- currentParametersArray: params.current ?? null,
20
- stateParameters: params.state ?? null,
21
- coreParameters: params.core ?? { type: 'type' },
18
+ desired: params.desired ?? null,
19
+ currentArray: params.current ?? null,
20
+ state: params.state ?? null,
21
+ core: params.core ?? { type: 'type' },
22
22
  settings: params.settings ?
23
23
  new ParsedResourceSettings<T>(params.settings)
24
24
  : new ParsedResourceSettings<T>({ id: 'type' }),