From 752410bcdc8b9ae83f5b3b811d0fcd9bf1c2ea1b Mon Sep 17 00:00:00 2001 From: guangwu Date: Fri, 12 Jan 2024 06:55:27 +0800 Subject: [PATCH] chore: unnecessary use of fmt.Sprintf (#3986) --- cmd/kots/cli/admin-console-upgrade.go | 2 +- pkg/handlers/deploy.go | 2 +- pkg/handlers/troubleshoot.go | 4 ++-- pkg/kotsadm/push_images.go | 6 +++--- pkg/version/metrics_test.go | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/kots/cli/admin-console-upgrade.go b/cmd/kots/cli/admin-console-upgrade.go index 6398be3cf7..69ab60cb56 100644 --- a/cmd/kots/cli/admin-console-upgrade.go +++ b/cmd/kots/cli/admin-console-upgrade.go @@ -33,7 +33,7 @@ func AdminConsoleUpgradeCmd() *cobra.Command { if v.GetBool("force-upgrade-kurl") { prompt := promptui.Prompt{ - Label: fmt.Sprintf("Upgrading a kotsadm instance created by kURL can result in data loss. Do you want to continue"), + Label: "Upgrading a kotsadm instance created by kURL can result in data loss. Do you want to continue", IsConfirm: true, } diff --git a/pkg/handlers/deploy.go b/pkg/handlers/deploy.go index 7e25d5c9d8..98f0af1a9b 100644 --- a/pkg/handlers/deploy.go +++ b/pkg/handlers/deploy.go @@ -83,7 +83,7 @@ func (h *Handler) DeployAppVersion(w http.ResponseWriter, r *http.Request) { deployedSequence, err := store.GetStore().GetCurrentParentSequence(a.ID, downstreams[0].ClusterID) if err != nil { - errMsg := fmt.Sprintf("failed to get deployed sequence") + errMsg := "failed to get deployed sequence" logger.Error(errors.Wrap(err, errMsg)) deployAppVersionResponse.Error = errMsg JSON(w, http.StatusInternalServerError, deployAppVersionResponse) diff --git a/pkg/handlers/troubleshoot.go b/pkg/handlers/troubleshoot.go index bdd065d750..456085ec1e 100644 --- a/pkg/handlers/troubleshoot.go +++ b/pkg/handlers/troubleshoot.go @@ -242,7 +242,7 @@ func (h *Handler) GetSupportBundleCommand(w http.ResponseWriter, r *http.Request response.Command = []string{ "curl https://krew.sh/support-bundle | bash", - fmt.Sprintf("kubectl support-bundle --load-cluster-specs"), + "kubectl support-bundle --load-cluster-specs", } opts := types.TroubleshootOptions{ @@ -263,7 +263,7 @@ func (h *Handler) GetSupportBundleCommand(w http.ResponseWriter, r *http.Request response.Command = []string{ "curl https://krew.sh/support-bundle | bash", - fmt.Sprintf("kubectl support-bundle --load-cluster-specs"), + "kubectl support-bundle --load-cluster-specs", } foundApp, err := store.GetStore().GetAppFromSlug(appSlug) diff --git a/pkg/kotsadm/push_images.go b/pkg/kotsadm/push_images.go index dd2ecfd7e1..2893168bf4 100644 --- a/pkg/kotsadm/push_images.go +++ b/pkg/kotsadm/push_images.go @@ -318,7 +318,7 @@ func PushAppImagesFromTempRegistry(airgapRootDir string, imageList []string, opt if options.LogForUI { wc := reportWriterWithProgress(imageInfos, options.ProgressWriter) reportWriter = wc.(io.Writer) - defer wc.Write([]byte(fmt.Sprintf("+status.flush:\n"))) + defer wc.Write([]byte("+status.flush:\n")) defer wc.Close() } @@ -413,7 +413,7 @@ func PushAppImagesFromDockerArchivePath(airgapRootDir string, options types.Push if options.LogForUI { wc := reportWriterWithProgress(imageInfos, options.ProgressWriter) reportWriter = wc.(io.Writer) - defer wc.Write([]byte(fmt.Sprintf("+status.flush:\n"))) + defer wc.Write([]byte("+status.flush:\n")) defer wc.Close() } @@ -489,7 +489,7 @@ func PushAppImagesFromDockerArchiveBundle(airgapBundle string, options types.Pus if options.LogForUI { wc := reportWriterWithProgress(imageInfos, options.ProgressWriter) reportWriter = wc.(io.Writer) - defer wc.Write([]byte(fmt.Sprintf("+status.flush:\n"))) + defer wc.Write([]byte("+status.flush:\n")) defer wc.Close() } diff --git a/pkg/version/metrics_test.go b/pkg/version/metrics_test.go index 883667ed34..bd1cee72d4 100644 --- a/pkg/version/metrics_test.go +++ b/pkg/version/metrics_test.go @@ -434,7 +434,7 @@ spec: } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - archiveDir, err := ioutil.TempDir("", fmt.Sprintf("kotsadm")) + archiveDir, err := ioutil.TempDir("", "kotsadm") req.NoError(err) defer os.RemoveAll(archiveDir) mockStore := tt.mockStoreFn(tt.app, tt.sequence, archiveDir, tt.files)