@hiiretail/gcp-infra-cli 0.76.2 → 0.76.3
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/generators/init/clan-infra/index.js +7 -0
- package/generators/init/clan-infra/templates/infra/common.hcl +1 -0
- package/generators/init/clan-infra/validate.js +8 -0
- package/generators/resources/monitoring/templates/alerts/terragrunt.hcl +1 -1
- package/generators/resources/monitoring/templates/slos/slos.yaml +1 -1
- package/generators/resources/monitoring/templates/slos/terragrunt.hcl +9 -1
- package/generators/resources/monitoring/validate.js +7 -5
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ const BaseGenerator = require('../../../src/BaseGenerator');
|
|
|
4
4
|
const { chain, required } = require('../../../src/validators');
|
|
5
5
|
const { getGcpProjects, validateGcpProjects } = require('./gcp-projects');
|
|
6
6
|
const getTribeAndClanName = require('./tribe-clan-repo');
|
|
7
|
+
const validate = require('./validate');
|
|
7
8
|
|
|
8
9
|
module.exports = class extends BaseGenerator {
|
|
9
10
|
prompting() {
|
|
@@ -36,6 +37,12 @@ module.exports = class extends BaseGenerator {
|
|
|
36
37
|
message: 'Provide the cost center your tribe belongs to',
|
|
37
38
|
validate: required,
|
|
38
39
|
},
|
|
40
|
+
{
|
|
41
|
+
type: 'input',
|
|
42
|
+
name: 'jiraProjectKey',
|
|
43
|
+
message: 'Provide the "jira project key" for your clan (the uppercase prefix in your task names, example: SRT)',
|
|
44
|
+
validate: required && validate.jiraProjectKey,
|
|
45
|
+
},
|
|
39
46
|
{
|
|
40
47
|
type: 'input',
|
|
41
48
|
name: 'repoName',
|
|
@@ -29,6 +29,6 @@ inputs = {
|
|
|
29
29
|
user_labels = {
|
|
30
30
|
cc = local.common_vars.locals.cost_center
|
|
31
31
|
clan = local.common_vars.locals.clan_name
|
|
32
|
-
jira_project_key = lookup(local.
|
|
32
|
+
jira_project_key = lookup(local.common_vars.locals, "jira_project_key", null)
|
|
33
33
|
},
|
|
34
34
|
}
|
|
@@ -9,6 +9,13 @@ include {
|
|
|
9
9
|
path = find_in_parent_folders("terragrunt_root.hcl")
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
dependency "notification_channels" {
|
|
13
|
+
config_path = "../../notification-channels"
|
|
14
|
+
mock_outputs = {
|
|
15
|
+
notification_channels = ["dummy-channel"]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
locals {
|
|
13
20
|
project_vars = read_terragrunt_config(find_in_parent_folders("project.hcl"))
|
|
14
21
|
}
|
|
@@ -19,7 +26,8 @@ inputs = merge(
|
|
|
19
26
|
{
|
|
20
27
|
service_name = "<%-systemName%>.<%-serviceName%>"
|
|
21
28
|
monitoring_project_id = lookup(local.project_vars.locals, "monitoring_project_id", local.project_vars.locals.tribe_project_id),
|
|
22
|
-
|
|
29
|
+
notification_channels = dependency.notification_channels.outputs.notification_channels,
|
|
23
30
|
telemetry_resource_name = "//container.googleapis.com/projects/${lookup(local.project_vars.locals, "monitoring_project_id", local.project_vars.locals.tribe_project_id)}/locations/europe-west1/clusters/k8s-cluster/k8s/namespaces/<%-serviceName%>"
|
|
31
|
+
slos = yamldecode(file("${get_terragrunt_dir()}/slos.yaml")),
|
|
24
32
|
}
|
|
25
33
|
)
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const validate = {};
|
|
2
2
|
|
|
3
|
+
const hasWhitespace = (str) => /\s/.test(str);
|
|
4
|
+
|
|
3
5
|
validate.hostName = (input) => {
|
|
4
6
|
const regex = new RegExp(/^(?:[a-z-]+\.){1,3}[a-z-]+$/g);
|
|
5
7
|
if (input.match(regex)) return true;
|
|
@@ -7,29 +9,29 @@ validate.hostName = (input) => {
|
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
validate.systemName = (input) => {
|
|
10
|
-
if (input.
|
|
12
|
+
if (input.length === 3 && !hasWhitespace(input)) return true;
|
|
11
13
|
return 'System name must be 3 characters';
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
validate.url = (input) => {
|
|
15
17
|
// eslint-disable-next-line no-useless-escape
|
|
16
18
|
const regex = new RegExp(/^https:\/\/[a-zA-Z]*.[a-zA-Z]*.[a-zA-Z]*\/[a-zA-Z\/+_-]*.$/g);
|
|
17
|
-
if (regex.test(input) || input === '') return true;
|
|
19
|
+
if ((regex.test(input) && !hasWhitespace(input)) || input === '') return true;
|
|
18
20
|
return 'You must enter a valid URL';
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
validate.instanceID = (input) => {
|
|
22
|
-
if (input.split('/').length === 6) return true;
|
|
24
|
+
if (input.split('/').length === 6 && !hasWhitespace(input)) return true;
|
|
23
25
|
return 'You must enter the full instance path (example: projects/example/locations/europe-west1/instances/instanceID)';
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
validate.databaseId = (input) => {
|
|
27
|
-
if (input.split(':').length === 2) return true;
|
|
29
|
+
if (input.split(':').length === 2 && !hasWhitespace(input)) return true;
|
|
28
30
|
return 'You must enter the full database path (example: my-project:databaseID)';
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
validate.pubSubSubscription = (input) => {
|
|
32
|
-
if (input.split('/').length === 4) return true;
|
|
34
|
+
if (input.split('/').length === 4 && !hasWhitespace(input)) return true;
|
|
33
35
|
return 'You must enter the full subscription path (example: projects/example/subscriptions/subscriptionId)';
|
|
34
36
|
};
|
|
35
37
|
|