@steve31415/baselib 3.8.3 → 3.9.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.
@@ -53,6 +53,14 @@ export function validateConfig(raw) {
53
53
  fail(`updateSecrets.${key} (want <secret-name>:<numeric version>)`);
54
54
  }
55
55
  }
56
+ if (c.updateEnv) {
57
+ for (const [key, value] of Object.entries(c.updateEnv)) {
58
+ if (!/^[A-Z][A-Z0-9_]*$/.test(key) || key === 'BUILD_ID')
59
+ fail(`updateEnv.${key} (key)`);
60
+ if (typeof value !== 'string' || /[|\n]/.test(value))
61
+ fail(`updateEnv.${key} (want a string without '|' or newlines)`);
62
+ }
63
+ }
56
64
  return c;
57
65
  }
58
66
  export async function loadConfig(repoRoot) {
@@ -241,11 +241,14 @@ export async function runDeploy(options) {
241
241
  });
242
242
  continue;
243
243
  }
244
+ // One --update-env-vars with gcloud's alternate-delimiter form (^|^ …)
245
+ // so declared values may contain commas; '|' is rejected by validateConfig.
246
+ const envPairs = [`BUILD_ID=${sha}`, ...Object.entries(config.updateEnv ?? {}).map(([k, v]) => `${k}=${v}`)];
244
247
  const updateArgs = [
245
248
  'run', 'services', 'update', service.name,
246
249
  ...gcloudBase, '--region', config.region, '--quiet', '--format=json',
247
250
  '--image', imageDigest,
248
- '--update-env-vars', `BUILD_ID=${sha}`,
251
+ '--update-env-vars', `^|^${envPairs.join('|')}`,
249
252
  '--update-labels', `pw-build-sha=${sha.slice(0, 40)}`,
250
253
  ];
251
254
  if (config.updateSecrets) {
@@ -47,6 +47,10 @@ export interface DeployConfig {
47
47
  releasePrefix: string;
48
48
  /** Secrets re-pinned on every routine deploy (name -> secret:version). */
49
49
  updateSecrets?: Record<string, string>;
50
+ /** Non-secret env vars asserted on every routine deploy (name -> value), so a
51
+ * runtime-config change is a commit the deploy carries rather than a hand-run
52
+ * `gcloud run services update`. Undeclared vars are left as they are. */
53
+ updateEnv?: Record<string, string>;
50
54
  /** Refuse to deploy across a migrations/ diff (notes2 semantics). */
51
55
  refuseMigrationDiffOnDeploy?: boolean;
52
56
  /** Repo-relative path of an optional ES module exporting hooks. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steve31415/baselib",
3
- "version": "3.8.3",
3
+ "version": "3.9.0",
4
4
  "description": "Plasticine new-world shared platform library: logging, auth, service-to-service auth, db, HTTP, sync, app updates",
5
5
  "type": "module",
6
6
  "license": "MIT",