blueprint-shared-facts 0.11.0 → 0.12.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.
@@ -4,7 +4,7 @@
4
4
  "package": "blueprint-shared-facts",
5
5
  "entry": "blueprint-shared",
6
6
  "describes": {
7
- "blueprint-shared-facts": "0.11.0"
7
+ "blueprint-shared-facts": "0.12.0"
8
8
  },
9
9
  "layer": "org",
10
10
  "facts": [
@@ -546,7 +546,7 @@
546
546
  "ci"
547
547
  ],
548
548
  "title": "job 不佔著 runner 等另一個 job",
549
- "description": "等另一個 run、PR 或 release-please 的迴圈最多問兩輪,三個輪數變數不超過 2,間隔變數不超過預設值。`writeback-ops.sh` 的寫入重試是登記過的例外。",
549
+ "description": "等另一個 run、PR 或 release-please 的迴圈最多問兩輪,三個輪數變數不超過 2,間隔變數不超過預設值。`writeback-ops.sh` 的寫入重試,與 `edge-address.sh` 重試 DNS over HTTPS 查詢(約 60 秒,不查任何 run 或 PR),是登記過的例外。",
550
550
  "variants": [
551
551
  {
552
552
  "since": "0.8.0",
@@ -583,6 +583,52 @@
583
583
  ]
584
584
  }
585
585
  }
586
+ },
587
+ {
588
+ "since": "0.12.0",
589
+ "content": {
590
+ "value": {
591
+ "rule": "A job on a self-hosted runner does not keep the runner waiting for another run. A loop that asks about another run, a pull request or release-please asks twice at most; the rest is triggered by an event, or the job fails and is dispatched again from outside.",
592
+ "roundVariables": [
593
+ "POLL_TRIES",
594
+ "CI_GATE_TRIES",
595
+ "CI_GATE_QUEUE_TRIES"
596
+ ],
597
+ "maxRounds": 2,
598
+ "roundVariablesWhere": "The three round variables are set on the workflow env, or in the env of every job whose runs-on is not a literal GitHub-hosted label (ubuntu-, macos-, windows-), and none is above maxRounds. The template ci.yml sets them on the jobs, the other workflows on the workflow.",
599
+ "sleepDefaults": {
600
+ "POLL_SLEEP": 3,
601
+ "CI_GATE_SLEEP": 15,
602
+ "WRITEBACK_RETRY_SLEEP": 5,
603
+ "WRITEBACK_RETRY_JITTER": 5,
604
+ "RETRY_SLEEP": 5
605
+ },
606
+ "sleepRule": "An interval variable is not set above its default (seconds).",
607
+ "writeRetries": [
608
+ {
609
+ "file": "templates/deploy/scripts/deploy/writeback-ops.sh",
610
+ "loop": "for ((i=1; i<=${WRITEBACK_TRIES:-6}; i++))",
611
+ "defaults": {
612
+ "WRITEBACK_TRIES": 6,
613
+ "WRITEBACK_RETRY_SLEEP": 5,
614
+ "WRITEBACK_RETRY_JITTER": 5
615
+ },
616
+ "limit": "WRITEBACK_TRIES rounds, 6 by default, of WRITEBACK_RETRY_SLEEP seconds (5) plus up to WRITEBACK_RETRY_JITTER seconds (5) at random",
617
+ "why": "the deploys of a monorepo write the ops declaration back at once, and each round lets one of them push"
618
+ },
619
+ {
620
+ "file": "templates/ops/scripts/lib/edge-address.sh",
621
+ "loop": "for (( round = 1; round <= attempts; round++ ))",
622
+ "defaults": {
623
+ "EDGE_ADDRESS_ATTEMPTS": 12,
624
+ "EDGE_ADDRESS_INTERVAL": 5
625
+ },
626
+ "limit": "EDGE_ADDRESS_ATTEMPTS rounds, 12 by default, of EDGE_ADDRESS_INTERVAL seconds (5), about 60 seconds",
627
+ "why": "the lookup of an edge address over DNS over HTTPS retries until a new Custom Domain, or another hostname of its zone, resolves; it asks no run, pull request or release-please, so no other job is waiting for this runner"
628
+ }
629
+ ]
630
+ }
631
+ }
586
632
  }
587
633
  ],
588
634
  "source": {
@@ -617,6 +663,16 @@
617
663
  },
618
664
  "limit": "WRITEBACK_TRIES rounds, 6 by default, of WRITEBACK_RETRY_SLEEP seconds (5) plus up to WRITEBACK_RETRY_JITTER seconds (5) at random",
619
665
  "why": "the deploys of a monorepo write the ops declaration back at once, and each round lets one of them push"
666
+ },
667
+ {
668
+ "file": "templates/ops/scripts/lib/edge-address.sh",
669
+ "loop": "for (( round = 1; round <= attempts; round++ ))",
670
+ "defaults": {
671
+ "EDGE_ADDRESS_ATTEMPTS": 12,
672
+ "EDGE_ADDRESS_INTERVAL": 5
673
+ },
674
+ "limit": "EDGE_ADDRESS_ATTEMPTS rounds, 12 by default, of EDGE_ADDRESS_INTERVAL seconds (5), about 60 seconds",
675
+ "why": "the lookup of an edge address over DNS over HTTPS retries until a new Custom Domain, or another hostname of its zone, resolves; it asks no run, pull request or release-please, so no other job is waiting for this runner"
620
676
  }
621
677
  ]
622
678
  }
@@ -1366,6 +1422,41 @@
1366
1422
  "bucketName": "The name of an R2 bucket is written once, in the terraform.tfvars.json of its iac step. When apply-ops.sh joins the settings of a workloads step to the wrangler.toml of the bundle, it adds bucket_name to every [[env.<env>.r2_buckets]] table that has none, with the name from the terraform.tfvars.json of the iac steps the workloads step needs in ops/needs.json"
1367
1423
  }
1368
1424
  }
1425
+ },
1426
+ {
1427
+ "since": "0.12.0",
1428
+ "content": {
1429
+ "value": {
1430
+ "role": "ops",
1431
+ "dir": "ops/",
1432
+ "needs": [
1433
+ "base"
1434
+ ],
1435
+ "for": "the repository that puts the declared bundles online: the monorepo (a single-repository product that deploys), the -ops repository of a poly product, and the ops repository of the organization layer, which belongs to no product and declares the locations, the parent clusters and the instances of ops/targets.json",
1436
+ "files": [
1437
+ ".github/workflows/ops-deploy.yml",
1438
+ "scripts/ci/check-targets.mjs",
1439
+ "scripts/deploy/apply-iac.sh",
1440
+ "scripts/deploy/apply-ops.sh",
1441
+ "scripts/deploy/smoke.sh",
1442
+ "scripts/deploy/healthz.sh",
1443
+ "scripts/deploy/ops-run.sh",
1444
+ "scripts/lib/bundle.sh",
1445
+ "scripts/lib/edge-address.sh",
1446
+ "scripts/lib/ops-steps.sh",
1447
+ "schemas/targets.schema.json"
1448
+ ],
1449
+ "packageJson": "The composed root package.json has wrangler as a devDependency and pnpm allows the build scripts of esbuild and workerd, because `pnpm dlx wrangler` is refused them",
1450
+ "onlyHere": "The only files that read the Cloudflare credentials: the jobs of ops-deploy.yml (iac reads CLOUDFLARE_R2_API_TOKEN, workloads reads CLOUDFLARE_API_TOKEN) and the scripts they call",
1451
+ "sameAs": "scripts/lib/bundle.sh is the same file as the one of the deploy role",
1452
+ "urls": "healthz.sh reads the URL pattern of each environment from ops/urls.json, which compose writes. The role has no repository variable for it. When the host of the pattern is not *.workers.dev and CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID are set, healthz.sh looks the host up as a Custom Domain of the account (scripts/lib/edge-address.sh): an existing one is reached with curl --resolve <host>:443:<edge address>, where the address is the one that another hostname of the same zone resolves to over DNS over HTTPS (the target itself when none does), so the request does not depend on the resolver; a host that is no Custom Domain is requested as usual",
1453
+ "targets": "The static job of ci.yml runs `node scripts/ci/check-targets.mjs` in a repository with this role. It validates ops/targets.json against schemas/targets.schema.json (the same JSON Schema as blueprint-shared.infra-layout.targets), then checks what the schema cannot: a ref points at an instance of the same kind, a host and a cluster are declared by the repository they name, a location or parent cluster with an environment suffix holds instances of that environment only, parent clusters and tenants are named by blueprint-shared.infra-layout.cluster-naming, and every iac/hosts/<location>/clusters/<cluster> and workloads/hosts/<location>/clusters/<cluster> directory is declared. The suffixes and the order of the cases are constants of the script that a test compares with the machine-readable fields of cluster-naming",
1454
+ "orgRepos": "scripts/ci/org-repos.json is a list of repository names that compose writes from the repository list of the organization of the repository (for the demo organization, the repository list of its facts), because the script cannot read the facts. A <RepoName>: prefix of a host or ref has to be in this list, and a name outside it fails. The list is of one organization, so two organizations that both have a repository of the same name never share a list. A host or ref into a repository of the list whose ops/targets.json was not given is printed as 未核對 with the instance and the host, and does not fail. A repository checks only its own ops/targets.json in its own CI; a run that is given the ops/targets.json of every repository of the organization (--targets <RepoName>=<file>) checks all of it",
1455
+ "iac": "ops/iac/<purpose>/<env>/<step name>/ holds an OpenTofu root module: main.tf (a module call with a git source and ref, and the backend block) and terraform.tfvars.json (the inputs, among them the name of the bucket). apply-iac.sh applies the steps of one environment in the order of ops/needs.json with tofu init and tofu apply",
1456
+ "bucketName": "The name of an R2 bucket is written once, in the terraform.tfvars.json of its iac step. When apply-ops.sh joins the settings of a workloads step to the wrangler.toml of the bundle, it adds bucket_name to every [[env.<env>.r2_buckets]] table that has none, with the name from the terraform.tfvars.json of the iac steps the workloads step needs in ops/needs.json",
1457
+ "firstDeploy": "The first deploy of a Workers unit creates its Custom Domain. A resolver that was asked for the new hostname before that keeps NXDOMAIN for the SOA MINIMUM of the zone (up to 1800 seconds), so apply-ops.sh does not probe a declared Custom Domain that the account does not have yet, and healthz.sh reaches an existing one by an edge address. The probe fails with the reason on stderr when no address is found"
1458
+ }
1459
+ }
1369
1460
  }
1370
1461
  ],
1371
1462
  "source": {
@@ -1388,17 +1479,19 @@
1388
1479
  "scripts/deploy/healthz.sh",
1389
1480
  "scripts/deploy/ops-run.sh",
1390
1481
  "scripts/lib/bundle.sh",
1482
+ "scripts/lib/edge-address.sh",
1391
1483
  "scripts/lib/ops-steps.sh",
1392
1484
  "schemas/targets.schema.json"
1393
1485
  ],
1394
1486
  "packageJson": "The composed root package.json has wrangler as a devDependency and pnpm allows the build scripts of esbuild and workerd, because `pnpm dlx wrangler` is refused them",
1395
1487
  "onlyHere": "The only files that read the Cloudflare credentials: the jobs of ops-deploy.yml (iac reads CLOUDFLARE_R2_API_TOKEN, workloads reads CLOUDFLARE_API_TOKEN) and the scripts they call",
1396
1488
  "sameAs": "scripts/lib/bundle.sh is the same file as the one of the deploy role",
1397
- "urls": "healthz.sh reads the URL pattern of each environment from ops/urls.json, which compose writes. The role has no repository variable for it",
1489
+ "urls": "healthz.sh reads the URL pattern of each environment from ops/urls.json, which compose writes. The role has no repository variable for it. When the host of the pattern is not *.workers.dev and CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID are set, healthz.sh looks the host up as a Custom Domain of the account (scripts/lib/edge-address.sh): an existing one is reached with curl --resolve <host>:443:<edge address>, where the address is the one that another hostname of the same zone resolves to over DNS over HTTPS (the target itself when none does), so the request does not depend on the resolver; a host that is no Custom Domain is requested as usual",
1398
1490
  "targets": "The static job of ci.yml runs `node scripts/ci/check-targets.mjs` in a repository with this role. It validates ops/targets.json against schemas/targets.schema.json (the same JSON Schema as blueprint-shared.infra-layout.targets), then checks what the schema cannot: a ref points at an instance of the same kind, a host and a cluster are declared by the repository they name, a location or parent cluster with an environment suffix holds instances of that environment only, parent clusters and tenants are named by blueprint-shared.infra-layout.cluster-naming, and every iac/hosts/<location>/clusters/<cluster> and workloads/hosts/<location>/clusters/<cluster> directory is declared. The suffixes and the order of the cases are constants of the script that a test compares with the machine-readable fields of cluster-naming",
1399
1491
  "orgRepos": "scripts/ci/org-repos.json is a list of repository names that compose writes from the repository list of the organization of the repository (for the demo organization, the repository list of its facts), because the script cannot read the facts. A <RepoName>: prefix of a host or ref has to be in this list, and a name outside it fails. The list is of one organization, so two organizations that both have a repository of the same name never share a list. A host or ref into a repository of the list whose ops/targets.json was not given is printed as 未核對 with the instance and the host, and does not fail. A repository checks only its own ops/targets.json in its own CI; a run that is given the ops/targets.json of every repository of the organization (--targets <RepoName>=<file>) checks all of it",
1400
1492
  "iac": "ops/iac/<purpose>/<env>/<step name>/ holds an OpenTofu root module: main.tf (a module call with a git source and ref, and the backend block) and terraform.tfvars.json (the inputs, among them the name of the bucket). apply-iac.sh applies the steps of one environment in the order of ops/needs.json with tofu init and tofu apply",
1401
- "bucketName": "The name of an R2 bucket is written once, in the terraform.tfvars.json of its iac step. When apply-ops.sh joins the settings of a workloads step to the wrangler.toml of the bundle, it adds bucket_name to every [[env.<env>.r2_buckets]] table that has none, with the name from the terraform.tfvars.json of the iac steps the workloads step needs in ops/needs.json"
1493
+ "bucketName": "The name of an R2 bucket is written once, in the terraform.tfvars.json of its iac step. When apply-ops.sh joins the settings of a workloads step to the wrangler.toml of the bundle, it adds bucket_name to every [[env.<env>.r2_buckets]] table that has none, with the name from the terraform.tfvars.json of the iac steps the workloads step needs in ops/needs.json",
1494
+ "firstDeploy": "The first deploy of a Workers unit creates its Custom Domain. A resolver that was asked for the new hostname before that keeps NXDOMAIN for the SOA MINIMUM of the zone (up to 1800 seconds), so apply-ops.sh does not probe a declared Custom Domain that the account does not have yet, and healthz.sh reaches an existing one by an edge address. The probe fails with the reason on stderr when no address is found"
1402
1495
  }
1403
1496
  }
1404
1497
  },
@@ -1720,6 +1813,26 @@
1720
1813
  "versionIdsAreNotShared": "The four environments are four Workers <unit>-<env>, and a version id belongs to one Worker, so the bundle hash is what is compared across environments, not the version id"
1721
1814
  }
1722
1815
  }
