@agilecustoms/envctl 0.28.1 → 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
|
@@ -26,8 +26,10 @@ export class EnvCtl {
|
|
|
26
26
|
console.log(`Env ${key} does not exist`);
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
+
console.log(`Env ${key} status: ${env.status}`);
|
|
30
|
+
const verb = env.status === EnvStatus.Deleting ? 'Scheduled for deletion' : 'Expires';
|
|
29
31
|
const date = new Date(env.ttl * 1000);
|
|
30
|
-
const
|
|
32
|
+
const formattedDate = date.toLocaleString(undefined, {
|
|
31
33
|
month: 'short',
|
|
32
34
|
day: '2-digit',
|
|
33
35
|
hour: '2-digit',
|
|
@@ -35,7 +37,7 @@ export class EnvCtl {
|
|
|
35
37
|
second: '2-digit',
|
|
36
38
|
hour12: false,
|
|
37
39
|
});
|
|
38
|
-
console.log(
|
|
40
|
+
console.log(`${verb} at ${formattedDate}`);
|
|
39
41
|
if (env.kind) {
|
|
40
42
|
const kind = this.cliHelper.getKind(cwd);
|
|
41
43
|
if (env.kind !== kind) {
|
|
@@ -57,9 +59,9 @@ export class EnvCtl {
|
|
|
57
59
|
checkInput(env, cwd) {
|
|
58
60
|
if (env.ephemeral)
|
|
59
61
|
return;
|
|
60
|
-
const
|
|
61
|
-
if (env.owner !==
|
|
62
|
-
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}`);
|
|
63
65
|
}
|
|
64
66
|
if (env.kind) {
|
|
65
67
|
const kind = this.cliHelper.getKind(cwd);
|
|
@@ -79,7 +81,7 @@ export class EnvCtl {
|
|
|
79
81
|
}
|
|
80
82
|
async plan(tfArgs, cwd) {
|
|
81
83
|
const key = this.terraformAdapter.getKey(cwd);
|
|
82
|
-
const
|
|
84
|
+
const userName = this.configService.getUserName();
|
|
83
85
|
const env = await this.tryGetEnv(key);
|
|
84
86
|
let vars = undefined;
|
|
85
87
|
if (env) {
|
|
@@ -91,7 +93,7 @@ export class EnvCtl {
|
|
|
91
93
|
}
|
|
92
94
|
vars = env.vars;
|
|
93
95
|
}
|
|
94
|
-
const envTerraform = { key, ephemeral: false, owner, args: tfArgs, vars };
|
|
96
|
+
const envTerraform = { key, ephemeral: false, owner: userName, args: tfArgs, vars };
|
|
95
97
|
await this.terraformAdapter.plan(envTerraform, cwd);
|
|
96
98
|
}
|
|
97
99
|
async createEphemeral(key) {
|
|
@@ -108,19 +110,21 @@ export class EnvCtl {
|
|
|
108
110
|
if (env === null) {
|
|
109
111
|
const kind = this.cliHelper.getKind(cwd);
|
|
110
112
|
console.log('Creating env metadata');
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
+
const userName = this.configService.getUserName();
|
|
114
|
+
await this.terraformAdapter.lockProviders(cwd);
|
|
115
|
+
const createEnv = { key, owner: userName, kind };
|
|
113
116
|
env = await this.envApi.create(createEnv);
|
|
114
117
|
}
|
|
115
118
|
else {
|
|
116
119
|
this.checkInput(env, cwd);
|
|
117
120
|
this.checkStatus(env);
|
|
121
|
+
await this.terraformAdapter.lockProviders(cwd);
|
|
118
122
|
if (env.status === EnvStatus.Init) {
|
|
119
123
|
await this.envApi.lockForUpdate(env);
|
|
120
124
|
}
|
|
121
125
|
else if (env.status == EnvStatus.Updating) {
|
|
122
|
-
const answerYes = await this.cliHelper.promptYesNo(`Env status is ${env.status},
|
|
123
|
-
|
|
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?`);
|
|
124
128
|
if (!answerYes) {
|
|
125
129
|
console.log('Aborting deployment');
|
|
126
130
|
return;
|