@firestartr/cli 1.54.0-snapshot-12 → 1.54.0-snapshot-13

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
@@ -151708,7 +151708,7 @@ module.exports = exports.default;
151708
151708
 
151709
151709
  /***/ }),
151710
151710
 
151711
- /***/ 60762:
151711
+ /***/ 89323:
151712
151712
  /***/ ((module, exports) => {
151713
151713
 
151714
151714
 
@@ -151775,7 +151775,7 @@ var _isArrayLike = __nccwpck_require__(10860);
151775
151775
 
151776
151776
  var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
151777
151777
 
151778
- var _getIterator = __nccwpck_require__(60762);
151778
+ var _getIterator = __nccwpck_require__(89323);
151779
151779
 
151780
151780
  var _getIterator2 = _interopRequireDefault(_getIterator);
151781
151781
 
@@ -357285,10 +357285,13 @@ class RevisionNormalizer extends Normalizer {
357285
357285
  }
357286
357286
  }
357287
357287
 
357288
+ // EXTERNAL MODULE: external "fs/promises"
357289
+ var external_fs_promises_ = __nccwpck_require__(73292);
357288
357290
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/normalizers/tfworkspace.ts
357289
357291
 
357290
357292
 
357291
357293
 
357294
+
357292
357295
  class TFWorkspaceNormalizer extends Normalizer {
357293
357296
  constructor() {
357294
357297
  super(...arguments);
@@ -357316,6 +357319,15 @@ class TFWorkspaceNormalizer extends Normalizer {
357316
357319
  const normalizedContent = await normalizeModuleContent(dirTfRootModule);
357317
357320
  cr.spec['module'] = normalizedContent;
357318
357321
  }
357322
+ if ('files' in claim.providers.terraform) {
357323
+ try {
357324
+ const additionalFiles = await loadAdditionalFiles(claim.providers.terraform['files'], external_path_.dirname(claimPath));
357325
+ cr.spec['files'] = additionalFiles;
357326
+ }
357327
+ catch (err) {
357328
+ throw new Error(`Loading additional files for TFWorkspace: ${claim.name}: ${err && err.message ? err.message : err}`);
357329
+ }
357330
+ }
357319
357331
  return cr;
357320
357332
  },
357321
357333
  identify() {
@@ -357344,6 +357356,33 @@ ${files[entry]}
357344
357356
  });
357345
357357
  return content;
357346
357358
  }
