From acb6211a2042372032f866092c938bac2cb90721 Mon Sep 17 00:00:00 2001 From: PuneetPunamiya Date: Tue, 26 Nov 2024 12:51:06 +0530 Subject: [PATCH] Fixes git-resolver configuration for serverUrl and scmType With the latest support for multiple git providers in git-resolvers, it was having a regression issue where if value serverUrl was not given then it used to return an error Hence this patch fixes the issue to avoid regression Signed-off-by: PuneetPunamiya --- pkg/remoteresolution/resolver/git/resolver_test.go | 6 +++--- pkg/resolution/resolver/git/resolver.go | 6 ------ pkg/resolution/resolver/git/resolver_test.go | 6 +++--- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/pkg/remoteresolution/resolver/git/resolver_test.go b/pkg/remoteresolution/resolver/git/resolver_test.go index c1b043983c7..84c5eb7c3e4 100644 --- a/pkg/remoteresolution/resolver/git/resolver_test.go +++ b/pkg/remoteresolution/resolver/git/resolver_test.go @@ -645,9 +645,9 @@ func TestResolve(t *testing.T) { gitresolution.APISecretKeyKey: "token", gitresolution.APISecretNamespaceKey: system.Namespace(), }, - apiToken: "some-token", - expectedStatus: resolution.CreateResolutionRequestFailureStatus(), - expectedErr: createError("missing or empty scm-type value in configmap"), + apiToken: "some-token", + expectedCommitSHA: commitSHAsInSCMRepo[0], + expectedStatus: resolution.CreateResolutionRequestStatusWithData(mainPipelineYAML), }} for _, tc := range testCases { diff --git a/pkg/resolution/resolver/git/resolver.go b/pkg/resolution/resolver/git/resolver.go index b20104acc7e..73815e96bbb 100644 --- a/pkg/resolution/resolver/git/resolver.go +++ b/pkg/resolution/resolver/git/resolver.go @@ -530,18 +530,12 @@ func getSCMTypeAndServerURL(ctx context.Context, params map[string]string) (stri } if scmType == "" { scmType = conf.SCMType - if scmType == "" { - return "", "", fmt.Errorf("missing or empty %s value in configmap", SCMTypeKey) - } } if key, ok := params[ServerURLParam]; ok { serverURL = key } if serverURL == "" { serverURL = conf.ServerURL - if serverURL == "" { - return "", "", fmt.Errorf("missing or empty %s value in configmap", ServerURLKey) - } } return scmType, serverURL, nil } diff --git a/pkg/resolution/resolver/git/resolver_test.go b/pkg/resolution/resolver/git/resolver_test.go index 7cb7a4dc865..9001ab27cbe 100644 --- a/pkg/resolution/resolver/git/resolver_test.go +++ b/pkg/resolution/resolver/git/resolver_test.go @@ -642,9 +642,9 @@ func TestResolve(t *testing.T) { APISecretKeyKey: "token", APISecretNamespaceKey: system.Namespace(), }, - apiToken: "some-token", - expectedStatus: resolution.CreateResolutionRequestFailureStatus(), - expectedErr: createError("missing or empty scm-type value in configmap"), + apiToken: "some-token", + expectedCommitSHA: commitSHAsInSCMRepo[0], + expectedStatus: resolution.CreateResolutionRequestStatusWithData(mainPipelineYAML), }} for _, tc := range testCases {