1816
+ },
1817
+ {
1818
+ "since": "0.12.0",
1819
+ "content": {
1820
+ "value": {
1821
+ "what": "The unit directory's wrangler.toml, which holds what every environment shares and has no [env. table (the settings of an environment are in ops), a package.json that holds only the name and the version of the unit's, plus its built output: dist/ (a service) and public/ (the static assets of a web unit). The dependencies of the unit's package.json do not travel with the bundle: dist/index.js is already bundled by wrangler, and a `workspace:*` dependency makes `pnpm exec wrangler` fail in the unpacked directory, which is outside the pnpm workspace",
1822
+ "hash": "SHA-256 of the sorted \"<sha256> <path>\" line of every file of the bundle. The archive is not hashed, because tar and gzip output differs between runs",
1823
+ "archive": "<unit>-<version>.tgz, and <unit>-<version>.sha256 with the hash, attached to a GitHub Release",
1824
+ "version": "The version is inside the bundle (package.json, with the name), so a bundle of the rc and the bundle of the GA are two bundles with two hashes. The hash is taken over the staged directory (bundle_stage), so it covers the reduced package.json, not the unit's own",
1825
+ "file": "scripts/lib/bundle.sh",
1826
+ "healthz": "/healthz of the Worker answers { version, bundleSha256, configSha256 }. wrangler deploy passes the hashes as --var BUNDLE_SHA256:<hash> and --var CONFIG_SHA256:<hash>, and the Worker returns them. configSha256 is the hash of the wrangler.toml that apply-ops.sh uploaded: the shared one of the bundle followed by the settings of the environment in ops. healthz.sh asks for it at the Custom Domain of the Worker by an edge address (curl --resolve), because the resolver may still hold NXDOMAIN for a hostname that was new at the deploy",
1827
+ "workers": {
1828
+ "service": "src/index.ts of the api-workers stack answers /healthz from package.json and env.BUNDLE_SHA256",
1829
+ "web": "src/worker.js of the web-workers stack answers /healthz the same way and hands every other path to the static assets (env.ASSETS). wrangler.toml has [assets] binding = \"ASSETS\" and run_worker_first = [\"/healthz\"], so the assets answer the other paths without running the script",
1830
+ "reference": "Cloudflare Workers documentation, Static Assets, Workers Assets Binding (the URL is in wrangler.toml of the web-workers stack), read 2026-11-03"
1831
+ },
1832
+ "webUpload": "A bundle with dist/index.js is uploaded as dist/index.js --no-bundle, and with --assets public when it has public/",
1833
+ "versionIdsAreNotShared": "The four environments are four Workers <unit>-<env>, and a version id belongs to one Worker, so the bundle hash is what is compared across environments, not the version id"
1834
+ }
1835
+ }
1723
1836
  }
1724
1837
  ],
1725
1838
  "source": {
@@ -1732,7 +1845,7 @@
1732
1845
  "archive": "<unit>-<version>.tgz, and <unit>-<version>.sha256 with the hash, attached to a GitHub Release",
1733
1846
  "version": "The version is inside the bundle (package.json, with the name), so a bundle of the rc and the bundle of the GA are two bundles with two hashes. The hash is taken over the staged directory (bundle_stage), so it covers the reduced package.json, not the unit's own",
1734
1847
  "file": "scripts/lib/bundle.sh",
1735
- "healthz": "/healthz of the Worker answers { version, bundleSha256, configSha256 }. versions upload passes the hashes as --var BUNDLE_SHA256:<hash> and --var CONFIG_SHA256:<hash>, and the Worker returns them. configSha256 is the hash of the wrangler.toml that apply-ops.sh uploaded: the shared one of the bundle followed by the settings of the environment in ops",
1848
+ "healthz": "/healthz of the Worker answers { version, bundleSha256, configSha256 }. wrangler deploy passes the hashes as --var BUNDLE_SHA256:<hash> and --var CONFIG_SHA256:<hash>, and the Worker returns them. configSha256 is the hash of the wrangler.toml that apply-ops.sh uploaded: the shared one of the bundle followed by the settings of the environment in ops. healthz.sh asks for it at the Custom Domain of the Worker by an edge address (curl --resolve), because the resolver may still hold NXDOMAIN for a hostname that was new at the deploy",
1736
1849
  "workers": {
1737
1850
  "service": "src/index.ts of the api-workers stack answers /healthz from package.json and env.BUNDLE_SHA256",
1738
1851
  "web": "src/worker.js of the web-workers stack answers /healthz the same way and hands every other path to the static assets (env.ASSETS). wrangler.toml has [assets] binding = \"ASSETS\" and run_worker_first = [\"/healthz\"], so the assets answer the other paths without running the script",
@@ -2212,6 +2325,40 @@
2212
2325
  "prod": "The workflow deploys what is declared. Only deploy-prod.yml writes the prod declaration"
2213
2326
  }
2214
2327
  }
2328
+ },
2329
+ {
2330
+ "since": "0.12.0",
2331
+ "content": {
2332
+ "value": {
2333
+ "file": "ops/.github/workflows/ops-deploy.yml",
2334
+ "role": "ops",
2335
+ "triggers": [
2336
+ "push to main that changes ops/versions.json, ops/versions.lock.json, ops/workloads/**, ops/iac/** or ops/needs.json",
2337
+ "workflow_dispatch with env and units"
2338
+ ],
2339
+ "steps": "scripts/deploy/ops-run.sh: apply-ops.sh puts the declared bundles online, then smoke.sh checks /healthz. Every run aligns every unit that ops/versions.json declares for the environment, because the concurrency group ops-deploy keeps one pending run and cancels the older one, so the units a cancelled run carried go online with the next run; a unit already online with the declared version and hashes is skipped. With --since every environment is aligned, and a unit that has settings in ops/workloads/ but no declared version is reported (\"<env> <unit> 沒有宣告版本,不部署\") and skipped, and when nothing is declared it ends with status 0. With --env the input units is only a hint that is printed",
2340
+ "wrangler": [
2341
+ "wrangler deploy --env <env>"
2342
+ ],
2343
+ "credentials": "The iac job reads CLOUDFLARE_R2_API_TOKEN (secret, the R2 write permission), CLOUDFLARE_ACCOUNT_ID (variable) and the state backend settings (TOFU_STATE_BUCKET and TOFU_STATE_ENDPOINT as variables, TOFU_STATE_ACCESS_KEY_ID and TOFU_STATE_SECRET_ACCESS_KEY as secrets). The workloads job reads CLOUDFLARE_API_TOKEN (secret, the permission of the Cloudflare template \"Edit Cloudflare Workers\", limited to the one account) and CLOUDFLARE_ACCOUNT_ID. Neither job reads the token of the other",
2344
+ "bundleToken": "The GitHub App token with contents: read on the repositories of the variable BUNDLE_REPOS, when it is set",
2345
+ "sources": [
2346
+ "https://developers.cloudflare.com/workers/ci-cd/external-cicd/github-actions/",
2347
+ "https://developers.cloudflare.com/workers/wrangler/commands/workers/",
2348
+ "https://developers.cloudflare.com/workers/wrangler/system-environment-variables/"
2349
+ ],
2350
+ "readOn": "2026-11-06",
2351
+ "enableCondition": "Neither job has an enable condition in the template. Only a demonstration repository has vars.DEPLOY_ENABLED == 'true' on both, added by compose, and the variable is unset there. A repository in real use does not carry it, and adds one only to control when deploying runs.",
2352
+ "runName": "run-name is `ops-deploy ${{ inputs.env || 'push' }}`: a workflow_dispatch run is named after its env input and a push run is `ops-deploy push`. A run list does not show the inputs of a dispatch, so the deploy gate of the release scripts reads the environment the run aligns from this name",
2353
+ "jobs": [
2354
+ "iac: on a GitHub-hosted runner, applies the iac steps of the environment (scripts/deploy/ops-run.sh --phase iac). It runs the steps in the order of ops/needs.json with apply-iac.sh, which stops before tofu init when a state backend setting is missing",
2355
+ "workloads: needs: iac, on the self-hosted runner, puts the declared bundles online and checks /healthz (scripts/deploy/ops-run.sh --phase workloads)"
2356
+ ],
2357
+ "moduleToken": "When the variable INFRA_MODULES_REPO is set, the iac job makes a GitHub App token for that repository (contents: read) and runs git config url.<base>.insteadOf with it before tofu init, so a main.tf with a git source on the private repository can be cloned",
2358
+ "unverified": "The real run of tofu init and tofu apply (the module fetch, the R2 backend and the provider) was not done. The jobs are tested against the stand-in of tofu in scripts/lib/",
2359
+ "prod": "The workflow deploys what is declared. Only deploy-prod.yml writes the prod declaration"
2360
+ }
2361
+ }
2215
2362
  }
2216
2363
  ],
2217
2364
  "source": {
@@ -2227,9 +2374,7 @@
2227
2374
  ],
2228
2375
  "steps": "scripts/deploy/ops-run.sh: apply-ops.sh puts the declared bundles online, then smoke.sh checks /healthz. Every run aligns every unit that ops/versions.json declares for the environment, because the concurrency group ops-deploy keeps one pending run and cancels the older one, so the units a cancelled run carried go online with the next run; a unit already online with the declared version and hashes is skipped. With --since every environment is aligned, and a unit that has settings in ops/workloads/ but no declared version is reported (\"<env> <unit> 沒有宣告版本,不部署\") and skipped, and when nothing is declared it ends with status 0. With --env the input units is only a hint that is printed",
2229
2376
  "wrangler": [
2230
- "wrangler versions upload",
2231
- "wrangler versions deploy <version id>@100 --env <env>",
2232
- "wrangler triggers deploy --env <env>"
2377
+ "wrangler deploy --env <env>"
2233
2378
  ],
2234
2379
  "credentials": "The iac job reads CLOUDFLARE_R2_API_TOKEN (secret, the R2 write permission), CLOUDFLARE_ACCOUNT_ID (variable) and the state backend settings (TOFU_STATE_BUCKET and TOFU_STATE_ENDPOINT as variables, TOFU_STATE_ACCESS_KEY_ID and TOFU_STATE_SECRET_ACCESS_KEY as secrets). The workloads job reads CLOUDFLARE_API_TOKEN (secret, the permission of the Cloudflare template \"Edit Cloudflare Workers\", limited to the one account) and CLOUDFLARE_ACCOUNT_ID. Neither job reads the token of the other",
2235
2380
  "bundleToken": "The GitHub App token with contents: read on the repositories of the variable BUNDLE_REPOS, when it is set",
@@ -2725,7 +2870,7 @@
2725
2870
  "templates"
2726
2871
  ],
2727
2872
  "title": "apply-ops.sh 範本",
2728
- "description": "依宣告與 lock 下載 bundle、核對雜湊,把 ops 該環境的設定接在 bundle 的 `wrangler.toml` 後面,`wrangler versions upload` 再 `versions deploy <id>@100`,最後 `wrangler triggers deploy` 套用路由、Custom Domain 與 workers_dev。照 `ops/needs.json` 對步驟目錄依相依拓撲排序,有環就報錯。",
2873
+ "description": "依宣告與 lock 下載 bundle、核對雜湊,把 ops 該環境的設定接在 bundle 的 `wrangler.toml` 後面,`wrangler deploy` 一步完成上傳、切 100% 流量,並套用路由、Custom Domain 與 workers_dev(全新的 Worker 不存在時 `versions upload` 會被拒,所以不用它)。宣告的 Custom Domain 在帳號裡還不存在時不探測 /healthz,避免解析器把新主機名的 NXDOMAIN 負向快取最多 1800 秒。照 `ops/needs.json` 對步驟目錄依相依拓撲排序,有環就報錯。",
2729
2874
  "variants": [
2730
2875
  {
2731
2876
  "since": "0.1.0",
@@ -2891,6 +3036,59 @@
2891
3036
  "iac": "The iac steps only take part in the order and in the cycle check here. They are applied by apply-iac.sh, which ops-run.sh runs first (scripts/lib/ops-steps.sh holds the order that both use)"
2892
3037
  }
2893
3038
  }
3039
+ },
3040
+ {
3041
+ "since": "0.12.0",
3042
+ "content": {
3043
+ "value": {
3044
+ "file": "ops/scripts/deploy/apply-ops.sh",
3045
+ "role": "ops",
3046
+ "usage": "apply-ops.sh <env> [--only unit1,unit2]",
3047
+ "perUnit": [
3048
+ "gh release download of the bundle that ops/versions.lock.json names",
3049
+ "stop when the hash of the downloaded bundle is not the one in the lock",
3050
+ "stop when the wrangler.toml of the bundle has an [env. table, and when ops/workloads/<purpose>/<env>/<unit>/wrangler.toml has a table that does not begin with [env.<env>]",
3051
+ "add bucket_name to every [[env.<env>.r2_buckets]] table of the file of ops that has none, in turn, with bucket_name from the terraform.tfvars.json of the iac steps that this step needs in ops/needs.json (iac/<purpose>/<env>/<name>). Too few names stop the run, and a table that carries its own bucket_name keeps it",
3052
+ "join the two: the file of ops, after a newline if the bundle's does not end with one, goes after the wrangler.toml of the bundle; the SHA-256 of the joined file is CONFIG_SHA256",
3053
+ "skip when /healthz already reports the declared version, the bundle hash and CONFIG_SHA256. A Custom Domain that the joined wrangler.toml declares (`custom_domain = true`) and the account does not have yet means the unit is not online: the probe is not made at all, because asking the resolver for a hostname that does not exist yet makes it keep NXDOMAIN for the SOA MINIMUM of the zone (up to 1800 seconds). One that exists is probed by healthz.sh with curl --resolve. Without CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID the probe goes through DNS as before",
3054
+ "wrangler deploy [dist/index.js --no-bundle] [--assets public] --env <env> --message \"<unit> <version> sha256:<hash>\" --var BUNDLE_SHA256:<hash> --var CONFIG_SHA256:<hash>, the id read from WRANGLER_OUTPUT_FILE_PATH (the deploy entry). It is deploy and not versions upload, because a Worker that does not exist yet (the first deploy) refuses versions upload; deploy uploads, moves 100% of the traffic and applies the routes, custom domains and workers_dev of the settings in one step"
3055
+ ],
3056
+ "order": "The steps are the directories <iac|workloads>/<purpose>/<env>/... of the environment (the iac steps that exist in ops/iac/ take part too), applied in the topological order of ops/needs.json, whose keys and values are step directories. A need on another environment or on hosts/ counts as applied. A unit it needs goes first, so the backend goes online before the front end. A step without an entry needs nothing. Units outside this run (--only) still take part in the order and in the cycle check",
3057
+ "cycle": "A cycle stops the run before any wrangler call, and the error names the steps on it, for example \"✗ 相依成環:workloads/edge/prod/a → workloads/edge/prod/b → workloads/edge/prod/a\" with exit status 1",
3058
+ "oneUnitRuns": "A prerelease run applies one unit, so the order has no effect there; a prod run applies every unit of the release and uses it",
3059
+ "env": [
3060
+ "WRANGLER (default <repository root>/node_modules/.bin/wrangler, the wrangler that the ops repository declares; the commands run in the unpacked bundle under a temporary directory outside the repository, where pnpm exec finds no wrangler)",
3061
+ "DEPLOY_LOG_DIR",
3062
+ "GH_TOKEN",
3063
+ "CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID (wrangler reads them, and so does the Custom Domain lookup of the probe)"
3064
+ ],
3065
+ "reads": [
3066
+ "ops/versions.json",
3067
+ "ops/versions.lock.json",
3068
+ "ops/needs.json",
3069
+ "ops/workloads/<purpose>/<env>/<unit>/wrangler.toml",
3070
+ "ops/iac/<purpose>/<env>/<name>/terraform.tfvars.json (bucket_name)",
3071
+ "ops/urls.json (through healthz.sh)",
3072
+ "the Workers Custom Domains of the account (Cloudflare API, with CLOUDFLARE_API_TOKEN)"
3073
+ ],
3074
+ "commands": {
3075
+ "deploy": {
3076
+ "command": "wrangler deploy [dist/index.js --no-bundle] [--assets public] --env <env> --message \"<unit> <version> sha256:<hash>\" --var BUNDLE_SHA256:<hash> --var CONFIG_SHA256:<hash>",
3077
+ "flags": "The entry point is a positional argument, or a directory of static assets with --assets. --message labels the version, --var injects a key-value pair into the script, --no-bundle uploads the Worker without the internal build. It sends 100% of the traffic to the new version and applies the routes, custom domains and workers_dev of the wrangler.toml. --env is a global flag of wrangler, not one of this command."
3078
+ },
3079
+ "output": "WRANGLER_OUTPUT_FILE_PATH makes wrangler write one JSON object per line, and the deploy entry ({\"type\":\"deploy\",\"version_id\":...}) is how the script reads the version id.",
3080
+ "credentials": "CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID, from the workflow. The token template is \"Edit Cloudflare Workers\"."
3081
+ },
3082
+ "sources": [
3083
+ "https://developers.cloudflare.com/workers/wrangler/commands/workers/",
3084
+ "https://developers.cloudflare.com/workers/wrangler/system-environment-variables/",
3085
+ "https://developers.cloudflare.com/workers/ci-cd/external-cicd/github-actions/"
3086
+ ],
3087
+ "readOn": "2026-11-06",
3088
+ "printed": "[apply-ops] <env> 套用順序:<step directories in order>",
3089
+ "iac": "The iac steps only take part in the order and in the cycle check here. They are applied by apply-iac.sh, which ops-run.sh runs first (scripts/lib/ops-steps.sh holds the order that both use)"
3090
+ }
3091
+ }
2894
3092
  }
