@agilecustoms/envctl 1.10.3 → 1.10.5
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BusinessException, KnownException, NotFoundException } from '../exceptions.js';
|
|
2
2
|
import { logger } from '../logger.js';
|
|
3
3
|
import { EnvStatus } from '../model/index.js';
|
|
4
|
+
import { toLocalTime } from '../util.js';
|
|
4
5
|
import { HttpClient, toUrl } from './HttpClient.js';
|
|
5
6
|
export class EnvApiClient {
|
|
6
7
|
httpClient;
|
|
@@ -45,6 +46,7 @@ export class EnvApiClient {
|
|
|
45
46
|
}
|
|
46
47
|
throw error;
|
|
47
48
|
}
|
|
49
|
+
logger.debug(`Env ${env.key} created with TTL ${toLocalTime(result.ttl)}`);
|
|
48
50
|
return { ...env, ephemeral: false, status: EnvStatus.Deploying, ttl: result.ttl };
|
|
49
51
|
}
|
|
50
52
|
async activate(env) {
|
package/dist/commands/_keys.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export const _keys = {
|
|
2
2
|
FORCE: 'Force deletion without confirmation',
|
|
3
3
|
KEY: 'Environment name/identifier - taken from remote stake key, must be unique for a given customer',
|
|
4
|
-
KIND: 'Environment kind: complete project (default) or some slice such as tt-core + tt-web'
|
|
5
|
-
OWNER: 'Environment owner (GH username)'
|
|
4
|
+
KIND: 'Environment kind: complete project (default) or some slice such as tt-core + tt-web'
|
|
6
5
|
};
|
|
@@ -3,6 +3,7 @@ import { EnvApiClient } from '../client/index.js';
|
|
|
3
3
|
import { KnownException } from '../exceptions.js';
|
|
4
4
|
import { logger } from '../logger.js';
|
|
5
5
|
import { EnvStatus } from '../model/index.js';
|
|
6
|
+
import { toLocalTime } from '../util.js';
|
|
6
7
|
import { BaseService } from './BaseService.js';
|
|
7
8
|
export const PLAN_FILE = '.terraform/envctl.plan';
|
|
8
9
|
export class EnvService extends BaseService {
|
|
@@ -23,16 +24,7 @@ export class EnvService extends BaseService {
|
|
|
23
24
|
}
|
|
24
25
|
logger.info(`Env ${key} status: ${env.status}`);
|
|
25
26
|
if (env.status !== EnvStatus.Deleting && env.status !== EnvStatus.DeleteError) {
|
|
26
|
-
|
|
27
|
-
const formattedDate = date.toLocaleString(undefined, {
|
|
28
|
-
month: 'short',
|
|
29
|
-
day: '2-digit',
|
|
30
|
-
hour: '2-digit',
|
|
31
|
-
minute: '2-digit',
|
|
32
|
-
second: '2-digit',
|
|
33
|
-
hour12: false,
|
|
34
|
-
});
|
|
35
|
-
logger.info(`Expires at ${formattedDate}`);
|
|
27
|
+
logger.info(`Expires at ${toLocalTime(env.ttl)}`);
|
|
36
28
|
}
|
|
37
29
|
if (env.kind) {
|
|
38
30
|
const kind = this.cli.getKind();
|
|
@@ -71,7 +63,7 @@ export class EnvService extends BaseService {
|
|
|
71
63
|
}
|
|
72
64
|
const newEnv = env === null;
|
|
73
65
|
await this.lockTerraform(env, newEnv);
|
|
74
|
-
await this.terraformAdapter.plan(env, tfArgs);
|
|
66
|
+
await this.terraformAdapter.plan(env ?? { key }, tfArgs);
|
|
75
67
|
}
|
|
76
68
|
async createEphemeral(key) {
|
|
77
69
|
const createEnv = { key };
|
|
@@ -127,7 +119,7 @@ export class EnvService extends BaseService {
|
|
|
127
119
|
logger.info(`Inferred kind from directory name: ${kind}`);
|
|
128
120
|
const createEnv = { key, kind };
|
|
129
121
|
await this.lockTerraform(createEnv, true);
|
|
130
|
-
tfArgs = await this.ensurePlan(
|
|
122
|
+
tfArgs = await this.ensurePlan({ key, ephemeral: false }, tfArgs);
|
|
131
123
|
logger.info('Creating env metadata');
|
|
132
124
|
env = await this.envApi.create(createEnv);
|
|
133
125
|
await this.runDeploy(env, tfArgs);
|
|
@@ -120,7 +120,7 @@ export class TerraformAdapter {
|
|
|
120
120
|
const argVars = this.getArgVars(args);
|
|
121
121
|
const specialFields = { ...env, env: env.key };
|
|
122
122
|
const extraArgs = [];
|
|
123
|
-
for (const name of ['env', '
|
|
123
|
+
for (const name of ['env', 'ephemeral']) {
|
|
124
124
|
if (varDefs[name] && !argVars[name]) {
|
|
125
125
|
extraArgs.push('-var=' + name + '=' + specialFields[name]);
|
|
126
126
|
}
|
|
@@ -192,9 +192,7 @@ export class TerraformAdapter {
|
|
|
192
192
|
return newVars;
|
|
193
193
|
}
|
|
194
194
|
async plan(env, args, onDemandVars = {}) {
|
|
195
|
-
|
|
196
|
-
args = this.tfArgs(env, args);
|
|
197
|
-
}
|
|
195
|
+
args = this.tfArgs(env, args);
|
|
198
196
|
await this._plan(args, onDemandVars, 1);
|
|
199
197
|
}
|
|
200
198
|
async _plan(args, onDemandVars, attemptNo) {
|
package/dist/util.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function toLocalTime(ttl, timeZone) {
|
|
2
|
+
const date = new Date(ttl * 1000);
|
|
3
|
+
return date.toLocaleString('en-US', {
|
|
4
|
+
timeZone,
|
|
5
|
+
month: 'short',
|
|
6
|
+
day: '2-digit',
|
|
7
|
+
hour: '2-digit',
|
|
8
|
+
minute: '2-digit',
|
|
9
|
+
second: '2-digit',
|
|
10
|
+
hour12: false,
|
|
11
|
+
});
|
|
12
|
+
}
|