libnetwork: setKey(): remove intermediate buffer

Use json.NewDecoder() instead, which accepts a reader.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-04-28 12:33:57 +02:00
parent a813d7e961
commit 9d8fcb3296
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -60,12 +60,8 @@ func setKey() error {
containerID, shortCtlrID := args[0], args[1]
// We expect specs.State as a json string in <stdin>
stateBuf, err := io.ReadAll(os.Stdin)
if err != nil {
return err
}
var state specs.State
if err = json.Unmarshal(stateBuf, &state); err != nil {
if err := json.NewDecoder(os.Stdin).Decode(&state); err != nil {
return err
}