@quadnix/octo 0.0.30 → 0.1.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 +25 -3
- package/dist/app.type.d.ts +143 -4
- package/dist/app.type.js +80 -9
- package/dist/app.type.js.map +1 -1
- package/dist/decorators/action.decorator.d.ts +10 -6
- package/dist/decorators/action.decorator.js +19 -6
- package/dist/decorators/action.decorator.js.map +1 -1
- package/dist/decorators/anchor.decorator.d.ts +12 -5
- package/dist/decorators/anchor.decorator.js +12 -5
- package/dist/decorators/anchor.decorator.js.map +1 -1
- package/dist/decorators/enable-hook.decorator.d.ts +1 -1
- package/dist/decorators/enable-hook.decorator.js +1 -1
- package/dist/decorators/factory.decorator.d.ts +18 -34
- package/dist/decorators/factory.decorator.js +18 -34
- package/dist/decorators/factory.decorator.js.map +1 -1
- package/dist/decorators/model.decorator.d.ts +1 -1
- package/dist/decorators/model.decorator.js +1 -1
- package/dist/decorators/module.decorator.d.ts +16 -10
- package/dist/decorators/module.decorator.js +16 -10
- package/dist/decorators/module.decorator.js.map +1 -1
- package/dist/decorators/on-event.decorator.d.ts +5 -0
- package/dist/decorators/on-event.decorator.js +5 -0
- package/dist/decorators/on-event.decorator.js.map +1 -1
- package/dist/decorators/validate.decorator.d.ts +15 -1
- package/dist/decorators/validate.decorator.js +15 -1
- package/dist/decorators/validate.decorator.js.map +1 -1
- package/dist/errors/container.error.d.ts +18 -0
- package/dist/errors/container.error.js +18 -0
- package/dist/errors/container.error.js.map +1 -1
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.js +1 -0
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/module.error.d.ts +6 -0
- package/dist/errors/module.error.js +6 -0
- package/dist/errors/module.error.js.map +1 -1
- package/dist/errors/node.error.d.ts +56 -0
- package/dist/errors/node.error.js +56 -0
- package/dist/errors/node.error.js.map +1 -1
- package/dist/errors/schema.error.d.ts +6 -0
- package/dist/errors/schema.error.js +6 -0
- package/dist/errors/schema.error.js.map +1 -1
- package/dist/errors/terraform.error.d.ts +19 -0
- package/dist/errors/terraform.error.js +23 -0
- package/dist/errors/terraform.error.js.map +1 -0
- package/dist/errors/transaction.error.d.ts +61 -0
- package/dist/errors/transaction.error.js +61 -0
- package/dist/errors/transaction.error.js.map +1 -1
- package/dist/events/action.event.d.ts +0 -2
- package/dist/events/action.event.js +0 -2
- package/dist/events/action.event.js.map +1 -1
- package/dist/events/event.model.d.ts +21 -5
- package/dist/events/event.model.js +11 -5
- package/dist/events/event.model.js.map +1 -1
- package/dist/events/hook/commit.hook.event.d.ts +0 -6
- package/dist/events/hook/commit.hook.event.js +0 -6
- package/dist/events/hook/commit.hook.event.js.map +1 -1
- package/dist/events/hook/hook.event.d.ts +0 -2
- package/dist/events/hook/hook.event.js +0 -2
- package/dist/events/hook/hook.event.js.map +1 -1
- package/dist/events/hook/model.hook.event.d.ts +0 -6
- package/dist/events/hook/model.hook.event.js +0 -6
- package/dist/events/hook/model.hook.event.js.map +1 -1
- package/dist/events/hook/resource.hook.event.d.ts +0 -6
- package/dist/events/hook/resource.hook.event.js +0 -6
- package/dist/events/hook/resource.hook.event.js.map +1 -1
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.js +3 -0
- package/dist/events/index.js.map +1 -1
- package/dist/events/mode-result.event.d.ts +57 -0
- package/dist/events/mode-result.event.js +24 -0
- package/dist/events/mode-result.event.js.map +1 -0
- package/dist/events/mode.event.d.ts +57 -0
- package/dist/events/mode.event.js +32 -0
- package/dist/events/mode.event.js.map +1 -0
- package/dist/events/module.event.d.ts +0 -2
- package/dist/events/module.event.js +0 -2
- package/dist/events/module.event.js.map +1 -1
- package/dist/events/registration.event.d.ts +18 -14
- package/dist/events/registration.event.js +18 -14
- package/dist/events/registration.event.js.map +1 -1
- package/dist/events/serialization.event.d.ts +15 -12
- package/dist/events/serialization.event.js +15 -12
- package/dist/events/serialization.event.js.map +1 -1
- package/dist/events/terraform.event.d.ts +42 -0
- package/dist/events/terraform.event.js +31 -0
- package/dist/events/terraform.event.js.map +1 -0
- package/dist/events/transaction.event.d.ts +0 -37
- package/dist/events/transaction.event.js +0 -28
- package/dist/events/transaction.event.js.map +1 -1
- package/dist/functions/container/container.d.ts +54 -13
- package/dist/functions/container/container.js +63 -18
- package/dist/functions/container/container.js.map +1 -1
- package/dist/functions/container/test-container.d.ts +43 -29
- package/dist/functions/container/test-container.js +71 -43
- package/dist/functions/container/test-container.js.map +1 -1
- package/dist/functions/dependency/dependency.d.ts +82 -8
- package/dist/functions/dependency/dependency.js +80 -14
- package/dist/functions/dependency/dependency.js.map +1 -1
- package/dist/functions/diff/aggregate-resource-actions.d.ts +19 -0
- package/dist/functions/diff/aggregate-resource-actions.js +41 -0
- package/dist/functions/diff/aggregate-resource-actions.js.map +1 -0
- package/dist/functions/diff/diff-metadata.d.ts +21 -3
- package/dist/functions/diff/diff-metadata.js +18 -0
- package/dist/functions/diff/diff-metadata.js.map +1 -1
- package/dist/functions/diff/diff.d.ts +55 -1
- package/dist/functions/diff/diff.js +44 -3
- package/dist/functions/diff/diff.js.map +1 -1
- package/dist/functions/diff/diff.utility.d.ts +17 -2
- package/dist/functions/diff/diff.utility.js +53 -38
- package/dist/functions/diff/diff.utility.js.map +1 -1
- package/dist/functions/hook/commit.hook.d.ts +16 -1
- package/dist/functions/hook/commit.hook.js +21 -6
- package/dist/functions/hook/commit.hook.js.map +1 -1
- package/dist/functions/hook/model-action.hook.d.ts +16 -1
- package/dist/functions/hook/model-action.hook.js +21 -6
- package/dist/functions/hook/model-action.hook.js.map +1 -1
- package/dist/functions/hook/resource-action.hook.d.ts +16 -1
- package/dist/functions/hook/resource-action.hook.js +21 -6
- package/dist/functions/hook/resource-action.hook.js.map +1 -1
- package/dist/functions/node/node-action.abstract.d.ts +23 -0
- package/dist/functions/node/node-action.abstract.js +20 -0
- package/dist/functions/node/node-action.abstract.js.map +1 -1
- package/dist/functions/node/node.abstract.d.ts +56 -5
- package/dist/functions/node/node.abstract.js +85 -12
- package/dist/functions/node/node.abstract.js.map +1 -1
- package/dist/functions/node/node.interface.d.ts +1 -0
- package/dist/functions/schema/schema.d.ts +7 -0
- package/dist/functions/schema/schema.js +9 -0
- package/dist/functions/schema/schema.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +244 -14
- package/dist/main.js +361 -72
- package/dist/main.js.map +1 -1
- package/dist/models/account/account.model.d.ts +37 -7
- package/dist/models/account/account.model.js +40 -8
- package/dist/models/account/account.model.js.map +1 -1
- package/dist/models/account/account.schema.d.ts +13 -1
- package/dist/models/account/account.schema.js +12 -0
- package/dist/models/account/account.schema.js.map +1 -1
- package/dist/models/app/app.model.d.ts +16 -1
- package/dist/models/app/app.model.js +19 -4
- package/dist/models/app/app.model.js.map +1 -1
- package/dist/models/app/app.schema.d.ts +6 -0
- package/dist/models/app/app.schema.js +6 -0
- package/dist/models/app/app.schema.js.map +1 -1
- package/dist/models/deployment/deployment.model.d.ts +13 -1
- package/dist/models/deployment/deployment.model.js +16 -4
- package/dist/models/deployment/deployment.model.js.map +1 -1
- package/dist/models/deployment/deployment.schema.d.ts +2 -0
- package/dist/models/deployment/deployment.schema.js +2 -0
- package/dist/models/deployment/deployment.schema.js.map +1 -1
- package/dist/models/environment/environment.model.d.ts +13 -1
- package/dist/models/environment/environment.model.js +20 -8
- package/dist/models/environment/environment.model.js.map +1 -1
- package/dist/models/environment/environment.schema.d.ts +2 -0
- package/dist/models/environment/environment.schema.js +2 -0
- package/dist/models/environment/environment.schema.js.map +1 -1
- package/dist/models/execution/execution.model.d.ts +20 -2
- package/dist/models/execution/execution.model.js +46 -28
- package/dist/models/execution/execution.model.js.map +1 -1
- package/dist/models/execution/execution.schema.d.ts +11 -0
- package/dist/models/execution/execution.schema.js +11 -0
- package/dist/models/execution/execution.schema.js.map +1 -1
- package/dist/models/filesystem/filesystem.model.d.ts +27 -1
- package/dist/models/filesystem/filesystem.model.js +30 -4
- package/dist/models/filesystem/filesystem.model.js.map +1 -1
- package/dist/models/filesystem/filesystem.schema.d.ts +5 -0
- package/dist/models/filesystem/filesystem.schema.js +5 -0
- package/dist/models/filesystem/filesystem.schema.js.map +1 -1
- package/dist/models/image/image.model.d.ts +17 -4
- package/dist/models/image/image.model.js +20 -7
- package/dist/models/image/image.model.js.map +1 -1
- package/dist/models/image/image.schema.d.ts +8 -0
- package/dist/models/image/image.schema.js +8 -0
- package/dist/models/image/image.schema.js.map +1 -1
- package/dist/models/model-action.interface.d.ts +17 -4
- package/dist/models/model.abstract.d.ts +96 -1
- package/dist/models/model.abstract.js +106 -7
- package/dist/models/model.abstract.js.map +1 -1
- package/dist/models/model.interface.d.ts +3 -0
- package/dist/models/pipeline/pipeline.model.d.ts +13 -1
- package/dist/models/pipeline/pipeline.model.js +18 -6
- package/dist/models/pipeline/pipeline.model.js.map +1 -1
- package/dist/models/pipeline/pipeline.schema.d.ts +8 -0
- package/dist/models/pipeline/pipeline.schema.js +8 -0
- package/dist/models/pipeline/pipeline.schema.js.map +1 -1
- package/dist/models/region/region.model.d.ts +16 -1
- package/dist/models/region/region.model.js +19 -4
- package/dist/models/region/region.model.js.map +1 -1
- package/dist/models/region/region.schema.d.ts +6 -0
- package/dist/models/region/region.schema.js +6 -0
- package/dist/models/region/region.schema.js.map +1 -1
- package/dist/models/server/server.model.d.ts +13 -1
- package/dist/models/server/server.model.js +16 -4
- package/dist/models/server/server.model.js.map +1 -1
- package/dist/models/server/server.schema.d.ts +3 -1
- package/dist/models/server/server.schema.js +3 -1
- package/dist/models/server/server.schema.js.map +1 -1
- package/dist/models/service/service.model.d.ts +15 -1
- package/dist/models/service/service.model.js +15 -1
- package/dist/models/service/service.model.js.map +1 -1
- package/dist/models/service/service.schema.d.ts +4 -1
- package/dist/models/service/service.schema.js +4 -1
- package/dist/models/service/service.schema.js.map +1 -1
- package/dist/models/subnet/subnet.model.d.ts +27 -3
- package/dist/models/subnet/subnet.model.js +40 -16
- package/dist/models/subnet/subnet.model.js.map +1 -1
- package/dist/models/subnet/subnet.schema.d.ts +9 -0
- package/dist/models/subnet/subnet.schema.js +9 -0
- package/dist/models/subnet/subnet.schema.js.map +1 -1
- package/dist/modes/apply-transaction.d.ts +23 -0
- package/dist/modes/apply-transaction.js +25 -0
- package/dist/modes/apply-transaction.js.map +1 -0
- package/dist/modes/commit.mode.d.ts +54 -0
- package/dist/modes/commit.mode.js +235 -0
- package/dist/modes/commit.mode.js.map +1 -0
- package/dist/modes/generate.mode.d.ts +29 -0
- package/dist/modes/generate.mode.js +49 -0
- package/dist/modes/generate.mode.js.map +1 -0
- package/dist/modes/run-action.mode.d.ts +30 -0
- package/dist/modes/run-action.mode.js +140 -0
- package/dist/modes/run-action.mode.js.map +1 -0
- package/dist/modes/validate.mode.d.ts +162 -0
- package/dist/modes/validate.mode.js +480 -0
- package/dist/modes/validate.mode.js.map +1 -0
- package/dist/modules/module.abstract.d.ts +51 -0
- package/dist/modules/module.abstract.js +36 -0
- package/dist/modules/module.abstract.js.map +1 -1
- package/dist/modules/module.container.d.ts +36 -0
- package/dist/modules/module.container.js +36 -0
- package/dist/modules/module.container.js.map +1 -1
- package/dist/modules/test-module.container.d.ts +139 -25
- package/dist/modules/test-module.container.js +410 -178
- package/dist/modules/test-module.container.js.map +1 -1
- package/dist/overlays/anchor.abstract.d.ts +32 -1
- package/dist/overlays/anchor.abstract.js +42 -11
- package/dist/overlays/anchor.abstract.js.map +1 -1
- package/dist/overlays/anchor.schema.d.ts +21 -0
- package/dist/overlays/anchor.schema.js +21 -0
- package/dist/overlays/anchor.schema.js.map +1 -1
- package/dist/overlays/overlay-data.repository.d.ts +18 -0
- package/dist/overlays/overlay-data.repository.js +18 -0
- package/dist/overlays/overlay-data.repository.js.map +1 -1
- package/dist/overlays/overlay.abstract.d.ts +56 -1
- package/dist/overlays/overlay.abstract.js +79 -20
- package/dist/overlays/overlay.abstract.js.map +1 -1
- package/dist/overlays/overlay.schema.d.ts +20 -0
- package/dist/overlays/overlay.schema.js +20 -0
- package/dist/overlays/overlay.schema.js.map +1 -1
- package/dist/resources/resource-action.interface.d.ts +26 -2
- package/dist/resources/resource-data.repository.d.ts +63 -1
- package/dist/resources/resource-data.repository.js +94 -4
- package/dist/resources/resource-data.repository.js.map +1 -1
- package/dist/resources/resource.abstract.d.ts +118 -3
- package/dist/resources/resource.abstract.js +166 -33
- package/dist/resources/resource.abstract.js.map +1 -1
- package/dist/resources/resource.schema.d.ts +29 -1
- package/dist/resources/resource.schema.js +28 -0
- package/dist/resources/resource.schema.js.map +1 -1
- package/dist/resources/terraform-resource.abstract.d.ts +44 -0
- package/dist/resources/terraform-resource.abstract.js +45 -0
- package/dist/resources/terraform-resource.abstract.js.map +1 -0
- package/dist/services/event/event.service.d.ts +30 -3
- package/dist/services/event/event.service.js +58 -16
- package/dist/services/event/event.service.js.map +1 -1
- package/dist/services/input/input.service.d.ts +52 -3
- package/dist/services/input/input.service.js +72 -8
- package/dist/services/input/input.service.js.map +1 -1
- package/dist/services/schema-translation/schema-translation.service.d.ts +9 -0
- package/dist/services/schema-translation/schema-translation.service.js +9 -0
- package/dist/services/schema-translation/schema-translation.service.js.map +1 -1
- package/dist/services/serialization/model/model-serialization.service.d.ts +26 -2
- package/dist/services/serialization/model/model-serialization.service.js +110 -62
- package/dist/services/serialization/model/model-serialization.service.js.map +1 -1
- package/dist/services/serialization/resource/resource-serialization.service.d.ts +33 -4
- package/dist/services/serialization/resource/resource-serialization.service.js +64 -28
- package/dist/services/serialization/resource/resource-serialization.service.js.map +1 -1
- package/dist/services/state-management/file-app-lock.utility.d.ts +43 -0
- package/dist/services/state-management/file-app-lock.utility.js +124 -0
- package/dist/services/state-management/file-app-lock.utility.js.map +1 -0
- package/dist/services/state-management/local-encryption.state-provider.d.ts +53 -2
- package/dist/services/state-management/local-encryption.state-provider.js +75 -49
- package/dist/services/state-management/local-encryption.state-provider.js.map +1 -1
- package/dist/services/state-management/local.state-provider.d.ts +49 -2
- package/dist/services/state-management/local.state-provider.js +70 -49
- package/dist/services/state-management/local.state-provider.js.map +1 -1
- package/dist/services/state-management/state-management.service.d.ts +141 -6
- package/dist/services/state-management/state-management.service.js +149 -4
- package/dist/services/state-management/state-management.service.js.map +1 -1
- package/dist/services/state-management/state-provider.interface.d.ts +55 -1
- package/dist/services/state-management/terraform-state.service.d.ts +76 -0
- package/dist/services/state-management/terraform-state.service.js +154 -0
- package/dist/services/state-management/terraform-state.service.js.map +1 -0
- package/dist/services/state-management/test.state-provider.d.ts +38 -1
- package/dist/services/state-management/test.state-provider.js +52 -21
- package/dist/services/state-management/test.state-provider.js.map +1 -1
- package/dist/services/terraform/terraform.service.d.ts +426 -0
- package/dist/services/terraform/terraform.service.js +995 -0
- package/dist/services/terraform/terraform.service.js.map +1 -0
- package/dist/services/terraform/terraform.type.d.ts +387 -0
- package/dist/services/terraform/terraform.type.js +579 -0
- package/dist/services/terraform/terraform.type.js.map +1 -0
- package/dist/services/transaction/transaction.service.d.ts +86 -10
- package/dist/services/transaction/transaction.service.js +387 -232
- package/dist/services/transaction/transaction.service.js.map +1 -1
- package/dist/services/validation/validation.service.d.ts +13 -1
- package/dist/services/validation/validation.service.js +12 -0
- package/dist/services/validation/validation.service.js.map +1 -1
- package/dist/utilities/array/array.utility.d.ts +3 -0
- package/dist/utilities/array/array.utility.js +3 -0
- package/dist/utilities/array/array.utility.js.map +1 -1
- package/dist/utilities/file/file.utility.d.ts +15 -0
- package/dist/utilities/file/file.utility.js +18 -1
- package/dist/utilities/file/file.utility.js.map +1 -1
- package/dist/utilities/hcl/hcl.utility.d.ts +61 -0
- package/dist/utilities/hcl/hcl.utility.js +229 -0
- package/dist/utilities/hcl/hcl.utility.js.map +1 -0
- package/dist/utilities/node/node.utility.d.ts +3 -0
- package/dist/utilities/node/node.utility.js +3 -0
- package/dist/utilities/node/node.utility.js.map +1 -1
- package/dist/utilities/object/object.utility.d.ts +12 -0
- package/dist/utilities/object/object.utility.js +12 -0
- package/dist/utilities/object/object.utility.js.map +1 -1
- package/dist/utilities/project/project.utility.d.ts +28 -0
- package/dist/utilities/project/project.utility.js +35 -0
- package/dist/utilities/project/project.utility.js.map +1 -0
- package/dist/utilities/string/string.utility.d.ts +21 -0
- package/dist/utilities/string/string.utility.js +39 -0
- package/dist/utilities/string/string.utility.js.map +1 -0
- package/dist/utilities/terraform/terraform.utility.d.ts +227 -0
- package/dist/utilities/terraform/terraform.utility.js +434 -0
- package/dist/utilities/terraform/terraform.utility.js.map +1 -0
- package/dist/utilities/test-helpers/test-classes.d.ts +18 -31
- package/dist/utilities/test-helpers/test-classes.js +18 -41
- package/dist/utilities/test-helpers/test-classes.js.map +1 -1
- package/dist/utilities/test-helpers/test-models.js +12 -0
- package/dist/utilities/test-helpers/test-models.js.map +1 -1
- package/dist/utilities/test-helpers/test-modes.d.ts +315 -0
- package/dist/utilities/test-helpers/test-modes.js +463 -0
- package/dist/utilities/test-helpers/test-modes.js.map +1 -0
- package/dist/utilities/test-helpers/test-modules.d.ts +41 -0
- package/dist/utilities/test-helpers/test-modules.js +79 -0
- package/dist/utilities/test-helpers/test-modules.js.map +1 -0
- package/dist/utilities/test-helpers/test-overlays.d.ts +17 -1
- package/dist/utilities/test-helpers/test-overlays.js +49 -5
- package/dist/utilities/test-helpers/test-overlays.js.map +1 -1
- package/dist/utilities/test-helpers/test-resources.d.ts +19 -1
- package/dist/utilities/test-helpers/test-resources.js +61 -3
- package/dist/utilities/test-helpers/test-resources.js.map +1 -1
- package/dist/utilities/validation/validation.utility.d.ts +24 -0
- package/dist/utilities/validation/validation.utility.js +24 -0
- package/dist/utilities/validation/validation.utility.js.map +1 -1
- package/package.json +6 -5
- package/dist/services/capture/capture.service.d.ts +0 -19
- package/dist/services/capture/capture.service.js +0 -43
- package/dist/services/capture/capture.service.js.map +0 -1
- package/dist/utilities/cidr/cidr.utility.d.ts +0 -10
- package/dist/utilities/cidr/cidr.utility.js +0 -51
- package/dist/utilities/cidr/cidr.utility.js.map +0 -1
package/dist/main.js
CHANGED
|
@@ -10,102 +10,208 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
import { strict as assert } from 'assert';
|
|
11
11
|
import { EnableHook } from './decorators/enable-hook.decorator.js';
|
|
12
12
|
import { TransactionError } from './errors/index.js';
|
|
13
|
+
import { CommitModeCompletedEvent, ModeFailedEvent, ModeFinishedEvent, ModeStartedEvent, TerraformFoldersWrittenEvent, ValidateModeCompletedEvent, } from './events/index.js';
|
|
13
14
|
import { Container } from './functions/container/container.js';
|
|
14
15
|
import { DiffMetadata } from './functions/diff/diff-metadata.js';
|
|
15
16
|
import { App } from './models/app/app.model.js';
|
|
17
|
+
import { applyModelTransaction } from './modes/apply-transaction.js';
|
|
18
|
+
import { commit as runCommit } from './modes/commit.mode.js';
|
|
19
|
+
import { generate as runGenerate } from './modes/generate.mode.js';
|
|
20
|
+
import { runAction as runRunAction } from './modes/run-action.mode.js';
|
|
21
|
+
import { validate as runValidate } from './modes/validate.mode.js';
|
|
16
22
|
import { ModuleContainer } from './modules/module.container.js';
|
|
17
|
-
import {
|
|
18
|
-
import { BaseResourceSchema } from './resources/resource.schema.js';
|
|
19
|
-
import { CaptureService } from './services/capture/capture.service.js';
|
|
23
|
+
import { EventService } from './services/event/event.service.js';
|
|
20
24
|
import { InputService } from './services/input/input.service.js';
|
|
21
25
|
import { SchemaTranslationService } from './services/schema-translation/schema-translation.service.js';
|
|
22
26
|
import { ModelSerializationService } from './services/serialization/model/model-serialization.service.js';
|
|
23
27
|
import { ResourceSerializationService } from './services/serialization/resource/resource-serialization.service.js';
|
|
24
28
|
import { StateManagementService, StateManagementServiceFactory, } from './services/state-management/state-management.service.js';
|
|
25
|
-
import {
|
|
29
|
+
import { TerraformService } from './services/terraform/terraform.service.js';
|
|
26
30
|
/**
|
|
31
|
+
* The entry point to Octo.
|
|
32
|
+
*
|
|
33
|
+
* You describe infrastructure by loading modules, and Octo turns that description into terraform,
|
|
34
|
+
* checks what terraform intends to do, and records what it did. That is the lifecycle, and it is
|
|
35
|
+
* always these four steps:
|
|
36
|
+
*
|
|
37
|
+
* 1. {@link Octo.generate} - write the terraform module folders for the infrastructure you described.
|
|
38
|
+
* 2. {@link Octo.validate} - correlate terraform's plans with your intent, and report the difference.
|
|
39
|
+
* 3. `terraform apply` - see {@link TerraformUtility}. Octo does not do this for you.
|
|
40
|
+
* 4. {@link Octo.commit} - record the applied result back into Octo's state.
|
|
41
|
+
*
|
|
42
|
+
* Splitting them is deliberate: nothing is applied until you have seen a report of what would change,
|
|
43
|
+
* and each step is a separate process, so a CI pipeline can gate between them.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const octo = new Octo();
|
|
48
|
+
* await octo.initialize(new LocalStateProvider('./infrastructure'));
|
|
49
|
+
*
|
|
50
|
+
* octo.registerTerraformConfig({ providers: { aws: { source: 'hashicorp/aws' } } });
|
|
51
|
+
* octo.registerTerraformProvider('aws', '1234567890', 'us-east-1');
|
|
52
|
+
*
|
|
53
|
+
* octo.loadModule(SimpleAppModule, 'app-module', { name: 'my-app' });
|
|
54
|
+
* await octo.compose();
|
|
55
|
+
*
|
|
56
|
+
* await octo.generate(octo.getRootModel(), { outputDir: './infrastructure/terraform' });
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
27
59
|
* @group Main
|
|
60
|
+
*
|
|
61
|
+
* @see Definition of [Modules](/docs/fundamentals/modules).
|
|
28
62
|
*/
|
|
29
63
|
export class Octo {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!appLockId) {
|
|
58
|
-
throw new TransactionError('App is not in lock state!');
|
|
59
|
-
}
|
|
60
|
-
const isAppLocked = await this.stateManagementService.isAppLocked(appLockId);
|
|
61
|
-
if (!isAppLocked) {
|
|
62
|
-
throw new TransactionError('App is not in lock state!');
|
|
63
|
-
}
|
|
64
|
-
await this.stateManagementService.updateAppLockTransaction(appLockId);
|
|
65
|
-
let resourceTransaction = undefined;
|
|
66
|
-
try {
|
|
67
|
-
resourceTransaction = await transaction.next();
|
|
68
|
-
if (yieldResourceTransaction) {
|
|
69
|
-
yield resourceTransaction.value;
|
|
70
|
-
}
|
|
71
|
-
return (await transaction.next()).value;
|
|
72
|
-
}
|
|
73
|
-
finally {
|
|
74
|
-
await this.commitTransaction(app, modelTransaction.value, resourceTransaction ? resourceTransaction.value : []);
|
|
64
|
+
/**
|
|
65
|
+
* The last step of the lifecycle - records the result of a `terraform apply` back into Octo's state.
|
|
66
|
+
*
|
|
67
|
+
* A terraform apply reports what it created, and part of that is what each octo resource's
|
|
68
|
+
* `response` is made of - ARNs, generated IDs, endpoints. Without this step the next run has no
|
|
69
|
+
* idea any of it exists.
|
|
70
|
+
*
|
|
71
|
+
* **All-or-nothing**: if an expected output is missing, this throws before touching state, so a
|
|
72
|
+
* partial apply never leaves a half-written record behind. Pass `partial` after an apply that
|
|
73
|
+
* failed and the missing outputs become warnings instead, with every resource they belong to left
|
|
74
|
+
* out of the committed graph. Outputs for a folder Octo does not track are ignored, and returned
|
|
75
|
+
* as warnings for you to surface.
|
|
76
|
+
*
|
|
77
|
+
* **Requires the lock**, and does not release it. Taking and releasing the lock belongs to whoever
|
|
78
|
+
* drives the lifecycle - the CLI's `octo commit` releases it once this returns, however it ended.
|
|
79
|
+
*
|
|
80
|
+
* @param app The root model, from {@link Octo.getRootModel}.
|
|
81
|
+
* @param options `lockId` is the lock from `octo lock`. `outputs` is
|
|
82
|
+
* `TerraformUtility.output(dir, { json: true })` in full. `partial` records what a failed apply
|
|
83
|
+
* did build.
|
|
84
|
+
* @param transaction The model transaction result.
|
|
85
|
+
* @throws {@link TransactionError} When the app is not locked, or `lockId` is not the lock held.
|
|
86
|
+
*/
|
|
87
|
+
async commit(app, options, transaction) {
|
|
88
|
+
// Checked before the mode starts, so a run without the lock reads no state and writes none.
|
|
89
|
+
if (!(await this.stateManagementService.isAppLocked(options.lockId))) {
|
|
90
|
+
throw new TransactionError('App is not locked!');
|
|
75
91
|
}
|
|
92
|
+
return this.runMode('commit', app.name, async () => {
|
|
93
|
+
const { userData } = await this.stateManagementService.getResourceState(this.stateManagementService.actualResourceStateFileName);
|
|
94
|
+
// Build the transaction unless a single-process driver already built it and passed it in.
|
|
95
|
+
const resolvedTransaction = transaction ?? (await applyModelTransaction(app));
|
|
96
|
+
const { externalResourceIds, modelTransaction, ...completed } = await runCommit({
|
|
97
|
+
...options,
|
|
98
|
+
previousFolders: userData.terraformFolders ?? [],
|
|
99
|
+
previousMappings: userData.terraformResources ?? [],
|
|
100
|
+
transaction: resolvedTransaction,
|
|
101
|
+
});
|
|
102
|
+
await this.commitTransaction(app, modelTransaction, []);
|
|
103
|
+
// The committed graph now carries everything an external resource's actions made of it, so the
|
|
104
|
+
// records they wrote mid-apply are cleared. Done after the state is persisted, so a failure
|
|
105
|
+
// here costs a stale record rather than the record itself.
|
|
106
|
+
await Promise.all(externalResourceIds.map((resourceId) => this.stateManagementService.deleteExternalResourceState(resourceId)));
|
|
107
|
+
// Emitted after the state is persisted, so a listener never sees an uncommitted commit.
|
|
108
|
+
this.eventService.emit(new CommitModeCompletedEvent(undefined, completed));
|
|
109
|
+
return { warnings: completed.warnings };
|
|
110
|
+
});
|
|
76
111
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
await this.saveResourceState();
|
|
84
|
-
// Reset the runtime environment with the latest state.
|
|
85
|
-
await this.retrieveResourceState();
|
|
86
|
-
}
|
|
112
|
+
/**
|
|
113
|
+
* Runs every loaded module, in the order {@link Octo.orderModules} set, building the model graph.
|
|
114
|
+
* Call it once, after loading modules and before any lifecycle step.
|
|
115
|
+
*
|
|
116
|
+
* @returns Every model and overlay the modules created, keyed by a unique ID.
|
|
117
|
+
*/
|
|
87
118
|
async compose() {
|
|
88
119
|
return await this.moduleContainer.apply();
|
|
89
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* The first step of the lifecycle - writes the terragrunt module folders for the infrastructure you
|
|
123
|
+
* described, one folder per module, and saves the model state.
|
|
124
|
+
*
|
|
125
|
+
* A new module gets a new folder, and a changed module is rewritten in the folder it already has.
|
|
126
|
+
* A module you *removed* is not deleted: its folder is **emptied**, keeping only the provider
|
|
127
|
+
* blocks, so the next terraform apply destroys the live infrastructure rather than orphaning it.
|
|
128
|
+
* Octo never deletes a folder.
|
|
129
|
+
*
|
|
130
|
+
* @param app The root model, from {@link Octo.getRootModel}.
|
|
131
|
+
* @param options `outputDir` is where the module folders are written.
|
|
132
|
+
* @param transaction The model transaction result.
|
|
133
|
+
*/
|
|
134
|
+
async generate(app, options, transaction) {
|
|
135
|
+
return this.runMode('generate', app.name, async () => {
|
|
136
|
+
// The previous folder records must be read before this run writes the new `models.json`, so a
|
|
137
|
+
// module deleted from intent is caught on the generate right after its removal.
|
|
138
|
+
const [{ userData: modelUserData }, { userData: actualResourceUserData }] = await Promise.all([
|
|
139
|
+
this.stateManagementService.getModelState(this.stateManagementService.modelStateFileName),
|
|
140
|
+
this.stateManagementService.getResourceState(this.stateManagementService.actualResourceStateFileName),
|
|
141
|
+
]);
|
|
142
|
+
const previousFolders = new Map();
|
|
143
|
+
for (const record of [
|
|
144
|
+
...(actualResourceUserData.terraformFolders ?? []),
|
|
145
|
+
...(modelUserData.terraformFolders ?? []),
|
|
146
|
+
]) {
|
|
147
|
+
previousFolders.set(record.moduleId, record);
|
|
148
|
+
}
|
|
149
|
+
// Build the transaction unless a single-process driver already built it and passed it in.
|
|
150
|
+
const resolvedTransaction = transaction ?? (await applyModelTransaction(app));
|
|
151
|
+
const previousFolderList = [...previousFolders.values()];
|
|
152
|
+
const resourceDiffs = await runGenerate({
|
|
153
|
+
...options,
|
|
154
|
+
previousFolders: previousFolderList,
|
|
155
|
+
transaction: resolvedTransaction,
|
|
156
|
+
});
|
|
157
|
+
const written = this.terraformService.getModuleIds();
|
|
158
|
+
this.eventService.emit(new TerraformFoldersWrittenEvent(undefined, {
|
|
159
|
+
emptied: previousFolderList
|
|
160
|
+
.map((folder) => folder.moduleId)
|
|
161
|
+
.filter((moduleId) => !written.includes(moduleId)),
|
|
162
|
+
outputDir: options.outputDir,
|
|
163
|
+
written,
|
|
164
|
+
}));
|
|
165
|
+
await this.saveModelState(app);
|
|
166
|
+
return resourceDiffs;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* To fetch a loaded module by its module ID.
|
|
171
|
+
*
|
|
172
|
+
* @returns The module, or `undefined` if no module was loaded under that ID.
|
|
173
|
+
*/
|
|
90
174
|
getModule(...args) {
|
|
91
175
|
return this.inputService.getModule(...args);
|
|
92
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* To fetch the resources a module produced, by its module ID.
|
|
179
|
+
*/
|
|
93
180
|
getModuleResources(...args) {
|
|
94
181
|
return this.inputService.getModuleResources(...args);
|
|
95
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* The root of the model graph - the one {@link App} the loaded modules produced. Every lifecycle
|
|
185
|
+
* step takes it. Call after {@link Octo.compose}.
|
|
186
|
+
*
|
|
187
|
+
* @throws If no app model, or more than one distinct app model, was registered.
|
|
188
|
+
*/
|
|
189
|
+
getRootModel() {
|
|
190
|
+
return this.inputService.getRootModel();
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Boots Octo. Call it once, before anything else.
|
|
194
|
+
*
|
|
195
|
+
* The two optional arguments are how you replace Octo's internals with your own: exclusions run
|
|
196
|
+
* first, so you can unregister a built-in {@link Factory} and then resolve yours in its place.
|
|
197
|
+
*
|
|
198
|
+
* @param stateProvider Where Octo reads and writes its state. See {@link IStateProvider}.
|
|
199
|
+
* @param initializeInContainer Factories to resolve at boot - event listeners, most commonly.
|
|
200
|
+
* @param excludeInContainer Factories to unregister at boot.
|
|
201
|
+
*/
|
|
96
202
|
async initialize(stateProvider, initializeInContainer = [], excludeInContainer = []) {
|
|
97
203
|
const container = Container.getInstance();
|
|
98
204
|
[
|
|
99
|
-
this.
|
|
205
|
+
this.eventService,
|
|
100
206
|
this.inputService,
|
|
101
207
|
this.modelSerializationService,
|
|
102
208
|
this.moduleContainer,
|
|
103
209
|
this.resourceSerializationService,
|
|
104
210
|
this.schemaTranslationService,
|
|
105
211
|
this.stateManagementService,
|
|
106
|
-
this.
|
|
212
|
+
this.terraformService,
|
|
107
213
|
] = await Promise.all([
|
|
108
|
-
container.get(
|
|
214
|
+
container.get(EventService),
|
|
109
215
|
container.get(InputService),
|
|
110
216
|
container.get(ModelSerializationService),
|
|
111
217
|
container.get(ModuleContainer),
|
|
@@ -114,7 +220,7 @@ export class Octo {
|
|
|
114
220
|
container.get(StateManagementService, {
|
|
115
221
|
args: [stateProvider],
|
|
116
222
|
}),
|
|
117
|
-
container.get(
|
|
223
|
+
container.get(TerraformService),
|
|
118
224
|
]);
|
|
119
225
|
for (const exclude of excludeInContainer) {
|
|
120
226
|
container.unRegisterFactory(exclude.type);
|
|
@@ -127,47 +233,230 @@ export class Octo {
|
|
|
127
233
|
// Reset the runtime environment with the latest state.
|
|
128
234
|
await this.retrieveResourceState();
|
|
129
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* To load a module, which {@link Octo.compose} will then run.
|
|
238
|
+
*
|
|
239
|
+
* The same module class can be loaded more than once under different module IDs, and the ID scopes
|
|
240
|
+
* everything that instance produces.
|
|
241
|
+
*
|
|
242
|
+
* @param module The module class, or its registered name.
|
|
243
|
+
* @param moduleId A unique ID for this instance of the module.
|
|
244
|
+
* @param inputs The inputs, matching the module's schema.
|
|
245
|
+
*/
|
|
130
246
|
loadModule(module, moduleId, inputs) {
|
|
131
247
|
this.moduleContainer.load(module, moduleId, inputs);
|
|
132
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* To set the order {@link Octo.compose} runs modules in, by listing their classes.
|
|
251
|
+
*
|
|
252
|
+
* Order matters because a module resolves what earlier modules produced - a subnet module must run
|
|
253
|
+
* after the region module whose region it attaches to.
|
|
254
|
+
*/
|
|
133
255
|
orderModules(...args) {
|
|
134
256
|
this.moduleContainer.order(...args);
|
|
135
257
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
258
|
+
/**
|
|
259
|
+
* To register callbacks that run at fixed points of the lifecycle. Use them to inject behavior -
|
|
260
|
+
* an audit trail, an approval gate - without modifying the framework.
|
|
261
|
+
*
|
|
262
|
+
* The hook points, each with its own signature:
|
|
263
|
+
* - `PreCommitHook` / `PostCommitHook` - around the commit.
|
|
264
|
+
* - `PreModelActionHook` / `PostModelActionHook` - around every model action.
|
|
265
|
+
* - `PreResourceActionHook` / `PostResourceActionHook` - around every resource action.
|
|
266
|
+
*
|
|
267
|
+
* @see Techniques for [Hooks](/docs/techniques/hooks).
|
|
268
|
+
*/
|
|
139
269
|
registerHooks(...args) {
|
|
140
270
|
this.moduleContainer.registerHooks(...args);
|
|
141
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* To teach Octo how to read one schema as another.
|
|
274
|
+
*
|
|
275
|
+
* Modules find each other by schema, so a module that changes its schema breaks its consumers.
|
|
276
|
+
* A translation is the escape hatch: register the schema you have, the schema your module expects,
|
|
277
|
+
* and a function between them, and the lookup keeps working while you migrate.
|
|
278
|
+
*
|
|
279
|
+
* @see Techniques for [Schema](/docs/techniques/schema).
|
|
280
|
+
*/
|
|
142
281
|
registerSchemaTranslation(...args) {
|
|
143
282
|
return this.schemaTranslationService.registerSchemaTranslation(...args);
|
|
144
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* To apply tags to resources in bulk, so that individual modules do not each have to be told about
|
|
286
|
+
* your organization's tagging policy.
|
|
287
|
+
*
|
|
288
|
+
* Each entry's `scope` decides its reach: empty tags every resource of the run, `moduleId` tags
|
|
289
|
+
* every resource of one module, and `resourceContext` tags a single resource.
|
|
290
|
+
*/
|
|
145
291
|
registerTags(args) {
|
|
146
292
|
for (const { scope, tags } of args) {
|
|
147
293
|
const isGlobal = !scope.moduleId && !scope.resourceContext;
|
|
148
294
|
this.inputService.registerTag((isGlobal || scope), tags);
|
|
149
295
|
}
|
|
150
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* To set the minimum terraform version, and the `required_providers` block rendered into every
|
|
299
|
+
* generated module folder.
|
|
300
|
+
*
|
|
301
|
+
* Call it after {@link Octo.initialize}, and before {@link Octo.generate}.
|
|
302
|
+
*/
|
|
303
|
+
registerTerraformConfig(...args) {
|
|
304
|
+
return this.terraformService.addTerraformConfig(...args);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* To register a terraform provider for one deployment target - a provider type, an account, and a
|
|
308
|
+
* region.
|
|
309
|
+
*
|
|
310
|
+
* Resources bind to a provider by `{ accountId, regionId }` alone, so this is the one place a
|
|
311
|
+
* provider type is named. Register one per account/region combination you deploy into.
|
|
312
|
+
*
|
|
313
|
+
* Call it after {@link Octo.initialize}, and before {@link Octo.generate}.
|
|
314
|
+
*/
|
|
315
|
+
registerTerraformProvider(...args) {
|
|
316
|
+
return this.terraformService.addTerraformProvider(...args);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Runs one resource action for an external resource.
|
|
320
|
+
*
|
|
321
|
+
* Terraform calls back into this mid-apply, through the generated CLI command; it is not a step you
|
|
322
|
+
* run yourself.
|
|
323
|
+
*
|
|
324
|
+
* @internal
|
|
325
|
+
*/
|
|
326
|
+
async runAction(app, options) {
|
|
327
|
+
return runRunAction(app, options);
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* The second step of the lifecycle - correlates terraform's plans with your intent, and reports
|
|
331
|
+
* what it finds. This is what you read before deciding whether to apply.
|
|
332
|
+
*
|
|
333
|
+
* The report answers two questions separately:
|
|
334
|
+
* 1. **What will change, and why.** Including terraform changes Octo did not flag directly but can
|
|
335
|
+
* attribute to something it did - a referenced resource whose identity moved, or an address the
|
|
336
|
+
* resource no longer renders.
|
|
337
|
+
* 2. **What changed that your intent does not explain** - drift, i.e. infrastructure modified
|
|
338
|
+
* outside Octo. Read `confidence` first: drift is only reliable when intent itself is unchanged.
|
|
339
|
+
*
|
|
340
|
+
* The report fails only when terraform could not plan a folder Octo generated. Folders Octo does
|
|
341
|
+
* not track are excluded, and noted. So is every external resource a previous run published and no
|
|
342
|
+
* commit has recorded, which is the only step that reads those records back for a user.
|
|
343
|
+
*
|
|
344
|
+
* @param app The root model, from {@link Octo.getRootModel}.
|
|
345
|
+
* @param plans The whole result of `TerraformUtility.plan(dir, { json: true })`. Its `errors` map
|
|
346
|
+
* carries terraform's own message for each folder that failed to plan.
|
|
347
|
+
* @param transaction The model transaction result.
|
|
348
|
+
*/
|
|
349
|
+
async validate(app, { errors: planErrors, plans }, transaction) {
|
|
350
|
+
return this.runMode('validate', app.name, async () => {
|
|
351
|
+
const { userData } = await this.stateManagementService.getResourceState(this.stateManagementService.actualResourceStateFileName);
|
|
352
|
+
const { terraformFolders, terraformResources } = userData;
|
|
353
|
+
const previousMappings = terraformResources ?? [];
|
|
354
|
+
const persistedMappings = new Map();
|
|
355
|
+
for (const mapping of previousMappings) {
|
|
356
|
+
persistedMappings.set(mapping.resourceContext, mapping);
|
|
357
|
+
}
|
|
358
|
+
const externalResourceStateIds = await this.stateManagementService.listExternalResourceStateIds();
|
|
359
|
+
// Build the transaction unless a single-process driver already built it and passed it in.
|
|
360
|
+
const resolvedTransaction = transaction ?? (await applyModelTransaction(app));
|
|
361
|
+
const report = await runValidate({
|
|
362
|
+
externalResourceStateIds,
|
|
363
|
+
persistedMappings,
|
|
364
|
+
planErrors,
|
|
365
|
+
plans,
|
|
366
|
+
previousFolders: terraformFolders ?? [],
|
|
367
|
+
transaction: resolvedTransaction,
|
|
368
|
+
});
|
|
369
|
+
this.eventService.emit(new ValidateModeCompletedEvent(undefined, { report }));
|
|
370
|
+
return report;
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* This function persists the model and resource state using {@link IStateProvider}.
|
|
375
|
+
* Then immediately fetches the resource state in memory for the next set of operations.
|
|
376
|
+
*
|
|
377
|
+
* @internal
|
|
378
|
+
*/
|
|
379
|
+
async commitTransaction(app, modelTransaction, resourceTransaction = []) {
|
|
380
|
+
// `modelTransaction` and `resourceTransaction` is used by hooks of type CommitHook.
|
|
381
|
+
assert(!!modelTransaction);
|
|
382
|
+
assert(!!resourceTransaction);
|
|
383
|
+
// Save the state of the new app and its resources.
|
|
384
|
+
await this.saveModelState(app);
|
|
385
|
+
await this.saveResourceState();
|
|
386
|
+
// Reset the runtime environment with the latest state.
|
|
387
|
+
await this.retrieveResourceState();
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* This function deserializes the resource state in memory.
|
|
391
|
+
* It deserializes the actual resource state into actual resources,
|
|
392
|
+
* and the last resource state into old resources.
|
|
393
|
+
*
|
|
394
|
+
* @internal
|
|
395
|
+
*/
|
|
151
396
|
async retrieveResourceState() {
|
|
152
|
-
const { data: actualSerializedOutput } = await this.stateManagementService.getResourceState(this.actualResourceStateFileName);
|
|
153
|
-
const { data: oldSerializedOutput } = await this.stateManagementService.getResourceState(this.oldResourceStateFileName);
|
|
397
|
+
const { data: actualSerializedOutput } = await this.stateManagementService.getResourceState(this.stateManagementService.actualResourceStateFileName);
|
|
398
|
+
const { data: oldSerializedOutput } = await this.stateManagementService.getResourceState(this.stateManagementService.oldResourceStateFileName);
|
|
154
399
|
// Initialize previous resource state.
|
|
155
400
|
await this.resourceSerializationService.deserialize(actualSerializedOutput, oldSerializedOutput);
|
|
156
401
|
}
|
|
402
|
+
/**
|
|
403
|
+
* Wraps a mode to emit its boundary events, and re-throws whatever the mode threw.
|
|
404
|
+
* The finishing events use `emitAndWait`, so a listener that writes a file completes first.
|
|
405
|
+
*
|
|
406
|
+
* @internal
|
|
407
|
+
*/
|
|
408
|
+
async runMode(mode, appName, body) {
|
|
409
|
+
const startedAt = Date.now();
|
|
410
|
+
const payload = { appName, mode };
|
|
411
|
+
this.eventService.emit(new ModeStartedEvent(mode, payload));
|
|
412
|
+
let result;
|
|
413
|
+
try {
|
|
414
|
+
result = await body();
|
|
415
|
+
}
|
|
416
|
+
catch (error) {
|
|
417
|
+
await this.eventService.emitAndWait(new ModeFailedEvent(mode, {
|
|
418
|
+
...payload,
|
|
419
|
+
durationInMs: Date.now() - startedAt,
|
|
420
|
+
error: error?.message ?? String(error),
|
|
421
|
+
}));
|
|
422
|
+
throw error;
|
|
423
|
+
}
|
|
424
|
+
await this.eventService.emitAndWait(new ModeFinishedEvent(mode, { ...payload, durationInMs: Date.now() - startedAt }));
|
|
425
|
+
return result;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* This function persists the in-memory model state.
|
|
429
|
+
*
|
|
430
|
+
* @internal
|
|
431
|
+
*/
|
|
157
432
|
async saveModelState(app) {
|
|
158
433
|
const modelSerializedOutput = await this.modelSerializationService.serialize(app);
|
|
159
|
-
await this.stateManagementService.saveModelState(this.modelStateFileName, modelSerializedOutput, {
|
|
434
|
+
await this.stateManagementService.saveModelState(this.stateManagementService.modelStateFileName, modelSerializedOutput, {
|
|
435
|
+
terraformFolders: this.terraformService.getFolderRecords(),
|
|
160
436
|
version: 1,
|
|
161
437
|
});
|
|
162
|
-
await Container.getInstance().get(OverlayDataRepository, { args: [true] });
|
|
163
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* This function persists the in-memory resource state.
|
|
441
|
+
* The actual resource state is persisted as actual,
|
|
442
|
+
* and the current resource state is persisted as old.
|
|
443
|
+
*
|
|
444
|
+
* @internal
|
|
445
|
+
*/
|
|
164
446
|
async saveResourceState() {
|
|
165
447
|
const actualSerializedOutput = await this.resourceSerializationService.serializeActualResources();
|
|
166
|
-
await this.stateManagementService.saveResourceState(this.actualResourceStateFileName, actualSerializedOutput, {
|
|
448
|
+
await this.stateManagementService.saveResourceState(this.stateManagementService.actualResourceStateFileName, actualSerializedOutput, {
|
|
449
|
+
terraformFolders: this.terraformService.getFolderRecords(),
|
|
450
|
+
terraformResources: this.terraformService.getOctoTerraformResourceMappings().map((m) => ({
|
|
451
|
+
moduleId: m.moduleId,
|
|
452
|
+
resourceContext: m.resourceContext,
|
|
453
|
+
resourceId: m.resourceId,
|
|
454
|
+
terraformAddresses: m.terraformAddresses,
|
|
455
|
+
})),
|
|
167
456
|
version: 1,
|
|
168
457
|
});
|
|
169
458
|
const oldSerializedOutput = await this.resourceSerializationService.serializeNewResources();
|
|
170
|
-
await this.stateManagementService.saveResourceState(this.oldResourceStateFileName, oldSerializedOutput, {
|
|
459
|
+
await this.stateManagementService.saveResourceState(this.stateManagementService.oldResourceStateFileName, oldSerializedOutput, {
|
|
171
460
|
version: 1,
|
|
172
461
|
});
|
|
173
462
|
}
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAS1C,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EACL,wBAAwB,EAExB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAEhB,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM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M,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CACjD,IAAI,CAAC,sBAAsB,CAAC,wBAAwB,EACpD,mBAAmB,EACnB;YACE,OAAO,EAAE,CAAC;SACX,CACF,CAAC;IACJ,CAAC;CACF;AAxHe;IADb,UAAU,CAAC,YAAY,CAAC;;qCAElB,GAAG;;6CAcT"}
|
|
@@ -2,25 +2,55 @@ import type { UnknownModel } from '../../app.type.js';
|
|
|
2
2
|
import { AModel } from '../model.abstract.js';
|
|
3
3
|
import { Region } from '../region/region.model.js';
|
|
4
4
|
import { AccountSchema, AccountType } from './account.schema.js';
|
|
5
|
-
type AwsCredentials = {
|
|
6
|
-
readonly accessKeyId: string;
|
|
7
|
-
readonly secretAccessKey: string;
|
|
8
|
-
};
|
|
9
5
|
/**
|
|
6
|
+
* An Account model is the cloud provider account the infrastructure below it is deployed into.
|
|
7
|
+
* It sits between the {@link App} and its {@link Region}s, so one app can span several accounts -
|
|
8
|
+
* e.g. a separate account per environment, or per cloud provider.
|
|
9
|
+
*
|
|
10
|
+
* Credentials are not held here. A module such as `AwsIniAccountModule` extends this model and
|
|
11
|
+
* supplies them through {@link Account.getCredentials}.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const account = new Account(AccountType.AWS, '1234567890');
|
|
16
|
+
* app.addAccount(account);
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
10
19
|
* @group Models/Account
|
|
20
|
+
*
|
|
21
|
+
* @see Definition of [Default Models](/docs/fundamentals/models#default-models).
|
|
11
22
|
*/
|
|
12
23
|
export declare class Account extends AModel<AccountSchema, Account> {
|
|
13
24
|
readonly accountId: string;
|
|
14
25
|
readonly accountType: AccountType;
|
|
26
|
+
/**
|
|
27
|
+
* @param accountType The cloud provider this account belongs to.
|
|
28
|
+
* @param accountId The provider's own identifier for the account.
|
|
29
|
+
*/
|
|
15
30
|
constructor(accountType: AccountType, accountId: string);
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
static unSynth(account: AccountSchema, deReferenceContext: (context: string) => Promise<UnknownModel>): Promise<Account>;
|
|
16
35
|
/**
|
|
17
36
|
* To add a {@link Region}.
|
|
18
37
|
*/
|
|
19
38
|
addRegion(region: Region): void;
|
|
20
|
-
|
|
39
|
+
/**
|
|
40
|
+
* The credentials this account authenticates with, for the paths octo drives itself rather than
|
|
41
|
+
* through a provider - an external resource's actions, most of all. The shape is the provider's
|
|
42
|
+
* own; octo only carries it from the model to whatever builds the client.
|
|
43
|
+
*
|
|
44
|
+
* @throws {@link ModelError} On the base model, which holds no credentials. Override it in the
|
|
45
|
+
* subclass a module creates.
|
|
46
|
+
*/
|
|
21
47
|
getCredentials(): object;
|
|
48
|
+
/**
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
22
51
|
setContext(): string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
23
55
|
synth(): AccountSchema;
|
|
24
|
-
static unSynth(account: AccountSchema, deReferenceContext: (context: string) => Promise<UnknownModel>): Promise<Account>;
|
|
25
56
|
}
|
|
26
|
-
export {};
|