@firestartr/cli 2.8.0-snapshot-2 → 2.8.0-snapshot-maps-claim-generator-1

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/build/index.js CHANGED
@@ -320683,13 +320683,6 @@ const GithubSchemas = [
320683
320683
  module: {
320684
320684
  type: 'string',
320685
320685
  },
320686
- variants: {
320687
- type: 'array',
320688
- items: {
320689
- $ref: 'firestartr.dev://terraform/TerraformProviderVariant',
320690
- },
320691
- description: 'variant clones of this workspace — stripped before parent claim validation',
320692
- },
320693
320686
  context: {
320694
320687
  type: 'object',
320695
320688
  properties: {
@@ -320724,90 +320717,6 @@ const GithubSchemas = [
320724
320717
  },
320725
320718
  ],
320726
320719
  },
320727
- TerraformProviderVariantOverride: {
320728
- $id: 'firestartr.dev://terraform/TerraformProviderVariantOverride',
320729
- description: 'Override fields for a variant of a TFWorkspaceClaim',
320730
- type: 'object',
320731
- properties: {
320732
- name: {
320733
- type: 'string',
320734
- description: 'override the terraform provider name',
320735
- },
320736
- values: {
320737
- type: 'object',
320738
- additionalProperties: true,
320739
- description: 'override values',
320740
- },
320741
- context: {
320742
- type: 'object',
320743
- properties: {
320744
- providers: {
320745
- type: 'array',
320746
- items: {
320747
- type: 'object',
320748
- properties: { name: { type: 'string' } },
320749
- additionalProperties: false,
320750
- },
320751
- },
320752
- backend: {
320753
- type: 'object',
320754
- properties: { name: { type: 'string' } },
320755
- additionalProperties: false,
320756
- },
320757
- },
320758
- additionalProperties: false,
320759
- description: 'override context',
320760
- },
320761
- files: {
320762
- $ref: 'firestartr.dev://terraform/TerraformProviderFiles',
320763
- },
320764
- policy: {
320765
- type: 'string',
320766
- enum: [
320767
- 'apply',
320768
- 'create-only',
320769
- 'create-update-only',
320770
- 'full-control',
320771
- 'observe',
320772
- 'observe-only',
320773
- ],
320774
- },
320775
- tfStateKey: {
320776
- $ref: 'firestartr.dev://common/TerraformStateKey',
320777
- },
320778
- sync: {
320779
- type: 'object',
320780
- properties: {
320781
- enabled: { type: 'boolean' },
320782
- period: { type: 'string', pattern: '^[0-9]+[smhd]$' },
320783
- schedule: { type: 'string' },
320784
- schedule_timezone: { type: 'string' },
320785
- policy: { type: 'string' },
320786
- },
320787
- additionalProperties: false,
320788
- },
320789
- valuesSchema: {
320790
- type: 'string',
320791
- },
320792
- },
320793
- additionalProperties: false,
320794
- },
320795
- TerraformProviderVariant: {
320796
- $id: 'firestartr.dev://terraform/TerraformProviderVariant',
320797
- description: 'A single variant of a TFWorkspace',
320798
- type: 'object',
320799
- properties: {
320800
- name: {
320801
- type: 'string',
320802
- description: 'name of the variant — used as claim name and CR name base',
320803
- },
320804
- overrides: {
320805
- $ref: 'firestartr.dev://terraform/TerraformProviderVariantOverride',
320806
- },
320807
- },
320808
- additionalProperties: false,
320809
- required: ['name', 'overrides'],
320810
- },
320811
320720
  },
320812
320721
  });
320813
320722
 
