@quadnix/octo-build 0.0.17 → 0.2.0
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/LICENSE +661 -0
- package/README.md +117 -8
- package/dist/commands/apply/apply.command.d.ts +25 -0
- package/dist/commands/apply/apply.command.js +130 -0
- package/dist/commands/apply/apply.command.js.map +1 -0
- package/dist/commands/apply/index.d.ts +1 -0
- package/dist/commands/apply/index.js +2 -0
- package/dist/commands/apply/index.js.map +1 -0
- package/dist/commands/build/build.command.d.ts +1 -1
- package/dist/commands/build/build.command.js +4 -4
- package/dist/commands/build/build.command.js.map +1 -1
- package/dist/commands/build/main.d.ts +22 -0
- package/dist/commands/build/main.js +22 -0
- package/dist/commands/build/main.js.map +1 -1
- package/dist/commands/build/parsers/build-file.parser.d.ts +6 -0
- package/dist/commands/build/parsers/build-file.parser.js +6 -0
- package/dist/commands/build/parsers/build-file.parser.js.map +1 -1
- package/dist/commands/build/streams/stream-manager.d.ts +6 -0
- package/dist/commands/build/streams/stream-manager.js +7 -1
- package/dist/commands/build/streams/stream-manager.js.map +1 -1
- package/dist/commands/commit/commit.command.d.ts +23 -0
- package/dist/commands/commit/commit.command.js +81 -0
- package/dist/commands/commit/commit.command.js.map +1 -0
- package/dist/commands/commit/index.d.ts +1 -0
- package/dist/commands/commit/index.js +2 -0
- package/dist/commands/commit/index.js.map +1 -0
- package/dist/commands/create-anchor/create-anchor.command.js +1 -1
- package/dist/commands/create-anchor/create-anchor.command.js.map +1 -1
- package/dist/commands/create-anchor/generator-octo-anchor-template/generators/app/index.d.ts +18 -3
- package/dist/commands/create-anchor/generator-octo-anchor-template/generators/app/index.js +29 -11
- package/dist/commands/create-anchor/generator-octo-anchor-template/generators/app/index.js.map +1 -1
- package/dist/commands/create-anchor/generator-octo-anchor-template/generators/app/templates/anchors/anchor/anchor.schema.ts.ejs +9 -1
- package/dist/commands/create-app/create-app.command.d.ts +1 -1
- package/dist/commands/create-app/create-app.command.js +7 -3
- package/dist/commands/create-app/create-app.command.js.map +1 -1
- package/dist/commands/create-app/generator-octo-app-template/generators/app/index.d.ts +17 -1
- package/dist/commands/create-app/generator-octo-app-template/generators/app/index.js +72 -16
- package/dist/commands/create-app/generator-octo-app-template/generators/app/index.js.map +1 -1
- package/dist/commands/create-app/generator-octo-app-template/generators/app/templates/README.md.ejs +73 -14
- package/dist/commands/create-app/generator-octo-app-template/generators/app/templates/gitignore.ejs +14 -0
- package/dist/commands/create-app/generator-octo-app-template/generators/app/templates/index.ts.ejs +19 -0
- package/dist/commands/create-app/generator-octo-app-template/generators/app/templates/package.json.ejs +9 -1
- package/dist/commands/create-app/generator-octo-app-template/generators/app/templates/src/aws-dynamodb-service/octo.yaml.ejs +111 -0
- package/dist/commands/create-app/generator-octo-app-template/generators/app/templates/src/aws-ecs-server/octo.yaml.ejs +28 -16
- package/dist/commands/create-app/generator-octo-app-template/generators/app/templates/src/aws-s3-website/octo.yaml.ejs +25 -3
- package/dist/commands/create-app/generator-octo-app-template/generators/app/templates/tsconfig.json.ejs +0 -3
- package/dist/commands/{create-resource/create-resource.command.d.ts → create-external-resource/create-external-resource.command.d.ts} +1 -1
- package/dist/commands/create-external-resource/create-external-resource.command.js +64 -0
- package/dist/commands/create-external-resource/create-external-resource.command.js.map +1 -0
- package/dist/commands/{create-resource/generator-octo-resource-template → create-external-resource/generator-octo-external-resource-template}/generators/app/index.d.ts +17 -2
- package/dist/commands/{create-resource/generator-octo-resource-template → create-external-resource/generator-octo-external-resource-template}/generators/app/index.js +36 -35
- package/dist/commands/create-external-resource/generator-octo-external-resource-template/generators/app/index.js.map +1 -0
- package/dist/commands/{create-resource/generator-octo-resource-template → create-external-resource/generator-octo-external-resource-template}/generators/app/templates/resources/resource/actions/add.resource.action.ts.ejs +7 -16
- package/dist/commands/{create-resource/generator-octo-resource-template → create-external-resource/generator-octo-external-resource-template}/generators/app/templates/resources/resource/actions/delete.resource.action.ts.ejs +21 -3
- package/dist/commands/create-external-resource/generator-octo-external-resource-template/generators/app/templates/resources/resource/actions/update.resource.action.ts.ejs +63 -0
- package/dist/commands/{create-resource/generator-octo-resource-template → create-external-resource/generator-octo-external-resource-template}/generators/app/templates/resources/resource/index.ts.ejs +1 -2
- package/dist/commands/create-external-resource/generator-octo-external-resource-template/generators/app/templates/resources/resource/resource.ts.ejs +28 -0
- package/dist/commands/create-external-resource/index.d.ts +1 -0
- package/dist/commands/create-external-resource/index.js +2 -0
- package/dist/commands/create-external-resource/index.js.map +1 -0
- package/dist/commands/create-model/create-model.command.js +1 -1
- package/dist/commands/create-model/create-model.command.js.map +1 -1
- package/dist/commands/create-model/generator-octo-model-template/generators/app/index.d.ts +17 -2
- package/dist/commands/create-model/generator-octo-model-template/generators/app/index.js +26 -9
- package/dist/commands/create-model/generator-octo-model-template/generators/app/index.js.map +1 -1
- package/dist/commands/create-model/generator-octo-model-template/generators/app/templates/models/model/model.ts.ejs +41 -1
- package/dist/commands/create-model/generator-octo-model-template/generators/app/templates/models/model/schema.ts.ejs +6 -1
- package/dist/commands/create-module/create-module.command.js +1 -1
- package/dist/commands/create-module/create-module.command.js.map +1 -1
- package/dist/commands/create-module/generator-octo-module-template/generators/app/index.d.ts +17 -2
- package/dist/commands/create-module/generator-octo-module-template/generators/app/index.js +27 -10
- package/dist/commands/create-module/generator-octo-module-template/generators/app/index.js.map +1 -1
- package/dist/commands/create-overlay/create-overlay.command.js +4 -3
- package/dist/commands/create-overlay/create-overlay.command.js.map +1 -1
- package/dist/commands/create-overlay/generator-octo-overlay-template/generators/app/index.d.ts +17 -2
- package/dist/commands/create-overlay/generator-octo-overlay-template/generators/app/index.js +26 -9
- package/dist/commands/create-overlay/generator-octo-overlay-template/generators/app/index.js.map +1 -1
- package/dist/commands/{create-cdk/create-cdk.command.d.ts → create-terraform-resource/create-terraform-resource.command.d.ts} +3 -3
- package/dist/commands/{create-resource/create-resource.command.js → create-terraform-resource/create-terraform-resource.command.js} +17 -11
- package/dist/commands/create-terraform-resource/create-terraform-resource.command.js.map +1 -0
- package/dist/commands/create-terraform-resource/generator-octo-terraform-resource-template/generators/app/index.d.ts +25 -0
- package/dist/commands/create-terraform-resource/generator-octo-terraform-resource-template/generators/app/index.js +71 -0
- package/dist/commands/create-terraform-resource/generator-octo-terraform-resource-template/generators/app/index.js.map +1 -0
- package/dist/commands/create-terraform-resource/generator-octo-terraform-resource-template/generators/app/templates/resources/resource/index.schema.ts.ejs +43 -0
- package/dist/commands/create-terraform-resource/generator-octo-terraform-resource-template/generators/app/templates/resources/resource/index.ts.ejs +1 -0
- package/dist/commands/create-terraform-resource/generator-octo-terraform-resource-template/generators/app/templates/resources/resource/resource.ts.ejs +83 -0
- package/dist/commands/create-terraform-resource/index.d.ts +1 -0
- package/dist/commands/create-terraform-resource/index.js +2 -0
- package/dist/commands/create-terraform-resource/index.js.map +1 -0
- package/dist/commands/generate/generate.command.d.ts +16 -0
- package/dist/commands/generate/generate.command.js +35 -0
- package/dist/commands/generate/generate.command.js.map +1 -0
- package/dist/commands/generate/index.d.ts +1 -0
- package/dist/commands/generate/index.js +2 -0
- package/dist/commands/generate/index.js.map +1 -0
- package/dist/commands/get-response/get-response.command.d.ts +18 -0
- package/dist/commands/get-response/get-response.command.js +39 -0
- package/dist/commands/get-response/get-response.command.js.map +1 -0
- package/dist/commands/get-response/index.d.ts +1 -0
- package/dist/commands/get-response/index.js +2 -0
- package/dist/commands/get-response/index.js.map +1 -0
- package/dist/commands/lock/index.d.ts +1 -0
- package/dist/commands/lock/index.js +2 -0
- package/dist/commands/lock/index.js.map +1 -0
- package/dist/commands/lock/lock.command.d.ts +18 -0
- package/dist/commands/lock/lock.command.js +31 -0
- package/dist/commands/lock/lock.command.js.map +1 -0
- package/dist/commands/run-action/index.d.ts +1 -0
- package/dist/commands/run-action/index.js +2 -0
- package/dist/commands/run-action/index.js.map +1 -0
- package/dist/commands/run-action/run-action.command.d.ts +12 -0
- package/dist/commands/run-action/run-action.command.js +40 -0
- package/dist/commands/run-action/run-action.command.js.map +1 -0
- package/dist/commands/unlock/index.d.ts +1 -0
- package/dist/commands/unlock/index.js +2 -0
- package/dist/commands/unlock/index.js.map +1 -0
- package/dist/commands/unlock/unlock.command.d.ts +18 -0
- package/dist/commands/unlock/unlock.command.js +35 -0
- package/dist/commands/unlock/unlock.command.js.map +1 -0
- package/dist/commands/validate/index.d.ts +1 -0
- package/dist/commands/validate/index.js +2 -0
- package/dist/commands/validate/index.js.map +1 -0
- package/dist/commands/validate/validate.command.d.ts +17 -0
- package/dist/commands/validate/validate.command.js +62 -0
- package/dist/commands/validate/validate.command.js.map +1 -0
- package/dist/index.js +20 -8
- package/dist/index.js.map +1 -1
- package/dist/resources/octo-v1.schema.json +108 -27
- package/dist/utilities/definition/yaml/yaml-definition.utility.d.ts +103 -13
- package/dist/utilities/definition/yaml/yaml-definition.utility.js +215 -68
- package/dist/utilities/definition/yaml/yaml-definition.utility.js.map +1 -1
- package/dist/utilities/octo/octo.utility.d.ts +65 -0
- package/dist/utilities/octo/octo.utility.js +178 -0
- package/dist/utilities/octo/octo.utility.js.map +1 -0
- package/dist/utilities/process/process.utility.d.ts +8 -0
- package/dist/utilities/process/process.utility.js +8 -0
- package/dist/utilities/process/process.utility.js.map +1 -1
- package/dist/utilities/project-index/project-index.utility.d.ts +27 -0
- package/dist/utilities/project-index/project-index.utility.js +71 -0
- package/dist/utilities/project-index/project-index.utility.js.map +1 -0
- package/dist/utilities/string/string.utility.d.ts +22 -0
- package/dist/utilities/string/string.utility.js +27 -0
- package/dist/utilities/string/string.utility.js.map +1 -1
- package/package.json +11 -8
- package/dist/commands/create-cdk/create-cdk.command.js +0 -70
- package/dist/commands/create-cdk/create-cdk.command.js.map +0 -1
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/index.d.ts +0 -10
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/index.js +0 -107
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/index.js.map +0 -1
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/README.md.ejs +0 -23
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/eslint.config.js.ejs +0 -337
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/gitignore.ejs +0 -82
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/gitkeep.ejs +0 -0
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/package.json.ejs +0 -57
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/prettierrc.ejs +0 -5
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/anchors/app/app.anchor.schema.ts.ejs +0 -19
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/anchors/app/app.anchor.ts.ejs +0 -17
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/factories/dummy-credentials.factory.ts.ejs +0 -28
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/modules/app/dummy-app/dummy-app.module.spec.ts.ejs +0 -90
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/modules/app/dummy-app/dummy-app.module.ts.ejs +0 -16
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/modules/app/dummy-app/index.schema.ts.ejs +0 -10
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/modules/app/dummy-app/index.ts.ejs +0 -3
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/modules/app/dummy-app/models/app/actions/add-dummy-app.model.action.ts.ejs +0 -59
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/modules/app/dummy-app/models/app/index.ts.ejs +0 -1
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/resources/http-fetch/actions/add-http-fetch.resource.action.ts.ejs +0 -55
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/resources/http-fetch/http-fetch.resource.ts.ejs +0 -12
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/resources/http-fetch/index.schema.ts.ejs +0 -35
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/resources/http-fetch/index.ts.ejs +0 -3
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/utilities/dummy/dummy.utility.ts.ejs +0 -11
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/tsconfig.build.json.ejs +0 -11
- package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/tsconfig.json.ejs +0 -39
- package/dist/commands/create-cdk/index.d.ts +0 -1
- package/dist/commands/create-cdk/index.js +0 -2
- package/dist/commands/create-cdk/index.js.map +0 -1
- package/dist/commands/create-resource/create-resource.command.js.map +0 -1
- package/dist/commands/create-resource/generator-octo-resource-template/generators/app/index.js.map +0 -1
- package/dist/commands/create-resource/generator-octo-resource-template/generators/app/templates/resources/resource/actions/update-tags.resource.action.ts.ejs +0 -86
- package/dist/commands/create-resource/generator-octo-resource-template/generators/app/templates/resources/resource/actions/validate.resource.action.ts.ejs +0 -40
- package/dist/commands/create-resource/generator-octo-resource-template/generators/app/templates/resources/resource/resource.ts.ejs +0 -12
- package/dist/commands/create-resource/index.d.ts +0 -1
- package/dist/commands/create-resource/index.js +0 -2
- package/dist/commands/create-resource/index.js.map +0 -1
- package/dist/commands/run/index.d.ts +0 -1
- package/dist/commands/run/index.js +0 -2
- package/dist/commands/run/index.js.map +0 -1
- package/dist/commands/run/run.command.d.ts +0 -11
- package/dist/commands/run/run.command.js +0 -96
- package/dist/commands/run/run.command.js.map +0 -1
- package/dist/commands/state/index.d.ts +0 -1
- package/dist/commands/state/index.js +0 -2
- package/dist/commands/state/index.js.map +0 -1
- package/dist/commands/state/state.command.d.ts +0 -14
- package/dist/commands/state/state.command.js +0 -79
- package/dist/commands/state/state.command.js.map +0 -1
- /package/dist/commands/{create-resource/generator-octo-resource-template → create-external-resource/generator-octo-external-resource-template}/generators/app/templates/resources/resource/index.schema.ts.ejs +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Generator, { type BaseOptions } from 'yeoman-generator';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export default class extends Generator {
|
|
6
|
+
private readonly packageName;
|
|
7
|
+
private readonly projectRootDir;
|
|
8
|
+
private readonly resourceName;
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
constructor(args: string[], opts: BaseOptions);
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
end(): void;
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
initializing(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
writing(): Promise<void>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { readdir, stat } from 'fs/promises';
|
|
2
|
+
import { join, resolve } from 'path';
|
|
3
|
+
import Generator, {} from 'yeoman-generator';
|
|
4
|
+
import { ProjectIndexUtility } from '../../../../../utilities/project-index/project-index.utility.js';
|
|
5
|
+
import { StringUtility } from '../../../../../utilities/string/string.utility.js';
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export default class extends Generator {
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
constructor(args, opts) {
|
|
14
|
+
super(args, opts);
|
|
15
|
+
this.resourceName = args[0];
|
|
16
|
+
this.packageName = args[1];
|
|
17
|
+
this.projectRootDir = args[2];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
end() {
|
|
23
|
+
const targetPath = resolve(join(this.projectRootDir, 'src', 'resources', this.resourceName));
|
|
24
|
+
this.log('✅ Your terraform resource has been generated successfully!');
|
|
25
|
+
this.log(`📁 Resource created at: ${targetPath}`);
|
|
26
|
+
ProjectIndexUtility.addImport(this.projectRootDir, `./resources/${this.resourceName}/index.js`);
|
|
27
|
+
this.log('📦 Next steps:');
|
|
28
|
+
this.log(` Address all "Fix me" in generated files`);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
async initializing() {
|
|
34
|
+
const targetPath = resolve(join(this.projectRootDir, 'src', 'resources', this.resourceName));
|
|
35
|
+
// Check if directory already exists and is not empty.
|
|
36
|
+
let targetPathStat;
|
|
37
|
+
try {
|
|
38
|
+
targetPathStat = await stat(targetPath);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (error.code !== 'ENOENT') {
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (targetPathStat?.isDirectory()) {
|
|
46
|
+
const files = await readdir(targetPath);
|
|
47
|
+
if (files.length > 0) {
|
|
48
|
+
throw new Error(`Directory '${targetPath}' already exists and is not empty!`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Set the destination root to the resource directory.
|
|
52
|
+
this.destinationRoot(targetPath);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
async writing() {
|
|
58
|
+
const templateData = {
|
|
59
|
+
packageName: this.packageName,
|
|
60
|
+
resourceName: this.resourceName,
|
|
61
|
+
resourceNamePascal: StringUtility.toPascalCase(this.resourceName),
|
|
62
|
+
};
|
|
63
|
+
// Create the terraform resource file.
|
|
64
|
+
this.fs.copyTpl(this.templatePath('resources/resource/resource.ts.ejs'), this.destinationPath(`${this.resourceName}.resource.ts`), templateData);
|
|
65
|
+
// Create schema file.
|
|
66
|
+
this.fs.copyTpl(this.templatePath('resources/resource/index.schema.ts.ejs'), this.destinationPath('index.schema.ts'), templateData);
|
|
67
|
+
// Create index.ts
|
|
68
|
+
this.fs.copyTpl(this.templatePath('resources/resource/index.ts.ejs'), this.destinationPath('index.ts'), templateData);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/commands/create-terraform-resource/generator-octo-terraform-resource-template/generators/app/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BaseResourceSchema, Schema, Validate } from '@quadnix/octo';
|
|
2
|
+
|
|
3
|
+
export class <%= resourceNamePascal %>Schema extends BaseResourceSchema {
|
|
4
|
+
@Validate({
|
|
5
|
+
destruct: (value: <%= resourceNamePascal %>Schema['properties']): string[] => [
|
|
6
|
+
// Fix me: Add properties for validation.
|
|
7
|
+
],
|
|
8
|
+
options: { minLength: 1 },
|
|
9
|
+
})
|
|
10
|
+
override properties = Schema<{
|
|
11
|
+
// Fix me: Add resource properties.
|
|
12
|
+
}>();
|
|
13
|
+
|
|
14
|
+
@Validate({
|
|
15
|
+
destruct: (value: <%= resourceNamePascal %>Schema['response']): string[] => {
|
|
16
|
+
const subjects: string[] = [];
|
|
17
|
+
// Fix me: Add a check per response key below.
|
|
18
|
+
if (value.SomeId) {
|
|
19
|
+
subjects.push(value.SomeId);
|
|
20
|
+
}
|
|
21
|
+
return subjects;
|
|
22
|
+
},
|
|
23
|
+
options: { minLength: 1 },
|
|
24
|
+
})
|
|
25
|
+
/**
|
|
26
|
+
* One key per Terraform output exposed in `toHCL()`. Each is emitted as an
|
|
27
|
+
* `output "${resourceId}-${key}"` and is how other resources and modules consume this resource,
|
|
28
|
+
* via `terraform.getRef(this, 'SomeId')`.
|
|
29
|
+
*
|
|
30
|
+
* The value passed to `Schema<...>()` is that key's **default**, and it is not decoration: it
|
|
31
|
+
* becomes the key's terragrunt `mock_outputs` entry, which is what a consumer plans against
|
|
32
|
+
* before this resource has been applied. Make each one a syntactically valid example of the real
|
|
33
|
+
* thing - a plausible ARN, a plausible id - because a consumer's `plan` runs the provider's own
|
|
34
|
+
* parsing over it. Without a default the mock falls back to the literal `mock-<outputName>`, and
|
|
35
|
+
* any consumer whose attribute must parse as an ARN or an id fails to plan.
|
|
36
|
+
*/
|
|
37
|
+
override response = Schema<{
|
|
38
|
+
// Fix me: Rename, and add one entry per output.
|
|
39
|
+
SomeId?: string;
|
|
40
|
+
}>({
|
|
41
|
+
SomeId: 'some-0123456789abcdef0',
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { <%= resourceNamePascal %> } from './<%= resourceName %>.resource.js';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ATerraformResource,
|
|
3
|
+
Diff,
|
|
4
|
+
DiffAction,
|
|
5
|
+
DiffUtility,
|
|
6
|
+
Resource,
|
|
7
|
+
type TerraformModuleScope,
|
|
8
|
+
} from '@quadnix/octo';
|
|
9
|
+
import { <%= resourceNamePascal %>Schema } from './index.schema.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A Terraform-managed resource. Its lifecycle (create / update / delete) is handled by Terraform
|
|
13
|
+
* via `toHCL()`, which Octo invokes automatically while generating Terraform files.
|
|
14
|
+
*
|
|
15
|
+
* Terraform resources cannot have resource actions — registering one throws. For a resource whose
|
|
16
|
+
* lifecycle runs outside Terraform (SDK calls, scripts), use `create-external-resource` instead.
|
|
17
|
+
*/
|
|
18
|
+
@Resource<<%= resourceNamePascal %>>('<%= packageName %>', '<%= resourceName %>', <%= resourceNamePascal %>Schema)
|
|
19
|
+
export class <%= resourceNamePascal %> extends ATerraformResource<<%= resourceNamePascal %>Schema, <%= resourceNamePascal %>> {
|
|
20
|
+
declare properties: <%= resourceNamePascal %>Schema['properties'];
|
|
21
|
+
declare response: <%= resourceNamePascal %>Schema['response'];
|
|
22
|
+
|
|
23
|
+
constructor(resourceId: string, properties: <%= resourceNamePascal %>Schema['properties'], parents: []) {
|
|
24
|
+
super(resourceId, properties, parents);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Declares what a property change does to the real resource.
|
|
29
|
+
*
|
|
30
|
+
* The default emits a granular in-place `UPDATE`, which is wrong for any attribute the provider
|
|
31
|
+
* marks force-new: Terraform would recreate the resource while Octo reported an update, and
|
|
32
|
+
* `octo validate` would flag the recreate as unexplained because there is no reason string to
|
|
33
|
+
* show. Returning `REPLACE` states the recreate up front, and the reason is what validate prints.
|
|
34
|
+
*
|
|
35
|
+
* Fix me: list the force-new attributes in the reason. If some properties are updatable in place
|
|
36
|
+
* and others are not, compare them separately and emit `REPLACE` only for the force-new ones.
|
|
37
|
+
*/
|
|
38
|
+
override async diffProperties(previous: <%= resourceNamePascal %>): Promise<Diff[]> {
|
|
39
|
+
if (!DiffUtility.isObjectDeepEquals(previous.properties, this.properties)) {
|
|
40
|
+
return [
|
|
41
|
+
new Diff(
|
|
42
|
+
this,
|
|
43
|
+
DiffAction.REPLACE,
|
|
44
|
+
'resourceId',
|
|
45
|
+
this.getContext(),
|
|
46
|
+
'Fix me: <attribute> is force-new on <terraform_resource_type>; a change recreates the resource',
|
|
47
|
+
),
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
override async toHCL(terraform: TerraformModuleScope): Promise<void> {
|
|
55
|
+
// The `as` cast is load-bearing: without it `this` stays polymorphic, the scope's response type
|
|
56
|
+
// resolves against `this` rather than this schema, and `output()` below does not typecheck.
|
|
57
|
+
const octoResource = terraform.addOctoTerraformResource(this as <%= resourceNamePascal %>, {
|
|
58
|
+
// Fix me: bind to the provider this resource deploys into (accountId + regionId of a registered provider).
|
|
59
|
+
provider: { accountId: 'Fix me', regionId: 'Fix me' },
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const tfResource = octoResource.addTerraformResource(
|
|
63
|
+
// Fix me: set the Terraform resource type (e.g. 'aws_vpc').
|
|
64
|
+
'terraform_resource_type',
|
|
65
|
+
this.resourceId,
|
|
66
|
+
{
|
|
67
|
+
// Fix me: set Terraform attributes. Reference a parent's output via
|
|
68
|
+
// terraform.getRef(this.parents[0], 'SomeResponseKey').
|
|
69
|
+
},
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// One entry per key declared on the schema's `response`. The two must agree: a key declared and
|
|
73
|
+
// not emitted here makes `octo commit` throw "missing terraform outputs" after a real apply,
|
|
74
|
+
// which is the most expensive place to find out.
|
|
75
|
+
octoResource.output({
|
|
76
|
+
SomeId: terraform.raw(`${tfResource.address}.id`),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (Object.keys(this.tags).length > 0) {
|
|
80
|
+
tfResource.attribute('tags', this.tags);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createTerraformResourceCommand } from './create-terraform-resource.command.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/create-terraform-resource/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
+
type GenerateCommandArguments = {
|
|
3
|
+
outputDir: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Step 1 of the octo lifecycle. See `Octo.generate()`.
|
|
7
|
+
*
|
|
8
|
+
* The state is refreshed before octo boots, because booting is what reads it.
|
|
9
|
+
*/
|
|
10
|
+
export declare const generateCommand: {
|
|
11
|
+
builder: (yargs: Argv) => Argv;
|
|
12
|
+
command: string;
|
|
13
|
+
describe: string;
|
|
14
|
+
handler: (argv: ArgumentsCamelCase<GenerateCommandArguments>) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { Container, StateManagementService } from '@quadnix/octo';
|
|
3
|
+
import { OctoUtility } from '../../utilities/octo/octo.utility.js';
|
|
4
|
+
/**
|
|
5
|
+
* Step 1 of the octo lifecycle. See `Octo.generate()`.
|
|
6
|
+
*
|
|
7
|
+
* The state is refreshed before octo boots, because booting is what reads it.
|
|
8
|
+
*/
|
|
9
|
+
export const generateCommand = {
|
|
10
|
+
builder: (yargs) => {
|
|
11
|
+
return yargs.option('outputDir', {
|
|
12
|
+
alias: 'o',
|
|
13
|
+
demandOption: true,
|
|
14
|
+
description: 'Directory to write the generated Terragrunt module folders into. Folders are overwritten in place, never ' +
|
|
15
|
+
'wiped; a deleted module leaves an emptied folder so a later apply destroys its resources.',
|
|
16
|
+
type: 'string',
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
command: 'generate',
|
|
20
|
+
describe: 'Step 1: generate Terragrunt module folders representing the full desired infrastructure.',
|
|
21
|
+
handler: async (argv) => {
|
|
22
|
+
const { outputDir } = argv;
|
|
23
|
+
await OctoUtility.runCommand('generate', async () => {
|
|
24
|
+
await OctoUtility.bootStateProvider();
|
|
25
|
+
await (await Container.getInstance().get(StateManagementService)).refreshState();
|
|
26
|
+
const { app, octo } = await OctoUtility.bootOcto();
|
|
27
|
+
const resolvedOutputDir = resolve(process.cwd(), outputDir);
|
|
28
|
+
await octo.generate(app, { outputDir: resolvedOutputDir });
|
|
29
|
+
// Nothing is printed here. The listeners report what was written and that the mode finished,
|
|
30
|
+
// on stderr, and failures reach stderr via `reportError`. Generate has no output of its own, so
|
|
31
|
+
// stdout stays empty.
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=generate.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.command.js","sourceRoot":"","sources":["../../../src/commands/generate/generate.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAMnE;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,CAAC,KAAW,EAAQ,EAAE;QAC7B,OAAO,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;YAC/B,KAAK,EAAE,GAAG;YACV,YAAY,EAAE,IAAI;YAClB,WAAW,EACT,2GAA2G;gBAC3G,2FAA2F;YAC7F,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,0FAA0F;IACpG,OAAO,EAAE,KAAK,EAAE,IAAkD,EAAiB,EAAE;QACnF,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAE3B,MAAM,WAAW,CAAC,UAAU,CAAC,UAAU,EAAE,KAAK,IAAI,EAAE;YAClD,MAAM,WAAW,CAAC,iBAAiB,EAAE,CAAC;YACtC,MAAM,CAAC,MAAM,SAAS,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;YAEjF,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;YAEnD,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;YAC5D,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC,CAAC;YAE3D,6FAA6F;YAC7F,gGAAgG;YAChG,sBAAsB;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generateCommand } from './generate.command.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/generate/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
+
type GetResponseCommandArguments = {
|
|
3
|
+
resourceId: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Prints a resource's recorded response as JSON.
|
|
7
|
+
*
|
|
8
|
+
* Terraform's `data "external"` runs this on every plan and every apply of a folder holding an
|
|
9
|
+
* external resource; it is not a step you run yourself. It reads octo state and nothing else - no
|
|
10
|
+
* modules are composed and no cloud is called, so it is safe at plan time and costs one file read.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getResponseCommand: {
|
|
13
|
+
builder: (yargs: Argv) => Argv;
|
|
14
|
+
command: string;
|
|
15
|
+
describe: string;
|
|
16
|
+
handler: (argv: ArgumentsCamelCase<GetResponseCommandArguments>) => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Container, StateManagementService } from '@quadnix/octo';
|
|
2
|
+
import { OctoUtility } from '../../utilities/octo/octo.utility.js';
|
|
3
|
+
/**
|
|
4
|
+
* Prints a resource's recorded response as JSON.
|
|
5
|
+
*
|
|
6
|
+
* Terraform's `data "external"` runs this on every plan and every apply of a folder holding an
|
|
7
|
+
* external resource; it is not a step you run yourself. It reads octo state and nothing else - no
|
|
8
|
+
* modules are composed and no cloud is called, so it is safe at plan time and costs one file read.
|
|
9
|
+
*/
|
|
10
|
+
export const getResponseCommand = {
|
|
11
|
+
builder: (yargs) => {
|
|
12
|
+
return yargs.option('resourceId', {
|
|
13
|
+
demandOption: true,
|
|
14
|
+
description: 'The id of the resource whose response should be printed.',
|
|
15
|
+
type: 'string',
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
command: 'get-response',
|
|
19
|
+
describe: "Print a resource's recorded response. Invoked by Terraform for an external resource.",
|
|
20
|
+
handler: async (argv) => {
|
|
21
|
+
const { resourceId } = argv;
|
|
22
|
+
try {
|
|
23
|
+
await OctoUtility.bootStateProvider();
|
|
24
|
+
const stateManagementService = await Container.getInstance().get(StateManagementService);
|
|
25
|
+
const response = await stateManagementService.getResourceResponse(resourceId);
|
|
26
|
+
if (!response) {
|
|
27
|
+
throw new Error(`No response recorded for resource "${resourceId}"! ` +
|
|
28
|
+
'Octo records one when the resource is applied, and commits it with the rest of the run.');
|
|
29
|
+
}
|
|
30
|
+
// stdout carries ONLY the response JSON - terraform's `data "external"` consumes it.
|
|
31
|
+
process.stdout.write(JSON.stringify(response));
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
OctoUtility.reportError(error);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=get-response.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-response.command.js","sourceRoot":"","sources":["../../../src/commands/get-response/get-response.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAMnE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO,EAAE,CAAC,KAAW,EAAQ,EAAE;QAC7B,OAAO,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE;YAChC,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE,0DAA0D;YACvE,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,cAAc;IACvB,QAAQ,EAAE,sFAAsF;IAChG,OAAO,EAAE,KAAK,EAAE,IAAqD,EAAiB,EAAE;QACtF,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QAE5B,IAAI,CAAC;YACH,MAAM,WAAW,CAAC,iBAAiB,EAAE,CAAC;YACtC,MAAM,sBAAsB,GAAG,MAAM,SAAS,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;YAEzF,MAAM,QAAQ,GAAG,MAAM,sBAAsB,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;YAC9E,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,MAAM,IAAI,KAAK,CACb,sCAAsC,UAAU,KAAK;oBACnD,yFAAyF,CAC5F,CAAC;YACJ,CAAC;YAED,qFAAqF;YACrF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QACjD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getResponseCommand } from './get-response.command.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/get-response/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { lockCommand } from './lock.command.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/lock/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
+
type LockCommandArguments = {
|
|
3
|
+
lockId?: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Takes the app lock, which `apply` and `commit` both require. With `--lockId`, resumes the run
|
|
7
|
+
* already holding that lock, which is how a run that died is finished.
|
|
8
|
+
*
|
|
9
|
+
* The lock id is the only thing printed on stdout, so a shell can capture it:
|
|
10
|
+
* `LOCK_ID=$(octo lock)`. Everything else goes to stderr.
|
|
11
|
+
*/
|
|
12
|
+
export declare const lockCommand: {
|
|
13
|
+
builder: (yargs: Argv) => Argv;
|
|
14
|
+
command: string;
|
|
15
|
+
describe: string;
|
|
16
|
+
handler: (argv: ArgumentsCamelCase<LockCommandArguments>) => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Container, StateManagementService } from '@quadnix/octo';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { OctoUtility } from '../../utilities/octo/octo.utility.js';
|
|
4
|
+
/**
|
|
5
|
+
* Takes the app lock, which `apply` and `commit` both require. With `--lockId`, resumes the run
|
|
6
|
+
* already holding that lock, which is how a run that died is finished.
|
|
7
|
+
*
|
|
8
|
+
* The lock id is the only thing printed on stdout, so a shell can capture it:
|
|
9
|
+
* `LOCK_ID=$(octo lock)`. Everything else goes to stderr.
|
|
10
|
+
*/
|
|
11
|
+
export const lockCommand = {
|
|
12
|
+
builder: (yargs) => {
|
|
13
|
+
return yargs.option('lockId', {
|
|
14
|
+
demandOption: false,
|
|
15
|
+
description: 'Resume the run holding this lock ID instead of taking a new lock. Stop that run first.',
|
|
16
|
+
type: 'string',
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
command: 'lock',
|
|
20
|
+
describe: 'Take the app state lock, printing its ID. Required before apply and commit.',
|
|
21
|
+
handler: async (argv) => {
|
|
22
|
+
await OctoUtility.runCommand('lock', async () => {
|
|
23
|
+
await OctoUtility.bootStateProvider();
|
|
24
|
+
const stateManagementService = await Container.getInstance().get(StateManagementService);
|
|
25
|
+
const { lockId } = await stateManagementService.lockApp(argv.lockId);
|
|
26
|
+
console.error(chalk.green(argv.lockId ? 'App lock is resumed.' : 'App is locked.'));
|
|
27
|
+
console.log(lockId);
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=lock.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock.command.js","sourceRoot":"","sources":["../../../src/commands/lock/lock.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAMnE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,OAAO,EAAE,CAAC,KAAW,EAAQ,EAAE;QAC7B,OAAO,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE;YAC5B,YAAY,EAAE,KAAK;YACnB,WAAW,EAAE,wFAAwF;YACrG,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE,6EAA6E;IACvF,OAAO,EAAE,KAAK,EAAE,IAA8C,EAAiB,EAAE;QAC/E,MAAM,WAAW,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;YAC9C,MAAM,WAAW,CAAC,iBAAiB,EAAE,CAAC;YACtC,MAAM,sBAAsB,GAAG,MAAM,SAAS,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;YAEzF,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAErE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;YACpF,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { runActionCommand } from './run-action.command.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/run-action/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
+
type RunActionCommandArguments = {
|
|
3
|
+
input?: string[];
|
|
4
|
+
resourceId: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const runActionCommand: {
|
|
7
|
+
builder: (yargs: Argv) => Argv;
|
|
8
|
+
command: string;
|
|
9
|
+
describe: string;
|
|
10
|
+
handler: (argv: ArgumentsCamelCase<RunActionCommandArguments>) => Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { OctoUtility } from '../../utilities/octo/octo.utility.js';
|
|
2
|
+
export const runActionCommand = {
|
|
3
|
+
builder: (yargs) => {
|
|
4
|
+
return yargs
|
|
5
|
+
.option('resourceId', {
|
|
6
|
+
demandOption: true,
|
|
7
|
+
description: 'The id of the resource whose action should run.',
|
|
8
|
+
type: 'string',
|
|
9
|
+
})
|
|
10
|
+
.option('input', {
|
|
11
|
+
array: true,
|
|
12
|
+
default: [],
|
|
13
|
+
description: 'Parent response input, as <parentResourceId>.<responseKey>=<value>. Repeatable.',
|
|
14
|
+
type: 'string',
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
command: 'run-action',
|
|
18
|
+
describe: 'Run a single resource action. Invoked by Terraform mid-apply for an external resource.',
|
|
19
|
+
handler: async (argv) => {
|
|
20
|
+
const { input, resourceId } = argv;
|
|
21
|
+
await OctoUtility.runCommand('run-action', async () => {
|
|
22
|
+
const inputs = {};
|
|
23
|
+
for (const entry of input ?? []) {
|
|
24
|
+
const separatorIndex = entry.indexOf('=');
|
|
25
|
+
if (separatorIndex < 0) {
|
|
26
|
+
throw new Error(`Invalid --input "${entry}"! Expected <parentResourceId>.<responseKey>=<value>.`);
|
|
27
|
+
}
|
|
28
|
+
inputs[entry.slice(0, separatorIndex)] = entry.slice(separatorIndex + 1);
|
|
29
|
+
}
|
|
30
|
+
const { app, octo } = await OctoUtility.bootOcto();
|
|
31
|
+
const result = await octo.runAction(app, {
|
|
32
|
+
inputs,
|
|
33
|
+
resourceId,
|
|
34
|
+
});
|
|
35
|
+
// stdout carries ONLY the response JSON — terraform's `data "external"` consumes it.
|
|
36
|
+
process.stdout.write(JSON.stringify(result.response));
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=run-action.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-action.command.js","sourceRoot":"","sources":["../../../src/commands/run-action/run-action.command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAOnE,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,OAAO,EAAE,CAAC,KAAW,EAAQ,EAAE;QAC7B,OAAO,KAAK;aACT,MAAM,CAAC,YAAY,EAAE;YACpB,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE,iDAAiD;YAC9D,IAAI,EAAE,QAAQ;SACf,CAAC;aACD,MAAM,CAAC,OAAO,EAAE;YACf,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,iFAAiF;YAC9F,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,YAAY;IACrB,QAAQ,EAAE,wFAAwF;IAClG,OAAO,EAAE,KAAK,EAAE,IAAmD,EAAiB,EAAE;QACpF,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QAEnC,MAAM,WAAW,CAAC,UAAU,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;YACpD,MAAM,MAAM,GAA2B,EAAE,CAAC;YAC1C,KAAK,MAAM,KAAK,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;gBAChC,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBAC1C,IAAI,cAAc,GAAG,CAAC,EAAE,CAAC;oBACvB,MAAM,IAAI,KAAK,CAAC,oBAAoB,KAAK,uDAAuD,CAAC,CAAC;gBACpG,CAAC;gBACD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;YAC3E,CAAC;YAED,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;YAEnD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE;gBACvC,MAAM;gBACN,UAAU;aACX,CAAC,CAAC;YAEH,qFAAqF;YACrF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { unlockCommand } from './unlock.command.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/unlock/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
+
type UnlockCommandArguments = {
|
|
3
|
+
lockId: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Finishes a run as it stands and releases its lock.
|
|
7
|
+
*
|
|
8
|
+
* A successful `commit` releases its own lock, so this is for a run that will not reach one - a run
|
|
9
|
+
* that never applied, or one somebody finished by hand. With a remote state provider, releasing
|
|
10
|
+
* seals what the run wrote.
|
|
11
|
+
*/
|
|
12
|
+
export declare const unlockCommand: {
|
|
13
|
+
builder: (yargs: Argv) => Argv;
|
|
14
|
+
command: string;
|
|
15
|
+
describe: string;
|
|
16
|
+
handler: (argv: ArgumentsCamelCase<UnlockCommandArguments>) => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Container, StateManagementService } from '@quadnix/octo';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { OctoUtility } from '../../utilities/octo/octo.utility.js';
|
|
4
|
+
/**
|
|
5
|
+
* Finishes a run as it stands and releases its lock.
|
|
6
|
+
*
|
|
7
|
+
* A successful `commit` releases its own lock, so this is for a run that will not reach one - a run
|
|
8
|
+
* that never applied, or one somebody finished by hand. With a remote state provider, releasing
|
|
9
|
+
* seals what the run wrote.
|
|
10
|
+
*/
|
|
11
|
+
export const unlockCommand = {
|
|
12
|
+
builder: (yargs) => {
|
|
13
|
+
return yargs.option('lockId', {
|
|
14
|
+
demandOption: true,
|
|
15
|
+
description: 'The lock ID to release, as printed by `octo lock`.',
|
|
16
|
+
type: 'string',
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
command: 'unlock',
|
|
20
|
+
describe: 'Finish a run as it stands, releasing its app state lock.',
|
|
21
|
+
handler: async (argv) => {
|
|
22
|
+
const { lockId } = argv;
|
|
23
|
+
await OctoUtility.runCommand('unlock', async () => {
|
|
24
|
+
await OctoUtility.bootStateProvider();
|
|
25
|
+
const stateManagementService = await Container.getInstance().get(StateManagementService);
|
|
26
|
+
if (!(await stateManagementService.getAppLock())) {
|
|
27
|
+
console.error(chalk.green('App is already unlocked.'));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
await stateManagementService.unlockApp(lockId);
|
|
31
|
+
console.error(chalk.green(`App was unlocked, releasing lock ID "${lockId}".`));
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=unlock.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unlock.command.js","sourceRoot":"","sources":["../../../src/commands/unlock/unlock.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAMnE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,OAAO,EAAE,CAAC,KAAW,EAAQ,EAAE;QAC7B,OAAO,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE;YAC5B,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE,oDAAoD;YACjE,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,0DAA0D;IACpE,OAAO,EAAE,KAAK,EAAE,IAAgD,EAAiB,EAAE;QACjF,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAExB,MAAM,WAAW,CAAC,UAAU,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;YAChD,MAAM,WAAW,CAAC,iBAAiB,EAAE,CAAC;YACtC,MAAM,sBAAsB,GAAG,MAAM,SAAS,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;YAEzF,IAAI,CAAC,CAAC,MAAM,sBAAsB,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;gBACjD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC,CAAC;gBACvD,OAAO;YACT,CAAC;YAED,MAAM,sBAAsB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAC/C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,wCAAwC,MAAM,IAAI,CAAC,CAAC,CAAC;QACjF,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { validateCommand } from './validate.command.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/validate/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
+
type ValidateCommandArguments = {
|
|
3
|
+
terraformBinary?: string;
|
|
4
|
+
terragruntBinary?: string;
|
|
5
|
+
terragruntDir: string;
|
|
6
|
+
timeoutInMs?: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Step 2 of the octo lifecycle. See `Octo.validate()`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const validateCommand: {
|
|
12
|
+
builder: (yargs: Argv) => Argv;
|
|
13
|
+
command: string;
|
|
14
|
+
describe: string;
|
|
15
|
+
handler: (argv: ArgumentsCamelCase<ValidateCommandArguments>) => Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
export {};
|