@hiiretail/gcp-infra-cli 0.104.0 → 1.0.1
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/README.md +9 -46
- package/bin/gcp-infra +5 -2
- package/package.json +7 -30
- package/src/gcp-infra.js +90 -0
- package/LICENSE +0 -21
- package/generators/clan-resources/clan-project/generator.json +0 -4
- package/generators/clan-resources/clan-project/index.js +0 -135
- package/generators/clan-resources/clan-project/templates/clan-resources/cloud-nat/terragrunt.hcl +0 -52
- package/generators/clan-resources/clan-project/templates/clan-resources/cloud-nat-static-ip/spec.hcl +0 -7
- package/generators/clan-resources/clan-project/templates/clan-resources/cloud-nat-static-ip/terragrunt.hcl +0 -25
- package/generators/clan-resources/clan-project/templates/clan-resources/cloud-router/terragrunt.hcl +0 -34
- package/generators/clan-resources/clan-project/templates/clan-resources/gke/gke-resources/terragrunt.hcl +0 -40
- package/generators/clan-resources/clan-project/templates/clan-resources/gke/spec.hcl +0 -18
- package/generators/clan-resources/clan-project/templates/clan-resources/gke/terragrunt.hcl +0 -52
- package/generators/clan-resources/clan-project/templates/clan-resources/network/firewall-rules/config/main.tf +0 -41
- package/generators/clan-resources/clan-project/templates/clan-resources/network/firewall-rules/config/vars.tf +0 -9
- package/generators/clan-resources/clan-project/templates/clan-resources/network/firewall-rules/terragrunt.hcl +0 -32
- package/generators/clan-resources/clan-project/templates/clan-resources/network/spec.hcl +0 -54
- package/generators/clan-resources/clan-project/templates/clan-resources/network/terragrunt.hcl +0 -29
- package/generators/clan-resources/clan-project/templates/clan-resources/private-vpc-connection/config/main.tf +0 -18
- package/generators/clan-resources/clan-project/templates/clan-resources/private-vpc-connection/config/vars.tf +0 -27
- package/generators/clan-resources/clan-project/templates/clan-resources/private-vpc-connection/terragrunt.hcl +0 -35
- package/generators/clan-resources/clan-project/templates/clan-resources/serverless-vpc-connector/terragrunt.hcl +0 -40
- package/generators/clan-resources/clan-project/templates/clan-resources/terragrunt.hcl +0 -3
- package/generators/clan-resources/command.json +0 -7
- package/generators/common-resources/bigquery/generator.json +0 -4
- package/generators/common-resources/bigquery/index.js +0 -284
- package/generators/common-resources/bigquery/templates/bigquery/spec.hcl +0 -8
- package/generators/common-resources/bigquery/templates/bigquery/terragrunt.hcl +0 -53
- package/generators/common-resources/bigquery/templates/scheduled-queries/terragrunt.hcl +0 -56
- package/generators/common-resources/bigquery/templates/schema/schema.json +0 -14
- package/generators/common-resources/budget/generator.json +0 -4
- package/generators/common-resources/budget/index.js +0 -89
- package/generators/common-resources/budget/templates/budget/terragrunt.hcl +0 -45
- package/generators/common-resources/cloud-armor/generator.json +0 -4
- package/generators/common-resources/cloud-armor/index.js +0 -45
- package/generators/common-resources/cloud-armor/templates/policies.yaml +0 -53
- package/generators/common-resources/cloud-armor/templates/terragrunt.hcl +0 -30
- package/generators/common-resources/cloud-storage/generator.json +0 -4
- package/generators/common-resources/cloud-storage/index.js +0 -156
- package/generators/common-resources/cloud-storage/templates/cloud-storage/storage.yaml +0 -26
- package/generators/common-resources/cloud-storage/templates/cloud-storage/terragrunt.hcl +0 -32
- package/generators/common-resources/cloudsql/generator.json +0 -4
- package/generators/common-resources/cloudsql/index.js +0 -106
- package/generators/common-resources/cloudsql/templates/mssql/instance/spec.hcl +0 -76
- package/generators/common-resources/cloudsql/templates/mssql/instance/terragrunt.hcl +0 -38
- package/generators/common-resources/cloudsql/templates/mssql/instance-secrets/terragrunt.hcl +0 -37
- package/generators/common-resources/cloudsql/templates/mysql/instance/spec.hcl +0 -73
- package/generators/common-resources/cloudsql/templates/mysql/instance/terragrunt.hcl +0 -40
- package/generators/common-resources/cloudsql/templates/mysql/instance-secrets/terragrunt.hcl +0 -38
- package/generators/common-resources/cloudsql/templates/postgres-clan/instance/spec.hcl +0 -102
- package/generators/common-resources/cloudsql/templates/postgres-clan/instance/terragrunt.hcl +0 -36
- package/generators/common-resources/cloudsql/templates/postgres-clan/instance-secrets/terragrunt.hcl +0 -44
- package/generators/common-resources/cloudsql-database/generator.json +0 -4
- package/generators/common-resources/cloudsql-database/index.js +0 -70
- package/generators/common-resources/cloudsql-database/templates/mysql/database/proxy_port.hcl +0 -4
- package/generators/common-resources/cloudsql-database/templates/mysql/database/terragrunt.hcl +0 -69
- package/generators/common-resources/cloudsql-database/templates/mysql/outputs.json +0 -5
- package/generators/common-resources/cloudsql-database/templates/mysql/secrets/terragrunt.hcl +0 -30
- package/generators/common-resources/cloudsql-database/templates/postgres/database/proxy_port.hcl +0 -4
- package/generators/common-resources/cloudsql-database/templates/postgres/database/spec.hcl +0 -17
- package/generators/common-resources/cloudsql-database/templates/postgres/database/terragrunt.hcl +0 -74
- package/generators/common-resources/cloudsql-database/templates/postgres/outputs.json +0 -5
- package/generators/common-resources/cloudsql-database/templates/postgres/secrets/terragrunt.hcl +0 -30
- package/generators/common-resources/command.json +0 -8
- package/generators/common-resources/confluent-cluster/generator.json +0 -4
- package/generators/common-resources/confluent-cluster/index.js +0 -52
- package/generators/common-resources/confluent-cluster/templates/confluent/spec.hcl +0 -5
- package/generators/common-resources/confluent-cluster/templates/confluent/terragrunt.hcl +0 -25
- package/generators/common-resources/datastore/generator.json +0 -4
- package/generators/common-resources/datastore/index.js +0 -91
- package/generators/common-resources/datastore/templates/datastore/indexes.yaml +0 -6
- package/generators/common-resources/datastore/templates/datastore/terragrunt.hcl +0 -23
- package/generators/common-resources/elastic-cloud/generator.json +0 -4
- package/generators/common-resources/elastic-cloud/index.js +0 -52
- package/generators/common-resources/elastic-cloud/templates/elastic/spec.hcl +0 -27
- package/generators/common-resources/elastic-cloud/templates/elastic/terragrunt.hcl +0 -27
- package/generators/common-resources/elastic-index-policy/generator.json +0 -4
- package/generators/common-resources/elastic-index-policy/handle-yaml.js +0 -76
- package/generators/common-resources/elastic-index-policy/index.js +0 -210
- package/generators/common-resources/elastic-index-policy/templates/policy/policy.yaml +0 -28
- package/generators/common-resources/elastic-index-policy/templates/policy/terragrunt.hcl +0 -25
- package/generators/common-resources/elastic-template/generator.json +0 -4
- package/generators/common-resources/elastic-template/index.js +0 -84
- package/generators/common-resources/elastic-template/templates/elastic-template/mappings.json +0 -1
- package/generators/common-resources/elastic-template/templates/elastic-template/terragrunt.hcl +0 -35
- package/generators/common-resources/firestore/generator.json +0 -4
- package/generators/common-resources/firestore/index.js +0 -141
- package/generators/common-resources/firestore/templates/firestore/indexes/indexes.yaml +0 -12
- package/generators/common-resources/firestore/templates/firestore/indexes/terragrunt.hcl +0 -27
- package/generators/common-resources/firestore/templates/firestore/spec.hcl +0 -31
- package/generators/common-resources/firestore/templates/firestore/terragrunt.hcl +0 -25
- package/generators/common-resources/iam/generator.json +0 -4
- package/generators/common-resources/iam/index.js +0 -62
- package/generators/common-resources/iam/templates/github/workflows/iam.yml +0 -18
- package/generators/common-resources/iam/templates/iam.yaml +0 -8
- package/generators/common-resources/iam/valid-prefix.js +0 -8
- package/generators/common-resources/kafka-connect/generator.json +0 -4
- package/generators/common-resources/kafka-connect/index.js +0 -75
- package/generators/common-resources/kafka-connect/templates/elastic/terragrunt.hcl +0 -92
- package/generators/common-resources/kafka-connect/templates/pubsub/terragrunt.hcl +0 -75
- package/generators/common-resources/kafka-topics/generator.json +0 -4
- package/generators/common-resources/kafka-topics/index.js +0 -54
- package/generators/common-resources/kafka-topics/templates/kafka/kafka.yaml +0 -20
- package/generators/common-resources/kafka-topics/templates/kafka/terragrunt.hcl +0 -21
- package/generators/common-resources/kms/generator.json +0 -4
- package/generators/common-resources/kms/index.js +0 -69
- package/generators/common-resources/kms/templates/kms/spec.hcl +0 -5
- package/generators/common-resources/kms/templates/kms/terragrunt.hcl +0 -33
- package/generators/common-resources/memorystore/generator.json +0 -4
- package/generators/common-resources/memorystore/index.js +0 -69
- package/generators/common-resources/memorystore/templates/outputs.json +0 -3
- package/generators/common-resources/memorystore/templates/redis-instance/spec.hcl +0 -16
- package/generators/common-resources/memorystore/templates/redis-instance/terragrunt.hcl +0 -35
- package/generators/common-resources/memorystore/templates/secrets/terragrunt.hcl +0 -31
- package/generators/common-resources/monitoring/generator.json +0 -4
- package/generators/common-resources/monitoring/handle-yaml.js +0 -48
- package/generators/common-resources/monitoring/index.js +0 -192
- package/generators/common-resources/monitoring/templates/alerts/generic-infra.yaml +0 -633
- package/generators/common-resources/monitoring/templates/alerts/terragrunt.hcl +0 -37
- package/generators/common-resources/monitoring/templates/service/service.yaml +0 -16
- package/generators/common-resources/monitoring/templates/service/terragrunt.hcl +0 -37
- package/generators/common-resources/monitoring/templates/uptime-checks/terragrunt.hcl +0 -36
- package/generators/common-resources/monitoring/templates/uptime-checks/uptime-checks.yaml +0 -3
- package/generators/common-resources/monitoring/validate.js +0 -58
- package/generators/common-resources/pubsub/append.js +0 -120
- package/generators/common-resources/pubsub/generator.json +0 -4
- package/generators/common-resources/pubsub/get-gcp-projects.js +0 -34
- package/generators/common-resources/pubsub/handle-subscribers.js +0 -63
- package/generators/common-resources/pubsub/index.js +0 -316
- package/generators/common-resources/pubsub/templates/pubsub/spec.hcl +0 -7
- package/generators/common-resources/pubsub/templates/pubsub/subscribers.yaml +0 -16
- package/generators/common-resources/pubsub/templates/pubsub/terragrunt.hcl +0 -34
- package/generators/common-resources/pubsub/templates/pubsub-dlq/terragrunt.hcl +0 -42
- package/generators/common-resources/pubsub/templates/pubsub-external/spec.hcl +0 -10
- package/generators/common-resources/pubsub/templates/pubsub-external/subscribers.yaml +0 -16
- package/generators/common-resources/pubsub/templates/pubsub-external/terragrunt.hcl +0 -31
- package/generators/common-resources/pubsub/validate.js +0 -44
- package/generators/common-resources/scheduler/append.js +0 -83
- package/generators/common-resources/scheduler/generator.json +0 -4
- package/generators/common-resources/scheduler/index.js +0 -103
- package/generators/common-resources/scheduler/templates/scheduler/terragrunt.hcl +0 -44
- package/generators/common-resources/spanner/append.js +0 -27
- package/generators/common-resources/spanner/generator.json +0 -4
- package/generators/common-resources/spanner/index.js +0 -169
- package/generators/common-resources/spanner/templates/spanner/databases.yaml +0 -5
- package/generators/common-resources/spanner/templates/spanner/spec.hcl +0 -22
- package/generators/common-resources/spanner/templates/spanner/terragrunt.hcl +0 -33
- package/generators/common-resources/spanner/validate.js +0 -38
- package/generators/docs/command.json +0 -7
- package/generators/docs/rca/generator.json +0 -4
- package/generators/docs/rca/index.js +0 -50
- package/generators/docs/rca/templates/docs/rca_external.md +0 -43
- package/generators/docs/rca/templates/docs/rca_internal.md +0 -88
- package/generators/docs/runbook/generator.json +0 -4
- package/generators/docs/runbook/index.js +0 -42
- package/generators/docs/runbook/templates/docs/runbook.md +0 -106
- package/generators/docs/srb/generator.json +0 -4
- package/generators/docs/srb/index.js +0 -62
- package/generators/docs/srb/templates/docs/README.md +0 -42
- package/generators/docs/srb/templates/docs/adr.cmd +0 -3
- package/generators/docs/srb/templates/docs/adr.sh +0 -4
- package/generators/docs/srb/templates/docs/architecture.md +0 -68
- package/generators/docs/srb/templates/docs/cost-estimates.md +0 -39
- package/generators/docs/srb/templates/docs/dsl2png.cmd +0 -3
- package/generators/docs/srb/templates/docs/dsl2png.sh +0 -4
- package/generators/docs/srb/templates/docs/sre.md +0 -43
- package/generators/docs/srb/templates/sample.dsl +0 -36
- package/generators/init/clan-infra/gcp-projects.js +0 -36
- package/generators/init/clan-infra/generator.json +0 -4
- package/generators/init/clan-infra/index.js +0 -170
- package/generators/init/clan-infra/templates/.yamllint +0 -17
- package/generators/init/clan-infra/templates/env/project.hcl +0 -15
- package/generators/init/clan-infra/templates/env/secrets/secrets.yaml +0 -4
- package/generators/init/clan-infra/templates/env/secrets/terragrunt.hcl +0 -31
- package/generators/init/clan-infra/templates/github/CODEOWNERS +0 -1
- package/generators/init/clan-infra/templates/github/workflows/infra-verify.yml +0 -16
- package/generators/init/clan-infra/templates/github/workflows/infra.yml +0 -17
- package/generators/init/clan-infra/templates/github/workflows/release-notes.yml +0 -33
- package/generators/init/clan-infra/templates/github/workflows/sync-docs.yml +0 -29
- package/generators/init/clan-infra/templates/infra/.terraform-version +0 -1
- package/generators/init/clan-infra/templates/infra/.terragrunt-version +0 -1
- package/generators/init/clan-infra/templates/infra/README.md +0 -5
- package/generators/init/clan-infra/templates/infra/common.hcl +0 -24
- package/generators/init/clan-infra/templates/infra/terragrunt_root.hcl +0 -44
- package/generators/init/clan-infra/templates/notification-channels/notification-channels.yaml +0 -7
- package/generators/init/clan-infra/templates/notification-channels/terragrunt.hcl +0 -29
- package/generators/init/clan-infra/templates/release-notes/example-service.yaml +0 -23
- package/generators/init/clan-infra/templates/release-notes-schema/release-notes.schema.json +0 -63
- package/generators/init/clan-infra/tribe-clan-repo.js +0 -38
- package/generators/init/clan-infra/validate.js +0 -8
- package/generators/init/command.json +0 -7
- package/generators/maintenance/command.json +0 -7
- package/generators/maintenance/manage-states/generator.json +0 -4
- package/generators/maintenance/manage-states/index.js +0 -188
- package/generators/maintenance/update-modules/generator.json +0 -4
- package/generators/maintenance/update-modules/index.js +0 -102
- package/generators/organization/clan-project/__tests__/__snapshots__/googlecloud.test.js.snap +0 -27
- package/generators/organization/clan-project/generator.json +0 -4
- package/generators/organization/clan-project/googlecloud.js +0 -119
- package/generators/organization/clan-project/index.js +0 -139
- package/generators/organization/clan-project/templates/clan/clan.yaml +0 -22
- package/generators/organization/clan-project/templates/clan/terragrunt.hcl +0 -39
- package/generators/organization/clan-project/templates/clan-project/project.yaml +0 -14
- package/generators/organization/clan-project/templates/clan-project/terragrunt.hcl +0 -51
- package/generators/organization/clan-project/templates/clans-folder/terragrunt.hcl +0 -3
- package/generators/organization/clan-project/templates/department/terragrunt.hcl +0 -32
- package/generators/organization/clan-project/templates/tribe/terragrunt.hcl +0 -67
- package/generators/organization/clan-project/templates/tribe/tribe.yaml +0 -19
- package/generators/organization/command.json +0 -8
- package/src/BaseGenerator.js +0 -73
- package/src/SecretsGenerator.js +0 -105
- package/src/cli.js +0 -73
- package/src/dependency-check.js +0 -48
- package/src/update-check.js +0 -30
- package/src/validators.js +0 -32
- package/src/yeoman.js +0 -71
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"type": "object",
|
|
3
|
-
"properties": {
|
|
4
|
-
"service_name": {
|
|
5
|
-
"type": "string"
|
|
6
|
-
},
|
|
7
|
-
"service_repository": {
|
|
8
|
-
"type": "string"
|
|
9
|
-
},
|
|
10
|
-
"service_description": {
|
|
11
|
-
"type": "string"
|
|
12
|
-
},
|
|
13
|
-
"releases": {
|
|
14
|
-
"type": "array",
|
|
15
|
-
"items": {
|
|
16
|
-
"type": "object",
|
|
17
|
-
"properties": {
|
|
18
|
-
"date": {
|
|
19
|
-
"format": "date"
|
|
20
|
-
},
|
|
21
|
-
"version": {
|
|
22
|
-
"type": "string"
|
|
23
|
-
},
|
|
24
|
-
"items": {
|
|
25
|
-
"type": "array",
|
|
26
|
-
"items": {
|
|
27
|
-
"type": "object",
|
|
28
|
-
"properties": {
|
|
29
|
-
"type": {
|
|
30
|
-
"type": "string",
|
|
31
|
-
"enum": [
|
|
32
|
-
"Feature",
|
|
33
|
-
"Changed",
|
|
34
|
-
"Fixed",
|
|
35
|
-
"Removed",
|
|
36
|
-
"Issue",
|
|
37
|
-
"Announcement"
|
|
38
|
-
]
|
|
39
|
-
},
|
|
40
|
-
"exposure": {
|
|
41
|
-
"type": "string",
|
|
42
|
-
"enum": [
|
|
43
|
-
"public",
|
|
44
|
-
"internal"
|
|
45
|
-
]
|
|
46
|
-
},
|
|
47
|
-
"description": {
|
|
48
|
-
"type": "string"
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"required": ["type", "exposure", "description"],
|
|
52
|
-
"additionalProperties": false
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"required": ["date", "version", "items"],
|
|
58
|
-
"additionalProperties": false
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
"required": ["service_name", "service_repository", "service_description", "releases"],
|
|
62
|
-
"additionalProperties": false
|
|
63
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
|
|
4
|
-
const getKeyValue = (content, key) => {
|
|
5
|
-
let value = '';
|
|
6
|
-
content.split(/\r?\n/).forEach((line) => {
|
|
7
|
-
if (line.includes(key)) {
|
|
8
|
-
value = line.split('=')[1].replace('"', '').replace('"', '').trim();
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
return value;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const getTribeAndClanName = () => {
|
|
15
|
-
const repoName = path.basename(path.resolve());
|
|
16
|
-
const isClanInfraRepo = repoName.match(/^(?:\w+-){2}common(?:$|\W)$/) !== null;
|
|
17
|
-
|
|
18
|
-
let tribe = '';
|
|
19
|
-
let clan = '';
|
|
20
|
-
|
|
21
|
-
if (isClanInfraRepo) {
|
|
22
|
-
[tribe, clan] = repoName.split('-');
|
|
23
|
-
} else {
|
|
24
|
-
const commonHCL = path.join('infra', 'common.hcl');
|
|
25
|
-
if (fs.existsSync(commonHCL)) {
|
|
26
|
-
const commonHCLContent = fs.readFileSync(commonHCL, 'utf8');
|
|
27
|
-
tribe = getKeyValue(commonHCLContent, 'tribe_name');
|
|
28
|
-
clan = getKeyValue(commonHCLContent, 'clan_name');
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
tribe,
|
|
34
|
-
clan,
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
module.exports = getTribeAndClanName;
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
const console = require('console');
|
|
2
|
-
const fg = require('fast-glob');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const chalk = require('chalk');
|
|
6
|
-
const inquirer = require('inquirer');
|
|
7
|
-
const Separator = require('enquirer-separator');
|
|
8
|
-
const { Storage } = require('@google-cloud/storage');
|
|
9
|
-
const BaseGenerator = require('../../../src/BaseGenerator');
|
|
10
|
-
|
|
11
|
-
const getBucketName = (answers) => {
|
|
12
|
-
const dirName = path.basename(process.cwd());
|
|
13
|
-
let bucketName = '';
|
|
14
|
-
if (dirName === 'tf-infra-gcp') {
|
|
15
|
-
bucketName = 'platform-tf-admin-prod';
|
|
16
|
-
} else if (dirName.endsWith('-common')) {
|
|
17
|
-
bucketName = `tf-state-${dirName.replace('-common', '')}-${answers.env}`;
|
|
18
|
-
} else {
|
|
19
|
-
throw new Error('Run this command from the root of tf-infra-gcp of -common repository');
|
|
20
|
-
}
|
|
21
|
-
return bucketName;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const downloadStateFiles = (files, dest) => {
|
|
25
|
-
files.forEach((file) => {
|
|
26
|
-
const destFile = path.join(dest, file.name);
|
|
27
|
-
const modTime = new Date(file.metadata.updated);
|
|
28
|
-
fs.mkdirSync(path.dirname(destFile), { recursive: true });
|
|
29
|
-
file.download({ destination: destFile }, () => {
|
|
30
|
-
console.log(`gs://${file.bucket.name}/${file.name} [${chalk.magenta(file.metadata.size)}] (${chalk.yellow(file.metadata.updated.slice(0, 10))})`);
|
|
31
|
-
fs.utimesSync(destFile, modTime, modTime);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
module.exports = class extends BaseGenerator {
|
|
37
|
-
prompting() {
|
|
38
|
-
const prompts = [
|
|
39
|
-
{
|
|
40
|
-
type: 'list',
|
|
41
|
-
name: 'command',
|
|
42
|
-
message: 'Select operation to do',
|
|
43
|
-
store: true,
|
|
44
|
-
choices: [
|
|
45
|
-
{
|
|
46
|
-
name: 'Search for orphan state files',
|
|
47
|
-
value: 'searchOrphanStates',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: 'Download all state files',
|
|
51
|
-
value: 'downloadAll',
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
type: 'list',
|
|
58
|
-
name: 'env',
|
|
59
|
-
message: 'Select environment to work with',
|
|
60
|
-
store: true,
|
|
61
|
-
choices: ['staging', 'prod'],
|
|
62
|
-
when: () => path.basename(process.cwd()).endsWith('-common'),
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
{
|
|
66
|
-
type: 'checkbox',
|
|
67
|
-
name: 'stateFiles',
|
|
68
|
-
message: 'Next state files are orphan',
|
|
69
|
-
when: async (response) => response.command === 'searchOrphanStates',
|
|
70
|
-
|
|
71
|
-
choices: async (response) => {
|
|
72
|
-
const constExpectedStates = [];
|
|
73
|
-
const choices = [];
|
|
74
|
-
|
|
75
|
-
if (path.basename(process.cwd()) === 'tf-infra-gcp') {
|
|
76
|
-
const tgFiles = fg.sync('organization/extendaretail-com/**/terragrunt.hcl', { dot: false });
|
|
77
|
-
tgFiles.forEach((el) => {
|
|
78
|
-
const genStateFile = el.replace(/^organization\//, '').replace('terragrunt.hcl', 'default.tfstate');
|
|
79
|
-
constExpectedStates.push(genStateFile);
|
|
80
|
-
});
|
|
81
|
-
} else {
|
|
82
|
-
const tgFiles = fg.sync(`infra/${response.env}/**/terragrunt.hcl`, { dot: false });
|
|
83
|
-
tgFiles.forEach((el) => {
|
|
84
|
-
const genStateFile = el.replace(/^infra\//, '').replace('terragrunt.hcl', 'terraform.tfstate/default.tfstate');
|
|
85
|
-
constExpectedStates.push(genStateFile);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const storage = new Storage();
|
|
90
|
-
const bucket = getBucketName(response);
|
|
91
|
-
const [files] = await storage.bucket(bucket).getFiles().catch((err) => {
|
|
92
|
-
console.log(chalk.red('Error occured during requesting the bucket:'));
|
|
93
|
-
console.log(err.message);
|
|
94
|
-
process.exit(1);
|
|
95
|
-
});
|
|
96
|
-
await Promise.all(files
|
|
97
|
-
.filter((file) => !constExpectedStates.includes(file.name))
|
|
98
|
-
.map(async (file) => {
|
|
99
|
-
let name = `${file.name} [${chalk.magenta(file.metadata.size)}] (${chalk.yellow(file.metadata.updated.slice(0, 10))})`;
|
|
100
|
-
|
|
101
|
-
if (file.name.endsWith('.tfstate')) {
|
|
102
|
-
const stateData = JSON.parse(await file.download());
|
|
103
|
-
if ((stateData.resources.length === 0)
|
|
104
|
-
|| (stateData.resources.every((i) => i.instances.length === 0))) {
|
|
105
|
-
name = `${chalk.green('[empty]')} ${name}`;
|
|
106
|
-
} else {
|
|
107
|
-
name = `${chalk.red('[contains]')} ${name}`;
|
|
108
|
-
}
|
|
109
|
-
} else if (file.name.endsWith('.tflock')) {
|
|
110
|
-
name = `${chalk.red('[LOCK]')} ${name}`;
|
|
111
|
-
} else {
|
|
112
|
-
name = `${chalk.yellowBright('[unknown]')} ${name}`;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
choices.push({
|
|
116
|
-
name,
|
|
117
|
-
value: file,
|
|
118
|
-
});
|
|
119
|
-
}));
|
|
120
|
-
|
|
121
|
-
if (choices.length === 0) {
|
|
122
|
-
this.log(chalk.green('There are no orhan state files. All files have related terragrunt code in the repository'));
|
|
123
|
-
process.exit();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
choices.sort((a, b) => (a.value.name > b.value.name ? 1 : -1));
|
|
127
|
-
choices.push(new Separator('------'));
|
|
128
|
-
return choices;
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
{
|
|
133
|
-
type: 'list',
|
|
134
|
-
name: 'subCommand',
|
|
135
|
-
message: 'What to do with selected files?',
|
|
136
|
-
choices: ['nothing', 'Download', 'Delete'],
|
|
137
|
-
default: 'nothing',
|
|
138
|
-
when: (response) => (response.command === 'searchOrphanStates') && (response.stateFiles.length > 0),
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
{
|
|
142
|
-
type: 'input',
|
|
143
|
-
name: 'savePath',
|
|
144
|
-
message: 'Enter destination directory to save state files to',
|
|
145
|
-
default: async (response) => (response.env ? `download-states-${response.env}` : 'download-states'),
|
|
146
|
-
when: async (response) => (response.command === 'downloadAll') || (response.subCommand === 'Download'),
|
|
147
|
-
},
|
|
148
|
-
];
|
|
149
|
-
|
|
150
|
-
return this.prompt(prompts).then((props) => {
|
|
151
|
-
this.answers = props;
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
writing() {
|
|
156
|
-
if ((this.answers.command === 'searchOrphanStates') && (this.answers.subCommand === 'Download')) {
|
|
157
|
-
downloadStateFiles(this.answers.stateFiles, this.answers.savePath);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if ((this.answers.command === 'searchOrphanStates') && (this.answers.subCommand === 'Delete')) {
|
|
161
|
-
console.log(chalk.red('Next files is going to be deleted:'));
|
|
162
|
-
this.answers.stateFiles.forEach((file) => {
|
|
163
|
-
console.log(`gs://${file.bucket.name}/${file.name} [${chalk.magenta(file.metadata.size)}] (${chalk.yellow(file.metadata.updated.slice(0, 10))})`);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
const deleteQuestion = [{
|
|
167
|
-
type: 'confirm',
|
|
168
|
-
name: 'confirm',
|
|
169
|
-
message: 'Do you really want to delete them?',
|
|
170
|
-
default: false,
|
|
171
|
-
}];
|
|
172
|
-
inquirer.prompt(deleteQuestion).then((deleteAnswer) => {
|
|
173
|
-
if (deleteAnswer.confirm === true) {
|
|
174
|
-
this.answers.stateFiles.forEach((file) => {
|
|
175
|
-
file.delete();
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (this.answers.command === 'downloadAll') {
|
|
182
|
-
const storage = new Storage();
|
|
183
|
-
storage.bucket(getBucketName(this.answers)).getFiles().then(([files]) => {
|
|
184
|
-
downloadStateFiles(files, this.answers.savePath);
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
const axios = require('axios');
|
|
2
|
-
const fg = require('fast-glob');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
const Separator = require('enquirer-separator');
|
|
6
|
-
const BaseGenerator = require('../../../src/BaseGenerator');
|
|
7
|
-
|
|
8
|
-
module.exports = class extends BaseGenerator {
|
|
9
|
-
prompting() {
|
|
10
|
-
const prompts = [
|
|
11
|
-
{
|
|
12
|
-
type: 'list',
|
|
13
|
-
name: 'moduleName',
|
|
14
|
-
message: 'Select Terraform module for update',
|
|
15
|
-
store: true,
|
|
16
|
-
choices: async () => {
|
|
17
|
-
const regex = new RegExp('source = "(.+?)?github.com/(.+?/.+?)(/.+)?\\?ref=(.+)"');
|
|
18
|
-
const hclFiles = fg.sync('**/terragrunt.hcl', { dot: false });
|
|
19
|
-
const foundModules = new Set();
|
|
20
|
-
|
|
21
|
-
hclFiles.forEach((hclFile) => {
|
|
22
|
-
const content = fs.readFileSync(hclFile, 'utf8');
|
|
23
|
-
const match = regex.exec(content);
|
|
24
|
-
if (match) {
|
|
25
|
-
foundModules.add(match[2]);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
return Array.from(foundModules).sort().concat([new Separator('------')]);
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
type: 'list',
|
|
34
|
-
name: 'moduleTag',
|
|
35
|
-
message: 'Select module version for update to',
|
|
36
|
-
store: true,
|
|
37
|
-
choices: async (response) => {
|
|
38
|
-
const tagsResponse = await axios.get(`https://api.github.com/repos/${response.moduleName}/tags`);
|
|
39
|
-
return tagsResponse.data.map((el) => el.name).concat([new Separator('------')]);
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
{
|
|
44
|
-
type: 'checkbox',
|
|
45
|
-
name: 'files',
|
|
46
|
-
message: 'Select Terragrunt files to update the module version',
|
|
47
|
-
choices: async (response) => {
|
|
48
|
-
const regex = new RegExp(`source = "(.+/)?(${response.moduleName})(/.+)?\\?ref=(.+)"`);
|
|
49
|
-
const hclFiles = fg.sync('**/terragrunt.hcl', { dot: false });
|
|
50
|
-
const matchedFiles = [];
|
|
51
|
-
|
|
52
|
-
hclFiles.forEach((hclFile) => {
|
|
53
|
-
const content = fs.readFileSync(hclFile, 'utf8');
|
|
54
|
-
const match = regex.exec(content);
|
|
55
|
-
if (match) {
|
|
56
|
-
const currentTag = match[4];
|
|
57
|
-
if (currentTag !== response.moduleTag) {
|
|
58
|
-
matchedFiles.push({
|
|
59
|
-
name: `${currentTag} => ${response.moduleTag}: ${hclFile}`,
|
|
60
|
-
value: hclFile,
|
|
61
|
-
checked: true,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
if (matchedFiles.length === 0) {
|
|
68
|
-
this.log(`There is no files left to update. All files uses ${chalk.cyan(response.moduleTag)} version of ${chalk.cyan(response.moduleName)} module`);
|
|
69
|
-
process.exit();
|
|
70
|
-
}
|
|
71
|
-
return matchedFiles.sort((a, b) => ((a.value > b.value) ? 1 : -1)).concat([new Separator('------')]);
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
];
|
|
75
|
-
|
|
76
|
-
return this.prompt(prompts).then((props) => {
|
|
77
|
-
this.answers = props;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
writing() {
|
|
82
|
-
const regex = new RegExp(`(source = "(.+/)?(${this.answers.moduleName})(/.+)?\\?ref=)(.+)"`);
|
|
83
|
-
this.answers.files.forEach((hclFile) => {
|
|
84
|
-
const content = fs.readFileSync(hclFile, 'utf8');
|
|
85
|
-
// const newContent = content.replace(regex, '$1' + this.answers.moduleTag + '"');
|
|
86
|
-
const newContent = content.replace(regex, `$1${this.answers.moduleTag}"`);
|
|
87
|
-
fs.writeFileSync(hclFile, newContent, 'utf8');
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
end() {
|
|
92
|
-
const {
|
|
93
|
-
moduleName,
|
|
94
|
-
moduleTag,
|
|
95
|
-
files,
|
|
96
|
-
} = this.answers;
|
|
97
|
-
this.log(`In next files ${chalk.green(moduleName)} module version was updated to ${chalk.green(moduleTag)} version:`);
|
|
98
|
-
files.forEach((f) => this.log(chalk.cyan(f)));
|
|
99
|
-
this.log('Next update infrastructure using pipeline or manually');
|
|
100
|
-
this.log('Note: Always use "git diff" before commit or apply the changes');
|
|
101
|
-
}
|
|
102
|
-
};
|
package/generators/organization/clan-project/__tests__/__snapshots__/googlecloud.test.js.snap
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`googlecloud It renders YAML with comments 1`] = `
|
|
4
|
-
"# - automl.googleapis.com # Cloud AutoML API
|
|
5
|
-
# - bigtable.googleapis.com # Cloud Bigtable
|
|
6
|
-
# - bigquery.googleapis.com # Cloud BigQuery
|
|
7
|
-
- cloudapis.googleapis.com # Google Cloud APIs
|
|
8
|
-
- clouddeploy.googleapis.com # Cloud Deploy API
|
|
9
|
-
# - cloudfunctions.googleapis.com # Cloud Functions API
|
|
10
|
-
- cloudresourcemanager.googleapis.com # Cloud Resource Manager API
|
|
11
|
-
# - compute.googleapis.com # Compute Engine API
|
|
12
|
-
- container.googleapis.com # Kubernetes
|
|
13
|
-
- containerregistry.googleapis.com # Container Registry
|
|
14
|
-
# - dataflow.googleapis.com # Dataflow API
|
|
15
|
-
- dns.googleapis.com # Cloud DNS API
|
|
16
|
-
# - firestore.googleapis.com # Cloud Firestore
|
|
17
|
-
- monitoring.googleapis.com # Stackdriver Monitoring API
|
|
18
|
-
# - pubsub.googleapis.com # Cloud Pub/Sub API
|
|
19
|
-
# - redis.googleapis.com # Memorystore (Redis)
|
|
20
|
-
- run.googleapis.com # Cloud Run API
|
|
21
|
-
- secretmanager.googleapis.com # Secret Manager API
|
|
22
|
-
# - spanner.googleapis.com # Cloud Spanner API
|
|
23
|
-
# - storage-api.googleapis.com # Cloud Storage
|
|
24
|
-
# - sqladmin.googleapis.com # Cloud SQL
|
|
25
|
-
- servicenetworking.googleapis.com # Service Networking API
|
|
26
|
-
- vpcaccess.googleapis.com # Serverless VPC Access API"
|
|
27
|
-
`;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
// List of APIs to include in the project.yaml file. Entries will be
|
|
2
|
-
// enabled depending on user selections in Yeoman.
|
|
3
|
-
const availableApis = [
|
|
4
|
-
{
|
|
5
|
-
value: 'automl.googleapis.com',
|
|
6
|
-
name: 'Cloud AutoML API',
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
value: 'bigtable.googleapis.com',
|
|
10
|
-
name: 'Cloud Bigtable',
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
value: 'bigquery.googleapis.com',
|
|
14
|
-
name: 'Cloud BigQuery',
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
value: 'cloudapis.googleapis.com',
|
|
18
|
-
name: 'Google Cloud APIs',
|
|
19
|
-
enabled: true,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
value: 'clouddeploy.googleapis.com',
|
|
23
|
-
name: 'Cloud Deploy API',
|
|
24
|
-
enabled: true,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
value: 'cloudfunctions.googleapis.com',
|
|
28
|
-
name: 'Cloud Functions API',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
value: 'cloudresourcemanager.googleapis.com',
|
|
32
|
-
name: 'Cloud Resource Manager API',
|
|
33
|
-
enabled: true,
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
value: 'compute.googleapis.com',
|
|
37
|
-
name: 'Compute Engine API',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
value: 'container.googleapis.com',
|
|
41
|
-
name: 'Kubernetes',
|
|
42
|
-
enabled: true,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
value: 'containerregistry.googleapis.com',
|
|
46
|
-
name: 'Container Registry',
|
|
47
|
-
enabled: true,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
value: 'dataflow.googleapis.com',
|
|
51
|
-
name: 'Dataflow API',
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
value: 'dns.googleapis.com',
|
|
55
|
-
name: 'Cloud DNS API',
|
|
56
|
-
enabled: true,
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
value: 'firestore.googleapis.com',
|
|
60
|
-
name: 'Cloud Firestore',
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
value: 'monitoring.googleapis.com',
|
|
64
|
-
name: 'Stackdriver Monitoring API',
|
|
65
|
-
enabled: true,
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
value: 'pubsub.googleapis.com',
|
|
69
|
-
name: 'Cloud Pub/Sub API',
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
value: 'redis.googleapis.com',
|
|
73
|
-
name: 'Memorystore (Redis)',
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
value: 'run.googleapis.com',
|
|
77
|
-
name: 'Cloud Run API',
|
|
78
|
-
enabled: true,
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
value: 'secretmanager.googleapis.com',
|
|
82
|
-
name: 'Secret Manager API',
|
|
83
|
-
enabled: true,
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
value: 'spanner.googleapis.com',
|
|
87
|
-
name: 'Cloud Spanner API',
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
value: 'storage-api.googleapis.com',
|
|
91
|
-
name: 'Cloud Storage',
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
value: 'sqladmin.googleapis.com',
|
|
95
|
-
name: 'Cloud SQL',
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
value: 'servicenetworking.googleapis.com',
|
|
99
|
-
name: 'Service Networking API',
|
|
100
|
-
enabled: true,
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
value: 'vpcaccess.googleapis.com',
|
|
104
|
-
name: 'Serverless VPC Access API',
|
|
105
|
-
enabled: true,
|
|
106
|
-
},
|
|
107
|
-
];
|
|
108
|
-
|
|
109
|
-
const apisYaml = (resources = []) => availableApis.map((entry) => ({
|
|
110
|
-
...entry,
|
|
111
|
-
enabled: entry.enabled || resources.includes(entry.value),
|
|
112
|
-
})).reduce((
|
|
113
|
-
acc,
|
|
114
|
-
entry,
|
|
115
|
-
) => `${acc}${entry.enabled ? ' -' : '# -'} ${entry.value.padEnd(60, ' ')} # ${entry.name}\n`, '').trimEnd();
|
|
116
|
-
|
|
117
|
-
module.exports = {
|
|
118
|
-
apisYaml,
|
|
119
|
-
};
|