2895
3093
  ],
2896
3094
  "source": {
@@ -2907,18 +3105,17 @@
2907
3105
  "stop when the wrangler.toml of the bundle has an [env. table, and when ops/workloads/<purpose>/<env>/<unit>/wrangler.toml has a table that does not begin with [env.<env>]",
2908
3106
  "add bucket_name to every [[env.<env>.r2_buckets]] table of the file of ops that has none, in turn, with bucket_name from the terraform.tfvars.json of the iac steps that this step needs in ops/needs.json (iac/<purpose>/<env>/<name>). Too few names stop the run, and a table that carries its own bucket_name keeps it",
2909
3107
  "join the two: the file of ops, after a newline if the bundle's does not end with one, goes after the wrangler.toml of the bundle; the SHA-256 of the joined file is CONFIG_SHA256",
2910
- "skip when /healthz already reports the declared version, the bundle hash and CONFIG_SHA256",
2911
- "wrangler versions upload --env <env> --message \"<unit> <version> sha256:<hash>\" --var BUNDLE_SHA256:<hash> --var CONFIG_SHA256:<hash>, the id read from WRANGLER_OUTPUT_FILE_PATH",
2912
- "wrangler versions deploy <id>@100 --env <env> --yes",
2913
- "wrangler triggers deploy --env <env>, because versions deploy moves traffic only and does not apply the routes, custom domains or workers_dev of the settings; it changes nothing when they are in place"
3108
+ "skip when /healthz already reports the declared version, the bundle hash and CONFIG_SHA256. A Custom Domain that the joined wrangler.toml declares (`custom_domain = true`) and the account does not have yet means the unit is not online: the probe is not made at all, because asking the resolver for a hostname that does not exist yet makes it keep NXDOMAIN for the SOA MINIMUM of the zone (up to 1800 seconds). One that exists is probed by healthz.sh with curl --resolve. Without CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID the probe goes through DNS as before",
3109
+ "wrangler deploy [dist/index.js --no-bundle] [--assets public] --env <env> --message \"<unit> <version> sha256:<hash>\" --var BUNDLE_SHA256:<hash> --var CONFIG_SHA256:<hash>, the id read from WRANGLER_OUTPUT_FILE_PATH (the deploy entry). It is deploy and not versions upload, because a Worker that does not exist yet (the first deploy) refuses versions upload; deploy uploads, moves 100% of the traffic and applies the routes, custom domains and workers_dev of the settings in one step"
2914
3110
  ],
2915
3111
  "order": "The steps are the directories <iac|workloads>/<purpose>/<env>/... of the environment (the iac steps that exist in ops/iac/ take part too), applied in the topological order of ops/needs.json, whose keys and values are step directories. A need on another environment or on hosts/ counts as applied. A unit it needs goes first, so the backend goes online before the front end. A step without an entry needs nothing. Units outside this run (--only) still take part in the order and in the cycle check",
2916
3112
  "cycle": "A cycle stops the run before any wrangler call, and the error names the steps on it, for example \"✗ 相依成環:workloads/edge/prod/a → workloads/edge/prod/b → workloads/edge/prod/a\" with exit status 1",
2917
3113
  "oneUnitRuns": "A prerelease run applies one unit, so the order has no effect there; a prod run applies every unit of the release and uses it",
2918
3114
  "env": [
2919
- "WRANGLER (default `pnpm exec wrangler`)",
3115
+ "WRANGLER (default <repository root>/node_modules/.bin/wrangler, the wrangler that the ops repository declares; the commands run in the unpacked bundle under a temporary directory outside the repository, where pnpm exec finds no wrangler)",
2920
3116
  "DEPLOY_LOG_DIR",
2921
- "GH_TOKEN"
3117
+ "GH_TOKEN",
3118
+ "CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID (wrangler reads them, and so does the Custom Domain lookup of the probe)"
2922
3119
  ],
2923
3120
  "reads": [
2924
3121
  "ops/versions.json",
@@ -2926,23 +3123,16 @@
2926
3123
  "ops/needs.json",
2927
3124
  "ops/workloads/<purpose>/<env>/<unit>/wrangler.toml",
2928
3125
  "ops/iac/<purpose>/<env>/<name>/terraform.tfvars.json (bucket_name)",
2929
- "ops/urls.json (through healthz.sh)"
3126
+ "ops/urls.json (through healthz.sh)",
3127
+ "the Workers Custom Domains of the account (Cloudflare API, with CLOUDFLARE_API_TOKEN)"
2930
3128
  ],
2931
3129
  "commands": {
2932
- "upload": {
2933
- "command": "wrangler versions upload [dist/index.js --no-bundle] [--assets public] --env <env> --message \"<unit> <version> sha256:<hash>\" --var BUNDLE_SHA256:<hash>",
2934
- "flags": "PATH is an entry point or a directory of static assets. --message labels the version, --var injects a key-value pair into the script, --assets names the static assets, --no-bundle uploads the Worker without the internal build. --env is a global flag of wrangler, not one of this command."
2935
- },
2936
3130
  "deploy": {
2937
- "command": "wrangler versions deploy <version-id>@100 --env <env> --yes --message \"<unit> <version>\"",
2938
- "flags": "The version spec is <version-id>@<percentage>, and a missing percentage shares the rest of the traffic. --yes (-y) accepts the prompt defaults. --message describes the deployment. --env is a global flag."
3131
+ "command": "wrangler deploy [dist/index.js --no-bundle] [--assets public] --env <env> --message \"<unit> <version> sha256:<hash>\" --var BUNDLE_SHA256:<hash> --var CONFIG_SHA256:<hash>",
3132
+ "flags": "The entry point is a positional argument, or a directory of static assets with --assets. --message labels the version, --var injects a key-value pair into the script, --no-bundle uploads the Worker without the internal build. It sends 100% of the traffic to the new version and applies the routes, custom domains and workers_dev of the wrangler.toml. --env is a global flag of wrangler, not one of this command."
2939
3133
  },
2940
- "output": "WRANGLER_OUTPUT_FILE_PATH makes wrangler write one JSON object per line for commands such as version uploads, which is how the script reads the version id.",
2941
- "credentials": "CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID, from the workflow. The token template is \"Edit Cloudflare Workers\".",
2942
- "triggers": {
2943
- "command": "wrangler triggers deploy --env <env>",
2944
- "flags": "Experimental. It applies the changes to the triggers (routes or domains and cron triggers) and workers_dev of the wrangler.toml in the working directory, which wrangler versions upload and wrangler versions deploy leave out. --env is a global flag."
2945
- }
3134
+ "output": "WRANGLER_OUTPUT_FILE_PATH makes wrangler write one JSON object per line, and the deploy entry ({\"type\":\"deploy\",\"version_id\":...}) is how the script reads the version id.",
3135
+ "credentials": "CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID, from the workflow. The token template is \"Edit Cloudflare Workers\"."
2946
3136
  },
2947
3137
  "sources": [
2948
3138
  "https://developers.cloudflare.com/workers/wrangler/commands/workers/",
@@ -3051,7 +3241,7 @@
3051
3241
  "templates"
3052
3242
  ],
3053
3243
  "title": "smoke.sh 範本",
3054
- "description": "上線後核對 /healthz 回報的版號與 bundle 雜湊等於宣告與 lock,並回報設定雜湊。失敗只印回滾指令,不自動回滾。",
3244
+ "description": "上線後核對 /healthz 回報的版號與 bundle 雜湊等於宣告與 lock,並回報設定雜湊。探測失敗時印出 healthz.sh 的原因(例如新主機名被負向快取),並存進 log 目錄。失敗只印回滾指令,不自動回滾。",
3055
3245
  "variants": [
3056
3246
  {
3057
3247
  "since": "0.1.0",
@@ -3083,6 +3273,27 @@
3083
3273
  "onFailure": "prod: prints the command that re-runs prod with the product tag before the deployed one (the newest product tag that ops/versions.lock.json names for the failed units; a placeholder when there is none before it), and plan-prod.sh then lists every unit that differs from that tag; any other environment: says prod is untouched. It never rolls back by itself"
3084
3274
  }
3085
3275
  }
3276
+ },
3277
+ {
3278
+ "since": "0.12.0",
3279
+ "content": {
3280
+ "value": {
3281
+ "file": "ops/scripts/deploy/smoke.sh",
3282
+ "role": "ops",
3283
+ "usage": "smoke.sh <env> <unit>=<version>...",
3284
+ "checks": [
3285
+ "ops/versions.json pins the version at the instance of the unit",
3286
+ "/healthz reports that version and the bundle hash of ops/versions.lock.json",
3287
+ "/healthz reports a configSha256"
3288
+ ],
3289
+ "onFailure": "prod: prints the command that re-runs prod with the product tag before the deployed one (the newest product tag that ops/versions.lock.json names for the failed units; a placeholder when there is none before it), and plan-prod.sh then lists every unit that differs from that tag; any other environment: says prod is untouched. It never rolls back by itself",
3290
+ "env": [
3291
+ "DEPLOY_LOG_DIR (default tmp/deploy-log)",
3292
+ "CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID (optional; with them healthz.sh reaches a Custom Domain by an edge address, without the resolver)"
3293
+ ],
3294
+ "stderr": "What healthz.sh writes to stderr is kept in <DEPLOY_LOG_DIR>/healthz-<unit>-<env>.err, and a failed probe prints its first lines under the failure line of the unit (\"原因:...\"), for example that the hostname may be cached as NXDOMAIN for up to the SOA MINIMUM of the zone"
3295
+ }
3296
+ }
3086
3297
  }
3087
3298
  ],
3088
3299
  "source": {
@@ -3098,7 +3309,12 @@
3098
3309
  "/healthz reports that version and the bundle hash of ops/versions.lock.json",
3099
3310
  "/healthz reports a configSha256"
3100
3311
  ],
3101
- "onFailure": "prod: prints the command that re-runs prod with the product tag before the deployed one (the newest product tag that ops/versions.lock.json names for the failed units; a placeholder when there is none before it), and plan-prod.sh then lists every unit that differs from that tag; any other environment: says prod is untouched. It never rolls back by itself"
3312
+ "onFailure": "prod: prints the command that re-runs prod with the product tag before the deployed one (the newest product tag that ops/versions.lock.json names for the failed units; a placeholder when there is none before it), and plan-prod.sh then lists every unit that differs from that tag; any other environment: says prod is untouched. It never rolls back by itself",
3313
+ "env": [
3314
+ "DEPLOY_LOG_DIR (default tmp/deploy-log)",
3315
+ "CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID (optional; with them healthz.sh reaches a Custom Domain by an edge address, without the resolver)"
3316
+ ],
3317
+ "stderr": "What healthz.sh writes to stderr is kept in <DEPLOY_LOG_DIR>/healthz-<unit>-<env>.err, and a failed probe prints its first lines under the failure line of the unit (\"原因:...\"), for example that the hostname may be cached as NXDOMAIN for up to the SOA MINIMUM of the zone"
3102
3318
  }
3103
3319
  }
3104
3320
  },
@@ -3324,7 +3540,7 @@
3324
3540
  "templates"
3325
3541
  ],
3326
3542
  "title": "ops/urls.json",
3327
- "description": "各環境 Worker 的網址樣式。compose 從 ops 單元公布的介面寫出,healthz.sh 讀它,取代原本的 repo 變數。",
3543
+ "description": "各環境 Worker 的網址樣式。compose 從 ops 單元公布的介面寫出,healthz.sh 讀它,取代原本的 repo 變數。healthz.sh 對屬於帳號 Custom Domain 的主機名用 edge 位址 `--resolve` 探測,不經解析器。",
3328
3544
  "variants": [
3329
3545
  {
3330
3546
  "since": "0.1.0",
@@ -3357,6 +3573,22 @@
3357
3573
  "decision": "ops-url-interface"
3358
3574
  }
3359
3575
  }
3576
+ },
3577
+ {
3578
+ "since": "0.12.0",
3579
+ "content": {
3580
+ "value": {
3581
+ "file": "ops/urls.json",
3582
+ "shape": "{ \"<env>\": \"<base URL of a Worker, with {worker} where <unit>-<env> goes>\" }",
3583
+ "envs": "The keys of ops/versions.json: dev, stg, prod",
3584
+ "writer": "the compose step, from the interface (the field urls) of the OpsName unit of the repository. A repository with the ops role has exactly one such unit (the ops repository of a poly product and the single repository of a monorepo product)",
3585
+ "readers": [
3586
+ "ops/scripts/deploy/healthz.sh (the probe of apply-ops.sh and smoke.sh; a host that is a Custom Domain of the account is reached by an edge address with curl --resolve, not through the resolver)"
3587
+ ],
3588
+ "sameValueElsewhere": "The facts package of the unit (<unit>.urls.patterns) and the [env.<env>.vars] tables of the wrangler.toml of the units that call a Worker hold the same patterns, written from the same interface",
3589
+ "decision": "ops-url-interface"
3590
+ }
3591
+ }
3360
3592
  }