@@ -321278,12 +321187,6 @@ async function loadClaim(claimRef, org, defaults = loadClaimDefaults(), patchCla
321278
321187
  try {
321279
321188
  const claimData = await lazyGetClaim(claimRef.split(/-/)[0], claimRef.replace(/^[^-]+-/, ''), org, cwd);
321280
321189
  const claim = patchClaim(catalog_common/* default.io.fromYaml */.Z.io.fromYaml(claimData), defaults);
321281
- let variants = [];
321282
- if (claim.kind === 'TFWorkspaceClaim' &&
321283
- claim.providers?.terraform?.variants) {
321284
- variants = claim.providers.terraform.variants;
321285
- delete claim.providers.terraform.variants;
321286
- }
321287
321190
  logger.silly(`Patched claim is:
321288
321191
  ---
321289
321192
  ${catalog_common/* default.io.toYaml */.Z.io.toYaml(claim)}`);
@@ -321321,44 +321224,6 @@ async function loadClaim(claimRef, org, defaults = loadClaimDefaults(), patchCla
321321
321224
  result = lodash_default().merge(result, resolvedReferences);
321322
321225
  }
321323
321226
  }
321324
- if (variants.length > 0) {
321325
- const parentClaimPath = VisitedClaims[claimRef];
321326
- for (const variant of variants) {
321327
- if (!variant.name || !variant.overrides) {
321328
- throw new Error(`Variant in claim ${claimRef} is missing required field 'name' or 'overrides'`);
321329
- }
321330
- const prohibitedOverrideFields = ['source', 'module'];
321331
- for (const field of prohibitedOverrideFields) {
321332
- if (field in variant.overrides) {
321333
- throw new Error(`Variant '${variant.name}' in claim ${claimRef} cannot override '${field}'`);
321334
- }
321335
- }
321336
- const variantClaim = lodash_default().cloneDeep(claim);
321337
- variantClaim.name = variant.name;
321338
- variantClaim.providers.terraform = lodash_default().merge({}, claim.providers.terraform, variant.overrides);
321339
- if (!variantClaim.annotations) {
321340
- variantClaim.annotations = {};
321341
- }
321342
- variantClaim.annotations['firestartr.dev/variant-of'] =
321343
- claim.providers.terraform.name;
321344
- const variantRef = `TFWorkspaceClaim-${variant.name}`;
321345
- if (result[variantRef]) {
321346
- throw new Error(`Variant name '${variant.name}' from claim '${claimRef}' conflicts with existing claim '${variantRef}'`);
321347
- }
321348
- logger.info(`Creating synthetic variant claim ${variantRef}`);
321349
- result[variantRef] = {};
321350
- result[variantRef]['claim'] = variantClaim;
321351
- result[variantRef]['claimPath'] = parentClaimPath;
321352
- result = await setNonVirtualClaimAdditionalData(result, variantClaim, variantRef, loadInitializers, loadGlobals, loadOverrides, loadNormalizers);
321353
- const variantReferences = extractAllRefs(catalog_common/* default.io.toYaml */.Z.io.toYaml(variantClaim));
321354
- for (const ref of variantReferences) {
321355
- if (!result[ref]) {
321356
- const [resolvedReferences] = await loadClaim(ref, org, defaults, patchClaim, loadInitializers, loadGlobals, loadOverrides, loadNormalizers, cwd, result, postValidations);
321357
- result = lodash_default().merge(result, resolvedReferences);
321358
- }
321359
- }
321360
- }
321361
- }
321362
321227
  }
