@agilecustoms/envctl 1.4.0 → 1.5.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.
|
@@ -212,7 +212,7 @@ export class TerraformAdapter {
|
|
|
212
212
|
tfVarName = '';
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
console.log('Running: terraform plan
|
|
215
|
+
console.log('Running: terraform plan', ...args, '\n');
|
|
216
216
|
try {
|
|
217
217
|
await this.cli.run('terraform', ['plan', ...args], out_scanner, in_scanner);
|
|
218
218
|
}
|
|
@@ -234,7 +234,7 @@ export class TerraformAdapter {
|
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
async apply(args, attemptNo = 1) {
|
|
237
|
-
console.log('Running: terraform apply
|
|
237
|
+
console.log('Running: terraform apply', ...args, '\n');
|
|
238
238
|
this.printTime();
|
|
239
239
|
try {
|
|
240
240
|
await this.cli.run('terraform', ['apply', ...args]);
|
|
@@ -3,6 +3,7 @@ import { EnvApiClient, TerraformAdapter } from '../client/index.js';
|
|
|
3
3
|
import { KnownException } from '../exceptions.js';
|
|
4
4
|
import { EnvStatus } from '../model/index.js';
|
|
5
5
|
import { BaseService } from './BaseService.js';
|
|
6
|
+
export const PLAN_FILE = '.terraform/envctl.plan';
|
|
6
7
|
export class EnvService extends BaseService {
|
|
7
8
|
cli;
|
|
8
9
|
envApi;
|
|
@@ -69,6 +70,7 @@ export class EnvService extends BaseService {
|
|
|
69
70
|
throw new KnownException(`Env ${env.key} status is DELETING, please wait`);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
73
|
+
await this.lockTerraform(env, env === null);
|
|
72
74
|
await this.terraformAdapter.plan(env, tfArgs);
|
|
73
75
|
}
|
|
74
76
|
async createEphemeral(key) {
|
|
@@ -78,20 +80,34 @@ export class EnvService extends BaseService {
|
|
|
78
80
|
async lockTerraform(env, newEnv = false) {
|
|
79
81
|
console.log('Lock providers');
|
|
80
82
|
const res = await this.terraformAdapter.lock(newEnv);
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
if (env !== null) {
|
|
84
|
+
if (res.lockFile) {
|
|
85
|
+
env.lockFile = res.lockFile;
|
|
86
|
+
}
|
|
87
|
+
if (res.stateFile) {
|
|
88
|
+
env.stateFile = res.stateFile;
|
|
89
|
+
}
|
|
86
90
|
}
|
|
87
91
|
}
|
|
88
92
|
async ensurePlan(env, args) {
|
|
89
93
|
if (args.length > 0 && !args[0].startsWith('-')) {
|
|
90
94
|
return args;
|
|
91
95
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
await this.terraformAdapter.plan(env, [`-out=${PLAN_FILE}`, ...args]);
|
|
97
|
+
const PLAN_ARGS = ['-var', '-target', '-replace', '-refresh'];
|
|
98
|
+
const applyArgs = [PLAN_FILE];
|
|
99
|
+
for (let i = 0; i < args.length; i++) {
|
|
100
|
+
const arg = args[i];
|
|
101
|
+
if (arg === '-var' || arg === '-var-file') {
|
|
102
|
+
i++;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (PLAN_ARGS.some(planArg => arg.startsWith(planArg))) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
applyArgs.push(arg);
|
|
109
|
+
}
|
|
110
|
+
return applyArgs;
|
|
95
111
|
}
|
|
96
112
|
async deploy(tfArgs) {
|
|
97
113
|
const key = this.terraformAdapter.getTerraformBackend().getKey();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agilecustoms/envctl",
|
|
3
3
|
"description": "node.js CLI client for manage environments",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"author": "Alex Chekulaev",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -32,11 +32,10 @@
|
|
|
32
32
|
"run-configure": "npm run run -- configure",
|
|
33
33
|
"~": "",
|
|
34
34
|
"run-core-init": " cd ../tt-core && terraform init -upgrade -backend-config=key=laxa1986 -reconfigure",
|
|
35
|
-
"run-core-tfplan": "cd ../tt-core && terraform plan -out=.terraform/plan",
|
|
36
35
|
"run-core-status": " npm run run -- status --cwd ../tt-core",
|
|
37
|
-
"run-core-plan": " npm run run -- plan --cwd ../tt-core",
|
|
36
|
+
"run-core-plan": " npm run run -- plan --cwd ../tt-core -out=.terraform/plan",
|
|
37
|
+
"run-core-deployp": "npm run run -- deploy --cwd ../tt-core .terraform/plan",
|
|
38
38
|
"run-core-deploy": " npm run run -- deploy --cwd ../tt-core -var=\"env_size=min\"",
|
|
39
|
-
"run-core-deployp": "npm run run -- deploy .terraform/plan --cwd ../tt-core",
|
|
40
39
|
"run-core-delete": " npm run run -- delete --cwd ../tt-core",
|
|
41
40
|
"run-core-destroy": "npm run run -- destroy --cwd ../tt-core",
|
|
42
41
|
"run-core-logs": " npm run run -- logs --cwd ../tt-core",
|