3361
3593
  ],
3362
3594
  "source": {
@@ -3369,7 +3601,7 @@
3369
3601
  "envs": "The keys of ops/versions.json: dev, stg, prod",
3370
3602
  "writer": "the compose step, from the interface (the field urls) of the OpsName unit of the repository. A repository with the ops role has exactly one such unit (the ops repository of a poly product and the single repository of a monorepo product)",
3371
3603
  "readers": [
3372
- "ops/scripts/deploy/healthz.sh (the probe of apply-ops.sh and smoke.sh)"
3604
+ "ops/scripts/deploy/healthz.sh (the probe of apply-ops.sh and smoke.sh; a host that is a Custom Domain of the account is reached by an edge address with curl --resolve, not through the resolver)"
3373
3605
  ],
3374
3606
  "sameValueElsewhere": "The facts package of the unit (<unit>.urls.patterns) and the [env.<env>.vars] tables of the wrangler.toml of the units that call a Worker hold the same patterns, written from the same interface",
3375
3607
  "decision": "ops-url-interface"
@@ -5454,7 +5686,7 @@
5454
5686
  "infra-layout"
5455
5687
  ],
5456
5688
  "title": "叢集與租戶的命名",
5457
- "description": "名稱是 `<用途>`,只看上層(位置、母叢集、虛擬叢集)的名稱。上層有任何一層帶環境後綴時不補環境,該上層只放實例路徑上是那個環境的實例,環境指服務自己部署的環境,不是使用它的單元的環境。組織的服務有自己的測試與正式部署時,實例名用自己的部署環境(例如 `secrets/stg`、`secrets/prod`)。VM 用用途命名,不用專案名或產品名。上層都沒帶時,只服務一個環境的補成 `<用途>-<環境>`,放了多個環境實例的母叢集不補,由裡面的租戶補。同上層同用途的第二個補區域或序號。環境標記分兩種位置:後綴只表示部署環境(位置、VM、叢集、租戶的 `-<環境>`,實例路徑的 `/<環境>`,網址的 `-<環境>`),前綴只表示服務哪個環境,只用在一個部署裡依服務環境分成多份的工作負載(部署進去的一個程式,不論是容器、Kubernetes 工作負載、Worker 或主機上的常駐程式),寫成 `<服務環境>-<用途>`,其他工作負載只寫 `<用途>`(`environmentMarks`)。同一個用途在同一個部署裡只有兩種合法寫法:只有一份叫 `<用途>`,分成多份時每份都帶前綴,`prod-` 也要寫。混用(`secrets` 加 `stg-secrets`)、同時帶前綴與後綴(`prod-secrets-stg`)、只有一份卻帶前綴(單獨的 `prod-secrets`)都不合法,變更流程與權限看所在部署的環境,不看工作負載的前綴(`workloadName`)。`decide` 與 `examples` 是可機讀的判斷順序與範例。AWS 位置只寫了命名規則,其餘未查證也沒有設計。",
5689
+ "description": "名稱是 `<用途>`,只看上層(位置、母叢集、虛擬叢集)的名稱。上層有任何一層帶環境後綴時不補環境,該上層只放實例路徑上是那個環境的實例,環境指服務自己部署的環境,不是使用它的單元的環境。組織的服務有自己的測試與正式部署時,實例名用自己的部署環境(例如 `secrets/stg`、`secrets/prod`)。VM 用用途命名,不用專案名或產品名。上層都沒帶時,只服務一個環境的補成 `<用途>-<環境>`,放了多個環境實例的母叢集不補,由裡面的租戶補。同上層同用途的第二個補區域或序號。環境標記分兩種位置:後綴只表示部署環境(位置、叢集、租戶的 `-<環境>`,實例路徑的 `/<環境>`,網址的 `-<環境>`),前綴只表示服務哪個環境,只用在一個部署裡依服務環境分成多份的工作負載(部署進去的一個程式,不論是容器、Kubernetes 工作負載、Worker 或主機上的常駐程式),寫成 `<服務環境>-<用途>`,其他工作負載只寫 `<用途>`(`environmentMarks`)。同一個用途在同一個部署裡只有兩種合法寫法:只有一份叫 `<用途>`,分成多份時每份都帶前綴,`prod-` 也要寫。混用(`secrets` 加 `stg-secrets`)、同時帶前綴與後綴(`prod-secrets-stg`)、只有一份卻帶前綴(單獨的 `prod-secrets`)都不合法,變更流程與權限看所在部署的環境,不看工作負載的前綴(`workloadName`)。`decide` 與 `examples` 是可機讀的判斷順序與範例。AWS 位置只寫了命名規則,其餘未查證也沒有設計。",
5458
5690
  "variants": [
5459
5691
  {
5460
5692
  "since": "0.4.0",
@@ -6391,388 +6623,1489 @@
6391
6623
  }
6392
6624
  }
6393
6625
  }