321363
321228
  catch (err) {
321364
321229
  throw `Lazy Loading: ${err}`;
@@ -323803,6 +323668,47 @@ function sanitizeApiEntityName(name) {
323803
323668
  .replace(/[^a-z0-9-]/g, '-')
323804
323669
  .replace(/^-+|-+$/g, '');
323805
323670
  }
323671
+ async function generateClaimsMap(claimsPath, outputPath, sha) {
323672
+ const map = {
323673
+ headers: {
323674
+ sha: sha ?? '',
323675
+ },
323676
+ claims: {},
323677
+ };
323678
+ await crawlClaimsDir(claimsPath, claimsPath, map.claims);
323679
+ await external_fs_default().promises.writeFile(outputPath, JSON.stringify(map, null, 2), 'utf-8');
323680
+ }
323681
+ async function crawlClaimsDir(dir, basePath, claims) {
323682
+ let entries;
323683
+ try {
323684
+ entries = await (0,promises_.readdir)(dir, { withFileTypes: true });
323685
+ }
323686
+ catch (err) {
323687
+ throw new Error(`Reading directory ${dir}: ${err}`);
323688
+ }
323689
+ for (const entry of entries) {
323690
+ const fullPath = external_path_default().join(dir, entry.name);
323691
+ if (entry.isDirectory()) {
323692
+ await crawlClaimsDir(fullPath, basePath, claims);
323693
+ }
323694
+ else if (entry.isFile() && entry.name.match(/\.yaml$|\.yml$/)) {
323695
+ try {
323696
+ const data = await external_fs_default().promises.readFile(fullPath, 'utf-8');
323697
+ const claim = catalog_common/* default.io.fromYaml */.Z.io.fromYaml(data);
323698
+ if (!('kind' in claim && 'name' in claim)) {
323699
+ logger.warn(`Skipping file ${fullPath}: missing kind or name`);
323700
+ continue;
323701
+ }
323702
+ const ref = `${claim.kind}-${claim.name}`;
323703
+ const relativePath = external_path_default().relative(basePath, fullPath);
323704
+ claims[ref] = { filePath: relativePath };
323705
+ }
323706
+ catch (err) {
323707
+ throw new Error(`Error processing claim file ${fullPath}: ${err}`);
323708
+ }
323709
+ }
323710
+ }
323711
+ }
323806
323712
 
323807
323713
  ;// CONCATENATED MODULE: ../cdk8s_renderer/imports/firestartr.dev.ts
323808
323714
  // generated by cdk8s
@@ -327807,9 +327713,6 @@ class TFWorkspaceChart extends BaseWorkspaceChart {
327807
327713
  return {
327808
327714
  metadata: {
327809
327715
  name: claim.providers.terraform.name,
327810
- ...(claim.annotations && Object.keys(claim.annotations).length > 0
327811
- ? { annotations: claim.annotations }
327812
- : {}),
327813
327716
  },
327814
327717
  spec: {
327815
327718
  firestartr: {
@@ -328233,10 +328136,7 @@ async function renderClaim(catalogScope, firestartrScope, claim, patches, previo
328233
328136
  let catalogEntity = undefined;
328234
328137
  let firestartrEntity = undefined;
328235
328138
  const extraCharts = [];
328236
- const isVariant = claim.annotations?.['firestartr.dev/variant-of'] !== undefined;
328237
- const chartId = isVariant
328238
- ? `${claim.kind}-${claim.name}.variant`.toLowerCase()
328239
- : `${claim.kind}-${claim.name}`.toLowerCase();
328139
+ const chartId = `${claim.kind}-${claim.name}`.toLowerCase();
328240
328140
  let firestartrId = null;
328241
328141
  if (previousCR) {
328242
328142
  firestartrId = previousCR?.spec?.firestartr?.tfStateKey || null;
@@ -328978,6 +328878,7 @@ async function addLastStateAndLastClaimAnnotations(filePath, lastStatePRLink, la
328978
328878
 
328979
328879
 
328980
328880
 
328881
+
328981
328882
 
328982
328883
 
328983
328884
  /* harmony default export */ const cdk8s_renderer = ({
@@ -342790,6 +342691,7 @@ const cdk8s_rendererSubcommands = {
342790
342691
  { name: 'render', alias: 'r', type: Boolean },
342791
342692
  { name: 'compare', type: Boolean },
342792
342693
  { name: 'render-plan', type: Boolean },
342694
+ { name: 'generate-claims-map', type: Boolean },
342793
342695
  /**
342794
342696
  * Specific parameters for render functionality
342795
342697
  */
@@ -342846,6 +342748,10 @@ const cdk8s_rendererSubcommands = {
342846
342748
  { name: 'lastStatePrLink', type: String },
342847
342749
  { name: 'lastClaimPrLink', type: String },
342848
342750
  { name: 'crLocation', type: String },
342751
+ /**
342752
+ * Specific parameters for claims-map generation
342753
+ */
342754
+ { name: 'claims-map-output', alias: 'm', type: String },
342849
342755
  ],
342850
342756
  run: async (options) => {
342851
342757
  if (options['render']) {
@@ -342858,6 +342764,9 @@ const cdk8s_rendererSubcommands = {
342858
342764
  else if (options['lastStatePrLink'] && options['lastClaimPrLink']) {
342859
342765
  await cdk8s_renderer.addLastStateAndLastClaimAnnotations(options['crLocation'], options['lastStatePrLink'], options['lastClaimPrLink']);
342860
342766
  }
342767
+ else if (options['generate-claims-map']) {
342768
+ await generateClaimsMap(options['claims'], options['claims-map-output'], options['sha']);
342769
+ }
342861
342770
  },
342862
342771
  };
342863
342772
 
@@ -521499,7 +521408,7 @@ const crsStatusSubcommand = {
521499
521408
  };
521500
521409
 
521501
521410
  ;// CONCATENATED MODULE: ./package.json
521502
- const package_namespaceObject = JSON.parse('{"i8":"2.8.0-snapshot-2"}');
521411
+ const package_namespaceObject = JSON.parse('{"i8":"2.8.0-snapshot-maps-claim-generator-1"}');
521503
521412
  ;// CONCATENATED MODULE: ../../package.json
521504
521413
  const package_namespaceObject_1 = {"i8":"2.7.0"};
521505
521414
  ;// CONCATENATED MODULE: ./src/subcommands/index.ts
@@ -13,6 +13,7 @@ import { runComparer } from './src/comparer';
13
13
  import { AllowedProviders, setDefaultBranch, setPath, setRepositoryUrl } from './src/config';
14
14
  import { render } from './src/renderer/renderer';
15
15
  export { AllowedProviders, configureProvider, setDefaultBranch, setRepositoryUrl, } from './src/config';
16
+ export { generateClaimsMap } from './src/utils/claimUtils';
16
17
  import { isCatalogEntity } from './src/validations/references';
17
18
  import { normalizeModuleContent } from './src/normalizers';
18
19
  import { loadCRs } from './src/loader/loader';
@@ -1192,13 +1192,6 @@ declare const schemas: {
1192
1192
  module: {
1193
1193
  type: string;
1194
1194
  };
1195
- variants: {
1196
- type: string;
1197
- items: {
1198
- $ref: string;
1199
- };
1200
- description: string;
1201
- };
1202
1195
  context: {
1203
1196
  type: string;
1204
1197
  properties: {
@@ -1233,102 +1226,6 @@ declare const schemas: {
1233
1226
  $ref?: undefined;
1234
1227
  })[];
1235
1228
  };
1236
- TerraformProviderVariantOverride: {
1237
- $id: string;
1238
- description: string;
1239
- type: string;
1240
- properties: {
1241
- name: {
1242
- type: string;
1243
- description: string;
1244
- };
1245
- values: {
1246
- type: string;
1247
- additionalProperties: boolean;
1248
- description: string;
1249
- };
1250
- context: {
1251
- type: string;
1252
- properties: {
1253
- providers: {
1254
- type: string;
1255
- items: {
1256
- type: string;
1257
- properties: {
1258
- name: {
1259
- type: string;
1260
- };
1261
- };
1262
- additionalProperties: boolean;
1263
- };
1264
- };
1265
- backend: {
1266
- type: string;
1267
- properties: {
1268
- name: {
1269
- type: string;
1270
- };
1271
- };
1272
- additionalProperties: boolean;
1273
- };
1274
- };
1275
- additionalProperties: boolean;
1276
- description: string;
1277
- };
1278
- files: {
1279
- $ref: string;
1280
- };
1281
- policy: {
1282
- type: string;
1283
- enum: string[];
1284
- };
1285
- tfStateKey: {
1286
- $ref: string;
1287
- };
1288
- sync: {
1289
- type: string;
1290
- properties: {
1291
- enabled: {
1292
- type: string;
1293
- };
1294
- period: {
1295
- type: string;
1296
- pattern: string;
1297
- };
1298
- schedule: {
1299
- type: string;
1300
- };
1301
- schedule_timezone: {
1302
- type: string;
1303
- };
1304
- policy: {
1305
- type: string;
1306
- };
1307
- };
1308
- additionalProperties: boolean;
1309
- };
1310
- valuesSchema: {
1311
- type: string;
1312
- };
1313
- };
1314
- additionalProperties: boolean;
1315
- };
1316
- TerraformProviderVariant: {
1317
- $id: string;
1318
- description: string;
1319
- type: string;
1320
- properties: {
1321
- name: {
1322
- type: string;
1323
- description: string;
1324
- };
1325
- overrides: {
1326
- $ref: string;
1327
- };
1328
- };
1329
- additionalProperties: boolean;
1330
- required: string[];
1331
- };
1332
1229
  };
1333
1230
  }[] | {
1334
1231
  $schema: string;
@@ -97,13 +97,6 @@ export declare const TerraformSchemas: {
97
97
  module: {
98
98
  type: string;
99
99
  };
100
- variants: {
101
- type: string;
102
- items: {
103
- $ref: string;
104
- };
105
- description: string;
106
- };
107
100
  context: {
108
101
  type: string;
109
102
  properties: {
@@ -138,101 +131,5 @@ export declare const TerraformSchemas: {
138
131
  $ref?: undefined;
139
132
  })[];
140
133
  };
141
- TerraformProviderVariantOverride: {
142
- $id: string;
143
- description: string;
144
- type: string;
145
- properties: {
146
- name: {
147
- type: string;
148
- description: string;
149
- };
150
- values: {
151
- type: string;
152
- additionalProperties: boolean;
153
- description: string;
154
- };
155
- context: {
156
- type: string;
157
- properties: {
158
- providers: {
159
- type: string;
160
- items: {
161
- type: string;
162
- properties: {
163
- name: {
164
- type: string;
165
- };
166
- };
167
- additionalProperties: boolean;
168
- };
169
- };
170
- backend: {
171
- type: string;
172
- properties: {
173
- name: {
174
- type: string;
175
- };
176
- };
177
- additionalProperties: boolean;
178
- };
179
- };
180
- additionalProperties: boolean;
181
- description: string;
182
- };
183
- files: {
184
- $ref: string;
185
- };
186
- policy: {
187
- type: string;
188
- enum: string[];
189
- };
190
- tfStateKey: {
191
- $ref: string;
192
- };
193
- sync: {
194
- type: string;
195
- properties: {
196
- enabled: {
197
- type: string;
198
- };
199
- period: {
200
- type: string;
201
- pattern: string;
202
- };
203
- schedule: {
204
- type: string;
205
- };
206
- schedule_timezone: {
207
- type: string;
208
- };
209
- policy: {
210
- type: string;
211
- };
212
- };
213
- additionalProperties: boolean;
214
- };
215
- valuesSchema: {
216
- type: string;
217
- };
218
- };
219
- additionalProperties: boolean;
220
- };
221
- TerraformProviderVariant: {
222
- $id: string;
223
- description: string;
224
- type: string;
225
- properties: {
226
- name: {
227
- type: string;
228
- description: string;
229
- };
230
- overrides: {
231
- $ref: string;
232
- };
233
- };
234
- additionalProperties: boolean;
235
- required: string[];
236
- };
237
134
  };
238
135
  }[];
@@ -97,13 +97,6 @@ declare const _default: {
97
97
  module: {
98
98
  type: string;
99
99
  };
100
- variants: {
101
- type: string;
102
- items: {
103
- $ref: string;
104
- };
105
- description: string;
106
- };
107
100
  context: {
108
101
  type: string;
109
102
  properties: {
@@ -138,102 +131,6 @@ declare const _default: {
138
131
  $ref?: undefined;
139
132
  })[];
140
133
  };
141
- TerraformProviderVariantOverride: {
142
- $id: string;
143
- description: string;
144
- type: string;
145
- properties: {
146
- name: {
147
- type: string;
148
- description: string;
149
- };
150
- values: {
151
- type: string;
152
- additionalProperties: boolean;
153
- description: string;
154
- };
155
- context: {
156
- type: string;
157
- properties: {
158
- providers: {
159
- type: string;
160
- items: {
161
- type: string;
162
- properties: {
163
- name: {
164
- type: string;
165
- };
166
- };
167
- additionalProperties: boolean;
168
- };
169
- };
170
- backend: {
171
- type: string;
172
- properties: {
173
- name: {
174
- type: string;
175
- };
176
- };
177
- additionalProperties: boolean;
178
- };
179
- };
180
- additionalProperties: boolean;
181
- description: string;
182
- };
183
- files: {
184
- $ref: string;
185
- };
186
- policy: {
187
- type: string;
188
- enum: string[];
189
- };
190
- tfStateKey: {
191
- $ref: string;
192
- };
193
- sync: {
194
- type: string;
195
- properties: {
196
- enabled: {
197
- type: string;
198
- };
199
- period: {
200
- type: string;
201
- pattern: string;
202
- };
203
- schedule: {
204
- type: string;
205
- };
206
- schedule_timezone: {
207
- type: string;
208
- };
209
- policy: {
210
- type: string;
211
- };
212
- };
213
- additionalProperties: boolean;
214
- };
215
- valuesSchema: {
216
- type: string;
217
- };
218
- };
219
- additionalProperties: boolean;
220
- };
221
- TerraformProviderVariant: {
222
- $id: string;
223
- description: string;
224
- type: string;
225
- properties: {
226
- name: {
227
- type: string;
228
- description: string;
229
- };
230
- overrides: {
231
- $ref: string;
232
- };
233
- };
234
- additionalProperties: boolean;
235
- required: string[];
236
- };
237
134
  };
238
135
  };
239
136
  export default _default;
@@ -5,3 +5,13 @@ export declare function resolveClaimEntries(claimRefsList: string[]): AsyncGener
5
5
  export declare function resolveClaimFileRef(claimFile: string): Promise<string>;
6
6
  export declare function getClaimsEntryAbsolutePath(claimsDir: string, entryPath: string): string;
7
7
  export declare function sanitizeApiEntityName(name: string): string;
8
+ export interface ClaimsMapEntry {
9
+ filePath: string;
10
+ }
11
+ export interface ClaimsMap {
12
+ headers: {
13
+ sha: string;
14
+ };
15
+ claims: Record<string, ClaimsMapEntry>;
16
+ }
17
+ export declare function generateClaimsMap(claimsPath: string, outputPath: string, sha?: string): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "2.8.0-snapshot-2",
3
+ "version": "2.8.0-snapshot-maps-claim-generator-1",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",