@pagopa/opex-dashboard 0.0.2 → 0.1.0
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 +78 -1
- package/bin/index.js +30 -5
- package/config.schema.json +174 -118
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,12 +60,76 @@ npx @pagopa/opex-dashboard generate -t azure-dashboard -c config.yaml --package
|
|
|
60
60
|
|
|
61
61
|
### 3. Deploy with Terraform
|
|
62
62
|
|
|
63
|
+
The deployment process depends on the configuration mode you chose:
|
|
64
|
+
|
|
65
|
+
#### Multi-Environment Mode
|
|
66
|
+
|
|
67
|
+
When using the multi-environment configuration (with `environments` section),
|
|
68
|
+
the generated package includes separate subdirectories for each environment:
|
|
69
|
+
|
|
63
70
|
```bash
|
|
64
71
|
cd output/azure-dashboard
|
|
72
|
+
# Deploy to dev
|
|
65
73
|
terraform init -backend-config=env/dev/backend.tfvars
|
|
66
74
|
terraform apply -var-file=env/dev/terraform.tfvars
|
|
75
|
+
|
|
76
|
+
# Deploy to prod
|
|
77
|
+
terraform init -backend-config=env/prod/backend.tfvars
|
|
78
|
+
terraform apply -var-file=env/prod/terraform.tfvars
|
|
67
79
|
```
|
|
68
80
|
|
|
81
|
+
**Generated structure:**
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
output/azure-dashboard/
|
|
85
|
+
├── main.tf
|
|
86
|
+
├── variables.tf
|
|
87
|
+
├── dashboard.tf
|
|
88
|
+
└── env/
|
|
89
|
+
├── dev/
|
|
90
|
+
│ ├── backend.tfvars
|
|
91
|
+
│ └── terraform.tfvars
|
|
92
|
+
├── uat/
|
|
93
|
+
│ ├── backend.tfvars
|
|
94
|
+
│ └── terraform.tfvars
|
|
95
|
+
└── prod/
|
|
96
|
+
├── backend.tfvars
|
|
97
|
+
└── terraform.tfvars
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### Flat Mode
|
|
101
|
+
|
|
102
|
+
When using flat configuration (with `prefix` and `env_short` directly under
|
|
103
|
+
`terraform`), all files are generated in the root directory:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
cd output/azure-dashboard
|
|
107
|
+
terraform init -backend-config=backend.tfvars
|
|
108
|
+
terraform apply -var-file=terraform.tfvars
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Generated structure:**
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
output/azure-dashboard/
|
|
115
|
+
├── main.tf
|
|
116
|
+
├── variables.tf
|
|
117
|
+
├── dashboard.tf
|
|
118
|
+
├── backend.tfvars
|
|
119
|
+
└── terraform.tfvars
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Use flat mode when:**
|
|
123
|
+
|
|
124
|
+
- Deploying to a single environment
|
|
125
|
+
- Managing infrastructure for a specific environment in a separate repository
|
|
126
|
+
- You don't need environment-specific subdirectories
|
|
127
|
+
|
|
128
|
+
**Use multi-environment mode when:**
|
|
129
|
+
|
|
130
|
+
- Managing multiple environments (dev/uat/prod) in the same repository
|
|
131
|
+
- You want organized environment-specific configurations in subdirectories
|
|
132
|
+
|
|
69
133
|
## Dashboard Components
|
|
70
134
|
|
|
71
135
|
For each endpoint in the OpenAPI spec, the dashboard includes:
|
|
@@ -137,7 +201,10 @@ availability_threshold`: float # Default: 0.99 (99%)
|
|
|
137
201
|
response_time_threshold: float # Default: 1.0 second
|
|
138
202
|
|
|
139
203
|
# When generating Terraform packages (using `--package` option),
|
|
140
|
-
# you can optionally configure environment-specific settings
|
|
204
|
+
# you can optionally configure environment-specific settings.
|
|
205
|
+
# Two configuration modes are supported:
|
|
206
|
+
|
|
207
|
+
# 1. Multi-environment mode (with subdirectories):
|
|
141
208
|
terraform:
|
|
142
209
|
environments:
|
|
143
210
|
dev:
|
|
@@ -150,6 +217,16 @@ terraform:
|
|
|
150
217
|
key: string
|
|
151
218
|
uat: # Similar to dev
|
|
152
219
|
prod: # Similar to dev
|
|
220
|
+
|
|
221
|
+
# 2. Flat mode (single environment, no subdirectories):
|
|
222
|
+
terraform:
|
|
223
|
+
prefix: string # Max 6 chars (required)
|
|
224
|
+
env_short: string # Max 1 char: 'd', 'u', 'p' (required)
|
|
225
|
+
backend: # Optional backend state configuration
|
|
226
|
+
resource_group_name: string
|
|
227
|
+
storage_account_name: string
|
|
228
|
+
container_name: string
|
|
229
|
+
key: string
|
|
153
230
|
```
|
|
154
231
|
|
|
155
232
|
See [`examples/`](./examples) directory for complete configuration samples.
|
package/bin/index.js
CHANGED
|
@@ -874,7 +874,28 @@ async function generateTerraformAssets(outputPath, terraformConfig) {
|
|
|
874
874
|
"utf-8"
|
|
875
875
|
)
|
|
876
876
|
]);
|
|
877
|
-
if (terraformConfig
|
|
877
|
+
if (terraformConfig && "prefix" in terraformConfig) {
|
|
878
|
+
const backendTfvarsContent = generateBackendTfvars(
|
|
879
|
+
terraformConfig.backend
|
|
880
|
+
);
|
|
881
|
+
const terraformTfvarsContent = generateTerraformTfvars({
|
|
882
|
+
backend: terraformConfig.backend,
|
|
883
|
+
env_short: terraformConfig.env_short,
|
|
884
|
+
prefix: terraformConfig.prefix
|
|
885
|
+
});
|
|
886
|
+
await Promise.all([
|
|
887
|
+
writeFile(
|
|
888
|
+
path2.join(outputPath, "backend.tfvars"),
|
|
889
|
+
backendTfvarsContent,
|
|
890
|
+
"utf-8"
|
|
891
|
+
),
|
|
892
|
+
writeFile(
|
|
893
|
+
path2.join(outputPath, "terraform.tfvars"),
|
|
894
|
+
terraformTfvarsContent,
|
|
895
|
+
"utf-8"
|
|
896
|
+
)
|
|
897
|
+
]);
|
|
898
|
+
} else if (terraformConfig && "environments" in terraformConfig) {
|
|
878
899
|
const envPromises = [];
|
|
879
900
|
for (const [env, envConfig] of Object.entries(
|
|
880
901
|
terraformConfig.environments
|
|
@@ -1210,13 +1231,17 @@ var EnvironmentConfigSchema = z4.object({
|
|
|
1210
1231
|
env_short: z4.string().max(1).describe("Environment short name (1 char: 'd'=dev, 'u'=uat, 'p'=prod)"),
|
|
1211
1232
|
prefix: z4.string().max(6).describe("Project prefix (max 6 chars, e.g., 'io', 'pagopa')")
|
|
1212
1233
|
});
|
|
1213
|
-
var
|
|
1234
|
+
var TerraformEnvironmentsConfigSchema = z4.object({
|
|
1214
1235
|
environments: z4.object({
|
|
1215
1236
|
dev: EnvironmentConfigSchema.optional(),
|
|
1216
1237
|
prod: EnvironmentConfigSchema.optional(),
|
|
1217
1238
|
uat: EnvironmentConfigSchema.optional()
|
|
1218
|
-
}).
|
|
1219
|
-
});
|
|
1239
|
+
}).describe("Environment-specific configurations for dev/uat/prod")
|
|
1240
|
+
}).strict();
|
|
1241
|
+
var TerraformConfigSchema = z4.union([
|
|
1242
|
+
EnvironmentConfigSchema.strict(),
|
|
1243
|
+
TerraformEnvironmentsConfigSchema
|
|
1244
|
+
]);
|
|
1220
1245
|
var ConfigSchema = z4.object({
|
|
1221
1246
|
action_groups: z4.array(z4.string()).describe(
|
|
1222
1247
|
"Array of Azure Action Group resource IDs for alarm notifications"
|
|
@@ -1447,5 +1472,5 @@ async function generateHandler(options) {
|
|
|
1447
1472
|
// src/cli/index.ts
|
|
1448
1473
|
var program = new Command2();
|
|
1449
1474
|
program.name("opex_dashboard").description("Generate operational dashboards from OpenAPI 3 specifications");
|
|
1450
|
-
program.addCommand(createGenerateCommand()).version("0.0
|
|
1475
|
+
program.addCommand(createGenerateCommand()).version("0.1.0");
|
|
1451
1476
|
program.parse(process.argv);
|
package/config.schema.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
4
|
"description": "Configuration schema for generating operational dashboards from OpenAPI specifications",
|
|
5
5
|
"title": "OpEx Dashboard Configuration",
|
|
6
|
-
"version": "0.0
|
|
6
|
+
"version": "0.1.0",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
9
|
"action_groups": {
|
|
@@ -184,164 +184,220 @@
|
|
|
184
184
|
},
|
|
185
185
|
"terraform": {
|
|
186
186
|
"description": "Optional Terraform and environment-specific configuration",
|
|
187
|
-
"
|
|
188
|
-
|
|
189
|
-
"environments": {
|
|
190
|
-
"description": "Environment-specific configurations for dev/uat/prod",
|
|
187
|
+
"anyOf": [
|
|
188
|
+
{
|
|
191
189
|
"type": "object",
|
|
192
190
|
"properties": {
|
|
193
|
-
"
|
|
191
|
+
"backend": {
|
|
192
|
+
"description": "Azure backend configuration for Terraform state",
|
|
194
193
|
"type": "object",
|
|
195
194
|
"properties": {
|
|
196
|
-
"
|
|
197
|
-
"description": "
|
|
198
|
-
"type": "
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
},
|
|
204
|
-
"key": {
|
|
205
|
-
"description": "State file key/path",
|
|
206
|
-
"type": "string"
|
|
207
|
-
},
|
|
208
|
-
"resource_group_name": {
|
|
209
|
-
"description": "Azure resource group for backend state",
|
|
210
|
-
"type": "string"
|
|
211
|
-
},
|
|
212
|
-
"storage_account_name": {
|
|
213
|
-
"description": "Storage account for Terraform state",
|
|
214
|
-
"type": "string"
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
"required": [
|
|
218
|
-
"container_name",
|
|
219
|
-
"key",
|
|
220
|
-
"resource_group_name",
|
|
221
|
-
"storage_account_name"
|
|
222
|
-
],
|
|
223
|
-
"additionalProperties": false
|
|
195
|
+
"container_name": {
|
|
196
|
+
"description": "Blob container name for Terraform state",
|
|
197
|
+
"type": "string"
|
|
198
|
+
},
|
|
199
|
+
"key": {
|
|
200
|
+
"description": "State file key/path",
|
|
201
|
+
"type": "string"
|
|
224
202
|
},
|
|
225
|
-
"
|
|
226
|
-
"description": "
|
|
227
|
-
"type": "string"
|
|
228
|
-
"maxLength": 1
|
|
203
|
+
"resource_group_name": {
|
|
204
|
+
"description": "Azure resource group for backend state",
|
|
205
|
+
"type": "string"
|
|
229
206
|
},
|
|
230
|
-
"
|
|
231
|
-
"description": "
|
|
232
|
-
"type": "string"
|
|
233
|
-
"maxLength": 6
|
|
207
|
+
"storage_account_name": {
|
|
208
|
+
"description": "Storage account for Terraform state",
|
|
209
|
+
"type": "string"
|
|
234
210
|
}
|
|
235
211
|
},
|
|
236
212
|
"required": [
|
|
237
|
-
"
|
|
238
|
-
"
|
|
213
|
+
"container_name",
|
|
214
|
+
"key",
|
|
215
|
+
"resource_group_name",
|
|
216
|
+
"storage_account_name"
|
|
239
217
|
],
|
|
240
218
|
"additionalProperties": false
|
|
241
219
|
},
|
|
242
|
-
"
|
|
220
|
+
"env_short": {
|
|
221
|
+
"description": "Environment short name (1 char: 'd'=dev, 'u'=uat, 'p'=prod)",
|
|
222
|
+
"type": "string",
|
|
223
|
+
"maxLength": 1
|
|
224
|
+
},
|
|
225
|
+
"prefix": {
|
|
226
|
+
"description": "Project prefix (max 6 chars, e.g., 'io', 'pagopa')",
|
|
227
|
+
"type": "string",
|
|
228
|
+
"maxLength": 6
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
"required": [
|
|
232
|
+
"env_short",
|
|
233
|
+
"prefix"
|
|
234
|
+
],
|
|
235
|
+
"additionalProperties": false
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"type": "object",
|
|
239
|
+
"properties": {
|
|
240
|
+
"environments": {
|
|
241
|
+
"description": "Environment-specific configurations for dev/uat/prod",
|
|
243
242
|
"type": "object",
|
|
244
243
|
"properties": {
|
|
245
|
-
"
|
|
246
|
-
"description": "Azure backend configuration for Terraform state",
|
|
244
|
+
"dev": {
|
|
247
245
|
"type": "object",
|
|
248
246
|
"properties": {
|
|
249
|
-
"
|
|
250
|
-
"description": "
|
|
251
|
-
"type": "
|
|
247
|
+
"backend": {
|
|
248
|
+
"description": "Azure backend configuration for Terraform state",
|
|
249
|
+
"type": "object",
|
|
250
|
+
"properties": {
|
|
251
|
+
"container_name": {
|
|
252
|
+
"description": "Blob container name for Terraform state",
|
|
253
|
+
"type": "string"
|
|
254
|
+
},
|
|
255
|
+
"key": {
|
|
256
|
+
"description": "State file key/path",
|
|
257
|
+
"type": "string"
|
|
258
|
+
},
|
|
259
|
+
"resource_group_name": {
|
|
260
|
+
"description": "Azure resource group for backend state",
|
|
261
|
+
"type": "string"
|
|
262
|
+
},
|
|
263
|
+
"storage_account_name": {
|
|
264
|
+
"description": "Storage account for Terraform state",
|
|
265
|
+
"type": "string"
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
"required": [
|
|
269
|
+
"container_name",
|
|
270
|
+
"key",
|
|
271
|
+
"resource_group_name",
|
|
272
|
+
"storage_account_name"
|
|
273
|
+
],
|
|
274
|
+
"additionalProperties": false
|
|
252
275
|
},
|
|
253
|
-
"
|
|
254
|
-
"description": "
|
|
255
|
-
"type": "string"
|
|
276
|
+
"env_short": {
|
|
277
|
+
"description": "Environment short name (1 char: 'd'=dev, 'u'=uat, 'p'=prod)",
|
|
278
|
+
"type": "string",
|
|
279
|
+
"maxLength": 1
|
|
256
280
|
},
|
|
257
|
-
"
|
|
258
|
-
"description": "
|
|
259
|
-
"type": "string"
|
|
260
|
-
|
|
261
|
-
"storage_account_name": {
|
|
262
|
-
"description": "Storage account for Terraform state",
|
|
263
|
-
"type": "string"
|
|
281
|
+
"prefix": {
|
|
282
|
+
"description": "Project prefix (max 6 chars, e.g., 'io', 'pagopa')",
|
|
283
|
+
"type": "string",
|
|
284
|
+
"maxLength": 6
|
|
264
285
|
}
|
|
265
286
|
},
|
|
266
287
|
"required": [
|
|
267
|
-
"
|
|
268
|
-
"
|
|
269
|
-
"resource_group_name",
|
|
270
|
-
"storage_account_name"
|
|
288
|
+
"env_short",
|
|
289
|
+
"prefix"
|
|
271
290
|
],
|
|
272
291
|
"additionalProperties": false
|
|
273
292
|
},
|
|
274
|
-
"
|
|
275
|
-
"description": "Environment short name (1 char: 'd'=dev, 'u'=uat, 'p'=prod)",
|
|
276
|
-
"type": "string",
|
|
277
|
-
"maxLength": 1
|
|
278
|
-
},
|
|
279
|
-
"prefix": {
|
|
280
|
-
"description": "Project prefix (max 6 chars, e.g., 'io', 'pagopa')",
|
|
281
|
-
"type": "string",
|
|
282
|
-
"maxLength": 6
|
|
283
|
-
}
|
|
284
|
-
},
|
|
285
|
-
"required": [
|
|
286
|
-
"env_short",
|
|
287
|
-
"prefix"
|
|
288
|
-
],
|
|
289
|
-
"additionalProperties": false
|
|
290
|
-
},
|
|
291
|
-
"uat": {
|
|
292
|
-
"type": "object",
|
|
293
|
-
"properties": {
|
|
294
|
-
"backend": {
|
|
295
|
-
"description": "Azure backend configuration for Terraform state",
|
|
293
|
+
"prod": {
|
|
296
294
|
"type": "object",
|
|
297
295
|
"properties": {
|
|
298
|
-
"
|
|
299
|
-
"description": "
|
|
300
|
-
"type": "
|
|
296
|
+
"backend": {
|
|
297
|
+
"description": "Azure backend configuration for Terraform state",
|
|
298
|
+
"type": "object",
|
|
299
|
+
"properties": {
|
|
300
|
+
"container_name": {
|
|
301
|
+
"description": "Blob container name for Terraform state",
|
|
302
|
+
"type": "string"
|
|
303
|
+
},
|
|
304
|
+
"key": {
|
|
305
|
+
"description": "State file key/path",
|
|
306
|
+
"type": "string"
|
|
307
|
+
},
|
|
308
|
+
"resource_group_name": {
|
|
309
|
+
"description": "Azure resource group for backend state",
|
|
310
|
+
"type": "string"
|
|
311
|
+
},
|
|
312
|
+
"storage_account_name": {
|
|
313
|
+
"description": "Storage account for Terraform state",
|
|
314
|
+
"type": "string"
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
"required": [
|
|
318
|
+
"container_name",
|
|
319
|
+
"key",
|
|
320
|
+
"resource_group_name",
|
|
321
|
+
"storage_account_name"
|
|
322
|
+
],
|
|
323
|
+
"additionalProperties": false
|
|
301
324
|
},
|
|
302
|
-
"
|
|
303
|
-
"description": "
|
|
304
|
-
"type": "string"
|
|
325
|
+
"env_short": {
|
|
326
|
+
"description": "Environment short name (1 char: 'd'=dev, 'u'=uat, 'p'=prod)",
|
|
327
|
+
"type": "string",
|
|
328
|
+
"maxLength": 1
|
|
305
329
|
},
|
|
306
|
-
"
|
|
307
|
-
"description": "
|
|
308
|
-
"type": "string"
|
|
309
|
-
|
|
310
|
-
"storage_account_name": {
|
|
311
|
-
"description": "Storage account for Terraform state",
|
|
312
|
-
"type": "string"
|
|
330
|
+
"prefix": {
|
|
331
|
+
"description": "Project prefix (max 6 chars, e.g., 'io', 'pagopa')",
|
|
332
|
+
"type": "string",
|
|
333
|
+
"maxLength": 6
|
|
313
334
|
}
|
|
314
335
|
},
|
|
315
336
|
"required": [
|
|
316
|
-
"
|
|
317
|
-
"
|
|
318
|
-
"resource_group_name",
|
|
319
|
-
"storage_account_name"
|
|
337
|
+
"env_short",
|
|
338
|
+
"prefix"
|
|
320
339
|
],
|
|
321
340
|
"additionalProperties": false
|
|
322
341
|
},
|
|
323
|
-
"
|
|
324
|
-
"
|
|
325
|
-
"
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
342
|
+
"uat": {
|
|
343
|
+
"type": "object",
|
|
344
|
+
"properties": {
|
|
345
|
+
"backend": {
|
|
346
|
+
"description": "Azure backend configuration for Terraform state",
|
|
347
|
+
"type": "object",
|
|
348
|
+
"properties": {
|
|
349
|
+
"container_name": {
|
|
350
|
+
"description": "Blob container name for Terraform state",
|
|
351
|
+
"type": "string"
|
|
352
|
+
},
|
|
353
|
+
"key": {
|
|
354
|
+
"description": "State file key/path",
|
|
355
|
+
"type": "string"
|
|
356
|
+
},
|
|
357
|
+
"resource_group_name": {
|
|
358
|
+
"description": "Azure resource group for backend state",
|
|
359
|
+
"type": "string"
|
|
360
|
+
},
|
|
361
|
+
"storage_account_name": {
|
|
362
|
+
"description": "Storage account for Terraform state",
|
|
363
|
+
"type": "string"
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
"required": [
|
|
367
|
+
"container_name",
|
|
368
|
+
"key",
|
|
369
|
+
"resource_group_name",
|
|
370
|
+
"storage_account_name"
|
|
371
|
+
],
|
|
372
|
+
"additionalProperties": false
|
|
373
|
+
},
|
|
374
|
+
"env_short": {
|
|
375
|
+
"description": "Environment short name (1 char: 'd'=dev, 'u'=uat, 'p'=prod)",
|
|
376
|
+
"type": "string",
|
|
377
|
+
"maxLength": 1
|
|
378
|
+
},
|
|
379
|
+
"prefix": {
|
|
380
|
+
"description": "Project prefix (max 6 chars, e.g., 'io', 'pagopa')",
|
|
381
|
+
"type": "string",
|
|
382
|
+
"maxLength": 6
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
"required": [
|
|
386
|
+
"env_short",
|
|
387
|
+
"prefix"
|
|
388
|
+
],
|
|
389
|
+
"additionalProperties": false
|
|
332
390
|
}
|
|
333
391
|
},
|
|
334
|
-
"required": [
|
|
335
|
-
"env_short",
|
|
336
|
-
"prefix"
|
|
337
|
-
],
|
|
338
392
|
"additionalProperties": false
|
|
339
393
|
}
|
|
340
394
|
},
|
|
395
|
+
"required": [
|
|
396
|
+
"environments"
|
|
397
|
+
],
|
|
341
398
|
"additionalProperties": false
|
|
342
399
|
}
|
|
343
|
-
|
|
344
|
-
"additionalProperties": false
|
|
400
|
+
]
|
|
345
401
|
},
|
|
346
402
|
"timespan": {
|
|
347
403
|
"description": "Time range for dashboard queries (e.g., 5m, 1h, 24h). Default: 5m",
|
package/package.json
CHANGED