sky state public patch
Update a single public-state path or replace the root object.
Synopsis
bash
sky state public patch <path> <value> --project <slug> [--env <slug>] [--op <add|replace|auto>] [--expect-none | --expect-version <version>] [--string] [--comment <message>] [--yes]
sky state public patch <json-object> --root --project <slug> [--env <slug>] [--expect-none | --expect-version <version>] [--comment <message>] [--yes]Description
patch writes one change to the public state of an environment as a new version. In the default auto mode it reads the current state first, uses add if the path does not exist yet and replace if it does, and creates missing parent objects along the path where that is possible.
--expect-version and --expect-none skip the initial read and state the expected version up front; see the options table. A path patch with --expect-version requires --op add or --op replace because the CLI cannot infer the operation without the current state.
Options
| Option | Description |
|---|---|
--project <slug> | Required. Project slug. |
--env <slug> | Target environment. See Environments. |
--expect-none | Write as a first write: the ops are applied to an empty {} document and the command fails if public state already exists. Mutually exclusive with --expect-version. |
--expect-version <version> | Positive integer. Write only if the current version equals this value. Mutually exclusive with --expect-none. |
--op <op> | add, replace, or auto. auto is the default and needs the current state, so a path patch cannot combine it with --expect-version. |
--root | Replace the whole state document. Mutually exclusive with <path>. |
--string | Treat <value> as a literal string. Without it the value is parsed as JSON first and used as a string only if that fails. |
--comment <message> | Commit message for the new version. |
--yes | Skip type-change confirmation prompts. |
--format <format> | Global format, supported values for this command: plain, json. |
Examples
bash
sky state public patch /banner/text "Holiday sale" --project my-app --env production
sky state public patch /banner/enabled true --project my-app --env staging
sky state public patch /limits/maxItems 50 --project my-app --env production
sky state public patch /banner '{"text":"Sale","enabled":true}' --project my-app --env production
sky state public patch --root '{"banner":{"text":"Hi"}}' --project my-app --env development
sky state public patch /label true --string --project my-app --env production
sky state public patch /banner/text "New" --expect-version 7 --op replace --project my-app --env production
sky state public patch --root '{"banner":{"text":"Hi"}}' --expect-none --project my-app --env developmentOutput
Plain output goes to stderr:
text
Patched
Environment: production
Path: /banner/text
Operation: replace
Version: v8JSON output goes to stdout:
json
{
"version": 8,
"path": "/banner/text",
"op": "replace"
}