@hiiretail/gcp-infra-cli 0.87.2 → 0.87.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.
@@ -12,8 +12,8 @@ const appendToDatabasesYaml = (databasesYamlPath, newDbEntry) => {
12
12
  // Exclude empty fields from newDbEntry
13
13
  const cleanNewDatabaseEntry = {
14
14
  name: newDbEntry.name,
15
- ...(newDbEntry.ddl ? { ddl: newDbEntry.ddl } : {}),
16
- ...(newDbEntry.retentionPeriod ? { retentionPeriod: newDbEntry.retentionPeriod } : {}),
15
+ ...(newDbEntry.ddl ? { ddl: [newDbEntry.ddl] } : {}),
16
+ ...(newDbEntry.retentionPeriod ? { version_retention_period: newDbEntry.retentionPeriod } : {}),
17
17
  };
18
18
 
19
19
  databases.push(cleanNewDatabaseEntry);
@@ -21,14 +21,20 @@ module.exports = class extends BaseGenerator {
21
21
  type: 'input',
22
22
  name: 'instanceName',
23
23
  message: 'Please provide a name for the instance',
24
- validate: (input) => required(input) && validName(input),
24
+ validate: (input) => {
25
+ const validation = validName(input);
26
+ return validation.valid ? true : validation.message;
27
+ },
25
28
  },
26
29
  {
27
30
  when: (response) => response.resourceType === 'instance',
28
31
  type: 'input',
29
32
  name: 'displayName',
30
33
  message: 'Please provide the descriptive name for this instance. Unique per project.',
31
- validate: (input) => required(input) && validName(input),
34
+ validate: (input) => {
35
+ const validation = validName(input);
36
+ return validation.valid ? true : validation.message;
37
+ },
32
38
  },
33
39
  {
34
40
  when: (response) => response.resourceType === 'instance',
@@ -57,7 +63,10 @@ module.exports = class extends BaseGenerator {
57
63
  type: 'input',
58
64
  name: 'databaseName',
59
65
  message: 'Please provide a name for the database',
60
- validate: (input) => required(input) && validName(input),
66
+ validate: (input) => {
67
+ const validation = validName(input);
68
+ return validation.valid ? true : validation.message;
69
+ },
61
70
  },
62
71
  {
63
72
  when: (response) => response.resourceType === 'database',
@@ -70,7 +79,10 @@ module.exports = class extends BaseGenerator {
70
79
  type: 'input',
71
80
  name: 'retentionPeriod',
72
81
  message: 'Please provide version retention period. Maximum value 7d, possible values include 84000s, 1h, 2d. Leave empty for default value 1h.',
73
- validate: (input) => required(input) && validRetentionPeriod(input),
82
+ validate: (input) => {
83
+ const validation = validRetentionPeriod(input);
84
+ return validation.valid ? true : validation.message;
85
+ },
74
86
  },
75
87
  ];
76
88
 
@@ -116,16 +128,18 @@ module.exports = class extends BaseGenerator {
116
128
  }
117
129
 
118
130
  if (!fs.existsSync(databasesYamlPath) && resourceType === 'database') {
119
- this.fs.copyTpl(
120
- this.templatePath('spanner/databases.yaml'),
121
- this.destinationPath(databasesYamlPath),
122
- {
123
- ...this.answers,
124
- databaseName,
125
- ddl,
126
- retentionPeriod,
127
- },
128
- );
131
+ ['terragrunt.hcl', 'databases.yaml'].forEach((file) => {
132
+ this.fs.copyTpl(
133
+ this.templatePath(`spanner/${file}`),
134
+ this.destinationPath(`${spannerPath}/${file}`),
135
+ {
136
+ ...this.answers,
137
+ databaseName,
138
+ ddl,
139
+ retentionPeriod,
140
+ },
141
+ );
142
+ });
129
143
  }
130
144
 
131
145
  if (fs.existsSync(databasesYamlPath) && resourceType === 'database') {
@@ -1,4 +1,5 @@
1
1
  databases:
2
2
  - name: "<%-databaseName%>" <% if (ddl == '') { %><% } else { %>
3
- ddl: "<%-ddl%>" <% } %> <% if (retentionPeriod == '') { %><% } else { %>
3
+ ddl:
4
+ - <%-ddl%> <% } %> <% if (retentionPeriod == '') { %><% } else { %>
4
5
  version_retention_period: "<%-retentionPeriod%>" <% } %>
@@ -9,7 +9,6 @@ const validRetentionPeriod = (input) => {
9
9
  const validFormats = /^(84000s|1h|2d|7d)$/;
10
10
 
11
11
  if (input === '') {
12
- // Empty input, using default value
13
12
  return { valid: true };
14
13
  }
15
14
  if (validFormats.test(input)) {
@@ -18,7 +17,7 @@ const validRetentionPeriod = (input) => {
18
17
 
19
18
  return {
20
19
  valid: false,
21
- message: 'Invalid retention period format. Possible values include 84000s, 1h, 2d, or leave empty for default value 1h',
20
+ message: 'Invalid retention period format. Possible values are 84000s, 1h, 2d, or leave empty for default value 1h',
22
21
  };
23
22
  };
24
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiiretail/gcp-infra-cli",
3
- "version": "0.87.2",
3
+ "version": "0.87.3",
4
4
  "description": "Infrastructure as code generator for GCP.",
5
5
  "main": "src/cli.js",
6
6
  "bin": {