Skip to content

Commit

Permalink
chore: use %q to simplify fmt.Sprintf (#21108)
Browse files Browse the repository at this point in the history
Signed-off-by: Joowon Lim <[email protected]>
  • Loading branch information
marinesnow34 authored Dec 9, 2024
1 parent 96d0226 commit 35c12d9
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ func TestDeleteInCluster(t *testing.T) {
Name: obj.Name,
}, got)

assert.EqualError(t, err, fmt.Sprintf("applications.argoproj.io \"%s\" not found", obj.Name))
assert.EqualError(t, err, fmt.Sprintf("applications.argoproj.io %q not found", obj.Name))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/argocd/commands/admin/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ func NewGenClusterConfigCommand(pathOpts *clientcmd.PathOptions) *cobra.Command
command.PersistentFlags().StringVar(&pathOpts.LoadingRules.ExplicitPath, pathOpts.ExplicitFileFlag, pathOpts.LoadingRules.ExplicitPath, "use a particular kubeconfig file")
command.Flags().StringVar(&bearerToken, "bearer-token", "", "Authentication token that should be used to access K8S API server")
command.Flags().BoolVar(&generateToken, "generate-bearer-token", false, "Generate authentication token that should be used to access K8S API server")
command.Flags().StringVar(&clusterOpts.ServiceAccount, "service-account", "argocd-manager", fmt.Sprintf("System namespace service account to use for kubernetes resource management. If not set then default \"%s\" SA will be used", clusterauth.ArgoCDManagerServiceAccount))
command.Flags().StringVar(&clusterOpts.ServiceAccount, "service-account", "argocd-manager", fmt.Sprintf("System namespace service account to use for kubernetes resource management. If not set then default %q SA will be used", clusterauth.ArgoCDManagerServiceAccount))
command.Flags().StringVar(&clusterOpts.SystemNamespace, "system-namespace", common.DefaultSystemNamespace, "Use different system namespace")
command.Flags().StringVarP(&outputFormat, "output", "o", "yaml", "Output format. One of: json|yaml")
command.Flags().StringArrayVar(&labels, "label", nil, "Set metadata labels (e.g. --label key=value)")
Expand Down
2 changes: 1 addition & 1 deletion cmd/argocd/commands/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func NewClusterAddCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clie
}
command.PersistentFlags().StringVar(&pathOpts.LoadingRules.ExplicitPath, pathOpts.ExplicitFileFlag, pathOpts.LoadingRules.ExplicitPath, "use a particular kubeconfig file")
command.Flags().BoolVar(&clusterOpts.Upsert, "upsert", false, "Override an existing cluster with the same name even if the spec differs")
command.Flags().StringVar(&clusterOpts.ServiceAccount, "service-account", "", fmt.Sprintf("System namespace service account to use for kubernetes resource management. If not set then default \"%s\" SA will be created", clusterauth.ArgoCDManagerServiceAccount))
command.Flags().StringVar(&clusterOpts.ServiceAccount, "service-account", "", fmt.Sprintf("System namespace service account to use for kubernetes resource management. If not set then default %q SA will be created", clusterauth.ArgoCDManagerServiceAccount))
command.Flags().StringVar(&clusterOpts.SystemNamespace, "system-namespace", common.DefaultSystemNamespace, "Use different system namespace")
command.Flags().BoolVarP(&skipConfirmation, "yes", "y", false, "Skip explicit confirmation")
command.Flags().StringArrayVar(&labels, "label", nil, "Set metadata labels (e.g. --label key=value)")
Expand Down
2 changes: 1 addition & 1 deletion controller/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func TestSetApplicationHealth_HealthImproves(t *testing.T) {
for _, tc := range testCases {
overrides := lua.ResourceHealthOverrides{
lua.GetConfigMapKey(schema.FromAPIVersionAndKind("v1", "Pod")): appv1.ResourceOverride{
HealthLua: fmt.Sprintf("hs = {}\nhs.status = \"%s\"\nhs.message = \"\"return hs", tc.newStatus),
HealthLua: fmt.Sprintf("hs = {}\nhs.status = %q\nhs.message = \"\"return hs", tc.newStatus),
},
}

Expand Down
4 changes: 2 additions & 2 deletions hack/gen-resources/generators/application_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ func (pg *ApplicationGenerator) Generate(opts *util.GenerateOpts) error {
if err != nil {
return err
}
log.Printf("Pick source \"%s\"", source)
log.Printf("Pick source %q", source)
destination, err := pg.buildDestination(opts, clusters.Items)
if err != nil {
return err
}
log.Printf("Pick destination \"%s\"", destination)
log.Printf("Pick destination %q", destination)
log.Printf("Create application")
_, err = applications.Create(context.TODO(), &v1alpha1.Application{
ObjectMeta: v1.ObjectMeta{
Expand Down
2 changes: 1 addition & 1 deletion util/argo/argo.go
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ func GenerateSpecIsDifferentErrorMessage(entity string, a, b interface{}) string
if len(difference) == 0 {
return basicMsg
}
return fmt.Sprintf("%s; difference in keys \"%s\"", basicMsg, strings.Join(difference, ","))
return fmt.Sprintf("%s; difference in keys %q", basicMsg, strings.Join(difference, ","))
}

func GetDifferentPathsBetweenStructs(a, b interface{}) ([]string, error) {
Expand Down
2 changes: 1 addition & 1 deletion util/session/sessionmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestSessionManager_AdminToken(t *testing.T) {
mapClaims := *(claims.(*jwt.MapClaims))
subject := mapClaims["sub"].(string)
if subject != "admin" {
t.Errorf("Token claim subject \"%s\" does not match expected subject \"%s\".", subject, "admin")
t.Errorf("Token claim subject %q does not match expected subject %q.", subject, "admin")
}
}

Expand Down

0 comments on commit 35c12d9

Please sign in to comment.