-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: check data field for user provided tls #8200
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8200 +/- ##
==========================================
+ Coverage 60.83% 60.93% +0.09%
==========================================
Files 354 354
Lines 40935 40935
==========================================
+ Hits 24903 24942 +39
+ Misses 13772 13714 -58
- Partials 2260 2279 +19
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
pkg/controller/plan/tls_utils.go
Outdated
return errors.New("tls secret's data field shouldn't be nil") | ||
} | ||
keys := []string{secretRef.CA, secretRef.Cert, secretRef.Key} | ||
for _, key := range keys { | ||
if _, ok := secret.StringData[key]; !ok { | ||
if (secret.StringData != nil && secret.StringData[key] == "") || (secret.Data != nil && secret.Data[key] == nil) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check len(secret.Data[key]) == 0
instead, the value can be an empty string.
kubectl create secret generic test-empty-value \
--from-literal=key=''
kubectl get secret test-empty-value -o yaml
>
apiVersion: v1
data:
key: ""
kind: Secret
metadata:
creationTimestamp: "2024-09-25T03:34:43Z"
name: test-empty-value
namespace: default
resourceVersion: "2309582"
uid: ff72e8d8-cbb2-4f7b-aac8-f5b6fd97b0b1
type: Opaque
pkg/controller/plan/tls_utils.go
Outdated
@@ -109,12 +109,12 @@ func CheckTLSSecretRef(ctx context.Context, cli client.Reader, namespace string, | |||
if err := cli.Get(ctx, types.NamespacedName{Namespace: namespace, Name: secretRef.Name}, secret); err != nil { | |||
return err | |||
} | |||
if secret.StringData == nil { | |||
if secret.StringData == nil && secret.Data == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only needs to check the data field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
resolve #8199