-
Notifications
You must be signed in to change notification settings - Fork 196
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8200 +/- ##
==========================================
+ Coverage 60.83% 63.75% +2.91%
==========================================
Files 354 361 +7
Lines 40935 45045 +4110
==========================================
+ Hits 24903 28718 +3815
- Misses 13772 13973 +201
- Partials 2260 2354 +94
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
/cherry-pick release-0.9 |
🤖 says: |
resolve #8199