mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-22 13:38:26 +00:00
Fix staticcheck (ST1005) errors
staticcheck was complaining as some of the error messages returned by govmm began with a capital letter. This commit fixes the issue. Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
This commit is contained in:
parent
737f03de59
commit
4beea5133e
@ -51,18 +51,18 @@ func CreateCloudInitISO(ctx context.Context, scratchDir, isoPath string,
|
||||
|
||||
err := os.MkdirAll(dataDirPath, 0750)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to create config drive directory %s : %v",
|
||||
return fmt.Errorf("unable to create config drive directory %s : %v",
|
||||
dataDirPath, err)
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(metaDataPath, metaData, 0644)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to create %s : %v", metaDataPath, err)
|
||||
return fmt.Errorf("unable to create %s : %v", metaDataPath, err)
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(userDataPath, userData, 0644)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to create %s : %v", userDataPath, err)
|
||||
return fmt.Errorf("unable to create %s : %v", userDataPath, err)
|
||||
}
|
||||
|
||||
cmd := exec.CommandContext(ctx, "xorriso", "-as", "mkisofs", "-R", "-V", "config-2",
|
||||
@ -70,7 +70,7 @@ func CreateCloudInitISO(ctx context.Context, scratchDir, isoPath string,
|
||||
cmd.SysProcAttr = attr
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to create cloudinit iso image %v", err)
|
||||
return fmt.Errorf("unable to create cloudinit iso image %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
30
qemu/qmp.go
30
qemu/qmp.go
@ -329,14 +329,14 @@ func (q *QMP) errorDesc(errorData interface{}) (string, error) {
|
||||
// convert error to json
|
||||
data, err := json.Marshal(errorData)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Unable to extract error information: %v", err)
|
||||
return "", fmt.Errorf("unable to extract error information: %v", err)
|
||||
}
|
||||
|
||||
// see: https://github.com/qemu/qemu/blob/stable-2.12/qapi/qmp-dispatch.c#L125
|
||||
var qmpErr map[string]string
|
||||
// convert json to qmpError
|
||||
if err = json.Unmarshal(data, &qmpErr); err != nil {
|
||||
return "", fmt.Errorf("Unable to convert json to qmpError: %v", err)
|
||||
return "", fmt.Errorf("unable to convert json to qmpError: %v", err)
|
||||
}
|
||||
|
||||
return qmpErr["desc"], nil
|
||||
@ -404,7 +404,7 @@ func (q *QMP) writeNextQMPCommand(cmdQueue *list.List) {
|
||||
encodedCmd, err := json.Marshal(&cmdData)
|
||||
if err != nil {
|
||||
cmd.res <- qmpResult{
|
||||
err: fmt.Errorf("Unable to marhsall command %s: %v",
|
||||
err: fmt.Errorf("unable to marhsall command %s: %v",
|
||||
cmd.name, err),
|
||||
}
|
||||
cmdQueue.Remove(cmdEl)
|
||||
@ -419,7 +419,7 @@ func (q *QMP) writeNextQMPCommand(cmdQueue *list.List) {
|
||||
|
||||
if err != nil {
|
||||
cmd.res <- qmpResult{
|
||||
err: fmt.Errorf("Unable to write command to qmp socket %v", err),
|
||||
err: fmt.Errorf("unable to write command to qmp socket %v", err),
|
||||
}
|
||||
cmdQueue.Remove(cmdEl)
|
||||
}
|
||||
@ -689,12 +689,12 @@ func QMPStart(ctx context.Context, socket string, cfg QMPConfig, disconnectedCh
|
||||
case <-ctx.Done():
|
||||
q.Shutdown()
|
||||
<-disconnectedCh
|
||||
return nil, nil, fmt.Errorf("Canceled by caller")
|
||||
return nil, nil, fmt.Errorf("canceled by caller")
|
||||
case <-disconnectedCh:
|
||||
return nil, nil, fmt.Errorf("Lost connection to VM")
|
||||
return nil, nil, fmt.Errorf("lost connection to VM")
|
||||
case q.version = <-connectedCh:
|
||||
if q.version == nil {
|
||||
return nil, nil, fmt.Errorf("Failed to find QMP version information")
|
||||
return nil, nil, fmt.Errorf("failed to find QMP version information")
|
||||
}
|
||||
}
|
||||
|
||||
@ -860,7 +860,7 @@ func (q *QMP) ExecuteSCSIDeviceAdd(ctx context.Context, blockdevID, devID, drive
|
||||
}
|
||||
|
||||
if !isSCSIDriver {
|
||||
return fmt.Errorf("Invalid SCSI driver provided %s", driver)
|
||||
return fmt.Errorf("invalid SCSI driver provided %s", driver)
|
||||
}
|
||||
|
||||
args := map[string]interface{}{
|
||||
@ -1171,13 +1171,13 @@ func (q *QMP) ExecuteQueryHotpluggableCPUs(ctx context.Context) ([]HotpluggableC
|
||||
// convert response to json
|
||||
data, err := json.Marshal(response)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to extract CPU information: %v", err)
|
||||
return nil, fmt.Errorf("unable to extract CPU information: %v", err)
|
||||
}
|
||||
|
||||
var cpus []HotpluggableCPU
|
||||
// convert json to []HotpluggableCPU
|
||||
if err = json.Unmarshal(data, &cpus); err != nil {
|
||||
return nil, fmt.Errorf("Unable to convert json to hotpluggable CPU: %v", err)
|
||||
return nil, fmt.Errorf("unable to convert json to hotpluggable CPU: %v", err)
|
||||
}
|
||||
|
||||
return cpus, nil
|
||||
@ -1211,7 +1211,7 @@ func (q *QMP) ExecQueryMemoryDevices(ctx context.Context) ([]MemoryDevices, erro
|
||||
// convert response to json
|
||||
data, err := json.Marshal(response)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to extract memory devices information: %v", err)
|
||||
return nil, fmt.Errorf("unable to extract memory devices information: %v", err)
|
||||
}
|
||||
|
||||
var memoryDevices []MemoryDevices
|
||||
@ -1235,7 +1235,7 @@ func (q *QMP) ExecQueryCpus(ctx context.Context) ([]CPUInfo, error) {
|
||||
// convert response to json
|
||||
data, err := json.Marshal(response)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to extract memory devices information: %v", err)
|
||||
return nil, fmt.Errorf("unable to extract memory devices information: %v", err)
|
||||
}
|
||||
|
||||
var cpuInfo []CPUInfo
|
||||
@ -1259,7 +1259,7 @@ func (q *QMP) ExecQueryCpusFast(ctx context.Context) ([]CPUInfoFast, error) {
|
||||
// convert response to json
|
||||
data, err := json.Marshal(response)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to extract memory devices information: %v", err)
|
||||
return nil, fmt.Errorf("unable to extract memory devices information: %v", err)
|
||||
}
|
||||
|
||||
var cpuInfoFast []CPUInfoFast
|
||||
@ -1434,12 +1434,12 @@ func (q *QMP) ExecuteQueryMigration(ctx context.Context) (MigrationStatus, error
|
||||
|
||||
data, err := json.Marshal(response)
|
||||
if err != nil {
|
||||
return MigrationStatus{}, fmt.Errorf("Unable to extract migrate status information: %v", err)
|
||||
return MigrationStatus{}, fmt.Errorf("unable to extract migrate status information: %v", err)
|
||||
}
|
||||
|
||||
var status MigrationStatus
|
||||
if err = json.Unmarshal(data, &status); err != nil {
|
||||
return MigrationStatus{}, fmt.Errorf("Unable to convert migrate status information: %v", err)
|
||||
return MigrationStatus{}, fmt.Errorf("unable to convert migrate status information: %v", err)
|
||||
}
|
||||
|
||||
return status, nil
|
||||
|
Loading…
Reference in New Issue
Block a user