@gebit/stax-cli 1.4.0 → 1.8.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 +1 -1
- package/dist/schema.js +12 -2
- package/dist/templates.js +54 -2
- package/dist/validate.js +136 -3
- package/package.json +1 -1
- package/schema/deploy-config.schema.json +161 -1
package/README.md
CHANGED
|
@@ -77,7 +77,7 @@ stax validate config other-dir -r --strict
|
|
|
77
77
|
| Invalid YAML; wrong field types (e.g. `local_backend: "false"` instead of a boolean) | Fields the schema does not know (often typos such as `depend_on`) |
|
|
78
78
|
| Missing `id` or `type`; unknown `type`; more than one `github-pages-site-deploy` stack or `destroy` on it | `depends_on` or `stack.<id>.var.<key>` pointing to a stack in another config |
|
|
79
79
|
| Type-specific required fields: `folder` for `terraform`/`opentofu`/`function-build-deploy`, Packer `packer_directory`/`packer_version`, `s3-site-deploy` `location`, `script` `script`, `bizep` `template`, `function-build-deploy` `runtime` | `source_repo` alias not defined in this file (configs deployed together share `externalRepos`) |
|
|
80
|
-
| Packer paths that are absolute, contain `..`, backslashes, empty segments or control characters; non-exact `packer_version` | No stacks defined |
|
|
80
|
+
| Packer paths that are absolute, contain `..`, backslashes, empty segments or control characters; non-exact `packer_version`; `build_target: hetzner` without `hetzner`; destination fields for a different build target (also rejected by deployment setup) | No stacks defined; deprecated Gallery aliases (`gallery_name` and the other top-level Gallery fields); `build_target: aws` (reserved, the workflow rejects it) |
|
|
81
81
|
| Duplicate stack ids; malformed `stack.<id>.var.<key>` references | |
|
|
82
82
|
| Dependency cycles (including through `stack.<id>...` inputs); dependency chains deeper than 14 levels | |
|
|
83
83
|
|
package/dist/schema.js
CHANGED
|
@@ -8,11 +8,21 @@ ajv.addKeyword({
|
|
|
8
8
|
});
|
|
9
9
|
export const validateDeployConfig = ajv.compile(schema);
|
|
10
10
|
export const STACK_TYPES = schema.$defs.stack.properties.type?.enum ?? [];
|
|
11
|
-
|
|
11
|
+
export const CREDENTIAL_NAMES = schema.$defs.credentials.propertyNames.enum;
|
|
12
|
+
/**
|
|
13
|
+
* Fields the schema requires for `type`, besides id and type, in schema order.
|
|
14
|
+
* Conditions that also depend on another field (build_target, for example) are
|
|
15
|
+
* not unconditional requirements of the type.
|
|
16
|
+
*/
|
|
12
17
|
export function requiredStackFields(type) {
|
|
13
18
|
return schema.$defs.stack.allOf
|
|
14
19
|
.filter(({ if: condition }) => {
|
|
15
|
-
const
|
|
20
|
+
const keys = Object.keys(condition.properties);
|
|
21
|
+
if (keys.length !== 1 || keys[0] !== "type")
|
|
22
|
+
return false;
|
|
23
|
+
if ((condition.required ?? ["type"]).some((field) => field !== "type"))
|
|
24
|
+
return false;
|
|
25
|
+
const { const: single, enum: anyOf } = condition.properties.type ?? {};
|
|
16
26
|
return single === type || (anyOf?.includes(type) ?? false);
|
|
17
27
|
})
|
|
18
28
|
.flatMap((rule) => rule.then.required);
|
package/dist/templates.js
CHANGED
|
@@ -1,4 +1,54 @@
|
|
|
1
1
|
export const WORKFLOW_REPOSITORY = "GEBITSolutions/stax";
|
|
2
|
+
/** Optional secrets a-wf-setup-ci.yml accepts. Cross-org callers must map these by name. */
|
|
3
|
+
const SETUP_CI_SECRETS = [
|
|
4
|
+
"ARM_CLIENT_ID",
|
|
5
|
+
"ARM_CLIENT_SECRET",
|
|
6
|
+
"ARM_SUBSCRIPTION_ID",
|
|
7
|
+
"ARM_TENANT_ID",
|
|
8
|
+
"AWS_ACCESS_KEY_ID",
|
|
9
|
+
"AWS_SECRET_ACCESS_KEY",
|
|
10
|
+
"AWS_SESSION_TOKEN",
|
|
11
|
+
"AWS_ROLE_ARN",
|
|
12
|
+
"CONFIG_GITHUB_TOKEN",
|
|
13
|
+
"RELEASE_APP_CLIENT_SECRET",
|
|
14
|
+
"RELEASE_GH_APP_PRIVATE_KEY",
|
|
15
|
+
];
|
|
16
|
+
/** Optional secrets a-wf-deploy-levels.yml accepts and forwards to stack workflows. */
|
|
17
|
+
const DEPLOY_LEVELS_SECRETS = [
|
|
18
|
+
"ARM_CLIENT_ID",
|
|
19
|
+
"ARM_CLIENT_SECRET",
|
|
20
|
+
"ARM_SUBSCRIPTION_ID",
|
|
21
|
+
"ARM_TENANT_ID",
|
|
22
|
+
"AWS_ACCESS_KEY_ID",
|
|
23
|
+
"AWS_ROLE_ARN",
|
|
24
|
+
"AWS_SECRET_ACCESS_KEY",
|
|
25
|
+
"AWS_SESSION_TOKEN",
|
|
26
|
+
"CI_AZURE_STATIC_WEB_APPS_API_TOKEN",
|
|
27
|
+
"CI_ENV_TRANSFER_GH_TOKEN",
|
|
28
|
+
"CI_GITHUB_PAT",
|
|
29
|
+
"CI_GITHUB_TOKEN_TERRAFORM",
|
|
30
|
+
"GPG_PASSPHRASE",
|
|
31
|
+
"GPG_PRIVATE_KEY",
|
|
32
|
+
"GPG_PUBLIC_KEY",
|
|
33
|
+
"HCLOUD_TOKEN",
|
|
34
|
+
"INFRACOST_API_KEY",
|
|
35
|
+
"PULP_HOSTNAME",
|
|
36
|
+
"PULP_PASSWORD",
|
|
37
|
+
"PULP_USERNAME",
|
|
38
|
+
"RELEASE_APP_CLIENT_SECRET",
|
|
39
|
+
"RELEASE_GH_APP_PRIVATE_KEY",
|
|
40
|
+
"REPO_KEYSTORE_SP_CLIENT_SECRET",
|
|
41
|
+
"TF_PROVIDER_GH_OWNER",
|
|
42
|
+
];
|
|
43
|
+
/** Render a `secrets:` map that passes each named secret through from the caller. */
|
|
44
|
+
function renderNamedSecrets(names, indent = 4) {
|
|
45
|
+
const pad = " ".repeat(indent);
|
|
46
|
+
const lines = [`${pad}secrets:`];
|
|
47
|
+
for (const name of names) {
|
|
48
|
+
lines.push(`${pad} ${name}: \${{ secrets.${name} }}`);
|
|
49
|
+
}
|
|
50
|
+
return lines.join("\n");
|
|
51
|
+
}
|
|
2
52
|
export const DEPLOY_WORKFLOW_PATH = ".github/workflows/deploy.yml";
|
|
3
53
|
export const DEPLOY_CONFIG_PATH = "configs/default.yaml";
|
|
4
54
|
const PROJECT_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
@@ -136,8 +186,10 @@ concurrency:
|
|
|
136
186
|
jobs:
|
|
137
187
|
setup:
|
|
138
188
|
name: Setup CI/CD
|
|
189
|
+
# secrets: inherit only works same-org/enterprise. Map by name for cross-org
|
|
190
|
+
# callers of GEBITSolutions/stax (Environment secrets resolve on nested jobs).
|
|
139
191
|
uses: ${workflowPrefix}/a-wf-setup-ci.yml@${frameworkRef}
|
|
140
|
-
|
|
192
|
+
${renderNamedSecrets(SETUP_CI_SECRETS)}
|
|
141
193
|
with:
|
|
142
194
|
actions-version: ${JSON.stringify(frameworkRef)}
|
|
143
195
|
environment: \${{ inputs.environment }}
|
|
@@ -151,7 +203,7 @@ jobs:
|
|
|
151
203
|
name: Deploy Levels
|
|
152
204
|
needs: setup
|
|
153
205
|
uses: ${workflowPrefix}/a-wf-deploy-levels.yml@${frameworkRef}
|
|
154
|
-
|
|
206
|
+
${renderNamedSecrets(DEPLOY_LEVELS_SECRETS)}
|
|
155
207
|
with:
|
|
156
208
|
actions-version: ${JSON.stringify(frameworkRef)}
|
|
157
209
|
ci_config: \${{ needs.setup.outputs.ci-config }}
|
package/dist/validate.js
CHANGED
|
@@ -2,7 +2,7 @@ import { readdirSync, statSync } from "node:fs";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { isMap, isScalar, LineCounter, parseDocument } from "yaml";
|
|
4
4
|
import { isRecord } from "./guards.js";
|
|
5
|
-
import { ajv, schema, validateDeployConfig as validateSchema } from "./schema.js";
|
|
5
|
+
import { ajv, CREDENTIAL_NAMES, schema, validateDeployConfig as validateSchema } from "./schema.js";
|
|
6
6
|
/** a-wf-deploy-levels runs dependency levels l0 to l13. */
|
|
7
7
|
const MAX_LEVELS = 14;
|
|
8
8
|
const KNOWN_KEYS = {
|
|
@@ -79,10 +79,18 @@ function checkSchema(data, report) {
|
|
|
79
79
|
// "if" errors only say a "then" branch failed; the branch's own error carries the detail.
|
|
80
80
|
if (error.keyword === "if")
|
|
81
81
|
continue;
|
|
82
|
+
// Ajv reports both the name schema's enum/pattern error and its propertyNames wrapper.
|
|
83
|
+
// For credential maps, use the wrapper so the finding points to the offending YAML key.
|
|
84
|
+
if (error.schemaPath.includes("/$defs/credentials/propertyNames/"))
|
|
85
|
+
continue;
|
|
82
86
|
const path = error.instancePath
|
|
83
87
|
.split("/")
|
|
84
88
|
.slice(1)
|
|
85
89
|
.map((segment) => (/^\d+$/.test(segment) ? Number(segment) : segment.replaceAll("~1", "/").replaceAll("~0", "~")));
|
|
90
|
+
if (error.keyword === "propertyNames" && path.at(-1) === "credentials") {
|
|
91
|
+
report.add("error", [...path, String(error.params.propertyName)], `unsupported credential name; expected one of: ${CREDENTIAL_NAMES.join(", ")}`);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
86
94
|
report.add("error", path, schemaMessage(error, path));
|
|
87
95
|
}
|
|
88
96
|
}
|
|
@@ -109,6 +117,77 @@ function packerPathProblem(value) {
|
|
|
109
117
|
return "must not contain empty path segments";
|
|
110
118
|
return undefined;
|
|
111
119
|
}
|
|
120
|
+
const GALLERY_FIELDS = [
|
|
121
|
+
"image_resource_group_name",
|
|
122
|
+
"gallery_name",
|
|
123
|
+
"image_definition_name",
|
|
124
|
+
"image_version",
|
|
125
|
+
"target_regions",
|
|
126
|
+
];
|
|
127
|
+
const RESERVED_SNAPSHOT_LABELS = ["managed_by", "stax_stack_id", "stax_env", "stax_git_sha", "stax_build_target"];
|
|
128
|
+
function sameJson(left, right) {
|
|
129
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
130
|
+
}
|
|
131
|
+
/** build_target rules that JSON Schema if/then cannot express: aliases, conflicts, and the AWS stub. */
|
|
132
|
+
function checkPackerBuildTarget(stack, index, report) {
|
|
133
|
+
const target = stack.build_target === undefined ? "azure" : stack.build_target;
|
|
134
|
+
if (target !== "azure" && target !== "hetzner" && target !== "aws")
|
|
135
|
+
return;
|
|
136
|
+
if (target === "aws") {
|
|
137
|
+
report.add("warning", ["stacks", index, "build_target"], "aws is reserved and not implemented; the workflow rejects it until an AMI executor exists");
|
|
138
|
+
}
|
|
139
|
+
for (const field of GALLERY_FIELDS) {
|
|
140
|
+
if (stack[field] !== undefined) {
|
|
141
|
+
report.add("warning", ["stacks", index, field], `deprecated alias of azure.${field}; move it under azure`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const azure = isRecord(stack.azure) ? stack.azure : undefined;
|
|
145
|
+
if (azure) {
|
|
146
|
+
for (const field of GALLERY_FIELDS) {
|
|
147
|
+
if (stack[field] !== undefined && azure[field] !== undefined && !sameJson(stack[field], azure[field])) {
|
|
148
|
+
report.add("error", ["stacks", index, "azure", field], `conflicts with deprecated alias ${field}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (target === "azure" && stack.hetzner !== undefined) {
|
|
153
|
+
report.add("error", ["stacks", index, "hetzner"], "does not apply when build_target is azure");
|
|
154
|
+
}
|
|
155
|
+
if (target === "azure" && stack.aws !== undefined) {
|
|
156
|
+
report.add("error", ["stacks", index, "aws"], "does not apply when build_target is azure");
|
|
157
|
+
}
|
|
158
|
+
if (target === "hetzner" && (azure || GALLERY_FIELDS.some((field) => stack[field] !== undefined))) {
|
|
159
|
+
report.add("error", ["stacks", index, "build_target"], "hetzner does not use Azure Gallery fields");
|
|
160
|
+
}
|
|
161
|
+
if (target === "hetzner" && stack.aws !== undefined) {
|
|
162
|
+
report.add("error", ["stacks", index, "aws"], "does not apply when build_target is hetzner");
|
|
163
|
+
}
|
|
164
|
+
if (target === "aws" && (azure || stack.hetzner !== undefined || GALLERY_FIELDS.some((field) => stack[field] !== undefined))) {
|
|
165
|
+
report.add("error", ["stacks", index, "build_target"], "aws does not use Azure Gallery or Hetzner fields");
|
|
166
|
+
}
|
|
167
|
+
if (isRecord(stack.hetzner) && isRecord(stack.hetzner.snapshot_labels)) {
|
|
168
|
+
for (const key of RESERVED_SNAPSHOT_LABELS) {
|
|
169
|
+
if (stack.hetzner.snapshot_labels[key] !== undefined) {
|
|
170
|
+
report.add("warning", ["stacks", index, "hetzner", "snapshot_labels", key], "reserved label; STAX overwrites it");
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if ((stack.destroy === true || stack.destroy === "true") && target !== "hetzner") {
|
|
175
|
+
report.add("warning", ["stacks", index, "destroy"], "Packer destroy is only supported for build_target hetzner; Azure Gallery builds stay build-only");
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/** Extra scan rules: goss path shape. Schema covers the rest. */
|
|
179
|
+
function checkPackerScan(stack, index, report) {
|
|
180
|
+
if (stack.scan === undefined)
|
|
181
|
+
return;
|
|
182
|
+
if (!isRecord(stack.scan))
|
|
183
|
+
return;
|
|
184
|
+
const goss = stack.scan.goss;
|
|
185
|
+
if (!isRecord(goss) || typeof goss.spec !== "string")
|
|
186
|
+
return;
|
|
187
|
+
const problem = packerPathProblem(goss.spec);
|
|
188
|
+
if (problem)
|
|
189
|
+
report.add("error", ["stacks", index, "scan", "goss", "spec"], problem);
|
|
190
|
+
}
|
|
112
191
|
/** Collects stack.<id>.var|secret.<key> references in an input value, like update_deploy_config. */
|
|
113
192
|
function collectStackReferences(value, path, out) {
|
|
114
193
|
if (typeof value === "string") {
|
|
@@ -172,6 +251,19 @@ function checkPipelineRules(data, report) {
|
|
|
172
251
|
if (problem)
|
|
173
252
|
report.add("error", ["stacks", index, field], problem);
|
|
174
253
|
}
|
|
254
|
+
checkPackerBuildTarget(stack, index, report);
|
|
255
|
+
checkPackerScan(stack, index, report);
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
if (stack.build_target !== undefined) {
|
|
259
|
+
report.add("warning", ["stacks", index, "build_target"], "applies to packer stacks only");
|
|
260
|
+
}
|
|
261
|
+
if (stack.scan !== undefined) {
|
|
262
|
+
report.add("warning", ["stacks", index, "scan"], "applies to packer stacks only");
|
|
263
|
+
}
|
|
264
|
+
if (isRecord(stack.hetzner) && stack.hetzner.token !== undefined) {
|
|
265
|
+
report.add("error", ["stacks", index, "hetzner", "token"], "applies to packer stacks with build_target hetzner only");
|
|
266
|
+
}
|
|
175
267
|
}
|
|
176
268
|
// Mirrors validateGitHubPagesConfig and github-pages-config.mjs.
|
|
177
269
|
if (stack.type === "github-pages-site-deploy") {
|
|
@@ -280,6 +372,45 @@ function checkEndpointURLs(deployment, report) {
|
|
|
280
372
|
function deploymentText(value) {
|
|
281
373
|
return value === undefined || value === null ? "" : String(value).trim();
|
|
282
374
|
}
|
|
375
|
+
/** Hetzner's token alias cannot coexist with an explicit HCLOUD_TOKEN mapping, including an inherited one. */
|
|
376
|
+
function checkCredentialRules(data, report) {
|
|
377
|
+
const inherited = isRecord(data.deployment) && isRecord(data.deployment.credentials) ? data.deployment.credentials : undefined;
|
|
378
|
+
if (!Array.isArray(data.stacks))
|
|
379
|
+
return;
|
|
380
|
+
data.stacks.forEach((stack, index) => {
|
|
381
|
+
if (!isRecord(stack) || stack.type !== "packer" || stack.build_target !== "hetzner")
|
|
382
|
+
return;
|
|
383
|
+
if (!isRecord(stack.hetzner) || stack.hetzner.token === undefined)
|
|
384
|
+
return;
|
|
385
|
+
const mapped = isRecord(stack.credentials) && Object.hasOwn(stack.credentials, "HCLOUD_TOKEN")
|
|
386
|
+
? stack.credentials
|
|
387
|
+
: inherited;
|
|
388
|
+
if (mapped && Object.hasOwn(mapped, "HCLOUD_TOKEN")) {
|
|
389
|
+
report.add("error", ["stacks", index, "hetzner", "token"], "conflicts with effective credentials.HCLOUD_TOKEN; use only one reference");
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
/** GitHub Environment variables are available only when the caller provides them (CLI defaults to its process). */
|
|
394
|
+
function checkCredentialVaultUrl(data, report, variables) {
|
|
395
|
+
if (variables.REPO_KEYSTORE_KEY_VAULT_URL?.trim())
|
|
396
|
+
return;
|
|
397
|
+
const deployment = isRecord(data.deployment) ? data.deployment : undefined;
|
|
398
|
+
const defaults = deployment && isRecord(deployment.credentials) ? deployment.credentials : undefined;
|
|
399
|
+
const hasDefaults = defaults !== undefined && Object.keys(defaults).length > 0;
|
|
400
|
+
if (!Array.isArray(data.stacks))
|
|
401
|
+
return;
|
|
402
|
+
data.stacks.forEach((stack, index) => {
|
|
403
|
+
if (!isRecord(stack))
|
|
404
|
+
return;
|
|
405
|
+
const backend = stack.secret_backend ?? deployment?.secret_backend ?? "gh";
|
|
406
|
+
const overrides = isRecord(stack.credentials) ? stack.credentials : undefined;
|
|
407
|
+
if (backend !== "keyvault" || (!hasDefaults && !(overrides && Object.keys(overrides).length > 0)))
|
|
408
|
+
return;
|
|
409
|
+
const path = deployment?.secret_backend === "keyvault" && hasDefaults
|
|
410
|
+
? ["deployment", "credentials"] : ["stacks", index, "credentials"];
|
|
411
|
+
report.add("error", path, "REPO_KEYSTORE_KEY_VAULT_URL is required for keyvault-backed credentials");
|
|
412
|
+
});
|
|
413
|
+
}
|
|
283
414
|
/** Mirrors the AWS option checks in .github/scripts/deployment-config.mjs and a-wf-setup-ci. */
|
|
284
415
|
function checkDeploymentRules(data, report) {
|
|
285
416
|
const deployment = data.deployment;
|
|
@@ -300,8 +431,8 @@ function checkDeploymentRules(data, report) {
|
|
|
300
431
|
return;
|
|
301
432
|
}
|
|
302
433
|
}
|
|
303
|
-
/** Validates one deploy config. Findings are sorted by position. */
|
|
304
|
-
export function validateConfigText(text) {
|
|
434
|
+
/** Validates one deploy config. Pass Environment variables explicitly when available; the CLI uses process.env. Findings are sorted by position. */
|
|
435
|
+
export function validateConfigText(text, variables = process.env) {
|
|
305
436
|
const lineCounter = new LineCounter();
|
|
306
437
|
const doc = parseDocument(text, { lineCounter, prettyErrors: false });
|
|
307
438
|
const report = new Reporter(doc, lineCounter);
|
|
@@ -328,6 +459,8 @@ export function validateConfigText(text) {
|
|
|
328
459
|
if (Array.isArray(data.stacks)) {
|
|
329
460
|
data.stacks.forEach((stack, index) => checkUnknownKeys(stack, KNOWN_KEYS.stack, ["stacks", index], report));
|
|
330
461
|
}
|
|
462
|
+
checkCredentialRules(data, report);
|
|
463
|
+
checkCredentialVaultUrl(data, report, variables);
|
|
331
464
|
checkDeploymentRules(data, report);
|
|
332
465
|
checkPipelineRules(data, report);
|
|
333
466
|
return report.findings.sort((a, b) => a.line - b.line || a.column - b.column);
|
package/package.json
CHANGED
|
@@ -32,6 +32,16 @@
|
|
|
32
32
|
"$defs": {
|
|
33
33
|
"deploymentValue": { "type": ["string", "null"], "pattern": "^[^\\r\\n]*$" },
|
|
34
34
|
"deploymentFlag": { "type": ["boolean", "string", "null"], "pattern": "^(?:true|false|[^\\S\\r\\n]*)$" },
|
|
35
|
+
"credentialReference": { "type": "string", "pattern": "^(secret_backend|gh)\\.secret\\.[A-Za-z0-9_]+$" },
|
|
36
|
+
"credentials": {
|
|
37
|
+
"description": "Explicit credential references. Only listed runtime credential names are accepted; values must reference GitHub or the selected secret backend.",
|
|
38
|
+
"type": "object",
|
|
39
|
+
"propertyNames": {
|
|
40
|
+
"pattern": "^[A-Z][A-Z0-9_]*$",
|
|
41
|
+
"enum": ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN", "HCLOUD_TOKEN", "INFRACOST_API_KEY", "CI_GITHUB_PAT", "CI_GITHUB_TOKEN_TERRAFORM", "TF_PROVIDER_GH_OWNER"]
|
|
42
|
+
},
|
|
43
|
+
"additionalProperties": { "$ref": "#/$defs/credentialReference" }
|
|
44
|
+
},
|
|
35
45
|
"endpointUrl": {
|
|
36
46
|
"type": ["string", "null"],
|
|
37
47
|
"pattern": "^(?:[^\\S\\r\\n]*(?:https://[^\\s@/?#\\\\]+(?:/[^\\s@?#\\\\]*)?|http://(?:localhost|127\\.0\\.0\\.1|\\[::1\\])(?::[0-9]+)?(?:/[^\\s@?#\\\\]*)?)[^\\S\\r\\n]*|[^\\S\\r\\n]*)$"
|
|
@@ -41,6 +51,8 @@
|
|
|
41
51
|
"additionalProperties": false,
|
|
42
52
|
"properties": {
|
|
43
53
|
"project": { "description": "Project name; falls back to GitHub PROJECT.", "$ref": "#/$defs/deploymentValue" },
|
|
54
|
+
"secret_backend": { "description": "Default secret store for secret_backend.secret.<key> references. Overridable per stack. Default gh.", "type": "string", "enum": ["keyvault", "gh"], "default": "gh" },
|
|
55
|
+
"credentials": { "description": "Default credential references for stacks in this deployment. A stack can override individual names.", "$ref": "#/$defs/credentials" },
|
|
44
56
|
"customer_id": { "description": "Customer identifier; falls back to CUSTOMER_ID.", "$ref": "#/$defs/deploymentValue" },
|
|
45
57
|
"stage": { "description": "Deployment stage; falls back to STAGE.", "$ref": "#/$defs/deploymentValue" },
|
|
46
58
|
"cloud": { "description": "Azure or AWS, case-insensitive; falls back to CLOUD.", "type": ["string", "null"], "pattern": "^(?:[aA][zZ][uU][rR][eE]|[aA][wW][sS]|[^\\S\\r\\n]*)$" },
|
|
@@ -102,6 +114,8 @@
|
|
|
102
114
|
"depends_on": { "description": "Stack ids deployed before this one.", "$ref": "#/$defs/stringList", "examples": [[]], "x-stax-types": "all" },
|
|
103
115
|
"stack-groups": { "description": "Groups for selecting stacks in the deploy form.", "$ref": "#/$defs/stringList", "examples": [["core"]], "x-stax-types": "all" },
|
|
104
116
|
"runs-on": { "description": "Runner label.", "type": "string", "examples": ["ubuntu-24.04"], "x-stax-types": "all" },
|
|
117
|
+
"secret_backend": { "description": "Overrides deployment.secret_backend for this stack. Default inherits deployment, then gh.", "type": "string", "enum": ["keyvault", "gh"], "examples": ["gh"], "x-stax-types": "all" },
|
|
118
|
+
"credentials": { "description": "Credential references merged over deployment.credentials by name. A mapped but missing secret fails deployment.", "$ref": "#/$defs/credentials", "examples": [{ "AWS_ACCESS_KEY_ID": "secret_backend.secret.aws_access_key_id" }], "x-stax-types": "all" },
|
|
105
119
|
"input": {
|
|
106
120
|
"description": "Inputs: reference strings (global.pipeline.var.<key>, stack.<id>.var.<key>, ...) or key/value maps.",
|
|
107
121
|
"type": "array",
|
|
@@ -126,7 +140,7 @@
|
|
|
126
140
|
"examples": ["main"],
|
|
127
141
|
"x-stax-types": ["terraform", "opentofu", "packer", "swa-site-deploy", "swa-docs-site-deploy", "s3-site-deploy", "script", "bizep", "github-pages-site-deploy"]
|
|
128
142
|
},
|
|
129
|
-
"destroy": { "description": "Destroy the stack instead of deploying it.", "type": ["boolean", "string"], "examples": [false], "x-stax-types": ["terraform", "opentofu", "swa-site-deploy", "swa-docs-site-deploy"] },
|
|
143
|
+
"destroy": { "description": "Destroy the stack instead of deploying it. For Packer, only build_target hetzner honors this; Azure Gallery builds stay build-only.", "type": ["boolean", "string"], "examples": [false], "x-stax-types": ["terraform", "opentofu", "packer", "swa-site-deploy", "swa-docs-site-deploy"] },
|
|
130
144
|
|
|
131
145
|
"folder": {
|
|
132
146
|
"description": "Stack directory: below stack_base_path for terraform/opentofu, below functions/ for function-build-deploy.",
|
|
@@ -146,6 +160,138 @@
|
|
|
146
160
|
"packer_directory": { "description": "Packer project path, relative to the source repository.", "$ref": "#/$defs/relativePath", "examples": ["packer/ubuntu"], "x-stax-types": ["packer"] },
|
|
147
161
|
"packer_template": { "description": "Template file or directory relative to packer_directory; defaults to '.'.", "$ref": "#/$defs/relativePath", "examples": ["azure.pkr.hcl"], "x-stax-types": ["packer"] },
|
|
148
162
|
"packer_version": { "description": "Exact Packer version.", "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$", "examples": ["1.11.2"], "x-stax-types": ["packer"] },
|
|
163
|
+
"build_target": {
|
|
164
|
+
"description": "Packer publisher. Omit or set azure for Compute Gallery. hetzner publishes a labelled snapshot and requires hetzner. aws is reserved and not implemented.",
|
|
165
|
+
"enum": ["azure", "hetzner", "aws"],
|
|
166
|
+
"default": "azure",
|
|
167
|
+
"examples": ["azure"],
|
|
168
|
+
"x-stax-types": ["packer"]
|
|
169
|
+
},
|
|
170
|
+
"azure": {
|
|
171
|
+
"description": "Azure Compute Gallery destination. Required on apply unless the same fields are still set as deprecated aliases or stack inputs.",
|
|
172
|
+
"type": "object",
|
|
173
|
+
"additionalProperties": false,
|
|
174
|
+
"properties": {
|
|
175
|
+
"image_resource_group_name": { "type": "string", "minLength": 1, "examples": ["rg-images"] },
|
|
176
|
+
"gallery_name": { "type": "string", "minLength": 1, "examples": ["corp_gallery"] },
|
|
177
|
+
"image_definition_name": { "type": "string", "minLength": 1, "examples": ["ubuntu2404"] },
|
|
178
|
+
"image_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$", "examples": ["1.2.3"] },
|
|
179
|
+
"target_regions": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 }, "examples": [["westeurope", "northeurope"]] }
|
|
180
|
+
},
|
|
181
|
+
"examples": [{
|
|
182
|
+
"image_resource_group_name": "rg-images",
|
|
183
|
+
"gallery_name": "corp_gallery",
|
|
184
|
+
"image_definition_name": "ubuntu2404",
|
|
185
|
+
"image_version": "1.2.3",
|
|
186
|
+
"target_regions": ["westeurope", "northeurope"]
|
|
187
|
+
}],
|
|
188
|
+
"x-stax-types": ["packer"]
|
|
189
|
+
},
|
|
190
|
+
"hetzner": {
|
|
191
|
+
"description": "Hetzner snapshot destination. Required when build_target is hetzner. cax* server types are arm64; the template's source image must match.",
|
|
192
|
+
"type": "object",
|
|
193
|
+
"additionalProperties": false,
|
|
194
|
+
"required": ["location", "server_type"],
|
|
195
|
+
"properties": {
|
|
196
|
+
"location": { "description": "Hetzner location, for example fsn1.", "type": "string", "pattern": "^[a-z]{2,4}[0-9]?$", "examples": ["fsn1"] },
|
|
197
|
+
"server_type": { "description": "Temporary build server type, for example cax11.", "type": "string", "pattern": "^[a-z][a-z0-9]{1,31}$", "examples": ["cax11"] },
|
|
198
|
+
"token": { "description": "Hetzner API token reference; alias of credentials.HCLOUD_TOKEN. Do not set both, including an inherited deployment credential. When unset, the workflow uses the HCLOUD_TOKEN GitHub Environment secret.", "$ref": "#/$defs/credentialReference", "examples": ["secret_backend.secret.hcloud_token", "gh.secret.hcloud_token"], "x-stax-types": ["packer"] },
|
|
199
|
+
"snapshot_name": { "description": "Snapshot name. Defaults to the stack id.", "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,62}$", "examples": ["personal-assistant-golden"] },
|
|
200
|
+
"snapshot_labels": {
|
|
201
|
+
"description": "Extra snapshot labels. STAX adds stax_stack_id, stax_env, stax_git_sha, stax_build_target and managed_by=stax.",
|
|
202
|
+
"type": "object",
|
|
203
|
+
"additionalProperties": { "type": "string", "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9_.-]{0,61}[A-Za-z0-9])?$" },
|
|
204
|
+
"propertyNames": { "pattern": "^[A-Za-z](?:[A-Za-z0-9_.-]{0,61}[A-Za-z0-9])?$" },
|
|
205
|
+
"examples": [{ "personal-assistant": "true", "role": "golden" }]
|
|
206
|
+
},
|
|
207
|
+
"keep_last": { "description": "Matching snapshots to retain after a successful build. Default 3. 0 keeps only the snapshot just built; on destroy, 0 deletes every match.", "type": "integer", "minimum": 0, "maximum": 100, "default": 3, "examples": [3] }
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"aws": {
|
|
211
|
+
"description": "Reserved for a later AMI publisher. build_target aws is rejected by the workflow.",
|
|
212
|
+
"type": "object",
|
|
213
|
+
"additionalProperties": false,
|
|
214
|
+
"required": ["regions"],
|
|
215
|
+
"properties": {
|
|
216
|
+
"regions": {
|
|
217
|
+
"type": "array",
|
|
218
|
+
"minItems": 1,
|
|
219
|
+
"items": { "type": "string", "pattern": "^[a-z]{2}-[a-z]+-[0-9]+$" },
|
|
220
|
+
"examples": [["eu-central-1"]]
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
"scan": {
|
|
225
|
+
"description": "Optional Packer image scan/test hooks. Omit to keep build-only behaviour. When set, STAX materialises .stax/scan/run.sh and runs it on the build VM before the image is captured; a failing hook fails packer build so Azure Gallery and Hetzner never publish. Requires the template to declare stax_scan_enabled and reference .stax/scan/run.sh.",
|
|
226
|
+
"type": "object",
|
|
227
|
+
"additionalProperties": false,
|
|
228
|
+
"minProperties": 1,
|
|
229
|
+
"properties": {
|
|
230
|
+
"trivy": {
|
|
231
|
+
"description": "Vulnerability/misconfig scan via aquasecurity/trivy rootfs. Fails when findings meet or exceed severity.",
|
|
232
|
+
"type": "object",
|
|
233
|
+
"additionalProperties": false,
|
|
234
|
+
"properties": {
|
|
235
|
+
"severity": {
|
|
236
|
+
"description": "Comma-separated uppercase severities passed to trivy --severity.",
|
|
237
|
+
"type": "string",
|
|
238
|
+
"pattern": "^[A-Z]+(?:,[A-Z]+)*$",
|
|
239
|
+
"default": "HIGH,CRITICAL",
|
|
240
|
+
"examples": ["HIGH,CRITICAL", "CRITICAL"]
|
|
241
|
+
},
|
|
242
|
+
"scanners": {
|
|
243
|
+
"description": "Trivy scanners to enable.",
|
|
244
|
+
"type": "array",
|
|
245
|
+
"minItems": 1,
|
|
246
|
+
"items": { "enum": ["vuln", "misconfig", "secret", "license"] },
|
|
247
|
+
"default": ["vuln"],
|
|
248
|
+
"examples": [["vuln"], ["vuln", "misconfig"]]
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
"lynis": {
|
|
253
|
+
"description": "Hardening audit via CISOfy Lynis. Fails when the hardening index is below min_hardening_index.",
|
|
254
|
+
"type": "object",
|
|
255
|
+
"additionalProperties": false,
|
|
256
|
+
"properties": {
|
|
257
|
+
"min_hardening_index": {
|
|
258
|
+
"description": "Minimum acceptable Lynis hardening index (0-100).",
|
|
259
|
+
"type": "integer",
|
|
260
|
+
"minimum": 0,
|
|
261
|
+
"maximum": 100,
|
|
262
|
+
"default": 50,
|
|
263
|
+
"examples": [50, 65]
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
"goss": {
|
|
268
|
+
"description": "Server spec tests via goss. Fails on any failed expectation.",
|
|
269
|
+
"type": "object",
|
|
270
|
+
"additionalProperties": false,
|
|
271
|
+
"required": ["spec"],
|
|
272
|
+
"properties": {
|
|
273
|
+
"spec": {
|
|
274
|
+
"description": "Goss spec path relative to packer_directory (no ..).",
|
|
275
|
+
"type": "string",
|
|
276
|
+
"minLength": 1,
|
|
277
|
+
"pattern": "^(?!.*\\.\\.)(?!/)[A-Za-z0-9._/-]+$",
|
|
278
|
+
"examples": ["goss.yaml", "tests/goss.yaml"]
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
"examples": [{
|
|
284
|
+
"trivy": { "severity": "HIGH,CRITICAL", "scanners": ["vuln", "misconfig"] },
|
|
285
|
+
"lynis": { "min_hardening_index": 50 },
|
|
286
|
+
"goss": { "spec": "goss.yaml" }
|
|
287
|
+
}],
|
|
288
|
+
"x-stax-types": ["packer"]
|
|
289
|
+
},
|
|
290
|
+
"image_resource_group_name": { "description": "Deprecated alias of azure.image_resource_group_name.", "type": "string", "minLength": 1 },
|
|
291
|
+
"gallery_name": { "description": "Deprecated alias of azure.gallery_name.", "type": "string", "minLength": 1 },
|
|
292
|
+
"image_definition_name": { "description": "Deprecated alias of azure.image_definition_name.", "type": "string", "minLength": 1 },
|
|
293
|
+
"image_version": { "description": "Deprecated alias of azure.image_version.", "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
|
|
294
|
+
"target_regions": { "description": "Deprecated alias of azure.target_regions.", "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
|
|
149
295
|
|
|
150
296
|
"image_name": { "type": "string", "examples": ["my-app"], "x-stax-types": ["docker-build-push"] },
|
|
151
297
|
"dockerfile_folder": { "description": "Build context containing the Dockerfile.", "type": "string", "examples": ["docker/my-app"], "x-stax-types": ["docker-build-push"] },
|
|
@@ -185,6 +331,20 @@
|
|
|
185
331
|
"if": { "properties": { "type": { "const": "packer" } }, "required": ["type"] },
|
|
186
332
|
"then": { "required": ["packer_directory", "packer_version"] }
|
|
187
333
|
},
|
|
334
|
+
{
|
|
335
|
+
"if": {
|
|
336
|
+
"properties": { "type": { "const": "packer" }, "build_target": { "const": "hetzner" } },
|
|
337
|
+
"required": ["type", "build_target"]
|
|
338
|
+
},
|
|
339
|
+
"then": { "required": ["hetzner"] }
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"if": {
|
|
343
|
+
"properties": { "type": { "const": "packer" }, "build_target": { "const": "aws" } },
|
|
344
|
+
"required": ["type", "build_target"]
|
|
345
|
+
},
|
|
346
|
+
"then": { "required": ["aws"] }
|
|
347
|
+
},
|
|
188
348
|
{
|
|
189
349
|
"if": { "properties": { "type": { "const": "s3-site-deploy" } }, "required": ["type"] },
|
|
190
350
|
"then": { "required": ["location"] }
|