oxidecomputer / oxide.rs

The Oxide Rust SDK and CLI
Mozilla Public License 2.0
38 stars 13 forks source link

When using json-body param to create idp saml, metadata param has to be in both command line and json-body #309

Open askfongjojo opened 1 year ago

askfongjojo commented 1 year ago

With #162, when attempting to pass the full request body, including idp metadata, via --json-body, it complains that --metadata-url|--metadata-value is missing.

If I exclude the idp metadata block within the json file, i.e. removing

  "idp_metadata_source": {
     "type": "base64_encoded_xml",
     "data": "..."
  },

and try oxide silo idp saml create --silo test --json-body idp.json --metadata-value $IDP_METADATA, it also doesn't like it:

thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Error("unknown variant ``, expected `url` or `base64_encoded_xml`", line: 7, column: 15)', cli/src/generated_cli.rs:7683:86
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: JoinError::Panic(Id(9), ...)', cli/src/main.rs:59:10

To use json-body (which is required when specifying a signing key pair), the only way to make it work is to include in the json the idp metadata (type populated, data as an empty string) AND supply the actual base64-encoded xml or url via --metadata-value|--metadata-url in the command line.

ahl commented 1 year ago

Ugh. That's very annoying. I'll get to work on it.

davepacheco commented 10 months ago

I ran into similar behavior with oxide image create. I assume it's the same cause:

dap@ivanova ~ $ echo '{"source": { "type": "url", "url": "http://catacomb.eng.oxide.computer/media/cloud/debian-11-genericcloud-amd64.raw", "block_size": 512 } }' | oxide image create --name my-image --description my-description --os debian --version 11 --json-body /dev/stdin
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Error("missing field `description`", line: 1, column: 139)', cli/src/generated_cli.rs:5801:84
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: JoinError::Panic(Id(17), ...)', cli/src/main.rs:59:10

dap@ivanova ~ $ echo '{"description": "dummy", "source": { "type": "url", "url": "http://catacomb.eng.oxide.computer/media/cloud/debian-11-genericcloud-amd64.raw", "block_size": 512 } }' | oxide image create --name my-image --description my-description --os debian --version 11 --json-body /dev/stdin
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Error("missing field `name`", line: 1, column: 163)', cli/src/generated_cli.rs:5801:84
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: JoinError::Panic(Id(17), ...)', cli/src/main.rs:59:10