@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,238 +1,137 @@
|
|
|
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 fs = require('fs');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const BaseGenerator = require('../../../src/BaseGenerator');
|
|
5
|
+
const { required } = require('../../../src/validators');
|
|
114
6
|
|
|
115
|
-
// generators/clan-resources/clan-project/index.js
|
|
116
|
-
var path = require("path");
|
|
117
|
-
var fs = require("fs");
|
|
118
|
-
var chalk = require("chalk");
|
|
119
|
-
var BaseGenerator = require_BaseGenerator();
|
|
120
|
-
var { required } = require_validators();
|
|
121
7
|
module.exports = class extends BaseGenerator {
|
|
122
8
|
constructor(args, opts) {
|
|
123
9
|
super(args, opts);
|
|
124
|
-
|
|
10
|
+
|
|
11
|
+
// Output directory relative to the tf-infra-gcp directory.
|
|
12
|
+
this.destinationRoot('organization');
|
|
125
13
|
}
|
|
14
|
+
|
|
126
15
|
prompting() {
|
|
127
16
|
const prompts = [
|
|
128
17
|
{
|
|
129
|
-
type:
|
|
130
|
-
name:
|
|
131
|
-
default:
|
|
132
|
-
message:
|
|
18
|
+
type: 'list',
|
|
19
|
+
name: 'domain',
|
|
20
|
+
default: 'extendaretail-com',
|
|
21
|
+
message: 'Choose GCP Organization',
|
|
133
22
|
store: true,
|
|
134
23
|
choices: this.listSubDirectories(this.destinationPath()),
|
|
135
|
-
validate: required
|
|
24
|
+
validate: required,
|
|
136
25
|
},
|
|
137
26
|
{
|
|
138
|
-
type:
|
|
139
|
-
name:
|
|
140
|
-
message:
|
|
27
|
+
type: 'list',
|
|
28
|
+
name: 'department',
|
|
29
|
+
message: 'Choose department',
|
|
141
30
|
store: true,
|
|
142
|
-
choices:
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
31
|
+
choices: (answers) =>
|
|
32
|
+
this.listSubDirectories(
|
|
33
|
+
path.join(this.destinationPath(), answers.domain, 'departments'),
|
|
34
|
+
),
|
|
35
|
+
validate: required,
|
|
146
36
|
},
|
|
147
37
|
{
|
|
148
|
-
type:
|
|
149
|
-
name:
|
|
150
|
-
message:
|
|
38
|
+
type: 'list',
|
|
39
|
+
name: 'tribe',
|
|
40
|
+
message: 'Choose tribe',
|
|
151
41
|
store: true,
|
|
152
|
-
choices:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
42
|
+
choices: (answers) =>
|
|
43
|
+
this.listSubDirectories(
|
|
44
|
+
path.join(
|
|
45
|
+
this.destinationPath(),
|
|
46
|
+
answers.domain,
|
|
47
|
+
'departments',
|
|
48
|
+
answers.department,
|
|
49
|
+
),
|
|
50
|
+
),
|
|
51
|
+
validate: required,
|
|
161
52
|
},
|
|
162
53
|
{
|
|
163
|
-
type:
|
|
164
|
-
name:
|
|
165
|
-
message:
|
|
54
|
+
type: 'list',
|
|
55
|
+
name: 'clan',
|
|
56
|
+
message: 'Choose clan',
|
|
166
57
|
store: true,
|
|
167
|
-
choices:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
58
|
+
choices: (answers) =>
|
|
59
|
+
this.listSubDirectories(
|
|
60
|
+
path.join(
|
|
61
|
+
this.destinationPath(),
|
|
62
|
+
answers.domain,
|
|
63
|
+
'departments',
|
|
64
|
+
answers.department,
|
|
65
|
+
answers.tribe,
|
|
66
|
+
'clans',
|
|
67
|
+
),
|
|
68
|
+
),
|
|
69
|
+
validate: required,
|
|
178
70
|
},
|
|
179
71
|
{
|
|
180
|
-
type:
|
|
181
|
-
name:
|
|
182
|
-
message:
|
|
183
|
-
default:
|
|
184
|
-
choices: [
|
|
185
|
-
}
|
|
72
|
+
type: 'list',
|
|
73
|
+
name: 'migration',
|
|
74
|
+
message: 'Is the project in the process of migration to Autopilot?',
|
|
75
|
+
default: 'yes',
|
|
76
|
+
choices: ['yes', 'no'],
|
|
77
|
+
},
|
|
186
78
|
];
|
|
79
|
+
|
|
187
80
|
return this.prompt(prompts).then((props) => {
|
|
188
81
|
this.answers = props;
|
|
189
82
|
});
|
|
190
83
|
}
|
|
84
|
+
|
|
191
85
|
writing() {
|
|
192
86
|
const { domain, department, tribe, clan, migration } = this.answers;
|
|
193
|
-
|
|
87
|
+
|
|
88
|
+
['prod', 'staging'].forEach((env) => {
|
|
194
89
|
this.copyDir(
|
|
195
|
-
|
|
90
|
+
'clan-resources',
|
|
196
91
|
path.join(
|
|
197
92
|
domain,
|
|
198
|
-
|
|
93
|
+
'departments',
|
|
199
94
|
department,
|
|
200
95
|
tribe,
|
|
201
|
-
|
|
96
|
+
'clans',
|
|
202
97
|
clan,
|
|
203
98
|
env,
|
|
204
|
-
|
|
99
|
+
'resources',
|
|
205
100
|
),
|
|
206
101
|
{
|
|
207
102
|
...this.answers,
|
|
208
|
-
env
|
|
209
|
-
}
|
|
103
|
+
env,
|
|
104
|
+
},
|
|
210
105
|
);
|
|
211
106
|
});
|
|
212
|
-
|
|
213
|
-
|
|
107
|
+
|
|
108
|
+
if (migration === 'yes') {
|
|
109
|
+
['prod', 'staging'].forEach((env) => {
|
|
214
110
|
const terragruntFilePath = path.join(
|
|
215
111
|
domain,
|
|
216
|
-
|
|
112
|
+
'departments',
|
|
217
113
|
department,
|
|
218
114
|
tribe,
|
|
219
|
-
|
|
115
|
+
'clans',
|
|
220
116
|
clan,
|
|
221
117
|
env,
|
|
222
|
-
|
|
118
|
+
'terragrunt.hcl',
|
|
223
119
|
);
|
|
224
|
-
|
|
120
|
+
|
|
121
|
+
fs.readFile(terragruntFilePath, 'utf8', (err, data) => {
|
|
225
122
|
if (err) {
|
|
226
123
|
return;
|
|
227
124
|
}
|
|
125
|
+
|
|
228
126
|
const modifiedData = data.replace(
|
|
229
127
|
/source\s*=\s*"git::https:\/\/github\.com\/extenda\/tf-module-gcp-project\/\/\?ref=.+"/,
|
|
230
|
-
'source = "git::https://github.com/extenda/tf-module-gcp-project//?ref=migration"'
|
|
128
|
+
'source = "git::https://github.com/extenda/tf-module-gcp-project//?ref=migration"',
|
|
231
129
|
);
|
|
232
|
-
|
|
130
|
+
|
|
131
|
+
fs.writeFile(terragruntFilePath, modifiedData, 'utf8', (error) => {
|
|
233
132
|
if (error) {
|
|
234
133
|
console.error(
|
|
235
|
-
`Error writing file ${terragruntFilePath}: ${error.message}
|
|
134
|
+
`Error writing file ${terragruntFilePath}: ${error.message}`,
|
|
236
135
|
);
|
|
237
136
|
} else {
|
|
238
137
|
console.log(`Updated file ${terragruntFilePath}`);
|
|
@@ -242,25 +141,26 @@ module.exports = class extends BaseGenerator {
|
|
|
242
141
|
});
|
|
243
142
|
}
|
|
244
143
|
}
|
|
144
|
+
|
|
245
145
|
end() {
|
|
246
146
|
const { domain, department, tribe, clan } = this.answers;
|
|
247
147
|
const clanDir = path.join(
|
|
248
148
|
domain,
|
|
249
|
-
|
|
149
|
+
'departments',
|
|
250
150
|
department,
|
|
251
151
|
tribe,
|
|
252
|
-
|
|
253
|
-
clan
|
|
152
|
+
'clans',
|
|
153
|
+
clan,
|
|
254
154
|
);
|
|
255
155
|
this.log(`
|
|
256
156
|
${chalk.green(`Your clan resources have now been created. To finalize your configuration, please continue
|
|
257
157
|
with manual editing of the generated files.`)}
|
|
258
|
-
${chalk.green(
|
|
259
|
-
\u2192 ${chalk.cyan(path.join(clanDir,
|
|
260
|
-
\u2192 ${chalk.cyan(path.join(clanDir,
|
|
261
|
-
\u2192 ${chalk.cyan(path.join(clanDir,
|
|
262
|
-
\u2192 ${chalk.cyan(path.join(clanDir,
|
|
263
|
-
${chalk.green(
|
|
158
|
+
${chalk.green('1.')} Review the configurations
|
|
159
|
+
\u2192 ${chalk.cyan(path.join(clanDir, 'prod', 'network', 'spec.hcl'))}
|
|
160
|
+
\u2192 ${chalk.cyan(path.join(clanDir, 'prod', 'gke', 'spec.hcl'))}
|
|
161
|
+
\u2192 ${chalk.cyan(path.join(clanDir, 'staging', 'network', 'spec.hcl'))}
|
|
162
|
+
\u2192 ${chalk.cyan(path.join(clanDir, 'staging', 'gke', 'spec.hcl'))}
|
|
163
|
+
${chalk.green('2.')} Push this change in a feature branch and open a pull request.
|
|
264
164
|
`);
|
|
265
165
|
}
|
|
266
166
|
};
|