357359
+ async function loadAdditionalFiles(files, tfRootModulePath) {
357360
+ const specFiles = [];
357361
+ for (const additionalFile of files) {
357362
+ const specFile = {
357363
+ path: additionalFile.destination,
357364
+ content: await loadAdditionalFile(additionalFile.source, tfRootModulePath),
357365
+ };
357366
+ specFiles.push(specFile);
357367
+ }
357368
+ return specFiles;
357369
+ }
357370
+ async function loadAdditionalFile(source, tfRootModulePath) {
357371
+ try {
357372
+ const filePath = external_path_.join(tfRootModulePath, source);
357373
+ const stats = await external_fs_promises_.stat(filePath);
357374
+ if (!stats.isFile()) {
357375
+ throw new Error(`${source} is not a file`);
357376
+ }
357377
+ const content = await external_fs_promises_.readFile(filePath, {
357378
+ encoding: 'utf8',
357379
+ });
357380
+ return Buffer.from(content, 'utf8').toString('base64');
357381
+ }
357382
+ catch (err) {
357383
+ throw new Error(`Loading additional tfworkspace file ${source}: ${err && err.message ? err.message : err}`);
357384
+ }
357385
+ }
357347
357386
  function validatek8sLimits(moduleContent) {
357348
357387
  const moduleLength = moduleContent.length;
357349
357388
  return moduleLength > 0 && moduleLength < 750000;
@@ -358345,6 +358384,26 @@ const GithubSchemas = [
358345
358384
  /* harmony default export */ const terraform_schema = ({
358346
358385
  $id: 'TerraformProvider',
358347
358386
  definitions: {
358387
+ TerraformProviderFiles: {
358388
+ $id: 'firestartr.dev://terraform/TerraformProviderFiles',
358389
+ description: 'A list of files included in the terraform project',
358390
+ type: 'array',
358391
+ items: {
358392
+ type: 'object',
358393
+ properties: {
358394
+ source: {
358395
+ type: 'string',
358396
+ description: 'path of the original file to include in the final CR',
358397
+ },
358398
+ destination: {
358399
+ type: 'string',
358400
+ description: 'path where the file will be placed in the final terraform project',
358401
+ },
358402
+ },
358403
+ additionalProperties: false,
358404
+ required: ['source', 'destination'],
358405
+ },
358406
+ },
358348
358407
  TerraformProvider: {
358349
358408
  $id: 'firestartr.dev://terraform/TerraformProvider',
358350
358409
  type: 'object',
@@ -358374,6 +358433,9 @@ const GithubSchemas = [
358374
358433
  type: 'string',
358375
358434
  enum: ['remote', 'inline', 'Remote', 'Inline'],
358376
358435
  },
358436
+ files: {
358437
+ $ref: 'firestartr.dev://terraform/TerraformProviderFiles',
358438
+ },
358377
358439
  sync: {
358378
358440
  type: 'object',
358379
358441
  properties: {
@@ -363389,6 +363451,7 @@ function toJson_FirestartrTerraformWorkspaceSpec(obj) {
363389
363451
  'module': obj.module,
363390
363452
  'source': obj.source,
363391
363453
  'values': obj.values,
363454
+ 'files': obj.files?.map(y => toJson_FirestartrTerraformWorkspaceSpecFiles(y)),
363392
363455
  'references': obj.references?.map(y => toJson_FirestartrTerraformWorkspaceSpecReferences(y)),
363393
363456
  'writeConnectionSecretToRef': toJson_FirestartrTerraformWorkspaceSpecWriteConnectionSecretToRef(obj.writeConnectionSecretToRef),
363394
363457
  };
@@ -363435,6 +363498,21 @@ var FirestartrTerraformWorkspaceSpecSource;
363435
363498
  /** Inline */
363436
363499
  FirestartrTerraformWorkspaceSpecSource["INLINE"] = "Inline";
363437
363500
  })(FirestartrTerraformWorkspaceSpecSource || (FirestartrTerraformWorkspaceSpecSource = {}));
363501
+ /**
363502
+ * Converts an object of type 'FirestartrTerraformWorkspaceSpecFiles' to JSON representation.
363503
+ */
363504
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
363505
+ function toJson_FirestartrTerraformWorkspaceSpecFiles(obj) {
363506
+ if (obj === undefined) {
363507
+ return undefined;
363508
+ }
363509
+ const result = {
363510
+ 'content': obj.content,
363511
+ 'path': obj.path,
363512
+ };
363513
+ // filter undefined values
363514
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
363515
+ }
363438
363516
  /**
363439
363517
  * Converts an object of type 'FirestartrTerraformWorkspaceSpecReferences' to JSON representation.
363440
363518
  */
@@ -372296,6 +372374,38 @@ class WriterProviderJson extends writer {
372296
372374
  }
372297
372375
  }
372298
372376
 
372377
+ ;// CONCATENATED MODULE: ../terraform_provisioner/src/writer_additional_files.ts
372378
+
372379
+
372380
+
372381
+ class WriterAdditionalFiles extends writer {
372382
+ constructor(files) {
372383
+ super();
372384
+ this.files = files;
372385
+ }
372386
+ // this writer does not "write" anything per se
372387
+ // it just complies with the abstract class it inherits from
372388
+ async _render() {
372389
+ return '';
372390
+ }
372391
+ async writeToTerraformProject(projectPath) {
372392
+ for (const file of this.files) {
372393
+ try {
372394
+ const targetPath = external_path_.resolve(projectPath, file.path);
372395
+ const absProjectPath = external_path_.resolve(projectPath);
372396
+ if (!targetPath.startsWith(absProjectPath + external_path_.sep)) {
372397
+ throw new Error(`Path traversal detected: ${file.path}`);
372398
+ }
372399
+ await external_fs_promises_.mkdir(external_path_.dirname(targetPath), { recursive: true });
372400
+ await external_fs_promises_.writeFile(targetPath, Buffer.from(file.content, 'base64').toString('utf8'));
372401
+ }
372402
+ catch (err) {
372403
+ throw new Error(`Error writing additional file: ${file.path}: ${err}`);
372404
+ }
372405
+ }
372406
+ }
372407
+ }
372408
+
372299
372409
  ;// CONCATENATED MODULE: ../terraform_provisioner/src/project_tf.ts
372300
372410
 
372301
372411
 
@@ -372303,6 +372413,7 @@ class WriterProviderJson extends writer {
372303
372413
 
372304
372414
 
372305
372415
 
372416
+
372306
372417
  class project_tf_TFProjectManager {
372307
372418
  constructor(ctx) {
372308
372419
  this.tfOutput = '';
@@ -372310,6 +372421,9 @@ class project_tf_TFProjectManager {
372310
372421
  this.mainTfWriter = new WriterMainTf(ctx.inline, ctx.requiredProviders, ctx.backend, ctx.tfStateKey);
372311
372422
  this.providerJsonWriter = new WriterProviderJson(ctx.inline, ctx.requiredProviders, ctx.backend, ctx.tfStateKey);
372312
372423
  this.tfVarsJsonWriter = new WriterTfVarsJson(ctx.values, ctx.references);
372424
+ if ('files' in ctx) {
372425
+ this.additionalFilesWriter = new WriterAdditionalFiles(ctx['files']);
372426
+ }
372313
372427
  this.secrets = ctx.secrets;
372314
372428
  }
372315
372429
  setStreamCallbacks(fnData, fnEnd, reopen = true) {
@@ -372330,6 +372444,10 @@ class project_tf_TFProjectManager {
372330
372444
  this.providerJsonWriter.writeToTerraformProject(external_path_.join(this.projectPath, 'firestartr-providers.tf.json'));
372331
372445
  await this.tfVarsJsonWriter.render();
372332
372446
  this.tfVarsJsonWriter.writeToTerraformProject(external_path_.join(this.projectPath, 'terraform.tfvars.json'));
372447
+ if (this.additionalFilesWriter) {
372448
+ await this.additionalFilesWriter.render();
372449
+ await this.additionalFilesWriter.writeToTerraformProject(this.projectPath);
372450
+ }
372333
372451
  }
372334
372452
  async __init() {
372335
372453
  this.tfOutput += await init(this.projectPath, this.secrets, this.stream);
@@ -372461,6 +372579,7 @@ var lib_ajv_default = /*#__PURE__*/__nccwpck_require__.n(lib_ajv);
372461
372579
 
372462
372580
 
372463
372581
 
372582
+
372464
372583
  class TFProjectManagerRemote {
372465
372584
  constructor(ctx) {
372466
372585
  this.tfOutput = '';
@@ -372469,6 +372588,9 @@ class TFProjectManagerRemote {
372469
372588
  this.secrets = ctx.secrets;
372470
372589
  this.writerTerraform = new WriterTerraform(ctx.requiredProviders, ctx.backend, ctx.tfStateKey, false);
372471
372590
  this.providerJsonWriter = new WriterProviderJson(ctx.inline, ctx.requiredProviders, ctx.backend, ctx.tfStateKey);
372591
+ if ('files' in ctx) {
372592
+ this.additionalFilesWriter = new WriterAdditionalFiles(ctx['files']);
372593
+ }
372472
372594
  this.tfVarsJsonWriter = new WriterTfVarsJson(ctx.values, ctx.references);
372473
372595
  }
372474
372596
  getOutput() {
@@ -372492,6 +372614,10 @@ class TFProjectManagerRemote {
372492
372614
  this.providerJsonWriter.writeToTerraformProject(external_path_.join(this.projectPath, 'firestartr-providers.tf.json'));
372493
372615
  await this.tfVarsJsonWriter.render();
372494
372616
  this.tfVarsJsonWriter.writeToTerraformProject(external_path_.join(this.projectPath, 'terraform.tfvars.json'));
372617
+ if (this.additionalFilesWriter) {
372618
+ await this.additionalFilesWriter.render();
372619
+ await this.additionalFilesWriter.writeToTerraformProject(this.projectPath);
372620
+ }
372495
372621
  }
372496
372622
  async __configGit() {
372497
372623
  external_fs_.existsSync('/home/node/.gitconfig') &&
@@ -373402,6 +373528,9 @@ function buildProvisionerContext(item, deps) {
373402
373528
  context['type'] = item.spec.source;
373403
373529
  context['inline'] = item.spec.module;
373404
373530
  context['module'] = item.spec.module;
373531
+ if ('files' in item.spec) {
373532
+ context['files'] = item.spec.files;
373533
+ }
373405
373534
  context['values'] = JSON.parse(item.spec.values);
373406
373535
  const result = adaptProviders(item, deps);
373407
373536
  context['requiredProviders'] = result.providers;
@@ -2308,6 +2308,12 @@ export interface FirestartrTerraformWorkspaceSpec {
2308
2308
  * @schema FirestartrTerraformWorkspaceSpec#values
2309
2309
  */
2310
2310
  readonly values?: string;
2311
+ /**
2312
+ * A list of files to be created in the Terraform workspace directory.
2313
+ *
2314
+ * @schema FirestartrTerraformWorkspaceSpec#files
2315
+ */
2316
+ readonly files?: FirestartrTerraformWorkspaceSpecFiles[];
2311
2317
  /**
2312
2318
  * @schema FirestartrTerraformWorkspaceSpec#references
2313
2319
  */
@@ -2360,6 +2366,27 @@ export declare enum FirestartrTerraformWorkspaceSpecSource {
2360
2366
  /** Inline */
2361
2367
  INLINE = "Inline"
2362
2368
  }
2369
+ /**
2370
+ * @schema FirestartrTerraformWorkspaceSpecFiles
2371
+ */
2372
+ export interface FirestartrTerraformWorkspaceSpecFiles {
2373
+ /**
2374
+ * The base64 encoded content of the file.
2375
+ *
2376
+ * @schema FirestartrTerraformWorkspaceSpecFiles#content
2377
+ */
2378
+ readonly content: string;
2379
+ /**
2380
+ * The target relative path for the file within the Terraform workspace directory.
2381
+ *
2382
+ * @schema FirestartrTerraformWorkspaceSpecFiles#path
2383
+ */
2384
+ readonly path: string;
2385
+ }
2386
+ /**
2387
+ * Converts an object of type 'FirestartrTerraformWorkspaceSpecFiles' to JSON representation.
2388
+ */
2389
+ export declare function toJson_FirestartrTerraformWorkspaceSpecFiles(obj: FirestartrTerraformWorkspaceSpecFiles | undefined): Record<string, any> | undefined;
2363
2390
  /**
2364
2391
  * @schema FirestartrTerraformWorkspaceSpecReferences
2365
2392
  */
@@ -20,6 +20,7 @@ export declare class CatalogTFWorkspaceChart extends BaseCatalogChart {
20
20
  source: import("../../../imports/firestartr.dev").FirestartrTerraformWorkspaceSpecSource;
21
21
  module: string;
22
22
  values: any;
23
+ files: import("../../claims/tfworkspaces/tfworkspace").TerraformProviderAdditionalFiles;
23
24
  context: {
24
25
  providers: {
25
26
  name: string;
@@ -659,6 +659,26 @@ declare const schemas: {
659
659
  })[] | {
660
660
  $id: string;
661
661
  definitions: {
662
+ TerraformProviderFiles: {
663
+ $id: string;
664
+ description: string;
665
+ type: string;
666
+ items: {
667
+ type: string;
668
+ properties: {
669
+ source: {
670
+ type: string;
671
+ description: string;
672
+ };
673
+ destination: {
674
+ type: string;
675
+ description: string;
676
+ };
677
+ };
678
+ additionalProperties: boolean;
679
+ required: string[];
680
+ };
681
+ };
662
682
  TerraformProvider: {
663
683
  $id: string;
664
684
  type: string;
@@ -682,6 +702,9 @@ declare const schemas: {
682
702
  type: string;
683
703
  enum: string[];
684
704
  };
705
+ files: {
706
+ $ref: string;
707
+ };
685
708
  sync: {
686
709
  type: string;
687
710
  properties: {
@@ -1,6 +1,26 @@
1
1
  export declare const TerraformSchemas: {
2
2
  $id: string;
3
3
  definitions: {
4
+ TerraformProviderFiles: {
5
+ $id: string;
6
+ description: string;
7
+ type: string;
8
+ items: {
9
+ type: string;
10
+ properties: {
11
+ source: {
12
+ type: string;
13
+ description: string;
14
+ };
15
+ destination: {
16
+ type: string;
17
+ description: string;
18
+ };
19
+ };
20
+ additionalProperties: boolean;
21
+ required: string[];
22
+ };
23
+ };
4
24
  TerraformProvider: {
5
25
  $id: string;
6
26
  type: string;
@@ -24,6 +44,9 @@ export declare const TerraformSchemas: {
24
44
  type: string;
25
45
  enum: string[];
26
46
  };
47
+ files: {
48
+ $ref: string;
49
+ };
27
50
  sync: {
28
51
  type: string;
29
52
  properties: {
@@ -1,6 +1,26 @@
1
1
  declare const _default: {
2
2
  $id: string;
3
3
  definitions: {
4
+ TerraformProviderFiles: {
5
+ $id: string;
6
+ description: string;
7
+ type: string;
8
+ items: {
9
+ type: string;
10
+ properties: {
11
+ source: {
12
+ type: string;
13
+ description: string;
14
+ };
15
+ destination: {
16
+ type: string;
17
+ description: string;
18
+ };
19
+ };
20
+ additionalProperties: boolean;
21
+ required: string[];
22
+ };
23
+ };
4
24
  TerraformProvider: {
5
25
  $id: string;
6
26
  type: string;
@@ -24,6 +44,9 @@ declare const _default: {
24
44
  type: string;
25
45
  enum: string[];
26
46
  };
47
+ files: {
48
+ $ref: string;
49
+ };
27
50
  sync: {
28
51
  type: string;
29
52
  properties: {
@@ -1,5 +1,10 @@
1
1
  import { FirestartrTerraformWorkspaceSpecSource } from '../../../imports/firestartr.dev';
2
2
  import { Workspace } from '../base/workspace';
3
+ export interface TerraformProviderAdditionalFile {
4
+ source: string;
5
+ destination: string;
6
+ }
7
+ export type TerraformProviderAdditionalFiles = TerraformProviderAdditionalFile[];
3
8
  export interface TFWorkspace extends Workspace {
4
9
  kind: 'TFWorkspaceClaim';
5
10
  resourceType: string;
@@ -10,6 +15,7 @@ export interface TFWorkspace extends Workspace {
10
15
  source: FirestartrTerraformWorkspaceSpecSource.INLINE | FirestartrTerraformWorkspaceSpecSource.REMOTE;
11
16
  module: string;
12
17
  values: any;
18
+ files: TerraformProviderAdditionalFiles;
13
19
  context: {
14
20
  providers: {
15
21
  name: string;
@@ -2,11 +2,13 @@
2
2
  import { WriterMainTf } from './writer_main_tf';
3
3
  import { WriterTfVarsJson } from './writer_tfvars_json';
4
4
  import { WriterProviderJson } from './writer_provider_tf_json';
5
+ import { WriterAdditionalFiles } from './writer_additional_files';
5
6
  import { PassThrough } from 'stream';
6
7
  export declare class TFProjectManager {
7
8
  mainTfWriter: WriterMainTf;
8
9
  providerJsonWriter: WriterProviderJson;
9
10
  tfVarsJsonWriter: WriterTfVarsJson;
11
+ additionalFilesWriter: WriterAdditionalFiles;
10
12
  secrets: any[];
11
13
  projectPath: string;
12
14
  tfOutput: any;
@@ -2,11 +2,13 @@
2
2
  import { WriterTerraform } from './writer_terraform';
3
3
  import { WriterTfVarsJson } from './writer_tfvars_json';
4
4
  import { WriterProviderJson } from './writer_provider_tf_json';
5
+ import { WriterAdditionalFiles } from './writer_additional_files';
5
6
  import { PassThrough } from 'stream';
6
7
  export declare class TFProjectManagerRemote {
7
8
  writerTerraform: WriterTerraform;
8
9
  providerJsonWriter: WriterProviderJson;
9
10
  tfVarsJsonWriter: WriterTfVarsJson;
11
+ additionalFilesWriter: WriterAdditionalFiles;
10
12
  ctx: any;
11
13
  secrets: any[];
12
14
  projectPath: string;
@@ -0,0 +1,13 @@
1
+ import Writer from './writer';
2
+ export interface FirestartrTerraformWorkspaceSpecFile {
3
+ content: string;
4
+ path: string;
5
+ }
6
+ type FirestartrTerraformWorkspaceSpecFiles = FirestartrTerraformWorkspaceSpecFile[];
7
+ export declare class WriterAdditionalFiles extends Writer {
8
+ files: FirestartrTerraformWorkspaceSpecFile[];
9
+ constructor(files: FirestartrTerraformWorkspaceSpecFiles);
10
+ _render(): Promise<string>;
11
+ writeToTerraformProject(projectPath: string): Promise<void>;
12
+ }
13
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "1.54.0-snapshot-12",
3
+ "version": "1.54.0-snapshot-13",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",