1
0
Fork 0
mirror of https://github.com/external-secrets/external-secrets.git synced 2024-12-14 11:57:59 +00:00

fix: gitlab empty response (#4152)

Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
This commit is contained in:
Gergely Brautigam 2024-11-26 08:14:47 +01:00 committed by GitHub
parent 3218a21cb7
commit b518bae15f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -224,14 +224,22 @@ func (g *gitlabBase) GetSecret(_ context.Context, ref esv1beta1.ExternalSecretDa
data, resp, err := g.projectVariablesClient.GetVariable(g.store.ProjectID, ref.Key, vopts)
metrics.ObserveAPICall(constants.ProviderGitLab, constants.CallGitLabProjectVariableGet, err)
if err != nil {
return nil, err
}
if resp == nil {
return nil, errors.New("gitlab response is nil")
}
if !isEmptyOrWildcard(g.store.Environment) && resp.StatusCode == http.StatusNotFound {
vopts.Filter.EnvironmentScope = "*"
data, resp, err = g.projectVariablesClient.GetVariable(g.store.ProjectID, ref.Key, vopts)
metrics.ObserveAPICall(constants.ProviderGitLab, constants.CallGitLabProjectVariableGet, err)
}
if resp.StatusCode >= 400 && resp.StatusCode != http.StatusNotFound && err != nil {
return nil, err
if resp.StatusCode >= 400 && resp.StatusCode != http.StatusNotFound {
return nil, fmt.Errorf("gitlab response status code was not OK: %d", resp.StatusCode)
}
err = g.ResolveGroupIds()