@hiiretail/gcp-infra-generators 1.0.0 → 1.0.2
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/dist/generators/clan-resources/clan-project/index.js +89 -189
- package/dist/generators/common-resources/bigquery/index.js +172 -267
- package/dist/generators/common-resources/budget/index.js +67 -153
- package/dist/generators/common-resources/cloud-armor/index.js +17 -167
- package/dist/generators/common-resources/cloud-storage/index.js +96 -205
- package/dist/generators/common-resources/cloudsql/index.js +71 -177
- package/dist/generators/common-resources/cloudsql-database/index.js +40 -287
- package/dist/generators/common-resources/confluent-cluster/index.js +23 -132
- package/dist/generators/common-resources/datastore/index.js +48 -194
- package/dist/generators/common-resources/elastic-cloud/index.js +22 -132
- package/dist/generators/common-resources/elastic-index-policy/handle-yaml.js +76 -0
- package/dist/generators/common-resources/elastic-index-policy/index.js +131 -286
- package/dist/generators/common-resources/elastic-template/index.js +52 -162
- package/dist/generators/common-resources/firestore/index.js +93 -233
- package/dist/generators/common-resources/iam/index.js +35 -157
- package/dist/generators/common-resources/iam/valid-prefix.js +8 -0
- package/dist/generators/common-resources/kafka-connect/index.js +35 -144
- package/dist/generators/common-resources/kafka-topics/index.js +20 -129
- package/dist/generators/common-resources/kms/index.js +31 -141
- package/dist/generators/common-resources/memorystore/index.js +42 -328
- package/dist/generators/common-resources/monitoring/handle-yaml.js +49 -0
- package/dist/generators/common-resources/monitoring/index.js +144 -322
- package/dist/generators/common-resources/monitoring/templates/alerts/generic-infra.yaml +37 -2
- package/dist/generators/common-resources/monitoring/validate.js +58 -0
- package/dist/generators/common-resources/pubsub/append.js +130 -0
- package/dist/generators/common-resources/pubsub/get-gcp-projects.js +34 -0
- package/dist/generators/common-resources/pubsub/handle-subscribers.js +68 -0
- package/dist/generators/common-resources/pubsub/index.js +194 -536
- package/dist/generators/common-resources/pubsub/validate.js +53 -0
- package/dist/generators/common-resources/scheduler/append.js +85 -0
- package/dist/generators/common-resources/scheduler/index.js +62 -249
- package/dist/generators/common-resources/spanner/append.js +31 -0
- package/dist/generators/common-resources/spanner/index.js +102 -269
- package/dist/generators/common-resources/spanner/validate.js +38 -0
- package/dist/generators/docs/rca/index.js +25 -135
- package/dist/generators/docs/runbook/index.js +16 -126
- package/dist/generators/docs/srb/index.js +33 -147
- package/dist/generators/docs/srb/run-docker.js +2 -0
- package/dist/generators/init/clan-infra/gcp-projects.js +47 -0
- package/dist/generators/init/clan-infra/index.js +95 -290
- package/dist/generators/init/clan-infra/tribe-clan-repo.js +38 -0
- package/dist/generators/init/clan-infra/validate.js +8 -0
- package/dist/generators/maintenance/manage-states/index.js +142 -219
- package/dist/generators/maintenance/update-modules/index.js +56 -155
- package/dist/generators/organization/clan-project/googlecloud.js +124 -0
- package/dist/generators/organization/clan-project/index.js +81 -303
- package/dist/node_modules/.package-lock.json +88 -31
- package/dist/node_modules/@google-cloud/storage/build/cjs/src/bucket.js +5 -5
- package/dist/node_modules/@google-cloud/storage/build/cjs/src/file.d.ts +1 -0
- package/dist/node_modules/@google-cloud/storage/build/cjs/src/file.js +10 -1
- package/dist/node_modules/@google-cloud/storage/build/cjs/src/storage.js +1 -1
- package/dist/node_modules/@google-cloud/storage/build/cjs/src/transfer-manager.d.ts +4 -4
- package/dist/node_modules/@google-cloud/storage/build/cjs/src/transfer-manager.js +4 -4
- package/dist/node_modules/@google-cloud/storage/build/cjs/src/util.d.ts +1 -1
- package/dist/node_modules/@google-cloud/storage/build/cjs/src/util.js +2 -2
- package/dist/node_modules/@google-cloud/storage/build/esm/src/bucket.js +5 -5
- package/dist/node_modules/@google-cloud/storage/build/esm/src/file.d.ts +1 -0
- package/dist/node_modules/@google-cloud/storage/build/esm/src/file.js +10 -1
- package/dist/node_modules/@google-cloud/storage/build/esm/src/storage.js +1 -1
- package/dist/node_modules/@google-cloud/storage/build/esm/src/transfer-manager.d.ts +4 -4
- package/dist/node_modules/@google-cloud/storage/build/esm/src/transfer-manager.js +4 -4
- package/dist/node_modules/@google-cloud/storage/build/esm/src/util.d.ts +1 -1
- package/dist/node_modules/@google-cloud/storage/build/esm/src/util.js +2 -2
- package/dist/node_modules/@google-cloud/storage/package.json +5 -5
- package/dist/package.json +45 -0
- package/dist/src/BaseGenerator.js +84 -0
- package/dist/src/SecretsGenerator.js +137 -0
- package/dist/src/cli.js +54 -255
- package/dist/src/dependency-check.js +48 -0
- package/dist/src/update-check.js +38 -0
- package/dist/src/validators.js +33 -0
- package/dist/src/yeoman.js +80 -0
- package/package.json +2 -3
- package/dist/node_modules/@google-cloud/storage/CHANGELOG.md +0 -1769
|
@@ -1,381 +1,226 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// src/validators.js
|
|
9
|
-
var require_validators = __commonJS({
|
|
10
|
-
"src/validators.js"(exports2, module2) {
|
|
11
|
-
var path2 = require("path");
|
|
12
|
-
module2.exports = {
|
|
13
|
-
chain: /* @__PURE__ */ __name((input, ...validators) => {
|
|
14
|
-
let msg = "";
|
|
15
|
-
validators.every((validator) => {
|
|
16
|
-
msg = validator(input);
|
|
17
|
-
return msg === true;
|
|
18
|
-
});
|
|
19
|
-
return msg === true ? true : msg;
|
|
20
|
-
}, "chain"),
|
|
21
|
-
filename: /* @__PURE__ */ __name((input) => {
|
|
22
|
-
if (!input) {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
return path2.basename(input) === input ? true : "Invalid filename";
|
|
26
|
-
}, "filename"),
|
|
27
|
-
maxLength: /* @__PURE__ */ __name((input, maxLength) => !input || input.length <= maxLength ? true : `Exceeds max \
|
|
28
|
-
length: ${maxLength}`, "maxLength"),
|
|
29
|
-
required: /* @__PURE__ */ __name((input) => {
|
|
30
|
-
const msg = "Required";
|
|
31
|
-
if (Array.isArray(input)) {
|
|
32
|
-
return input.length > 0 ? true : msg;
|
|
33
|
-
}
|
|
34
|
-
if (input) {
|
|
35
|
-
return input.trim().length > 0 ? true : msg;
|
|
36
|
-
}
|
|
37
|
-
return msg;
|
|
38
|
-
}, "required")
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// src/BaseGenerator.js
|
|
44
|
-
var require_BaseGenerator = __commonJS({
|
|
45
|
-
"src/BaseGenerator.js"(exports2, module2) {
|
|
46
|
-
var Generator = require("yeoman-generator");
|
|
47
|
-
var path2 = require("path");
|
|
48
|
-
var fs2 = require("fs");
|
|
49
|
-
var inquirer = require("inquirer");
|
|
50
|
-
var { chain, required: required2, filename } = require_validators();
|
|
51
|
-
module2.exports = class extends Generator {
|
|
52
|
-
constructor(args, opts) {
|
|
53
|
-
super(args, opts);
|
|
54
|
-
this.baseDir = path2.resolve(path2.join(__dirname, ".."));
|
|
55
|
-
this.destinationRoot(process.cwd());
|
|
56
|
-
const [command, generator] = opts.namespace.split(":").slice(-2);
|
|
57
|
-
this.generatorId = path2.join(command, generator);
|
|
58
|
-
this.sourceRoot(
|
|
59
|
-
path2.join(this.baseDir, "generators", this.generatorId, "templates")
|
|
60
|
-
);
|
|
61
|
-
this.copyDir = (templateDir, targetDir, answers = this.answers, skipIfExists = false) => {
|
|
62
|
-
if (skipIfExists && fs2.existsSync(targetDir)) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
this.fs.copyTpl(
|
|
66
|
-
this.templatePath(`${templateDir}/**/*`),
|
|
67
|
-
this.destinationPath(targetDir),
|
|
68
|
-
answers
|
|
69
|
-
);
|
|
70
|
-
};
|
|
71
|
-
this.listSubDirectories = (parent) => fs2.readdirSync(parent).filter((f) => !f.startsWith(".")).filter((f) => fs2.
|
|
72
|
-
lstatSync(path2.join(parent, f)).isDirectory()).sort((a, b) => a.localeCompare(b));
|
|
73
|
-
this.kebabCase = (input) => input.replace(/\s|_/g, "-");
|
|
74
|
-
this.chooseOrCreatePrompts = (name, getChoicesDirectory) => [
|
|
75
|
-
{
|
|
76
|
-
when: /* @__PURE__ */ __name((answers) => fs2.existsSync(getChoicesDirectory(answers)), "when"),
|
|
77
|
-
type: "list",
|
|
78
|
-
name,
|
|
79
|
-
message: `Choose ${name}`,
|
|
80
|
-
store: true,
|
|
81
|
-
choices: /* @__PURE__ */ __name((answers) => [
|
|
82
|
-
...this.listSubDirectories(getChoicesDirectory(answers)),
|
|
83
|
-
new inquirer.Separator(),
|
|
84
|
-
`Create new ${name}`
|
|
85
|
-
], "choices"),
|
|
86
|
-
validate: required2,
|
|
87
|
-
filter: this.kebabCase
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
when: /* @__PURE__ */ __name((answers) => !fs2.existsSync(getChoicesDirectory(answers)) || answers[name] ===
|
|
91
|
-
`Create-new-${name}`, "when"),
|
|
92
|
-
type: "input",
|
|
93
|
-
name: `new-${name}`,
|
|
94
|
-
message: `New ${name} name`,
|
|
95
|
-
store: false,
|
|
96
|
-
validate: /* @__PURE__ */ __name((input) => chain(input, required2, filename), "validate"),
|
|
97
|
-
filter: this.kebabCase
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
when: /* @__PURE__ */ __name((answers) => !fs2.existsSync(getChoicesDirectory(answers)) || answers[name] ===
|
|
101
|
-
"Create-new-tribe", "when"),
|
|
102
|
-
type: "input",
|
|
103
|
-
name: "costCenter",
|
|
104
|
-
message: "Please provide the Cost Center of the Tribe",
|
|
105
|
-
store: false,
|
|
106
|
-
validate: /* @__PURE__ */ __name((input) => chain(input, required2, filename), "validate"),
|
|
107
|
-
filter: this.kebabCase
|
|
108
|
-
}
|
|
109
|
-
];
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
});
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const chalk = require('chalk');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const BaseGenerator = require('../../../src/BaseGenerator');
|
|
5
|
+
const { required } = require('../../../src/validators');
|
|
6
|
+
const handlePolicies = require('./handle-yaml');
|
|
114
7
|
|
|
115
|
-
// generators/common-resources/elastic-index-policy/handle-yaml.js
|
|
116
|
-
var require_handle_yaml = __commonJS({
|
|
117
|
-
"generators/common-resources/elastic-index-policy/handle-yaml.js"(exports2, module2) {
|
|
118
|
-
var fs2 = require("fs");
|
|
119
|
-
var yaml = require("js-yaml");
|
|
120
|
-
var handleHotPhase = /* @__PURE__ */ __name((answers, phaseData) => {
|
|
121
|
-
if (answers.hotReadonly === "true") {
|
|
122
|
-
phaseData.readonly = { enabled: true };
|
|
123
|
-
}
|
|
124
|
-
if (answers.hotPriority) {
|
|
125
|
-
phaseData.set_priority = { priority: answers.hotPriority };
|
|
126
|
-
}
|
|
127
|
-
}, "handleHotPhase");
|
|
128
|
-
var handleColdPhase = /* @__PURE__ */ __name((answers, phaseData) => {
|
|
129
|
-
if (answers.coldReadonly === "true") {
|
|
130
|
-
phaseData.readonly = { enabled: true };
|
|
131
|
-
}
|
|
132
|
-
if (answers.coldPriority) {
|
|
133
|
-
phaseData.set_priority = { priority: answers.coldPriority };
|
|
134
|
-
}
|
|
135
|
-
if (answers.coldFreeze === "true") {
|
|
136
|
-
phaseData.freeze = { enabled: true };
|
|
137
|
-
}
|
|
138
|
-
}, "handleColdPhase");
|
|
139
|
-
var handleWarmPhase = /* @__PURE__ */ __name((answers, phaseData) => {
|
|
140
|
-
if (answers.warmReadonly === "true") {
|
|
141
|
-
phaseData.readonly = { enabled: true };
|
|
142
|
-
}
|
|
143
|
-
if (answers.warmPriority) {
|
|
144
|
-
phaseData.set_priority = { priority: answers.warmPriority };
|
|
145
|
-
}
|
|
146
|
-
if (answers.warmMigrate === "true") {
|
|
147
|
-
phaseData.migrate = { enabled: true };
|
|
148
|
-
}
|
|
149
|
-
}, "handleWarmPhase");
|
|
150
|
-
var handlePolicies2 = /* @__PURE__ */ __name(async (answers, yamlPath) => {
|
|
151
|
-
const existingData = yaml.load(fs2.readFileSync(yamlPath, "utf8")) || {
|
|
152
|
-
policies: []
|
|
153
|
-
};
|
|
154
|
-
const policy = {
|
|
155
|
-
name: answers.policyName
|
|
156
|
-
};
|
|
157
|
-
answers.phase.forEach((phase) => {
|
|
158
|
-
const phaseData = {
|
|
159
|
-
min_age: answers[`${phase}MinAge`]
|
|
160
|
-
};
|
|
161
|
-
if (phase === "hot") {
|
|
162
|
-
handleHotPhase(answers, phaseData);
|
|
163
|
-
}
|
|
164
|
-
if (phase === "cold") {
|
|
165
|
-
handleColdPhase(answers, phaseData);
|
|
166
|
-
}
|
|
167
|
-
if (phase === "warm") {
|
|
168
|
-
handleWarmPhase(answers, phaseData);
|
|
169
|
-
}
|
|
170
|
-
policy[phase] = phaseData;
|
|
171
|
-
});
|
|
172
|
-
existingData.policies.push(policy);
|
|
173
|
-
fs2.writeFileSync(yamlPath, yaml.dump(existingData));
|
|
174
|
-
}, "handlePolicies");
|
|
175
|
-
module2.exports = handlePolicies2;
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
// generators/common-resources/elastic-index-policy/index.js
|
|
180
|
-
var path = require("path");
|
|
181
|
-
var chalk = require("chalk");
|
|
182
|
-
var fs = require("fs");
|
|
183
|
-
var BaseGenerator = require_BaseGenerator();
|
|
184
|
-
var { required } = require_validators();
|
|
185
|
-
var handlePolicies = require_handle_yaml();
|
|
186
8
|
module.exports = class extends BaseGenerator {
|
|
187
9
|
prompting() {
|
|
188
10
|
const prompts = [
|
|
189
11
|
{
|
|
190
|
-
type:
|
|
191
|
-
name:
|
|
192
|
-
message:
|
|
193
|
-
validate: required
|
|
12
|
+
type: 'input',
|
|
13
|
+
name: 'policyName',
|
|
14
|
+
message: 'Please provide the name of the lifecycle policy',
|
|
15
|
+
validate: required,
|
|
194
16
|
},
|
|
195
17
|
{
|
|
196
|
-
type:
|
|
197
|
-
name:
|
|
198
|
-
message:
|
|
18
|
+
type: 'checkbox',
|
|
19
|
+
name: 'phase',
|
|
20
|
+
message: 'Please select lifecycle phases to be used within the policy',
|
|
199
21
|
choices: [
|
|
200
22
|
{
|
|
201
|
-
name:
|
|
202
|
-
value:
|
|
23
|
+
name: 'The index is actively being updated and queried - hot',
|
|
24
|
+
value: 'hot',
|
|
203
25
|
},
|
|
204
26
|
{
|
|
205
|
-
name:
|
|
206
|
-
value:
|
|
27
|
+
name: 'The index is no longer being updated but is still being queried - warm',
|
|
28
|
+
value: 'warm',
|
|
207
29
|
},
|
|
208
30
|
{
|
|
209
|
-
name:
|
|
210
|
-
value:
|
|
31
|
+
name: 'The index is no longer being updated and is queried infrequently - cold',
|
|
32
|
+
value: 'cold',
|
|
211
33
|
},
|
|
212
34
|
{
|
|
213
|
-
name:
|
|
214
|
-
value:
|
|
35
|
+
name: 'The index is no longer being updated and is queried rarely - frozen',
|
|
36
|
+
value: 'frozen',
|
|
215
37
|
},
|
|
216
38
|
{
|
|
217
|
-
name:
|
|
218
|
-
value:
|
|
219
|
-
}
|
|
220
|
-
]
|
|
221
|
-
}
|
|
39
|
+
name: 'The index is no longer needed and can safely be removed - delete',
|
|
40
|
+
value: 'delete',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
222
44
|
];
|
|
45
|
+
|
|
223
46
|
return this.prompt(prompts).then((props) => {
|
|
224
47
|
this.answers = props;
|
|
48
|
+
|
|
225
49
|
const additionalPrompts = [];
|
|
226
|
-
|
|
50
|
+
|
|
51
|
+
if (this.answers.phase.includes('hot')) {
|
|
227
52
|
additionalPrompts.push({
|
|
228
|
-
type:
|
|
229
|
-
name:
|
|
230
|
-
message:
|
|
231
|
-
10h, 10d
|
|
232
|
-
validate: required
|
|
53
|
+
type: 'input',
|
|
54
|
+
name: 'hotMinAge',
|
|
55
|
+
message:
|
|
56
|
+
'Please provide a minimum age for the hot phase to control the timing of the transition. Format: 10s, 10h, 10d',
|
|
57
|
+
validate: required,
|
|
233
58
|
});
|
|
59
|
+
|
|
234
60
|
additionalPrompts.push({
|
|
235
|
-
type:
|
|
236
|
-
name:
|
|
237
|
-
message:
|
|
238
|
-
choices: [
|
|
61
|
+
type: 'list',
|
|
62
|
+
name: 'hotReadonly',
|
|
63
|
+
message: 'Please select true to make the index read-only',
|
|
64
|
+
choices: ['true', 'false'],
|
|
239
65
|
});
|
|
66
|
+
|
|
240
67
|
additionalPrompts.push({
|
|
241
|
-
type:
|
|
242
|
-
name:
|
|
243
|
-
message:
|
|
68
|
+
type: 'input',
|
|
69
|
+
name: 'hotPriority',
|
|
70
|
+
message:
|
|
71
|
+
'Please provide the priority for the index. Must be 0 or greater (leave empty to add later)',
|
|
244
72
|
});
|
|
245
73
|
}
|
|
246
|
-
|
|
74
|
+
|
|
75
|
+
if (this.answers.phase.includes('cold')) {
|
|
247
76
|
additionalPrompts.push({
|
|
248
|
-
type:
|
|
249
|
-
name:
|
|
250
|
-
message:
|
|
251
|
-
, 10h, 10d
|
|
252
|
-
validate: required
|
|
77
|
+
type: 'input',
|
|
78
|
+
name: 'coldMinAge',
|
|
79
|
+
message:
|
|
80
|
+
'Please provide a minimum age for the cold phase to control the timing of the transition. Format: 10s, 10h, 10d',
|
|
81
|
+
validate: required,
|
|
253
82
|
});
|
|
83
|
+
|
|
254
84
|
additionalPrompts.push({
|
|
255
|
-
type:
|
|
256
|
-
name:
|
|
257
|
-
message:
|
|
258
|
-
choices: [
|
|
85
|
+
type: 'list',
|
|
86
|
+
name: 'coldReadonly',
|
|
87
|
+
message: 'Please select true to make the index read-only',
|
|
88
|
+
choices: ['true', 'false'],
|
|
259
89
|
});
|
|
90
|
+
|
|
260
91
|
additionalPrompts.push({
|
|
261
|
-
type:
|
|
262
|
-
name:
|
|
263
|
-
message:
|
|
92
|
+
type: 'input',
|
|
93
|
+
name: 'coldPriority',
|
|
94
|
+
message:
|
|
95
|
+
'Please provide the priority for the index. Must be 0 or greater (leave empty to add later)',
|
|
264
96
|
});
|
|
97
|
+
|
|
265
98
|
additionalPrompts.push({
|
|
266
|
-
type:
|
|
267
|
-
name:
|
|
268
|
-
message:
|
|
269
|
-
|
|
99
|
+
type: 'list',
|
|
100
|
+
name: 'coldFreeze',
|
|
101
|
+
message:
|
|
102
|
+
'Please select true if you want to freeze the index to minimize its memory footprint',
|
|
103
|
+
choices: ['true', 'false'],
|
|
270
104
|
});
|
|
271
105
|
}
|
|
272
|
-
|
|
106
|
+
|
|
107
|
+
if (this.answers.phase.includes('warm')) {
|
|
273
108
|
additionalPrompts.push({
|
|
274
|
-
type:
|
|
275
|
-
name:
|
|
276
|
-
message:
|
|
277
|
-
, 10h, 10d
|
|
278
|
-
validate: required
|
|
109
|
+
type: 'input',
|
|
110
|
+
name: 'warmMinAge',
|
|
111
|
+
message:
|
|
112
|
+
'Please provide a minimum age for the warm phase to control the timing of the transition. Format: 10s, 10h, 10d',
|
|
113
|
+
validate: required,
|
|
279
114
|
});
|
|
115
|
+
|
|
280
116
|
additionalPrompts.push({
|
|
281
|
-
type:
|
|
282
|
-
name:
|
|
283
|
-
message:
|
|
284
|
-
choices: [
|
|
117
|
+
type: 'list',
|
|
118
|
+
name: 'warmReadonly',
|
|
119
|
+
message: 'Please select true to make the index read-only',
|
|
120
|
+
choices: ['true', 'false'],
|
|
285
121
|
});
|
|
122
|
+
|
|
286
123
|
additionalPrompts.push({
|
|
287
|
-
type:
|
|
288
|
-
name:
|
|
289
|
-
message:
|
|
124
|
+
type: 'input',
|
|
125
|
+
name: 'warmPriority',
|
|
126
|
+
message:
|
|
127
|
+
'Please provide the priority for the index. Must be 0 or greater (leave empty to add later)',
|
|
290
128
|
});
|
|
129
|
+
|
|
291
130
|
additionalPrompts.push({
|
|
292
|
-
type:
|
|
293
|
-
name:
|
|
294
|
-
message:
|
|
295
|
-
|
|
296
|
-
choices: [
|
|
131
|
+
type: 'list',
|
|
132
|
+
name: 'warmMigrate',
|
|
133
|
+
message:
|
|
134
|
+
'Please select true if you want to move the index to the data tier that corresponds to the current phase',
|
|
135
|
+
choices: ['true', 'false'],
|
|
297
136
|
});
|
|
298
137
|
}
|
|
299
|
-
|
|
138
|
+
|
|
139
|
+
if (this.answers.phase.includes('frozen')) {
|
|
300
140
|
additionalPrompts.push({
|
|
301
|
-
type:
|
|
302
|
-
name:
|
|
303
|
-
message:
|
|
304
|
-
|
|
305
|
-
validate: required
|
|
141
|
+
type: 'input',
|
|
142
|
+
name: 'frozenMinAge',
|
|
143
|
+
message:
|
|
144
|
+
'Please provide a minimum age for the frozen phase to control the timing of the transition. Format: 10s, 10h, 10d',
|
|
145
|
+
validate: required,
|
|
306
146
|
});
|
|
307
147
|
}
|
|
308
|
-
|
|
148
|
+
|
|
149
|
+
if (this.answers.phase.includes('delete')) {
|
|
309
150
|
additionalPrompts.push({
|
|
310
|
-
type:
|
|
311
|
-
name:
|
|
312
|
-
message:
|
|
313
|
-
|
|
314
|
-
validate: required
|
|
151
|
+
type: 'input',
|
|
152
|
+
name: 'deleteMinAge',
|
|
153
|
+
message:
|
|
154
|
+
'Please provide a minimum age for the delete phase to control the timing of the transition. Format: 10s, 10h, 10d',
|
|
155
|
+
validate: required,
|
|
315
156
|
});
|
|
316
157
|
}
|
|
158
|
+
|
|
317
159
|
return this.prompt(additionalPrompts).then((promptProps) => {
|
|
318
160
|
this.answers = {
|
|
319
161
|
...this.answers,
|
|
320
|
-
...promptProps
|
|
162
|
+
...promptProps,
|
|
321
163
|
};
|
|
322
164
|
});
|
|
323
165
|
});
|
|
324
166
|
}
|
|
167
|
+
|
|
325
168
|
writing() {
|
|
326
169
|
const { policyName, phase } = this.answers;
|
|
170
|
+
|
|
327
171
|
return Promise.all(
|
|
328
|
-
[
|
|
172
|
+
['prod', 'staging'].map(async (env) => {
|
|
329
173
|
const resourceDir = path.join(
|
|
330
174
|
process.cwd(),
|
|
331
|
-
|
|
175
|
+
'infra',
|
|
332
176
|
env,
|
|
333
|
-
|
|
177
|
+
'elastic-index-policy',
|
|
334
178
|
);
|
|
335
179
|
this.fs.copyTpl(
|
|
336
|
-
this.templatePath(
|
|
180
|
+
this.templatePath('policy/terragrunt.hcl'),
|
|
337
181
|
this.destinationPath(`${resourceDir}/terragrunt.hcl`),
|
|
338
182
|
{
|
|
339
183
|
...this.answers,
|
|
340
184
|
env,
|
|
341
185
|
policyName,
|
|
342
|
-
phase
|
|
343
|
-
}
|
|
186
|
+
phase,
|
|
187
|
+
},
|
|
344
188
|
);
|
|
189
|
+
|
|
345
190
|
const yamlPath = `${resourceDir}/policy.yaml`;
|
|
346
191
|
if (!fs.existsSync(resourceDir)) {
|
|
347
192
|
fs.mkdirSync(resourceDir, { recursive: true });
|
|
348
193
|
}
|
|
194
|
+
|
|
349
195
|
if (!fs.existsSync(yamlPath)) {
|
|
350
|
-
fs.writeFileSync(yamlPath,
|
|
196
|
+
fs.writeFileSync(yamlPath, '');
|
|
351
197
|
this.fs.copyTpl(
|
|
352
|
-
this.templatePath(
|
|
198
|
+
this.templatePath('policy/policy.yaml'),
|
|
353
199
|
this.destinationPath(yamlPath),
|
|
354
200
|
{
|
|
355
201
|
...this.answers,
|
|
356
202
|
env,
|
|
357
203
|
policyName,
|
|
358
|
-
phase
|
|
359
|
-
}
|
|
204
|
+
phase,
|
|
205
|
+
},
|
|
360
206
|
);
|
|
361
207
|
} else {
|
|
362
208
|
await handlePolicies(this.answers, yamlPath);
|
|
363
209
|
}
|
|
364
|
-
})
|
|
210
|
+
}),
|
|
365
211
|
);
|
|
366
212
|
}
|
|
213
|
+
|
|
367
214
|
end() {
|
|
368
|
-
const specStageFile = path.join(
|
|
369
|
-
const specProdFile = path.join(
|
|
215
|
+
const specStageFile = path.join('infra', 'staging', 'elastic-index-policy');
|
|
216
|
+
const specProdFile = path.join('infra', 'prod', 'elastic-index-policy');
|
|
370
217
|
this.log(`
|
|
371
|
-
${chalk.green(`Your Elastic Lifecycle policy configurations have now been created. To finalize your configuration,
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
${chalk.
|
|
376
|
-
|
|
377
|
-
\u2192 ${chalk.cyan(path.join(specProdFile, "policy.yaml"))}
|
|
378
|
-
${chalk.green("2.")} Push this change in a feature branch and open a pull request.
|
|
218
|
+
${chalk.green(`Your Elastic Lifecycle policy configurations have now been created. To finalize your configuration, please continue
|
|
219
|
+
with manual editing of the generated files. Check tf-module-gcp-elastic/policy module for more options you can add to the policy.`)}
|
|
220
|
+
${chalk.green('1.')} Review policy configuration
|
|
221
|
+
\u2192 ${chalk.cyan(path.join(specStageFile, 'policy.yaml'))}
|
|
222
|
+
\u2192 ${chalk.cyan(path.join(specProdFile, 'policy.yaml'))}
|
|
223
|
+
${chalk.green('2.')} Push this change in a feature branch and open a pull request.
|
|
379
224
|
`);
|
|
380
225
|
}
|
|
381
226
|
};
|