Skip to content

Commit df9aa28

Browse files
committed
fix(cli): drop reserved annotation check
Signed-off-by: Eric Curtin <eric.curtin@docker.com>
1 parent 919189a commit df9aa28

5 files changed

Lines changed: 11 additions & 37 deletions

File tree

‎crates/openshell-cli/src/commands/common.rs‎

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -932,22 +932,6 @@ pub fn parse_env_from_pairs(items: &[String]) -> Result<HashMap<String, String>>
932932
Ok(map)
933933
}
934934

935-
/// Annotation keys under this prefix are managed by the system, not callers.
936-
const RESERVED_ANNOTATION_PREFIX: &str = "openshell.nvidia.com/";
937-
938-
pub fn parse_annotation_pairs(items: &[String]) -> Result<HashMap<String, String>> {
939-
let map = parse_key_value_pairs(items, "--annotation")?;
940-
if let Some(key) = map
941-
.keys()
942-
.find(|key| key.starts_with(RESERVED_ANNOTATION_PREFIX))
943-
{
944-
return Err(miette::miette!(
945-
"--annotation keys starting with {RESERVED_ANNOTATION_PREFIX} are reserved; got '{key}'"
946-
));
947-
}
948-
Ok(map)
949-
}
950-
951935
/// Resolve `--secret-material-env KEY[=ENVVAR]` values from the CLI process
952936
/// environment (`ENVVAR` defaults to `KEY`) so secrets never transit argv.
953937
pub fn parse_secret_material_env_pairs(items: &[String]) -> Result<HashMap<String, String>> {
@@ -1130,35 +1114,26 @@ mod tests {
11301114
use super::*;
11311115

11321116
#[test]
1133-
fn parse_annotation_pairs_keeps_slashes_spaces_and_equals() {
1117+
fn parse_key_value_pairs_keeps_slashes_spaces_and_equals() {
11341118
let items = vec!["source=/home/you/my policy.yaml?a=b".to_string()];
1135-
let map = parse_annotation_pairs(&items).expect("annotation should parse");
1119+
let map = parse_key_value_pairs(&items, "--annotation").expect("annotation should parse");
11361120
assert_eq!(
11371121
map.get("source").map(String::as_str),
11381122
Some("/home/you/my policy.yaml?a=b")
11391123
);
11401124
}
11411125

11421126
#[test]
1143-
fn parse_annotation_pairs_rejects_malformed_and_empty_keys() {
1144-
let err = parse_annotation_pairs(&["nokey".to_string()]).expect_err("missing '='");
1127+
fn parse_key_value_pairs_rejects_malformed_and_empty_keys() {
1128+
let err =
1129+
parse_key_value_pairs(&["nokey".to_string()], "--annotation").expect_err("missing '='");
11451130
assert!(err.to_string().contains("--annotation expects KEY=VALUE"));
11461131

1147-
let err = parse_annotation_pairs(&["=value".to_string()]).expect_err("empty key");
1132+
let err =
1133+
parse_key_value_pairs(&["=value".to_string()], "--annotation").expect_err("empty key");
11481134
assert!(err.to_string().contains("--annotation key cannot be empty"));
11491135
}
11501136

1151-
#[test]
1152-
fn parse_annotation_pairs_rejects_reserved_keys() {
1153-
let err = parse_annotation_pairs(&["openshell.nvidia.com/retention=ephemeral".to_string()])
1154-
.expect_err("reserved key");
1155-
assert!(err.to_string().contains("are reserved"));
1156-
1157-
assert!(
1158-
parse_annotation_pairs(&["example.com/openshell.nvidia.com/x=1".to_string()]).is_ok()
1159-
);
1160-
}
1161-
11621137
#[test]
11631138
fn parse_duration_to_ms_parses_supported_units() {
11641139
assert_eq!(parse_duration_to_ms("30s").expect("parse"), 30_000);

‎crates/openshell-cli/src/main.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3410,7 +3410,7 @@ async fn run_async() -> Result<()> {
34103410

34113411
// Parse --label and --annotation flags into maps.
34123412
let labels_map = run::parse_key_value_pairs(&labels, "--label")?;
3413-
let annotations_map = run::parse_annotation_pairs(&annotations)?;
3413+
let annotations_map = run::parse_key_value_pairs(&annotations, "--annotation")?;
34143414

34153415
// Parse --env flags into a HashMap<String, String>.
34163416
let mut env_map = run::parse_env_pairs(&envs)?;

‎crates/openshell-cli/src/run.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
//! CLI command implementations.
55
66
pub use crate::commands::common::{
7-
PolicyGetView, parse_annotation_pairs, parse_credential_expiry_cli_value, parse_env_from_pairs,
8-
parse_env_pairs,
7+
PolicyGetView, parse_credential_expiry_cli_value, parse_env_from_pairs, parse_env_pairs,
98
parse_key_value_pairs, parse_secret_material_env_pairs, warn_credential_env_vars,
109
};
1110
use crate::commands::common::{

‎docs/how-it-works/sandboxes/overview.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ openshell sandbox list --selector env=dev
437437
openshell sandbox list --selector env=dev,team=platform
438438
```
439439
440-
Use `--annotation KEY=VALUE` for non-secret metadata that does not fit label limits, such as a file path. Annotation values can contain `/`, spaces, and `=`, and appear in the `annotations` field of `sandbox get -o json` and `sandbox list -o json`. Keys starting with `openshell.nvidia.com/` are reserved.
440+
Use `--annotation KEY=VALUE` for non-secret metadata that does not fit label limits, such as a file path. Annotation values can contain `/`, spaces, and `=`, and appear in the `annotations` field of `sandbox get -o json` and `sandbox list -o json`.
441441
442442
```shell
443443
openshell sandbox create --annotation "policy-source-file=/home/you/policies/research policy.yaml" -- claude

‎skills/openshell-cli/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ Key flags:
305305
- `--driver-config-json`: Pass experimental driver-specific sandbox configuration
306306
- `--template NAME`: Create from a named sandbox workload template. Conflicts with inline workload flags such as `--from`, `--gpu`, `--cpu`, `--memory`, `--env`, `--env-from`, and `--driver-config-json`.
307307
- `--label KEY=VALUE`: Add labels for later selection (repeatable)
308-
- `--annotation KEY=VALUE`: Add non-secret metadata such as file paths; keys starting with `openshell.nvidia.com/` are reserved (repeatable)
308+
- `--annotation KEY=VALUE`: Add non-secret metadata such as file paths (repeatable)
309309
- `--env KEY=VALUE`: Set non-secret sandbox environment variables (repeatable); use `--provider` for credentials
310310
- `--env-from KEY[=ENVVAR]`: Read a sandbox environment value from the CLI process environment without putting its value in arguments; use `--provider` to keep credentials hidden from the workload
311311
- `--tty`: Allocate a retained PTY for the canonical main process

0 commit comments

Comments
 (0)