chore: unnecessary use of fmt.Sprintf d

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
This commit is contained in:
guoguangwu
2023-11-12 21:08:23 +08:00
committed by Zexi Li
parent aad04d9cdc
commit 65d66edbc7
16 changed files with 24 additions and 25 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ func (o *FakeObject) pop(playerId int) {
}
o.playerIdCount -= 1
if o.playerIdCount < 0 {
panic(fmt.Sprintf("obj overly unlocked"))
panic("obj overly unlocked")
} else if o.playerIdCount == 0 {
o.playerId = -1
}
@@ -304,7 +304,7 @@ parseEc:
return nil, newInvalidValueError(v.Key, fmt.Sprintf("invalid ec private key: %s", err))
}
}
return nil, newInvalidValueError(v.Key, fmt.Sprintf("invalid private key"))
return nil, newInvalidValueError(v.Key, "invalid private key")
}
func (v *ValidatorPrivateKey) parseFromString(s string) (crypto.PrivateKey, error) {
+1 -1
View File
@@ -534,7 +534,7 @@ func (self *SKVMHostDriver) getDeployConfig(host *models.SHost) ([]*api.DeployCo
authInfo += fmt.Sprintf("YUNION_HOST_ADMIN=%s\n", options.Options.AdminUser)
authInfo += fmt.Sprintf("YUNION_HOST_PASSWORD=%s\n", options.Options.AdminPassword)
authInfo += fmt.Sprintf("YUNION_HOST_PROJECT=%s\n", options.Options.AdminProject)
authInfo += fmt.Sprintf("YUNION_START=yes\n")
authInfo += "YUNION_START=yes\n"
apiServer, err := tokens.GetControlPlaneEndpoint()
if err != nil {
log.Errorf("Failed to get kubernetes controlplane endpoint: %v", err)
@@ -110,7 +110,7 @@ func (self *ScalingGroupDeleteTask) OnInit(ctx context.Context, obj db.IStandalo
return
}
if count != 0 {
self.taskFailed(ctx, sg, jsonutils.NewString(fmt.Sprintf("There are some guests in ScalingGroup, please delete them firstly")))
self.taskFailed(ctx, sg, jsonutils.NewString("There are some guests in ScalingGroup, please delete them firstly"))
return
}
+1 -1
View File
@@ -373,7 +373,7 @@ Loop:
if err != nil {
log.Errorf("unable to kill process '%d'", vd.Proc.Process.Pid)
}
return errors.Error(fmt.Sprintf("VDDKDisk read timeout, program blocked"))
return errors.Error("VDDKDisk read timeout, program blocked")
}
return nil
}
+1 -1
View File
@@ -200,7 +200,7 @@ func (s *SGuestSuspendTask) onSaveMemStateWait(results string) {
func (s *SGuestSuspendTask) onSaveMemStateCheck(status string) {
if status == "failed" {
hostutils.TaskFailed(s.ctx, fmt.Sprintf("Save memory state failed"))
hostutils.TaskFailed(s.ctx, "Save memory state failed")
// TODO: send cont command
return
} else if status != "completed" {
+6 -6
View File
@@ -683,12 +683,12 @@ func (s *SKVMGuestInstance) generateStopScript(data *jsonutils.JSONDict) string
cmd += "fi\n"
cmd += fmt.Sprintf("for d in $(ls -d /dev/hugepages/%s*)\n", uuid)
cmd += fmt.Sprintf("do\n")
cmd += fmt.Sprintf(" if [ -d $d ]; then\n")
cmd += fmt.Sprintf(" umount $d\n")
cmd += fmt.Sprintf(" rm -rf $d\n")
cmd += fmt.Sprintf(" fi\n")
cmd += fmt.Sprintf("done\n")
cmd += "do\n"
cmd += " if [ -d $d ]; then\n"
cmd += " umount $d\n"
cmd += " rm -rf $d\n"
cmd += " fi\n"
cmd += "done\n"
for _, nic := range nics {
if nic.Driver == api.NETWORK_DRIVER_VFIO {
+2 -2
View File
@@ -511,7 +511,7 @@ func getNicDeviceOption(
if nic.Driver == "virtio" {
if nic.NumQueues > 1 {
cmd += fmt.Sprintf(",mq=on")
cmd += ",mq=on"
}
if nic.Vectors != nil {
cmd += fmt.Sprintf(",vectors=%d", *nic.Vectors)
@@ -614,7 +614,7 @@ func getMigrateOptions(drvOpt QemuOptions, input *GenerateStartOptionsInput) []s
opts := make([]string, 0)
if input.NeedMigrate {
if input.LiveMigrateUseTLS {
opts = append(opts, fmt.Sprintf("-incoming defer"))
opts = append(opts, "-incoming defer")
} else {
opts = append(opts, fmt.Sprintf("-incoming tcp:0:%d", input.LiveMigratePort))
}
+1 -1
View File
@@ -1309,7 +1309,7 @@ func (h *SHostInfo) ensureHostRecord(zoneId string) (*api.HostDetails, error) {
// 上次未能正常offline, 补充一次健康日志
if hosts[0].HostStatus == api.HOST_ONLINE {
reason := fmt.Sprintf("The host status is online when it staring. Maybe the control center was down earlier")
reason := "The host status is online when it staring. Maybe the control center was down earlier"
logclient.AddSimpleActionLog(h, logclient.ACT_HEALTH_CHECK, map[string]string{"reason": reason}, hostutils.GetComputeSession(context.Background()).GetToken(), false)
data := jsonutils.NewDict()
data.Add(jsonutils.NewString(h.GetName()), "name")
+1 -1
View File
@@ -440,7 +440,7 @@ func (m *HmpMonitor) BlockStream(drive string, callback StringCallback) {
}
func (m *HmpMonitor) BlockJobComplete(drive string, callback StringCallback) {
m.Query(fmt.Sprintf("block_job_complete"), callback)
m.Query("block_job_complete", callback)
}
func (m *HmpMonitor) BlockReopenImage(drive, newImagePath, format string, cb StringCallback) {
+2 -2
View File
@@ -200,12 +200,12 @@ func DmRemove(dmPath string) error {
}
func DmCreate(lv1, lv2, dmName string) error {
var dmCreateScript = fmt.Sprintf(`
var dmCreateScript = `
size1=$(blockdev --getsz $1)
size2=$(blockdev --getsz $2)
echo "0 $size1 linear $1 0
$size1 $size2 linear $2 0" | dmsetup create $3
`)
`
out, err := procutils.NewRemoteCommandAsFarAsPossible("bash", "-c", dmCreateScript, "--", lv1, lv2, dmName).Output()
if err != nil {
return errors.Wrapf(err, "create device mapper failed %s", out)
+1 -1
View File
@@ -188,7 +188,7 @@ func (b *LoadbalancerCorpus) genHaproxyConfigCommon(lb *Loadbalancer, listener *
}
}
if listener.EnableHttp2 {
bind += fmt.Sprintf(" alpn h2,http/1.1")
bind += " alpn h2,http/1.1"
}
}
data["bind"] = bind
+1 -1
View File
@@ -218,7 +218,7 @@ func (this *ClientSession) getServiceVersionURLs(service, region, zone, endpoint
if err != nil {
msg = fmt.Sprintf("fail to retrieve keystone urls: %s", err)
} else if len(urls) == 0 {
msg = fmt.Sprintf("empty keystone url")
msg = "empty keystone url"
} else {
msg = fmt.Sprintf("Schema of keystone authUrl and endpoint mismatch: %s!=%s", this.client.authUrl, urls)
}
@@ -16,7 +16,6 @@ package baremetal
import (
"context"
"fmt"
"yunion.io/x/onecloud/pkg/scheduler/algorithm/predicates"
"yunion.io/x/onecloud/pkg/scheduler/core"
@@ -46,7 +45,7 @@ func (p *CdromBootPredicate) Execute(ctx context.Context, u *core.Unit, c core.C
h := predicates.NewPredicateHelper(p, u, c)
info := c.Getter().GetIpmiInfo()
if !info.CdromBoot {
h.Exclude(fmt.Sprintf("ipmi not support cdrom boot"))
h.Exclude("ipmi not support cdrom boot")
}
return h.GetResult()
}
+2 -2
View File
@@ -57,10 +57,10 @@ func switchHandler(c *gin.Context) {
var result string
if counter%2 == 1 {
o.Options.DisableBaremetalPredicates = true
result = fmt.Sprintf("ignore_baremetal_filter_switch is true")
result = "ignore_baremetal_filter_switch is true"
} else {
o.Options.DisableBaremetalPredicates = false
result = fmt.Sprintf("ignore_baremetal_filter_switch is false")
result = "ignore_baremetal_filter_switch is false"
}
c.JSON(http.StatusOK, result)
+1 -1
View File
@@ -705,7 +705,7 @@ func (img *SQemuImage) CreateQcow2(sizeMB int, compact bool, backPath string, pa
encFormat = EncryptFormatLuks
}
options = append(options, fmt.Sprintf("encrypt.format=%s", encFormat))
options = append(options, fmt.Sprintf("encrypt.key-secret=sec0"))
options = append(options, "encrypt.key-secret=sec0")
if encFormat == EncryptFormatLuks {
options = append(options, fmt.Sprintf("encrypt.cipher-alg=%s", encAlg))
}