aws / aws-nitro-enclaves-cli

Tooling for Nitro Enclave Management
Apache License 2.0
120 stars 81 forks source link

`nitro-cli terminate-enclave --all` outputs malformed JSON object if it terminates multiple enclaves #483

Open kwantam opened 1 year ago

kwantam commented 1 year ago

The output from nitro-cli terminate-enclave --all when multiple enclaves get killed is:

{
  "EnclaveName": "some_enclave",
  "EnclaveID": "i-EnclaveId1",
  "Terminated": true
}
{
  "EnclaveName": "other_enclave",
  "EnclaveID": "i-EnclaveId2",
  "Terminated": true
}

It would be handy if this were instead

[
    {
      "EnclaveName": "some_enclave",
      "EnclaveID": "i-EnclaveId1",
      "Terminated": true
    },
    {
      "EnclaveName": "other_enclave",
      "EnclaveID": "i-EnclaveId2",
      "Terminated": true
    }
]

(Relatedly, the output when no enclaves are killed is the empty string, whereas it would be handy for it to be the empty JSON array [].)

It would be great if the output were always a valid JSON array; this would help with automated processing of results, say, with jq.

petreeftime commented 1 year ago

Looking at a fix in #486, but I'm considering making the output an array for nitro-cli terminate-enclave --enclave-id ... and nitro-cli terminate-enclave --enclave-name ... to make the output consistent.

petreeftime commented 1 year ago

However, this is an output change, so it will require a minor version bump at least, to make sure it doesn't break workflows.

kwantam commented 1 year ago

Agreed on both points; always returning an array seems great, modulo backwards incompatibility.