func imageStateTestCmd(cmd *cobra.Command, args []string) { if len(args) < 1 { nmUsage(cmd, nil) } hexBytes, _ := hex.DecodeString(args[0]) req, err := protocol.NewImageStateWriteReq() if err != nil { nmUsage(nil, err) } req.Hash = hexBytes req.Confirm = false nmr, err := req.Encode() if err != nil { nmUsage(nil, err) } runner, err := getTargetCmdRunner() if err != nil { nmUsage(nil, err) } defer runner.Conn.Close() if err := runner.WriteReq(nmr); err != nil { nmUsage(nil, err) } rawRsp, err := runner.ReadResp() if err != nil { nmUsage(nil, err) } rsp, err := protocol.DecodeImageStateResponse(rawRsp.Data) if err != nil { nmUsage(nil, err) } if err := imageStatePrintRsp(rsp); err != nil { nmUsage(nil, err) } }
func imageStateConfirmCmd(cmd *cobra.Command, args []string) { req, err := protocol.NewImageStateWriteReq() if err != nil { nmUsage(nil, err) } req.Confirm = true nmr, err := req.Encode() if err != nil { nmUsage(cmd, err) } runner, err := getTargetCmdRunner() if err != nil { nmUsage(nil, err) } defer runner.Conn.Close() if err := runner.WriteReq(nmr); err != nil { nmUsage(nil, err) } rawRsp, err := runner.ReadResp() if err != nil { nmUsage(nil, err) } rsp, err := protocol.DecodeImageStateResponse(rawRsp.Data) if err != nil { nmUsage(nil, err) } if err := imageStatePrintRsp(rsp); err != nil { nmUsage(nil, err) } }