6394
- }
6395
- ],
6396
- "source": {
6397
- "kind": "published"
6398
- },
6399
- "content": {
6400
- "value": {
6401
- "appliesTo": "every location: a GCP project, an AWS account and a physical machine alike. For an AWS location only this naming rule is written; nothing else is designed for AWS yet (unverified).",
6402
- "looksAt": "the names of the parents only. The parents of a cluster or tenant are its location, its parent cluster and its virtual cluster, from the outside in",
6403
- "environmentSuffixes": [
6404
- "-dev",
6405
- "-stg",
6406
- "-prod",
6407
- "-shared"
6408
- ],
6409
- "rules": [
6410
- "The name is <purpose>.",
6411
- "A parent whose name has an environment suffix holds the instances of that environment only. The environment of an instance is the <environment> of its instance path, which is the environment the service itself is deployed in. The environments of the units that use the instance are not compared with the suffix.",
6412
- "When any parent has an environment suffix, the environment is not added.",
6413
- "When no parent has an environment suffix, a cluster or tenant whose instance path has one environment is named <purpose>-<environment>.",
6414
- "When no parent has an environment suffix, a parent cluster that holds the instances of several environments takes no environment, because it has no single one to write. The tenants inside it take the environment instead.",
6415
- "A second one of the same purpose under the same parent adds the region, or a sequence number when both are in the same region, for example platform-asia-northeast1 or events-2."
6416
- ],
6417
- "decide": [
6418
- {
6419
- "when": "a parent name ends in an environment suffix",
6420
- "name": "<purpose>",
6421
- "check": "every environment served is the environment of that suffix"
6422
- },
6423
- {
6424
- "when": "no parent has an environment suffix and one environment is served",
6425
- "name": "<purpose>-<environment>"
6426
- },
6427
- {
6428
- "when": "no parent has an environment suffix and several environments are served",
6429
- "name": "<purpose>"
6430
- }
6431
- ],
6432
- "duplicate": {
6433
- "when": "a second one of the same purpose under the same parent",
6434
- "region": "<name>-<region>",
6435
- "sequence": "<name>-<n>, n from 2"
6436
- },
6437
- "examples": [
6438
- {
6439
- "kind": "parent cluster",
6440
- "parents": [
6441
- "gcp-shared"
6442
- ],
6443
- "purpose": "platform",
6444
- "serves": [
6445
- "shared"
6446
- ],
6447
- "name": "platform",
6626
+ },
6627
+ {
6628
+ "since": "0.12.0",
6629
+ "content": {
6630
+ "value": {
6631
+ "appliesTo": "every location: a GCP project, an AWS account and a physical machine alike. For an AWS location only this naming rule is written; nothing else is designed for AWS yet (unverified).",
6632
+ "looksAt": "the names of the parents only. The parents of a cluster or tenant are its location, its parent cluster and its virtual cluster, from the outside in",
6633
+ "environmentSuffixes": [
6634
+ "-dev",
6635
+ "-stg",
6636
+ "-prod",
6637
+ "-shared"
6638
+ ],
6639
+ "rules": [
6640
+ "The name is <purpose>.",
6641
+ "A parent whose name has an environment suffix holds the instances of that environment only. The environment of an instance is the <environment> of its instance path, which is the environment the service itself is deployed in. The environments of the units that use the instance are not compared with the suffix.",
6642
+ "When any parent has an environment suffix, the environment is not added.",
6643
+ "When no parent has an environment suffix, a cluster or tenant whose instance path has one environment is named <purpose>-<environment>.",
6644
+ "When no parent has an environment suffix, a parent cluster that holds the instances of several environments takes no environment, because it has no single one to write. The tenants inside it take the environment instead.",
6645
+ "A second one of the same purpose under the same parent adds the region, or a sequence number when both are in the same region, for example platform-asia-northeast1 or events-2."
6646
+ ],
6647
+ "decide": [
6648
+ {
6649
+ "when": "a parent name ends in an environment suffix",
6650
+ "name": "<purpose>",
6651
+ "check": "every environment served is the environment of that suffix"
6652
+ },
6653
+ {
6654
+ "when": "no parent has an environment suffix and one environment is served",
6655
+ "name": "<purpose>-<environment>"
6656
+ },
6657
+ {
6658
+ "when": "no parent has an environment suffix and several environments are served",
6659
+ "name": "<purpose>"
6660
+ }
6661
+ ],
6662
+ "duplicate": {
6663
+ "when": "a second one of the same purpose under the same parent",
6664
+ "region": "<name>-<region>",
6665
+ "sequence": "<name>-<n>, n from 2"
6666
+ },
6667
+ "examples": [
6668
+ {
6669
+ "kind": "parent cluster",
6670
+ "parents": [
6671
+ "gcp-shared"
6672
+ ],
6673
+ "purpose": "platform",
6674
+ "serves": [
6675
+ "shared"
6676
+ ],
6677
+ "name": "platform",
6678
+ "reason": "the location ends in -shared"
6679
+ },
6680
+ {
6681
+ "kind": "parent cluster",
6682
+ "parents": [
6683
+ "gcp-dev"
6684
+ ],
6685
+ "purpose": "platform",
6686
+ "serves": [
6687
+ "dev"
6688
+ ],
6689
+ "name": "platform",
6690
+ "reason": "the location ends in -dev"
6691
+ },
6692
+ {
6693
+ "kind": "parent cluster",
6694
+ "parents": [
6695
+ "gcp-stg"
6696
+ ],
6697
+ "purpose": "platform",
6698
+ "serves": [
6699
+ "stg"
6700
+ ],
6701
+ "name": "platform",
6702
+ "reason": "the location ends in -stg"
6703
+ },
6704
+ {
6705
+ "kind": "parent cluster",
6706
+ "parents": [
6707
+ "gcp-prod"
6708
+ ],
6709
+ "purpose": "platform",
6710
+ "serves": [
6711
+ "prod"
6712
+ ],
6713
+ "name": "platform",
6714
+ "reason": "the location ends in -prod"
6715
+ },
6716
+ {
6717
+ "kind": "parent cluster",
6718
+ "parents": [
6719
+ "macbook"
6720
+ ],
6721
+ "purpose": "platform",
6722
+ "serves": [
6723
+ "dev"
6724
+ ],
6725
+ "name": "platform-dev",
6726
+ "reason": "the location has no suffix and the cluster serves dev only"
6727
+ },
6728
+ {
6729
+ "kind": "parent cluster",
6730
+ "parents": [
6731
+ "mac-mini"
6732
+ ],
6733
+ "purpose": "platform",
6734
+ "serves": [
6735
+ "prod"
6736
+ ],
6737
+ "name": "platform-prod",
6738
+ "reason": "the location has no suffix and the cluster serves prod only"
6739
+ },
6740
+ {
6741
+ "kind": "parent cluster",
6742
+ "parents": [
6743
+ "macbook"
6744
+ ],
6745
+ "purpose": "platform",
6746
+ "serves": [
6747
+ "dev",
6748
+ "stg"
6749
+ ],
6750
+ "name": "platform",
6751
+ "reason": "the location has no suffix and the cluster has no single environment"
6752
+ },
6753
+ {
6754
+ "kind": "virtual cluster",
6755
+ "parents": [
6756
+ "gcp-stg",
6757
+ "platform"
6758
+ ],
6759
+ "purpose": "events",
6760
+ "serves": [
6761
+ "stg"
6762
+ ],
6763
+ "name": "events",
6764
+ "reason": "the location ends in -stg"
6765
+ },
6766
+ {
6767
+ "kind": "virtual cluster",
6768
+ "parents": [
6769
+ "gcp-prod",
6770
+ "platform"
6771
+ ],
6772
+ "purpose": "events",
6773
+ "serves": [
6774
+ "prod"
6775
+ ],
6776
+ "name": "events",
6777
+ "reason": "the location ends in -prod"
6778
+ },
6779
+ {
6780
+ "kind": "virtual cluster",
6781
+ "parents": [
6782
+ "macbook",
6783
+ "platform-dev"
6784
+ ],
6785
+ "purpose": "events",
6786
+ "serves": [
6787
+ "dev"
6788
+ ],
6789
+ "name": "events",
6790
+ "reason": "the parent cluster ends in -dev"
6791
+ },
6792
+ {
6793
+ "kind": "virtual cluster",
6794
+ "parents": [
6795
+ "macbook",
6796
+ "platform"
6797
+ ],
6798
+ "purpose": "events",
6799
+ "serves": [
6800
+ "dev"
6801
+ ],
6802
+ "name": "events-dev",
6803
+ "reason": "neither the location nor the parent cluster has a suffix"
6804
+ },
6805
+ {
6806
+ "kind": "virtual cluster",
6807
+ "parents": [
6808
+ "macbook",
6809
+ "platform"
6810
+ ],
6811
+ "purpose": "events",
6812
+ "serves": [
6813
+ "stg"
6814
+ ],
6815
+ "name": "events-stg",
6816
+ "reason": "neither the location nor the parent cluster has a suffix"
6817
+ },
6818
+ {
6819
+ "kind": "virtual cluster",
6820
+ "parents": [
6821
+ "gcp-prod",
6822
+ "platform"
6823
+ ],
6824
+ "purpose": "events",
6825
+ "serves": [
6826
+ "prod"
6827
+ ],
6828
+ "sequence": 2,
6829
+ "name": "events-2",
6830
+ "reason": "the second of the purpose in one cluster, in one region, so a sequence number"
6831
+ },
6832
+ {
6833
+ "kind": "namespace",
6834
+ "parents": [
6835
+ "gcp-dev",
6836
+ "platform"
6837
+ ],
6838
+ "purpose": "orbit",
6839
+ "serves": [
6840
+ "dev"
6841
+ ],
6842
+ "name": "orbit",
6843
+ "reason": "the location ends in -dev"
6844
+ },
6845
+ {
6846
+ "kind": "namespace",
6847
+ "parents": [
6848
+ "gcp-stg",
6849
+ "platform"
6850
+ ],
6851
+ "purpose": "orbit",
6852
+ "serves": [
6853
+ "stg"
6854
+ ],
6855
+ "name": "orbit",
6856
+ "reason": "the location ends in -stg"
6857
+ },
6858
+ {
6859
+ "kind": "namespace",
6860
+ "parents": [
6861
+ "gcp-prod",
6862
+ "platform"
6863
+ ],
6864
+ "purpose": "orbit",
6865
+ "serves": [
6866
+ "prod"
6867
+ ],
6868
+ "name": "orbit",
6869
+ "reason": "the location ends in -prod"
6870
+ },
6871
+ {
6872
+ "kind": "namespace",
6873
+ "parents": [
6874
+ "mac-mini",
6875
+ "platform-prod"
6876
+ ],
6877
+ "purpose": "ci",
6878
+ "serves": [
6879
+ "prod"
6880
+ ],
6881
+ "name": "ci",
6882
+ "reason": "the parent cluster ends in -prod"
6883
+ },
6884
+ {
6885
+ "kind": "namespace in a virtual cluster",
6886
+ "parents": [
6887
+ "gcp-prod",
6888
+ "platform",
6889
+ "events"
6890
+ ],
6891
+ "purpose": "stream",
6892
+ "serves": [
6893
+ "prod"
6894
+ ],
6895
+ "name": "stream",
6896
+ "reason": "the location ends in -prod"
6897
+ }
6898
+ ],
6899
+ "instancePath": "The instance path stays <purpose>/<environment>. The names of the clusters and namespaces are worked out from the instance path and the parents. Clusters of the same name are told apart by their parents, for example gcp-prod/platform/events, and monitoring adds a location label to tell them apart. A virtual cluster is installed in the namespace of the same name in its parent cluster.",
6900
+ "serviceEnvironment": "A service of the organization that has its own test and production deployments takes the environment of its own deployment as the <environment> of its instance path, for example secrets/stg and secrets/prod. It does not take shared, and it does not take the environment of the units that use it. The environment a workload serves is written only on a workload that a deployment splits by the environment it serves, and only as a prefix (/workloadName).",
6901
+ "vmName": "A VM is named after its purpose, for example secrets or ci. It is never named after a project or a product.",
6902
+ "environmentMarks": {
6903
+ "meaning": "An environment mark has two positions with two meanings. A suffix says which environment the thing is deployed in. A prefix says which environment the workload serves.",
6904
+ "positions": [
6905
+ {
6906
+ "mark": "suffix",
6907
+ "where": "location",
6908
+ "form": "<name>-<environment>",
6909
+ "says": "the environment of the deployment"
6910
+ },
6911
+ {
6912
+ "mark": "suffix",
6913
+ "where": "cluster",
6914
+ "form": "<name>-<environment>",
6915
+ "says": "the environment of the deployment"
6916
+ },
6917
+ {
6918
+ "mark": "suffix",
6919
+ "where": "tenant",
6920
+ "form": "<name>-<environment>",
6921
+ "says": "the environment of the deployment"
6922
+ },
6923
+ {
6924
+ "mark": "suffix",
6925
+ "where": "instance path",
6926
+ "form": "/<environment>",
6927
+ "says": "the environment of the deployment"
6928
+ },
6929
+ {
6930
+ "mark": "suffix",
6931
+ "where": "url",
6932
+ "form": "-<environment>",
6933
+ "says": "the environment of the deployment"
6934
+ },
6935
+ {
6936
+ "mark": "prefix",
6937
+ "where": "a workload split by the environment it serves",
6938
+ "form": "<service environment>-<purpose>",
6939
+ "says": "the environment the workload serves"
6940
+ }
6941
+ ],
6942
+ "otherWorkloads": "Every other workload is named <purpose>. Its deployment environment is the one of the parent above it.",
6943
+ "vm": "A VM is named after its purpose (/vmName) and takes no environment suffix, because it is a resource of a single deployment (rule 2 of blueprint-shared.infra-layout.resource-naming).",
6944
+ "otherResources": "The naming of every other resource category is in blueprint-shared.infra-layout.resource-naming."
6945
+ },
6946
+ "workloadName": {
6947
+ "meaning": "A workload is one program deployed into a deployment, whatever runs it: a container, a Kubernetes workload, a Worker or a resident program of the host. It is the software that ops/workloads/ deploys (blueprint-shared.infra-layout.ops-dirs).",
6948
+ "form": "one copy of a purpose in a deployment is <purpose>; several copies each take the prefix <service environment>-<purpose>",
6949
+ "prefixes": [
6950
+ "dev-",
6951
+ "stg-",
6952
+ "prod-"
6953
+ ],
6954
+ "pattern": "^[a-z0-9][a-z0-9-]*$",
6955
+ "rules": [
6956
+ "In one deployment a purpose has exactly two legal forms: one copy named <purpose>, or several copies that each take a prefix. The prod- prefix is written too.",
6957
+ "A mix of the two is not legal, for example secrets together with stg-secrets.",
6958
+ "A workload never carries a prefix and a suffix together, for example prod-secrets-stg.",
6959
+ "A prefix is one of the prefixes listed here. A single copy never takes one, so prod-secrets alone is not legal.",
6960
+ "The change process and the permissions follow the environment of the deployment the workload is in, never the prefix of the workload."
6961
+ ],
6962
+ "examples": {
6963
+ "valid": [
6964
+ {
6965
+ "names": [
6966
+ "proxy"
6967
+ ],
6968
+ "reason": "one copy, named by its purpose"
6969
+ },
6970
+ {
6971
+ "names": [
6972
+ "prod-secrets",
6973
+ "stg-secrets",
6974
+ "dev-secrets"
6975
+ ],
6976
+ "reason": "split by the environment served, and every copy takes a prefix"
6977
+ }
6978
+ ],
6979
+ "invalid": [
6980
+ {
6981
+ "names": [
6982
+ "secrets",
6983
+ "stg-secrets"
6984
+ ],
6985
+ "reason": "a mix of the plain form and the prefixed form"
6986
+ },
6987
+ {
6988
+ "names": [
6989
+ "prod-secrets-stg"
6990
+ ],
6991
+ "reason": "a prefix and a suffix on one workload"
6992
+ },
6993
+ {
6994
+ "names": [
6995
+ "prod-secrets"
6996
+ ],
6997
+ "reason": "one copy takes no prefix"
6998
+ }
6999
+ ]
7000
+ }
7001
+ }
7002
+ }
7003
+ }
7004
+ }
7005
+ ],
7006
+ "source": {
7007
+ "kind": "published"
7008
+ },
7009
+ "content": {
7010
+ "value": {
7011
+ "appliesTo": "every location: a GCP project, an AWS account and a physical machine alike. For an AWS location only this naming rule is written; nothing else is designed for AWS yet (unverified).",
7012
+ "looksAt": "the names of the parents only. The parents of a cluster or tenant are its location, its parent cluster and its virtual cluster, from the outside in",
7013
+ "environmentSuffixes": [
7014
+ "-dev",
7015
+ "-stg",
7016
+ "-prod",
7017
+ "-shared"
7018
+ ],
7019
+ "rules": [
7020
+ "The name is <purpose>.",
7021
+ "A parent whose name has an environment suffix holds the instances of that environment only. The environment of an instance is the <environment> of its instance path, which is the environment the service itself is deployed in. The environments of the units that use the instance are not compared with the suffix.",
7022
+ "When any parent has an environment suffix, the environment is not added.",
7023
+ "When no parent has an environment suffix, a cluster or tenant whose instance path has one environment is named <purpose>-<environment>.",
7024
+ "When no parent has an environment suffix, a parent cluster that holds the instances of several environments takes no environment, because it has no single one to write. The tenants inside it take the environment instead.",
7025
+ "A second one of the same purpose under the same parent adds the region, or a sequence number when both are in the same region, for example platform-asia-northeast1 or events-2."
7026
+ ],
7027
+ "decide": [
7028
+ {
7029
+ "when": "a parent name ends in an environment suffix",
7030
+ "name": "<purpose>",
7031
+ "check": "every environment served is the environment of that suffix"
7032
+ },
7033
+ {
7034
+ "when": "no parent has an environment suffix and one environment is served",
7035
+ "name": "<purpose>-<environment>"
7036
+ },
7037
+ {
7038
+ "when": "no parent has an environment suffix and several environments are served",
7039
+ "name": "<purpose>"
7040
+ }
7041
+ ],
7042
+ "duplicate": {
7043
+ "when": "a second one of the same purpose under the same parent",
7044
+ "region": "<name>-<region>",
7045
+ "sequence": "<name>-<n>, n from 2"
7046
+ },
7047
+ "examples": [
7048
+ {
7049
+ "kind": "parent cluster",
7050
+ "parents": [
7051
+ "gcp-shared"
7052
+ ],
7053
+ "purpose": "platform",
7054
+ "serves": [
7055
+ "shared"
7056
+ ],
7057
+ "name": "platform",
6448
7058
  "reason": "the location ends in -shared"
6449
7059
  },
6450
7060
  {
6451
- "kind": "parent cluster",
6452
- "parents": [
6453
- "gcp-dev"
6454
- ],
6455
- "purpose": "platform",
6456
- "serves": [
6457
- "dev"
7061
+ "kind": "parent cluster",
7062
+ "parents": [
7063
+ "gcp-dev"
7064
+ ],
7065
+ "purpose": "platform",
7066
+ "serves": [
7067
+ "dev"
7068
+ ],
7069
+ "name": "platform",
7070
+ "reason": "the location ends in -dev"
7071
+ },
7072
+ {
7073
+ "kind": "parent cluster",
7074
+ "parents": [
7075
+ "gcp-stg"
7076
+ ],
7077
+ "purpose": "platform",
7078
+ "serves": [
7079
+ "stg"
7080
+ ],
7081
+ "name": "platform",
7082
+ "reason": "the location ends in -stg"
7083
+ },
7084
+ {
7085
+ "kind": "parent cluster",
7086
+ "parents": [
7087
+ "gcp-prod"
7088
+ ],
7089
+ "purpose": "platform",
7090
+ "serves": [
7091
+ "prod"
7092
+ ],
7093
+ "name": "platform",
7094
+ "reason": "the location ends in -prod"
7095
+ },
7096
+ {
7097
+ "kind": "parent cluster",
7098
+ "parents": [
7099
+ "macbook"
7100
+ ],
7101
+ "purpose": "platform",
7102
+ "serves": [
7103
+ "dev"
7104
+ ],
7105
+ "name": "platform-dev",
7106
+ "reason": "the location has no suffix and the cluster serves dev only"
7107
+ },
7108
+ {
7109
+ "kind": "parent cluster",
7110
+ "parents": [
7111
+ "mac-mini"
7112
+ ],
7113
+ "purpose": "platform",
7114
+ "serves": [
7115
+ "prod"
7116
+ ],
7117
+ "name": "platform-prod",
7118
+ "reason": "the location has no suffix and the cluster serves prod only"
7119
+ },
7120
+ {
7121
+ "kind": "parent cluster",
7122
+ "parents": [
7123
+ "macbook"
7124
+ ],
7125
+ "purpose": "platform",
7126
+ "serves": [
7127
+ "dev",
7128
+ "stg"
7129
+ ],
7130
+ "name": "platform",
7131
+ "reason": "the location has no suffix and the cluster has no single environment"
7132
+ },
7133
+ {
7134
+ "kind": "virtual cluster",
7135
+ "parents": [
7136
+ "gcp-stg",
7137
+ "platform"
7138
+ ],
7139
+ "purpose": "events",
7140
+ "serves": [
7141
+ "stg"
7142
+ ],
7143
+ "name": "events",
7144
+ "reason": "the location ends in -stg"
7145
+ },
7146
+ {
7147
+ "kind": "virtual cluster",
7148
+ "parents": [
7149
+ "gcp-prod",
7150
+ "platform"
7151
+ ],
7152
+ "purpose": "events",
7153
+ "serves": [
7154
+ "prod"
7155
+ ],
7156
+ "name": "events",
7157
+ "reason": "the location ends in -prod"
7158
+ },
7159
+ {
7160
+ "kind": "virtual cluster",
7161
+ "parents": [
7162
+ "macbook",
7163
+ "platform-dev"
7164
+ ],
7165
+ "purpose": "events",
7166
+ "serves": [
7167
+ "dev"
7168
+ ],
7169
+ "name": "events",
7170
+ "reason": "the parent cluster ends in -dev"
7171
+ },
7172
+ {
7173
+ "kind": "virtual cluster",
7174
+ "parents": [
7175
+ "macbook",
7176
+ "platform"
7177
+ ],
7178
+ "purpose": "events",
7179
+ "serves": [
7180
+ "dev"
7181
+ ],
7182
+ "name": "events-dev",
7183
+ "reason": "neither the location nor the parent cluster has a suffix"
7184
+ },
7185
+ {
7186
+ "kind": "virtual cluster",
7187
+ "parents": [
7188
+ "macbook",
7189
+ "platform"
7190
+ ],
7191
+ "purpose": "events",
7192
+ "serves": [
7193
+ "stg"
7194
+ ],
7195
+ "name": "events-stg",
7196
+ "reason": "neither the location nor the parent cluster has a suffix"
7197
+ },
7198
+ {
7199
+ "kind": "virtual cluster",
7200
+ "parents": [
7201
+ "gcp-prod",
7202
+ "platform"
7203
+ ],
7204
+ "purpose": "events",
7205
+ "serves": [
7206
+ "prod"
7207
+ ],
7208
+ "sequence": 2,
7209
+ "name": "events-2",
7210
+ "reason": "the second of the purpose in one cluster, in one region, so a sequence number"
7211
+ },
7212
+ {
7213
+ "kind": "namespace",
7214
+ "parents": [
7215
+ "gcp-dev",
7216
+ "platform"
7217
+ ],
7218
+ "purpose": "orbit",
7219
+ "serves": [
7220
+ "dev"
7221
+ ],
7222
+ "name": "orbit",
7223
+ "reason": "the location ends in -dev"
7224
+ },
7225
+ {
7226
+ "kind": "namespace",
7227
+ "parents": [
7228
+ "gcp-stg",
7229
+ "platform"
7230
+ ],
7231
+ "purpose": "orbit",
7232
+ "serves": [
7233
+ "stg"
7234
+ ],
7235
+ "name": "orbit",
7236
+ "reason": "the location ends in -stg"
7237
+ },
7238
+ {
7239
+ "kind": "namespace",
7240
+ "parents": [
7241
+ "gcp-prod",
7242
+ "platform"
7243
+ ],
7244
+ "purpose": "orbit",
7245
+ "serves": [
7246
+ "prod"
7247
+ ],
7248
+ "name": "orbit",
7249
+ "reason": "the location ends in -prod"
7250
+ },
7251
+ {
7252
+ "kind": "namespace",
7253
+ "parents": [
7254
+ "mac-mini",
7255
+ "platform-prod"
7256
+ ],
7257
+ "purpose": "ci",
7258
+ "serves": [
7259
+ "prod"
7260
+ ],
7261
+ "name": "ci",
7262
+ "reason": "the parent cluster ends in -prod"
7263
+ },
7264
+ {
7265
+ "kind": "namespace in a virtual cluster",
7266
+ "parents": [
7267
+ "gcp-prod",
7268
+ "platform",
7269
+ "events"
7270
+ ],
7271
+ "purpose": "stream",
7272
+ "serves": [
7273
+ "prod"
7274
+ ],
7275
+ "name": "stream",
7276
+ "reason": "the location ends in -prod"
7277
+ }
7278
+ ],
7279
+ "instancePath": "The instance path stays <purpose>/<environment>. The names of the clusters and namespaces are worked out from the instance path and the parents. Clusters of the same name are told apart by their parents, for example gcp-prod/platform/events, and monitoring adds a location label to tell them apart. A virtual cluster is installed in the namespace of the same name in its parent cluster.",
7280
+ "serviceEnvironment": "A service of the organization that has its own test and production deployments takes the environment of its own deployment as the <environment> of its instance path, for example secrets/stg and secrets/prod. It does not take shared, and it does not take the environment of the units that use it. The environment a workload serves is written only on a workload that a deployment splits by the environment it serves, and only as a prefix (/workloadName).",
7281
+ "vmName": "A VM is named after its purpose, for example secrets or ci. It is never named after a project or a product.",
7282
+ "environmentMarks": {
7283
+ "meaning": "An environment mark has two positions with two meanings. A suffix says which environment the thing is deployed in. A prefix says which environment the workload serves.",
7284
+ "positions": [
7285
+ {
7286
+ "mark": "suffix",
7287
+ "where": "location",
7288
+ "form": "<name>-<environment>",
7289
+ "says": "the environment of the deployment"
7290
+ },
7291
+ {
7292
+ "mark": "suffix",
7293
+ "where": "cluster",
7294
+ "form": "<name>-<environment>",
7295
+ "says": "the environment of the deployment"
7296
+ },
7297
+ {
7298
+ "mark": "suffix",
7299
+ "where": "tenant",
7300
+ "form": "<name>-<environment>",
7301
+ "says": "the environment of the deployment"
7302
+ },
7303
+ {
7304
+ "mark": "suffix",
7305
+ "where": "instance path",
7306
+ "form": "/<environment>",
7307
+ "says": "the environment of the deployment"
7308
+ },
7309
+ {
7310
+ "mark": "suffix",
7311
+ "where": "url",
7312
+ "form": "-<environment>",
7313
+ "says": "the environment of the deployment"
7314
+ },
7315
+ {
7316
+ "mark": "prefix",
7317
+ "where": "a workload split by the environment it serves",
7318
+ "form": "<service environment>-<purpose>",
7319
+ "says": "the environment the workload serves"
7320
+ }
7321
+ ],
7322
+ "otherWorkloads": "Every other workload is named <purpose>. Its deployment environment is the one of the parent above it.",
7323
+ "vm": "A VM is named after its purpose (/vmName) and takes no environment suffix, because it is a resource of a single deployment (rule 2 of blueprint-shared.infra-layout.resource-naming).",
7324
+ "otherResources": "The naming of every other resource category is in blueprint-shared.infra-layout.resource-naming."
7325
+ },
7326
+ "workloadName": {
7327
+ "meaning": "A workload is one program deployed into a deployment, whatever runs it: a container, a Kubernetes workload, a Worker or a resident program of the host. It is the software that ops/workloads/ deploys (blueprint-shared.infra-layout.ops-dirs).",
7328
+ "form": "one copy of a purpose in a deployment is <purpose>; several copies each take the prefix <service environment>-<purpose>",
7329
+ "prefixes": [
7330
+ "dev-",
7331
+ "stg-",
7332
+ "prod-"
7333
+ ],
7334
+ "pattern": "^[a-z0-9][a-z0-9-]*$",
7335
+ "rules": [
7336
+ "In one deployment a purpose has exactly two legal forms: one copy named <purpose>, or several copies that each take a prefix. The prod- prefix is written too.",
7337
+ "A mix of the two is not legal, for example secrets together with stg-secrets.",
7338
+ "A workload never carries a prefix and a suffix together, for example prod-secrets-stg.",
7339
+ "A prefix is one of the prefixes listed here. A single copy never takes one, so prod-secrets alone is not legal.",
7340
+ "The change process and the permissions follow the environment of the deployment the workload is in, never the prefix of the workload."
7341
+ ],
7342
+ "examples": {
7343
+ "valid": [
7344
+ {
7345
+ "names": [
7346
+ "proxy"
7347
+ ],
7348
+ "reason": "one copy, named by its purpose"
7349
+ },
7350
+ {
7351
+ "names": [
7352
+ "prod-secrets",
7353
+ "stg-secrets",
7354
+ "dev-secrets"
7355
+ ],
7356
+ "reason": "split by the environment served, and every copy takes a prefix"
7357
+ }
7358
+ ],
7359
+ "invalid": [
7360
+ {
7361
+ "names": [
7362
+ "secrets",
7363
+ "stg-secrets"
7364
+ ],
7365
+ "reason": "a mix of the plain form and the prefixed form"
7366
+ },
7367
+ {
7368
+ "names": [
7369
+ "prod-secrets-stg"
7370
+ ],
7371
+ "reason": "a prefix and a suffix on one workload"
7372
+ },
7373
+ {
7374
+ "names": [
7375
+ "prod-secrets"
7376
+ ],
7377
+ "reason": "one copy takes no prefix"
7378
+ }
7379
+ ]
7380
+ }
7381
+ }
7382
+ }
7383
+ }
7384
+ },
7385
+ {
7386
+ "id": "blueprint-shared.infra-layout.resource-naming",
7387
+ "tool": "blueprint-shared",
7388
+ "topics": [
7389
+ "infra-layout"
7390
+ ],
7391
+ "title": "資源的命名",
7392
+ "description": "每種資源類別先登記命名空間的種類與名稱給誰看,程式照登記選五條規則其中一條,所以每個名稱只落到一條。給使用者看的入口,正式部署不加環境後綴,其他部署加 `-<環境>`。給維運者看的資源,正式部署也加 `-prod`。單一部署的命名空間(GCP 專案裡的資源、VM 裡與 OpenBao 裡的名稱)只寫用途名,不帶環境。全球命名空間與會被搬動的檔案和目錄,名稱以範圍識別開頭,全球資源用專案 id,檔案與目錄用部署識別 `<用途>-<環境>`,正式部署也寫出來。環境後綴一律放最後。規則 2 到 4 只用在服務單一部署環境的名稱,服務多個環境的不標,跨環境共用的標 `-shared`。產品程式讀的設定鍵、程式之間約好的值、Ansible role 的變數、容器內的路徑與程式的安裝目錄用產品名,照 `purposeAndProduct`。zone 層的設定與只活在一次 CI 執行裡的名稱照規則 4。租戶環境前綴照 `cluster-naming` 的 `/workloadName`,叢集、租戶與工作負載照它的 `decide`。名稱不符規則時一律改,不設例外清單。檔內有二十一類的登記表、三項通用檢查與四件要人判斷的事。",
7393
+ "variants": [
7394
+ {
7395
+ "since": "0.12.0",
7396
+ "content": {
7397
+ "value": {
7398
+ "principle": "Every resource category registers two properties: the kind of its namespace and who reads the name. A program chooses the rule from them (ruleSelection), so every name falls under exactly one rule. A name that does not follow its rule is renamed; the rebuild, downtime or new IP it costs is paid, and no list of exceptions is kept, because a wrong name left in place gets copied.",
7399
+ "environmentValues": {
7400
+ "deployments": [
7401
+ "dev",
7402
+ "stg",
7403
+ "prod"
7404
+ ],
7405
+ "shared": "shared",
7406
+ "several": "several",
7407
+ "meaning": "The environment of a deployment is dev, stg or prod. shared marks a name shared across environments and takes -shared (rules 3 and 4). several marks a name that serves several environments and takes no mark."
7408
+ },
7409
+ "suffixPosition": "A suffix that tells deployments apart (rules 3 and 4) is the last part of the name. Rule 5 names start with the identity of the scope, whose environment is the last part of that identity.",
7410
+ "rules": [
7411
+ {
7412
+ "n": 1,
7413
+ "title": "instance path",
7414
+ "when": "a deployment identity written as an instance path, and the keys that reuse it, such as the instance keys of versions.json and targets.json, a state prefix and --deployment",
7415
+ "form": {
7416
+ "prod": "<purpose>/prod",
7417
+ "other": "<purpose>/<environment>"
7418
+ }
7419
+ },
7420
+ {
7421
+ "n": 2,
7422
+ "title": "single deployment scope",
7423
+ "when": "the namespace holds one deployment only, such as the resources inside a GCP project, names inside a VM and names inside OpenBao",
7424
+ "form": {
7425
+ "prod": "<purpose>",
7426
+ "other": "<purpose>"
7427
+ }
7428
+ },
7429
+ {
7430
+ "n": 3,
7431
+ "title": "entry in a shared scope",
7432
+ "when": "a name for users in a namespace that the organization shares, such as a URL, an identity-proxy app or a SaaS OIDC app that an app launcher shows",
7433
+ "form": {
7434
+ "prod": "<base>",
7435
+ "other": "<base>-<environment>"
7436
+ }
7437
+ },
7438
+ {
7439
+ "n": 4,
7440
+ "title": "maintenance resource in a shared scope",
7441
+ "when": "a name for operators in a namespace that the organization shares, such as a tunnel, an access policy, a Worker or a location name",
7442
+ "form": {
7443
+ "prod": "<base>-prod",
7444
+ "other": "<base>-<environment>"
7445
+ }
7446
+ },
7447
+ {
7448
+ "n": 5,
7449
+ "title": "full name with a scope",
7450
+ "when": "a globally shared namespace, or a file or directory that is moved away from where it was made",
7451
+ "form": {
7452
+ "prod": "<scope>-<purpose>",
7453
+ "other": "<scope>-<purpose>"
7454
+ }
7455
+ }
7456
+ ],
7457
+ "ruleSelection": [
7458
+ {
7459
+ "namespaces": [
7460
+ "repository"
7461
+ ],
7462
+ "reader": "program",
7463
+ "rule": 1
7464
+ },
7465
+ {
7466
+ "namespaces": [
7467
+ "single-deployment"
7468
+ ],
7469
+ "rule": 2
7470
+ },
7471
+ {
7472
+ "namespaces": [
7473
+ "domain",
7474
+ "account"
7475
+ ],
7476
+ "reader": "user",
7477
+ "rule": 3
7478
+ },
7479
+ {
7480
+ "namespaces": [
7481
+ "account",
7482
+ "organization",
7483
+ "run"
7484
+ ],
7485
+ "reader": "operator",
7486
+ "rule": 4
7487
+ },
7488
+ {
7489
+ "namespaces": [
7490
+ "global",
7491
+ "none"
7492
+ ],
7493
+ "rule": 5
7494
+ },
7495
+ {
7496
+ "namespaces": [
7497
+ "cluster"
7498
+ ],
7499
+ "rule": "cluster-naming"
7500
+ },
7501
+ {
7502
+ "namespaces": [
7503
+ "product"
7504
+ ],
7505
+ "rule": "purpose-and-product"
7506
+ }
7507
+ ],
7508
+ "readers": [
7509
+ "program",
7510
+ "user",
7511
+ "operator"
7512
+ ],
7513
+ "namespaceKinds": [
7514
+ {
7515
+ "id": "repository",
7516
+ "meaning": "the keys of a file in the repository, shared by every deployment",
7517
+ "sharedAcrossDeployments": true
7518
+ },
7519
+ {
7520
+ "id": "domain",
7521
+ "meaning": "a DNS domain of the organization",
7522
+ "sharedAcrossDeployments": true
7523
+ },
7524
+ {
7525
+ "id": "account",
7526
+ "meaning": "an account of a platform, for example a Cloudflare account",
7527
+ "sharedAcrossDeployments": true
7528
+ },
7529
+ {
7530
+ "id": "organization",
7531
+ "meaning": "the locations of the organization, which include the GCP project ids",
7532
+ "sharedAcrossDeployments": true
7533
+ },
7534
+ {
7535
+ "id": "single-deployment",
7536
+ "meaning": "a space that holds one deployment, such as a GCP project, a VM or an OpenBao",
7537
+ "sharedAcrossDeployments": false
7538
+ },
7539
+ {
7540
+ "id": "global",
7541
+ "meaning": "a namespace shared by everyone on the platform, such as GCS buckets",
7542
+ "sharedAcrossDeployments": true
7543
+ },
7544
+ {
7545
+ "id": "none",
7546
+ "meaning": "no namespace, the name travels with a file or a directory",
7547
+ "sharedAcrossDeployments": true
7548
+ },
7549
+ {
7550
+ "id": "cluster",
7551
+ "meaning": "the parents of a cluster, tenant or workload (blueprint-shared.infra-layout.cluster-naming)",
7552
+ "sharedAcrossDeployments": false
7553
+ },
7554
+ {
7555
+ "id": "run",
7556
+ "meaning": "one run of a CI workflow; its names are gone when the run ends, and one run can hold several deployments",
7557
+ "sharedAcrossDeployments": true
7558
+ },
7559
+ {
7560
+ "id": "product",
7561
+ "meaning": "the code and the interfaces of a product, which are the same in every deployment",
7562
+ "sharedAcrossDeployments": true
7563
+ }
7564
+ ],
7565
+ "categories": [
7566
+ {
7567
+ "id": "instance-path-key",
7568
+ "meaning": "a key in instance path form, and the keys that reuse it",
7569
+ "namespace": "repository",
7570
+ "reader": "program",
7571
+ "rule": 1
7572
+ },
7573
+ {
7574
+ "id": "url",
7575
+ "meaning": "a URL and its DNS record",
7576
+ "namespace": "domain",
7577
+ "reader": "user",
7578
+ "rule": 3,
7579
+ "tenantPrefix": true,
7580
+ "nameForm": "hostname"
7581
+ },
7582
+ {
7583
+ "id": "user-entry-access-app",
7584
+ "meaning": "an identity-proxy app that is the entry users open",
7585
+ "namespace": "account",
7586
+ "reader": "user",
7587
+ "rule": 3
7588
+ },
7589
+ {
7590
+ "id": "saas-oidc-app",
7591
+ "meaning": "a SaaS OIDC app that an app launcher shows",
7592
+ "namespace": "account",
7593
+ "reader": "user",
7594
+ "rule": 3
7595
+ },
7596
+ {
7597
+ "id": "ops-path-access-app",
7598
+ "meaning": "an identity-proxy app that protects a maintenance path such as a health check",
7599
+ "namespace": "account",
7600
+ "reader": "operator",
7601
+ "rule": 4
7602
+ },
7603
+ {
7604
+ "id": "access-policy",
7605
+ "meaning": "a policy of the identity proxy",
7606
+ "namespace": "account",
7607
+ "reader": "operator",
7608
+ "rule": 4
7609
+ },
7610
+ {
7611
+ "id": "access-service-token",
7612
+ "meaning": "a service token of the identity proxy",
7613
+ "namespace": "account",
7614
+ "reader": "operator",
7615
+ "rule": 4
7616
+ },
7617
+ {
7618
+ "id": "tunnel",
7619
+ "meaning": "a tunnel of the edge network",
7620
+ "namespace": "account",
7621
+ "reader": "operator",
7622
+ "rule": 4
7623
+ },
7624
+ {
7625
+ "id": "worker",
7626
+ "meaning": "a Worker deployed into the account of the edge platform",
7627
+ "namespace": "account",
7628
+ "reader": "operator",
7629
+ "rule": 4
7630
+ },
7631
+ {
7632
+ "id": "zone-setting",
7633
+ "meaning": "a setting of a DNS zone on the edge platform, such as an entrypoint ruleset; a zone often serves several deployments, and then the name takes no environment mark (environmentScope)",
7634
+ "namespace": "account",
7635
+ "reader": "operator",
7636
+ "rule": 4
7637
+ },
7638
+ {
7639
+ "id": "location-and-gcp-project-id",
7640
+ "meaning": "a location, and the id of the GCP project that is a location",
7641
+ "namespace": "organization",
7642
+ "reader": "operator",
7643
+ "rule": 4
7644
+ },
7645
+ {
7646
+ "id": "ci-run-name",
7647
+ "meaning": "a name that lives inside one CI workflow run, such as an artifact; the run id is part of the base, and the environment of the deployment is the last part",
7648
+ "namespace": "run",
7649
+ "reader": "operator",
7650
+ "rule": 4
7651
+ },
7652
+ {
7653
+ "id": "gcp-project-resource",
7654
+ "meaning": "a resource inside a GCP project: a service account, a KMS key, a secret, a workload identity",
7655
+ "namespace": "single-deployment",
7656
+ "reader": "operator",
7657
+ "rule": 2
7658
+ },
7659
+ {
7660
+ "id": "vm-and-derived",
7661
+ "meaning": "a VM and what is derived from it: network, subnet, firewall, IP, boot disk, network tag",
7662
+ "namespace": "single-deployment",
7663
+ "reader": "operator",
7664
+ "rule": 2
7665
+ },
7666
+ {
7667
+ "id": "vm-internal-name",
7668
+ "meaning": "a name inside a VM that belongs to the deployment: compose project, a directory of its data or settings, systemd unit, system user and group, WireGuard interface",
7669
+ "namespace": "single-deployment",
7670
+ "reader": "operator",
7671
+ "rule": 2,
7672
+ "tenantPrefix": true
7673
+ },
7674
+ {
7675
+ "id": "openbao-name",
7676
+ "meaning": "a name inside the secrets store",
7677
+ "namespace": "single-deployment",
7678
+ "reader": "operator",
7679
+ "rule": 2
7680
+ },
7681
+ {
7682
+ "id": "bucket-object",
7683
+ "meaning": "an object inside a bucket",
7684
+ "namespace": "single-deployment",
7685
+ "reader": "operator",
7686
+ "rule": 2,
7687
+ "tenantPrefix": true
7688
+ },
7689
+ {
7690
+ "id": "gcs-bucket",
7691
+ "meaning": "a GCS bucket",
7692
+ "namespace": "global",
7693
+ "reader": "operator",
7694
+ "rule": 5,
7695
+ "scope": "project-id"
7696
+ },
7697
+ {
7698
+ "id": "movable-file-or-dir",
7699
+ "meaning": "a file or a directory that is moved away from where it was made, such as a key file, a backup directory or a state backup",
7700
+ "namespace": "none",
7701
+ "reader": "operator",
7702
+ "rule": 5,
7703
+ "scope": "deployment-id"
7704
+ },
7705
+ {
7706
+ "id": "product-program-name",
7707
+ "meaning": "a name that belongs to the program of a product, not to a deployment: a configuration key it reads, a value programs agree on such as an audience, a variable or role of its Ansible role, a path inside its container, and the directory it is installed in",
7708
+ "namespace": "product",
7709
+ "reader": "program",
7710
+ "rule": "purpose-and-product",
7711
+ "follows": "/purposeAndProduct"
7712
+ },
7713
+ {
7714
+ "id": "cluster-tenant-workload",
7715
+ "meaning": "a cluster, a tenant or a workload",
7716
+ "namespace": "cluster",
7717
+ "reader": "operator",
7718
+ "rule": "cluster-naming",
7719
+ "follows": "blueprint-shared.infra-layout.cluster-naming"
7720
+ }
7721
+ ],
7722
+ "scopeIdentity": {
7723
+ "project-id": {
7724
+ "form": "<project id>",
7725
+ "used": "a globally shared resource, for example the bucket <project id>-tofu-state"
7726
+ },
7727
+ "deployment-id": {
7728
+ "form": "<purpose>-<environment>",
7729
+ "used": "a file or a directory; prod is written too, for example secrets-prod-backup.agekey"
7730
+ }
7731
+ },
7732
+ "gcpProjectId": "A GCP project id is in a global namespace, but it is a location, so it follows rule 4 and is written <organization>-<environment>. The organization prefix keeps it from clashing with another organization.",
7733
+ "workloadInSharedNamespace": "A workload deployed into a shared namespace, for example a Worker in an account, takes the purpose name of its instance as the base, for example secrets-ui, and then follows rule 4.",
7734
+ "labels": "A resource of rule 2 carries the label environment=<environment> when the platform supports labels. Outside its scope it is referred to by its full name, for example <VM name>.<zone>.<project> for an ssh alias.",
7735
+ "purposeAndProduct": "What is deployed uses the purpose name, for example secrets. The program, the package and the Ansible role of a product use the product name.",
7736
+ "environmentScope": "Rules 2 to 4 are used only for names that serve one deployment environment. A name that serves several environments takes no environment mark, and one shared across environments takes -shared.",
7737
+ "tenantAndWorkload": "The tenant environment prefix of a name follows /workloadName of blueprint-shared.infra-layout.cluster-naming, and a cluster, tenant or workload follows its decide. This fact does not change them.",
7738
+ "universalChecks": [
7739
+ "Every name in a declaration maps to a registered category.",
7740
+ "Two deployments never produce the same name in a namespace they both write into.",
7741
+ "A variable that carries the deployment environment in IaC has no default, because an unset one would become the name of the prod deployment."
7742
+ ],
7743
+ "humanJudgement": [
7744
+ "Whether a category is registered correctly, judged once when a new category is registered.",
7745
+ "Names that are not written in the repository, such as a key file on a personal computer, a directory on a NAS or a resource created by hand in a console.",
7746
+ "Whether a purpose name is well chosen.",
7747
+ "Whether a stg in the middle of a name is a tenant prefix or the deployment environment, judged from the structure of the declaration."
7748
+ ]
7749
+ }
7750
+ }
7751
+ }
7752
+ ],
7753
+ "source": {
7754
+ "kind": "published"
7755
+ },
7756
+ "content": {
7757
+ "value": {
7758
+ "principle": "Every resource category registers two properties: the kind of its namespace and who reads the name. A program chooses the rule from them (ruleSelection), so every name falls under exactly one rule. A name that does not follow its rule is renamed; the rebuild, downtime or new IP it costs is paid, and no list of exceptions is kept, because a wrong name left in place gets copied.",
7759
+ "environmentValues": {
7760
+ "deployments": [
7761
+ "dev",
7762
+ "stg",
7763
+ "prod"
7764
+ ],
7765
+ "shared": "shared",
7766
+ "several": "several",
7767
+ "meaning": "The environment of a deployment is dev, stg or prod. shared marks a name shared across environments and takes -shared (rules 3 and 4). several marks a name that serves several environments and takes no mark."
7768
+ },
7769
+ "suffixPosition": "A suffix that tells deployments apart (rules 3 and 4) is the last part of the name. Rule 5 names start with the identity of the scope, whose environment is the last part of that identity.",
7770
+ "rules": [
7771
+ {
7772
+ "n": 1,
7773
+ "title": "instance path",
7774
+ "when": "a deployment identity written as an instance path, and the keys that reuse it, such as the instance keys of versions.json and targets.json, a state prefix and --deployment",
7775
+ "form": {
7776
+ "prod": "<purpose>/prod",
7777
+ "other": "<purpose>/<environment>"
7778
+ }
7779
+ },
7780
+ {
7781
+ "n": 2,
7782
+ "title": "single deployment scope",
7783
+ "when": "the namespace holds one deployment only, such as the resources inside a GCP project, names inside a VM and names inside OpenBao",
7784
+ "form": {
7785
+ "prod": "<purpose>",
7786
+ "other": "<purpose>"
7787
+ }
7788
+ },
7789
+ {
7790
+ "n": 3,
7791
+ "title": "entry in a shared scope",
7792
+ "when": "a name for users in a namespace that the organization shares, such as a URL, an identity-proxy app or a SaaS OIDC app that an app launcher shows",
7793
+ "form": {
7794
+ "prod": "<base>",
7795
+ "other": "<base>-<environment>"
7796
+ }
7797
+ },
7798
+ {
7799
+ "n": 4,
7800
+ "title": "maintenance resource in a shared scope",
7801
+ "when": "a name for operators in a namespace that the organization shares, such as a tunnel, an access policy, a Worker or a location name",
7802
+ "form": {
7803
+ "prod": "<base>-prod",
7804
+ "other": "<base>-<environment>"
7805
+ }
7806
+ },
7807
+ {
7808
+ "n": 5,
7809
+ "title": "full name with a scope",
7810
+ "when": "a globally shared namespace, or a file or directory that is moved away from where it was made",
7811
+ "form": {
7812
+ "prod": "<scope>-<purpose>",
7813
+ "other": "<scope>-<purpose>"
7814
+ }
7815
+ }
7816
+ ],
7817
+ "ruleSelection": [
7818
+ {
7819
+ "namespaces": [
7820
+ "repository"
6458
7821
  ],
6459
- "name": "platform",
6460
- "reason": "the location ends in -dev"
7822
+ "reader": "program",
7823
+ "rule": 1
6461
7824
  },
6462
7825
  {
6463
- "kind": "parent cluster",
6464
- "parents": [
6465
- "gcp-stg"
7826
+ "namespaces": [
7827
+ "single-deployment"
6466
7828
  ],
6467
- "purpose": "platform",
6468
- "serves": [
6469
- "stg"
7829
+ "rule": 2
7830
+ },
7831
+ {
7832
+ "namespaces": [
7833
+ "domain",
7834
+ "account"
6470
7835
  ],
6471
- "name": "platform",
6472
- "reason": "the location ends in -stg"
7836
+ "reader": "user",
7837
+ "rule": 3
6473
7838
  },
6474
7839
  {
6475
- "kind": "parent cluster",
6476
- "parents": [
6477
- "gcp-prod"
7840
+ "namespaces": [
7841
+ "account",
7842
+ "organization",
7843
+ "run"
6478
7844
  ],
6479
- "purpose": "platform",
6480
- "serves": [
6481
- "prod"
7845
+ "reader": "operator",
7846
+ "rule": 4
7847
+ },
7848
+ {
7849
+ "namespaces": [
7850
+ "global",
7851
+ "none"
6482
7852
  ],
6483
- "name": "platform",
6484
- "reason": "the location ends in -prod"
7853
+ "rule": 5
6485
7854
  },
6486
7855
  {
6487
- "kind": "parent cluster",
6488
- "parents": [
6489
- "macbook"
7856
+ "namespaces": [
7857
+ "cluster"
6490
7858
  ],
6491
- "purpose": "platform",
6492
- "serves": [
6493
- "dev"
7859
+ "rule": "cluster-naming"
7860
+ },
7861
+ {
7862
+ "namespaces": [
7863
+ "product"
6494
7864
  ],
6495
- "name": "platform-dev",
6496
- "reason": "the location has no suffix and the cluster serves dev only"
7865
+ "rule": "purpose-and-product"
7866
+ }
7867
+ ],
7868
+ "readers": [
7869
+ "program",
7870
+ "user",
7871
+ "operator"
7872
+ ],
7873
+ "namespaceKinds": [
7874
+ {
7875
+ "id": "repository",
7876
+ "meaning": "the keys of a file in the repository, shared by every deployment",
7877
+ "sharedAcrossDeployments": true
7878
+ },
7879
+ {
7880
+ "id": "domain",
7881
+ "meaning": "a DNS domain of the organization",
7882
+ "sharedAcrossDeployments": true
7883
+ },
7884
+ {
7885
+ "id": "account",
7886
+ "meaning": "an account of a platform, for example a Cloudflare account",
7887
+ "sharedAcrossDeployments": true
7888
+ },
7889
+ {
7890
+ "id": "organization",
7891
+ "meaning": "the locations of the organization, which include the GCP project ids",
7892
+ "sharedAcrossDeployments": true
7893
+ },
7894
+ {
7895
+ "id": "single-deployment",
7896
+ "meaning": "a space that holds one deployment, such as a GCP project, a VM or an OpenBao",
7897
+ "sharedAcrossDeployments": false
7898
+ },
7899
+ {
7900
+ "id": "global",
7901
+ "meaning": "a namespace shared by everyone on the platform, such as GCS buckets",
7902
+ "sharedAcrossDeployments": true
7903
+ },
7904
+ {
7905
+ "id": "none",
7906
+ "meaning": "no namespace, the name travels with a file or a directory",
7907
+ "sharedAcrossDeployments": true
7908
+ },
7909
+ {
7910
+ "id": "cluster",
7911
+ "meaning": "the parents of a cluster, tenant or workload (blueprint-shared.infra-layout.cluster-naming)",
7912
+ "sharedAcrossDeployments": false
7913
+ },
7914
+ {
7915
+ "id": "run",
7916
+ "meaning": "one run of a CI workflow; its names are gone when the run ends, and one run can hold several deployments",
7917
+ "sharedAcrossDeployments": true
7918
+ },
7919
+ {
7920
+ "id": "product",
7921
+ "meaning": "the code and the interfaces of a product, which are the same in every deployment",
7922
+ "sharedAcrossDeployments": true
7923
+ }
7924
+ ],
7925
+ "categories": [
7926
+ {
7927
+ "id": "instance-path-key",
7928
+ "meaning": "a key in instance path form, and the keys that reuse it",
7929
+ "namespace": "repository",
7930
+ "reader": "program",
7931
+ "rule": 1
7932
+ },
7933
+ {
7934
+ "id": "url",
7935
+ "meaning": "a URL and its DNS record",
7936
+ "namespace": "domain",
7937
+ "reader": "user",
7938
+ "rule": 3,
7939
+ "tenantPrefix": true,
7940
+ "nameForm": "hostname"
7941
+ },
7942
+ {
7943
+ "id": "user-entry-access-app",
7944
+ "meaning": "an identity-proxy app that is the entry users open",
7945
+ "namespace": "account",
7946
+ "reader": "user",
7947
+ "rule": 3
7948
+ },
7949
+ {
7950
+ "id": "saas-oidc-app",
7951
+ "meaning": "a SaaS OIDC app that an app launcher shows",
7952
+ "namespace": "account",
7953
+ "reader": "user",
7954
+ "rule": 3
7955
+ },
7956
+ {
7957
+ "id": "ops-path-access-app",
7958
+ "meaning": "an identity-proxy app that protects a maintenance path such as a health check",
7959
+ "namespace": "account",
7960
+ "reader": "operator",
7961
+ "rule": 4
7962
+ },
7963
+ {
7964
+ "id": "access-policy",
7965
+ "meaning": "a policy of the identity proxy",
7966
+ "namespace": "account",
7967
+ "reader": "operator",
7968
+ "rule": 4
6497
7969
  },
6498
7970
  {
6499
- "kind": "parent cluster",
6500
- "parents": [
6501
- "mac-mini"
6502
- ],
6503
- "purpose": "platform",
6504
- "serves": [
6505
- "prod"
6506
- ],
6507
- "name": "platform-prod",
6508
- "reason": "the location has no suffix and the cluster serves prod only"
7971
+ "id": "access-service-token",
7972
+ "meaning": "a service token of the identity proxy",
7973
+ "namespace": "account",
7974
+ "reader": "operator",
7975
+ "rule": 4
6509
7976
  },
6510
7977
  {
6511
- "kind": "parent cluster",
6512
- "parents": [
6513
- "macbook"
6514
- ],
6515
- "purpose": "platform",
6516
- "serves": [
6517
- "dev",
6518
- "stg"
6519
- ],
6520
- "name": "platform",
6521
- "reason": "the location has no suffix and the cluster has no single environment"
7978
+ "id": "tunnel",
7979
+ "meaning": "a tunnel of the edge network",
7980
+ "namespace": "account",
7981
+ "reader": "operator",
7982
+ "rule": 4
6522
7983
  },
6523
7984
  {
6524
- "kind": "virtual cluster",
6525
- "parents": [
6526
- "gcp-stg",
6527
- "platform"
6528
- ],
6529
- "purpose": "events",
6530
- "serves": [
6531
- "stg"
6532
- ],
6533
- "name": "events",
6534
- "reason": "the location ends in -stg"
7985
+ "id": "worker",
7986
+ "meaning": "a Worker deployed into the account of the edge platform",
7987
+ "namespace": "account",
7988
+ "reader": "operator",
7989
+ "rule": 4
6535
7990
  },
6536
7991
  {
6537
- "kind": "virtual cluster",
6538
- "parents": [
6539
- "gcp-prod",
6540
- "platform"
6541
- ],
6542
- "purpose": "events",
6543
- "serves": [
6544
- "prod"
6545
- ],
6546
- "name": "events",
6547
- "reason": "the location ends in -prod"
7992
+ "id": "zone-setting",
7993
+ "meaning": "a setting of a DNS zone on the edge platform, such as an entrypoint ruleset; a zone often serves several deployments, and then the name takes no environment mark (environmentScope)",
7994
+ "namespace": "account",
7995
+ "reader": "operator",
7996
+ "rule": 4
6548
7997
  },
6549
7998
  {
6550
- "kind": "virtual cluster",
6551
- "parents": [
6552
- "macbook",
6553
- "platform-dev"
6554
- ],
6555
- "purpose": "events",
6556
- "serves": [
6557
- "dev"
6558
- ],
6559
- "name": "events",
6560
- "reason": "the parent cluster ends in -dev"
7999
+ "id": "location-and-gcp-project-id",
8000
+ "meaning": "a location, and the id of the GCP project that is a location",
8001
+ "namespace": "organization",
8002
+ "reader": "operator",
8003
+ "rule": 4
6561
8004
  },
6562
8005
  {
6563
- "kind": "virtual cluster",
6564
- "parents": [
6565
- "macbook",
6566
- "platform"
6567
- ],
6568
- "purpose": "events",
6569
- "serves": [
6570
- "dev"
6571
- ],
6572
- "name": "events-dev",
6573
- "reason": "neither the location nor the parent cluster has a suffix"
8006
+ "id": "ci-run-name",
8007
+ "meaning": "a name that lives inside one CI workflow run, such as an artifact; the run id is part of the base, and the environment of the deployment is the last part",
8008
+ "namespace": "run",
8009
+ "reader": "operator",
8010
+ "rule": 4
6574
8011
  },
6575
8012
  {
6576
- "kind": "virtual cluster",
6577
- "parents": [
6578
- "macbook",
6579
- "platform"
6580
- ],
6581
- "purpose": "events",
6582
- "serves": [
6583
- "stg"
6584
- ],
6585
- "name": "events-stg",
6586
- "reason": "neither the location nor the parent cluster has a suffix"
8013
+ "id": "gcp-project-resource",
8014
+ "meaning": "a resource inside a GCP project: a service account, a KMS key, a secret, a workload identity",
8015
+ "namespace": "single-deployment",
8016
+ "reader": "operator",
8017
+ "rule": 2
6587
8018
  },
6588
8019
  {
6589
- "kind": "virtual cluster",
6590
- "parents": [
6591
- "gcp-prod",
6592
- "platform"
6593
- ],
6594
- "purpose": "events",
6595
- "serves": [
6596
- "prod"
6597
- ],
6598
- "sequence": 2,
6599
- "name": "events-2",
6600
- "reason": "the second of the purpose in one cluster, in one region, so a sequence number"
8020
+ "id": "vm-and-derived",
8021
+ "meaning": "a VM and what is derived from it: network, subnet, firewall, IP, boot disk, network tag",
8022
+ "namespace": "single-deployment",
8023
+ "reader": "operator",
8024
+ "rule": 2
6601
8025
  },
6602
8026
  {
6603
- "kind": "namespace",
6604
- "parents": [
6605
- "gcp-dev",
6606
- "platform"
6607
- ],
6608
- "purpose": "orbit",
6609
- "serves": [
6610
- "dev"
6611
- ],
6612
- "name": "orbit",
6613
- "reason": "the location ends in -dev"
8027
+ "id": "vm-internal-name",
8028
+ "meaning": "a name inside a VM that belongs to the deployment: compose project, a directory of its data or settings, systemd unit, system user and group, WireGuard interface",
8029
+ "namespace": "single-deployment",
8030
+ "reader": "operator",
8031
+ "rule": 2,
8032
+ "tenantPrefix": true
6614
8033
  },
6615
8034
  {
6616
- "kind": "namespace",
6617
- "parents": [
6618
- "gcp-stg",
6619
- "platform"
6620
- ],
6621
- "purpose": "orbit",
6622
- "serves": [
6623
- "stg"
6624
- ],
6625
- "name": "orbit",
6626
- "reason": "the location ends in -stg"
8035
+ "id": "openbao-name",
8036
+ "meaning": "a name inside the secrets store",
8037
+ "namespace": "single-deployment",
8038
+ "reader": "operator",
8039
+ "rule": 2
6627
8040
  },
6628
8041
  {
6629
- "kind": "namespace",
6630
- "parents": [
6631
- "gcp-prod",
6632
- "platform"
6633
- ],
6634
- "purpose": "orbit",
6635
- "serves": [
6636
- "prod"
6637
- ],
6638
- "name": "orbit",
6639
- "reason": "the location ends in -prod"
8042
+ "id": "bucket-object",
8043
+ "meaning": "an object inside a bucket",
8044
+ "namespace": "single-deployment",
8045
+ "reader": "operator",
8046
+ "rule": 2,
8047
+ "tenantPrefix": true
6640
8048
  },
6641
8049
  {
6642
- "kind": "namespace",
6643
- "parents": [
6644
- "mac-mini",
6645
- "platform-prod"
6646
- ],
6647
- "purpose": "ci",
6648
- "serves": [
6649
- "prod"
6650
- ],
6651
- "name": "ci",
6652
- "reason": "the parent cluster ends in -prod"
8050
+ "id": "gcs-bucket",
8051
+ "meaning": "a GCS bucket",
8052
+ "namespace": "global",
8053
+ "reader": "operator",
8054
+ "rule": 5,
8055
+ "scope": "project-id"
6653
8056
  },
6654
8057
  {
6655
- "kind": "namespace in a virtual cluster",
6656
- "parents": [
6657
- "gcp-prod",
6658
- "platform",
6659
- "events"
6660
- ],
6661
- "purpose": "stream",
6662
- "serves": [
6663
- "prod"
6664
- ],
6665
- "name": "stream",
6666
- "reason": "the location ends in -prod"
8058
+ "id": "movable-file-or-dir",
8059
+ "meaning": "a file or a directory that is moved away from where it was made, such as a key file, a backup directory or a state backup",
8060
+ "namespace": "none",
8061
+ "reader": "operator",
8062
+ "rule": 5,
8063
+ "scope": "deployment-id"
8064
+ },
8065
+ {
8066
+ "id": "product-program-name",
8067
+ "meaning": "a name that belongs to the program of a product, not to a deployment: a configuration key it reads, a value programs agree on such as an audience, a variable or role of its Ansible role, a path inside its container, and the directory it is installed in",
8068
+ "namespace": "product",
8069
+ "reader": "program",
8070
+ "rule": "purpose-and-product",
8071
+ "follows": "/purposeAndProduct"
8072
+ },
8073
+ {
8074
+ "id": "cluster-tenant-workload",
8075
+ "meaning": "a cluster, a tenant or a workload",
8076
+ "namespace": "cluster",
8077
+ "reader": "operator",
8078
+ "rule": "cluster-naming",
8079
+ "follows": "blueprint-shared.infra-layout.cluster-naming"
6667
8080
  }
6668
8081
  ],
6669
- "instancePath": "The instance path stays <purpose>/<environment>. The names of the clusters and namespaces are worked out from the instance path and the parents. Clusters of the same name are told apart by their parents, for example gcp-prod/platform/events, and monitoring adds a location label to tell them apart. A virtual cluster is installed in the namespace of the same name in its parent cluster.",
6670
- "serviceEnvironment": "A service of the organization that has its own test and production deployments takes the environment of its own deployment as the <environment> of its instance path, for example secrets/stg and secrets/prod. It does not take shared, and it does not take the environment of the units that use it. The environment a workload serves is written only on a workload that a deployment splits by the environment it serves, and only as a prefix (/workloadName).",
6671
- "vmName": "A VM is named after its purpose, for example secrets or ci. It is never named after a project or a product.",
6672
- "environmentMarks": {
6673
- "meaning": "An environment mark has two positions with two meanings. A suffix says which environment the thing is deployed in. A prefix says which environment the workload serves.",
6674
- "positions": [
6675
- {
6676
- "mark": "suffix",
6677
- "where": "location",
6678
- "form": "<name>-<environment>",
6679
- "says": "the environment of the deployment"
6680
- },
6681
- {
6682
- "mark": "suffix",
6683
- "where": "vm",
6684
- "form": "<name>-<environment>",
6685
- "says": "the environment of the deployment"
6686
- },
6687
- {
6688
- "mark": "suffix",
6689
- "where": "cluster",
6690
- "form": "<name>-<environment>",
6691
- "says": "the environment of the deployment"
6692
- },
6693
- {
6694
- "mark": "suffix",
6695
- "where": "tenant",
6696
- "form": "<name>-<environment>",
6697
- "says": "the environment of the deployment"
6698
- },
6699
- {
6700
- "mark": "suffix",
6701
- "where": "instance path",
6702
- "form": "/<environment>",
6703
- "says": "the environment of the deployment"
6704
- },
6705
- {
6706
- "mark": "suffix",
6707
- "where": "url",
6708
- "form": "-<environment>",
6709
- "says": "the environment of the deployment"
6710
- },
6711
- {
6712
- "mark": "prefix",
6713
- "where": "a workload split by the environment it serves",
6714
- "form": "<service environment>-<purpose>",
6715
- "says": "the environment the workload serves"
6716
- }
6717
- ],
6718
- "otherWorkloads": "Every other workload is named <purpose>. Its deployment environment is the one of the parent above it."
6719
- },
6720
- "workloadName": {
6721
- "meaning": "A workload is one program deployed into a deployment, whatever runs it: a container, a Kubernetes workload, a Worker or a resident program of the host. It is the software that ops/workloads/ deploys (blueprint-shared.infra-layout.ops-dirs).",
6722
- "form": "one copy of a purpose in a deployment is <purpose>; several copies each take the prefix <service environment>-<purpose>",
6723
- "prefixes": [
6724
- "dev-",
6725
- "stg-",
6726
- "prod-"
6727
- ],
6728
- "pattern": "^[a-z0-9][a-z0-9-]*$",
6729
- "rules": [
6730
- "In one deployment a purpose has exactly two legal forms: one copy named <purpose>, or several copies that each take a prefix. The prod- prefix is written too.",
6731
- "A mix of the two is not legal, for example secrets together with stg-secrets.",
6732
- "A workload never carries a prefix and a suffix together, for example prod-secrets-stg.",
6733
- "A prefix is one of the prefixes listed here. A single copy never takes one, so prod-secrets alone is not legal.",
6734
- "The change process and the permissions follow the environment of the deployment the workload is in, never the prefix of the workload."
6735
- ],
6736
- "examples": {
6737
- "valid": [
6738
- {
6739
- "names": [
6740
- "proxy"
6741
- ],
6742
- "reason": "one copy, named by its purpose"
6743
- },
6744
- {
6745
- "names": [
6746
- "prod-secrets",
6747
- "stg-secrets",
6748
- "dev-secrets"
6749
- ],
6750
- "reason": "split by the environment served, and every copy takes a prefix"
6751
- }
6752
- ],
6753
- "invalid": [
6754
- {
6755
- "names": [
6756
- "secrets",
6757
- "stg-secrets"
6758
- ],
6759
- "reason": "a mix of the plain form and the prefixed form"
6760
- },
6761
- {
6762
- "names": [
6763
- "prod-secrets-stg"
6764
- ],
6765
- "reason": "a prefix and a suffix on one workload"
6766
- },
6767
- {
6768
- "names": [
6769
- "prod-secrets"
6770
- ],
6771
- "reason": "one copy takes no prefix"
6772
- }
6773
- ]
8082
+ "scopeIdentity": {
8083
+ "project-id": {
8084
+ "form": "<project id>",
8085
+ "used": "a globally shared resource, for example the bucket <project id>-tofu-state"
8086
+ },
8087
+ "deployment-id": {
8088
+ "form": "<purpose>-<environment>",
8089
+ "used": "a file or a directory; prod is written too, for example secrets-prod-backup.agekey"
6774
8090
  }
6775
- }
8091
+ },
8092
+ "gcpProjectId": "A GCP project id is in a global namespace, but it is a location, so it follows rule 4 and is written <organization>-<environment>. The organization prefix keeps it from clashing with another organization.",
8093
+ "workloadInSharedNamespace": "A workload deployed into a shared namespace, for example a Worker in an account, takes the purpose name of its instance as the base, for example secrets-ui, and then follows rule 4.",
8094
+ "labels": "A resource of rule 2 carries the label environment=<environment> when the platform supports labels. Outside its scope it is referred to by its full name, for example <VM name>.<zone>.<project> for an ssh alias.",
8095
+ "purposeAndProduct": "What is deployed uses the purpose name, for example secrets. The program, the package and the Ansible role of a product use the product name.",
8096
+ "environmentScope": "Rules 2 to 4 are used only for names that serve one deployment environment. A name that serves several environments takes no environment mark, and one shared across environments takes -shared.",
8097
+ "tenantAndWorkload": "The tenant environment prefix of a name follows /workloadName of blueprint-shared.infra-layout.cluster-naming, and a cluster, tenant or workload follows its decide. This fact does not change them.",
8098
+ "universalChecks": [
8099
+ "Every name in a declaration maps to a registered category.",
8100
+ "Two deployments never produce the same name in a namespace they both write into.",
8101
+ "A variable that carries the deployment environment in IaC has no default, because an unset one would become the name of the prod deployment."
8102
+ ],
8103
+ "humanJudgement": [
8104
+ "Whether a category is registered correctly, judged once when a new category is registered.",
8105
+ "Names that are not written in the repository, such as a key file on a personal computer, a directory on a NAS or a resource created by hand in a console.",
8106
+ "Whether a purpose name is well chosen.",
8107
+ "Whether a stg in the middle of a name is a tenant prefix or the deployment environment, judged from the structure of the declaration."
8108
+ ]
6776
8109
  }
6777
8110
  }
6778
8111
  },