mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
chore(lint): enable sprintfQuotedString rule from go-critic (#23401)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
@@ -69,7 +69,6 @@ linters:
|
||||
- rangeValCopy
|
||||
- regexpSimplify
|
||||
- sloppyReassign
|
||||
- sprintfQuotedString
|
||||
- tooManyResultsChecker
|
||||
- typeAssertChain
|
||||
- typeDefFirst
|
||||
|
||||
@@ -192,15 +192,15 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
badge := assets.BadgeSVG
|
||||
badge = leftRectColorPattern.ReplaceAllString(badge, fmt.Sprintf(`id="leftRect" fill="%s" $2`, leftColorString))
|
||||
badge = rightRectColorPattern.ReplaceAllString(badge, fmt.Sprintf(`id="rightRect" fill="%s" $2`, rightColorString))
|
||||
badge = leftRectColorPattern.ReplaceAllString(badge, fmt.Sprintf(`id="leftRect" fill=%q $2`, leftColorString))
|
||||
badge = rightRectColorPattern.ReplaceAllString(badge, fmt.Sprintf(`id="rightRect" fill=%q $2`, rightColorString))
|
||||
badge = replaceFirstGroupSubMatch(leftTextPattern, badge, leftText)
|
||||
badge = replaceFirstGroupSubMatch(rightTextPattern, badge, rightText)
|
||||
|
||||
if !notFound && revisionEnabled && revision != "" {
|
||||
// Enable display of revision components
|
||||
badge = displayNonePattern.ReplaceAllString(badge, `display="inline"`)
|
||||
badge = revisionRectColorPattern.ReplaceAllString(badge, fmt.Sprintf(`id="revisionRect" fill="%s" $2`, rightColorString))
|
||||
badge = revisionRectColorPattern.ReplaceAllString(badge, fmt.Sprintf(`id="revisionRect" fill=%q $2`, rightColorString))
|
||||
|
||||
adjustWidth = true
|
||||
displayedRevision = revision
|
||||
|
||||
@@ -1337,7 +1337,7 @@ func TestNamespacedSelfManagedApps(t *testing.T) {
|
||||
SetTrackingMethod("annotation").
|
||||
SetAppNamespace(fixture.AppNamespace()).
|
||||
When().
|
||||
PatchFile("resources.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/spec/source/repoURL", "value": "%s"}]`, fixture.RepoURL(fixture.RepoURLTypeFile))).
|
||||
PatchFile("resources.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/spec/source/repoURL", "value": %q}]`, fixture.RepoURL(fixture.RepoURLTypeFile))).
|
||||
CreateApp().
|
||||
Sync().
|
||||
Then().
|
||||
|
||||
@@ -1807,7 +1807,7 @@ func TestSourceNamespaceCanBeMigratedToManagedNamespaceWithoutBeingPrunedOrOutOf
|
||||
Prune(true).
|
||||
Path("guestbook-with-plain-namespace-manifest").
|
||||
When().
|
||||
PatchFile("guestbook-ui-namespace.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/metadata/name", "value": "%s"}]`, fixture.DeploymentNamespace())).
|
||||
PatchFile("guestbook-ui-namespace.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/metadata/name", "value": %q}]`, fixture.DeploymentNamespace())).
|
||||
CreateApp().
|
||||
Sync().
|
||||
Then().
|
||||
@@ -1840,7 +1840,7 @@ func TestSelfManagedApps(t *testing.T) {
|
||||
Given(t).
|
||||
Path("self-managed-app").
|
||||
When().
|
||||
PatchFile("resources.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/spec/source/repoURL", "value": "%s"}]`, fixture.RepoURL(fixture.RepoURLTypeFile))).
|
||||
PatchFile("resources.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/spec/source/repoURL", "value": %q}]`, fixture.RepoURL(fixture.RepoURLTypeFile))).
|
||||
CreateApp().
|
||||
Sync().
|
||||
Then().
|
||||
|
||||
@@ -40,7 +40,7 @@ func testHookSuccessful(t *testing.T, hookType HookType) {
|
||||
Given(t).
|
||||
Path("hook").
|
||||
When().
|
||||
PatchFile("hook.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/metadata/annotations", "value": {"argocd.argoproj.io/hook": "%s"}}]`, hookType)).
|
||||
PatchFile("hook.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/metadata/annotations", "value": {"argocd.argoproj.io/hook": %q}}]`, hookType)).
|
||||
CreateApp().
|
||||
Sync().
|
||||
Then().
|
||||
@@ -469,7 +469,7 @@ func testHookFinalizer(t *testing.T, hookType HookType) {
|
||||
}).
|
||||
Path("hook-resource-deleted-externally").
|
||||
When().
|
||||
PatchFile("hook.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/metadata/annotations", "value": {"argocd.argoproj.io/hook": "%s"}}]`, hookType)).
|
||||
PatchFile("hook.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/metadata/annotations", "value": {"argocd.argoproj.io/hook": %q}}]`, hookType)).
|
||||
CreateApp().
|
||||
Sync().
|
||||
Then().
|
||||
|
||||
@@ -344,7 +344,7 @@ func TestUseJWTToken(t *testing.T) {
|
||||
// Create second role with kubectl, to test that it will not affect 1st role
|
||||
_, err = fixture.Run("", "kubectl", "patch", "appproject", projectName, "--type", "merge",
|
||||
"-n", fixture.TestNamespace(),
|
||||
"-p", fmt.Sprintf(`{"spec":{"roles":[{"name":"%s"},{"name":"%s"}]}}`, roleName, roleName2))
|
||||
"-p", fmt.Sprintf(`{"spec":{"roles":[{"name":%q},{"name":%q}]}}`, roleName, roleName2))
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = fixture.RunCli("proj", "role", "create-token", projectName, roleName2)
|
||||
|
||||
@@ -65,8 +65,8 @@ func TestSelectiveSyncWithoutNamespace(t *testing.T) {
|
||||
}).
|
||||
SelectedResource("apps:Deployment:guestbook-ui").
|
||||
When().
|
||||
PatchFile("guestbook-ui-deployment-ns.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/metadata/namespace", "value": "%s"}]`, selectedResourceNamespace)).
|
||||
PatchFile("guestbook-ui-svc-ns.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/metadata/namespace", "value": "%s"}]`, selectedResourceNamespace)).
|
||||
PatchFile("guestbook-ui-deployment-ns.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/metadata/namespace", "value": %q}]`, selectedResourceNamespace)).
|
||||
PatchFile("guestbook-ui-svc-ns.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/metadata/namespace", "value": %q}]`, selectedResourceNamespace)).
|
||||
CreateApp().
|
||||
Sync().
|
||||
Then().
|
||||
@@ -95,8 +95,8 @@ func TestSelectiveSyncWithNamespace(t *testing.T) {
|
||||
}).
|
||||
SelectedResource(fmt.Sprintf("apps:Deployment:%s/guestbook-ui", selectedResourceNamespace)).
|
||||
When().
|
||||
PatchFile("guestbook-ui-deployment-ns.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/metadata/namespace", "value": "%s"}]`, selectedResourceNamespace)).
|
||||
PatchFile("guestbook-ui-svc-ns.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/metadata/namespace", "value": "%s"}]`, selectedResourceNamespace)).
|
||||
PatchFile("guestbook-ui-deployment-ns.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/metadata/namespace", "value": %q}]`, selectedResourceNamespace)).
|
||||
PatchFile("guestbook-ui-svc-ns.yaml", fmt.Sprintf(`[{"op": "replace", "path": "/metadata/namespace", "value": %q}]`, selectedResourceNamespace)).
|
||||
CreateApp().
|
||||
Sync().
|
||||
Then().
|
||||
|
||||
@@ -197,7 +197,7 @@ func TestSyncWithValidSAButDisallowedDestination(t *testing.T) {
|
||||
When().
|
||||
And(func() {
|
||||
// Patch destination to disallow target destination namespace
|
||||
patch := []byte(fmt.Sprintf(`{"spec": {"destinations": [{"namespace": "%s"}]}}`, "!"+fixture.DeploymentNamespace()))
|
||||
patch := []byte(fmt.Sprintf(`{"spec": {"destinations": [{"namespace": %q}]}}`, "!"+fixture.DeploymentNamespace()))
|
||||
|
||||
_, err := fixture.AppClientset.ArgoprojV1alpha1().AppProjects(fixture.TestNamespace()).Patch(t.Context(), projectName, types.MergePatchType, patch, metav1.PatchOptions{})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -38,7 +38,7 @@ func Test_JSONLogging(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
out := buf.String()
|
||||
assert.Contains(t, out, fmt.Sprintf(`"grpc.request.content":{"name":"%s"`, req.Name))
|
||||
assert.Contains(t, out, fmt.Sprintf(`"grpc.request.content":{"name":%q`, req.Name))
|
||||
}
|
||||
|
||||
func Test_logRequest(t *testing.T) {
|
||||
|
||||
@@ -316,7 +316,7 @@ func TestGetTagsFromURLPrivateRepoWithAzureWorkloadIdentityAuthentication(t *tes
|
||||
|
||||
switch r.URL.Path {
|
||||
case "/v2/":
|
||||
w.Header().Set("Www-Authenticate", fmt.Sprintf(`Bearer realm="%s",service="%s"`, mockedServerURL(), mockedServerURL()[8:]))
|
||||
w.Header().Set("Www-Authenticate", fmt.Sprintf(`Bearer realm=%q,service=%q`, mockedServerURL(), mockedServerURL()[8:]))
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
|
||||
case "/oauth2/exchange":
|
||||
@@ -437,7 +437,7 @@ func TestGetTagsFromURLEnvironmentAuthentication(t *testing.T) {
|
||||
configPath := filepath.Join(tempDir, "config.json")
|
||||
t.Setenv("DOCKER_CONFIG", tempDir)
|
||||
|
||||
config := fmt.Sprintf(`{"auths":{"%s":{"auth":"%s"}}}`, server.URL, bearerToken)
|
||||
config := fmt.Sprintf(`{"auths":{%q:{"auth":%q}}}`, server.URL, bearerToken)
|
||||
require.NoError(t, os.WriteFile(configPath, []byte(config), 0o666))
|
||||
|
||||
testCases := []struct {
|
||||
|
||||
@@ -67,7 +67,7 @@ func TestGetPasswordShouldGenerateTokenIfNotPresentInCache(t *testing.T) {
|
||||
mockServer := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case "/v2/":
|
||||
w.Header().Set("Www-Authenticate", fmt.Sprintf(`Bearer realm="%s",service="%s"`, mockedServerURL(), mockedServerURL()[8:]))
|
||||
w.Header().Set("Www-Authenticate", fmt.Sprintf(`Bearer realm=%q,service=%q`, mockedServerURL(), mockedServerURL()[8:]))
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
|
||||
case "/oauth2/exchange":
|
||||
@@ -281,16 +281,16 @@ func TestGetAccessToken_FetchNewTokenIfExistingIsExpired(t *testing.T) {
|
||||
switch r.URL.Path {
|
||||
case "/v2/":
|
||||
assert.Equal(t, "/v2/", r.URL.Path)
|
||||
w.Header().Set("Www-Authenticate", fmt.Sprintf(`Bearer realm="%s",service="%s"`, mockedServerURL(), mockedServerURL()[8:]))
|
||||
w.Header().Set("Www-Authenticate", fmt.Sprintf(`Bearer realm=%q,service=%q`, mockedServerURL(), mockedServerURL()[8:]))
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
case "/oauth2/exchange":
|
||||
assert.Equal(t, "/oauth2/exchange", r.URL.Path)
|
||||
var response string
|
||||
switch callCount {
|
||||
case 0:
|
||||
response = fmt.Sprintf(`{"refresh_token": "%s"}`, accessToken1)
|
||||
response = fmt.Sprintf(`{"refresh_token": %q}`, accessToken1)
|
||||
case 1:
|
||||
response = fmt.Sprintf(`{"refresh_token": "%s"}`, accessToken2)
|
||||
response = fmt.Sprintf(`{"refresh_token": %q}`, accessToken2)
|
||||
default:
|
||||
response = `{"refresh_token": "defaultToken"}`
|
||||
}
|
||||
@@ -335,16 +335,16 @@ func TestGetAccessToken_ReuseTokenIfExistingIsNotExpired(t *testing.T) {
|
||||
switch r.URL.Path {
|
||||
case "/v2/":
|
||||
assert.Equal(t, "/v2/", r.URL.Path)
|
||||
w.Header().Set("Www-Authenticate", fmt.Sprintf(`Bearer realm="%s",service="%s"`, mockedServerURL(), mockedServerURL()[8:]))
|
||||
w.Header().Set("Www-Authenticate", fmt.Sprintf(`Bearer realm=%q,service=%q`, mockedServerURL(), mockedServerURL()[8:]))
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
case "/oauth2/exchange":
|
||||
assert.Equal(t, "/oauth2/exchange", r.URL.Path)
|
||||
var response string
|
||||
switch callCount {
|
||||
case 0:
|
||||
response = fmt.Sprintf(`{"refresh_token": "%s"}`, accessToken1)
|
||||
response = fmt.Sprintf(`{"refresh_token": %q}`, accessToken1)
|
||||
case 1:
|
||||
response = fmt.Sprintf(`{"refresh_token": "%s"}`, accessToken2)
|
||||
response = fmt.Sprintf(`{"refresh_token": %q}`, accessToken2)
|
||||
default:
|
||||
response = `{"refresh_token": "defaultToken"}`
|
||||
}
|
||||
|
||||
@@ -618,7 +618,7 @@ func Test_affectedRevisionInfo_appRevisionHasChanged(t *testing.T) {
|
||||
// The payload's "push.changes[0].new.name" member seems to only have the branch name (based on the example payload).
|
||||
// https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#EventPayloads-Push
|
||||
var pl bitbucket.RepoPushPayload
|
||||
_ = json.Unmarshal([]byte(fmt.Sprintf(`{"push":{"changes":[{"new":{"name":"%s"}}]}}`, branchName)), &pl)
|
||||
_ = json.Unmarshal([]byte(fmt.Sprintf(`{"push":{"changes":[{"new":{"name":%q}}]}}`, branchName)), &pl)
|
||||
return pl
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user