Skip to content

Commit 27ad7e1

Browse files
committed
controller/k8stools: add more error context to GetGredFromSecret
It should help to debug failed e2e tests Signed-off-by: f41gh7 <nik@victoriametrics.com>
1 parent 1cf6435 commit 27ad7e1

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

internal/controller/operator/factory/k8stools/secret_content.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,6 @@ func LoadBasicAuthSecret(ctx context.Context, rclient client.Client, ns string,
111111
return bac, nil
112112
}
113113

114-
func extractCredKey(secret *corev1.Secret, sel *corev1.SecretKeySelector) (string, error) {
115-
if s, ok := secret.Data[sel.Key]; ok {
116-
return maybeTrimSpace(string(s)), nil
117-
}
118-
return "", &KeyNotFoundError{sel.Key, sel.Name, "secret"}
119-
}
120-
121114
// GetCredFromSecret fetch content of secret by given key
122115
func GetCredFromSecret(
123116
ctx context.Context,
@@ -139,7 +132,10 @@ func GetCredFromSecret(
139132
}
140133
cache[cacheKey] = s
141134
}
142-
return extractCredKey(s, sel)
135+
if s, ok := s.Data[sel.Key]; ok {
136+
return maybeTrimSpace(string(s)), nil
137+
}
138+
return "", &KeyNotFoundError{sel.Key, cacheKey, "secret"}
143139
}
144140

145141
// GetCredFromConfigMap fetches content of configmap by given key

0 commit comments

Comments
 (0)