@agilecustoms/envctl 0.28.2 → 0.29.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.
|
@@ -53,6 +53,10 @@ export class TerraformAdapter {
|
|
|
53
53
|
}
|
|
54
54
|
return key;
|
|
55
55
|
}
|
|
56
|
+
async lockProviders(cwd) {
|
|
57
|
+
console.log('Update lock file');
|
|
58
|
+
await this.processRunner.run('terraform', ['providers', 'lock', '-platform=linux_amd64'], cwd);
|
|
59
|
+
}
|
|
56
60
|
printTime() {
|
|
57
61
|
const now = new Date();
|
|
58
62
|
const utc = now.toISOString();
|
|
@@ -12,12 +12,11 @@ async function handler() {
|
|
|
12
12
|
const answers = await inquirer.prompt([
|
|
13
13
|
{
|
|
14
14
|
type: 'input',
|
|
15
|
-
name: '
|
|
16
|
-
message: '
|
|
17
|
-
+ 'this value will be used as default - if not provided via --owner key in "deploy" command\n'
|
|
15
|
+
name: 'userName',
|
|
16
|
+
message: 'userName is required to deploy any env\n'
|
|
18
17
|
+ '(prefer GitHub username)\n'
|
|
19
|
-
+ '
|
|
18
|
+
+ 'userName:',
|
|
20
19
|
},
|
|
21
20
|
]);
|
|
22
|
-
configService.saveConfig({
|
|
21
|
+
configService.saveConfig({ userName: answers.userName });
|
|
23
22
|
}
|
|
@@ -23,11 +23,11 @@ export class ConfigService {
|
|
|
23
23
|
}
|
|
24
24
|
return this.config;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
29
|
-
throw new KnownException('please first set
|
|
26
|
+
getUserName() {
|
|
27
|
+
const userName = this.loadConfig()?.userName;
|
|
28
|
+
if (!userName) {
|
|
29
|
+
throw new KnownException('please first set userName via calling \'envctl configure\'');
|
|
30
30
|
}
|
|
31
|
-
return
|
|
31
|
+
return userName;
|
|
32
32
|
}
|
|
33
33
|
}
|
package/dist/service/EnvCtl.js
CHANGED
|
@@ -59,9 +59,9 @@ export class EnvCtl {
|
|
|
59
59
|
checkInput(env, cwd) {
|
|
60
60
|
if (env.ephemeral)
|
|
61
61
|
return;
|
|
62
|
-
const
|
|
63
|
-
if (env.owner !==
|
|
64
|
-
throw new KnownException(`Can not change env owner ${env.owner} -> ${
|
|
62
|
+
const userName = this.configService.getUserName();
|
|
63
|
+
if (env.owner !== userName) {
|
|
64
|
+
throw new KnownException(`Can not change env owner ${env.owner} -> ${userName}`);
|
|
65
65
|
}
|
|
66
66
|
if (env.kind) {
|
|
67
67
|
const kind = this.cliHelper.getKind(cwd);
|
|
@@ -81,7 +81,7 @@ export class EnvCtl {
|
|
|
81
81
|
}
|
|
82
82
|
async plan(tfArgs, cwd) {
|
|
83
83
|
const key = this.terraformAdapter.getKey(cwd);
|
|
84
|
-
const
|
|
84
|
+
const userName = this.configService.getUserName();
|
|
85
85
|
const env = await this.tryGetEnv(key);
|
|
86
86
|
let vars = undefined;
|
|
87
87
|
if (env) {
|
|
@@ -93,7 +93,7 @@ export class EnvCtl {
|
|
|
93
93
|
}
|
|
94
94
|
vars = env.vars;
|
|
95
95
|
}
|
|
96
|
-
const envTerraform = { key, ephemeral: false, owner, args: tfArgs, vars };
|
|
96
|
+
const envTerraform = { key, ephemeral: false, owner: userName, args: tfArgs, vars };
|
|
97
97
|
await this.terraformAdapter.plan(envTerraform, cwd);
|
|
98
98
|
}
|
|
99
99
|
async createEphemeral(key) {
|
|
@@ -110,19 +110,21 @@ export class EnvCtl {
|
|
|
110
110
|
if (env === null) {
|
|
111
111
|
const kind = this.cliHelper.getKind(cwd);
|
|
112
112
|
console.log('Creating env metadata');
|
|
113
|
-
const
|
|
114
|
-
|
|
113
|
+
const userName = this.configService.getUserName();
|
|
114
|
+
await this.terraformAdapter.lockProviders(cwd);
|
|
115
|
+
const createEnv = { key, owner: userName, kind };
|
|
115
116
|
env = await this.envApi.create(createEnv);
|
|
116
117
|
}
|
|
117
118
|
else {
|
|
118
119
|
this.checkInput(env, cwd);
|
|
119
120
|
this.checkStatus(env);
|
|
121
|
+
await this.terraformAdapter.lockProviders(cwd);
|
|
120
122
|
if (env.status === EnvStatus.Init) {
|
|
121
123
|
await this.envApi.lockForUpdate(env);
|
|
122
124
|
}
|
|
123
125
|
else if (env.status == EnvStatus.Updating) {
|
|
124
|
-
const answerYes = await this.cliHelper.promptYesNo(`Env status is ${env.status},
|
|
125
|
-
|
|
126
|
+
const answerYes = await this.cliHelper.promptYesNo(`Env status is ${env.status}, likely due to an error from a previous run\n
|
|
127
|
+
Do you want to proceed with deployment?`);
|
|
126
128
|
if (!answerYes) {
|
|
127
129
|
console.log('Aborting deployment');
|
|
128
130
|
return;
|