Explorar el Código

libnetwork: setKey(): remove intermediate buffer

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn hace 2 años
padre
commit
9d8fcb3296
Se han modificado 1 ficheros con 1 adiciones y 5 borrados
  1. 1 5
      libnetwork/sandbox_externalkey_unix.go

+ 1 - 5
libnetwork/sandbox_externalkey_unix.go

@@ -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
 	}