Skip to content

Commit

Permalink
Merge pull request #1867 from kube-logging/fix/nil-panic
Browse files Browse the repository at this point in the history
fix: nil ptr panic on empty secrets slice during cfg-check
  • Loading branch information
csatib02 authored Nov 28, 2024
2 parents eae0264 + cf21662 commit e45bb86
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/resources/fluentd/outputsecret.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import (
)

func (r *Reconciler) markSecrets(secrets *secret.MountSecrets) ([]runtime.Object, reconciler.DesiredState, error) {
if secrets == nil {
return nil, reconciler.StateAbsent, nil
}

var loggingRef string
if r.Logging.Spec.LoggingRef != "" {
loggingRef = r.Logging.Spec.LoggingRef
Expand All @@ -51,6 +55,7 @@ func (r *Reconciler) markSecrets(secrets *secret.MountSecrets) ([]runtime.Object
secretItem.ObjectMeta.Annotations[annotationKey] = "watched"
markedSecrets = append(markedSecrets, secretItem)
}

return markedSecrets, reconciler.StatePresent, nil
}

Expand All @@ -65,8 +70,12 @@ func (r *Reconciler) outputSecret(secrets *secret.MountSecrets, mountPath string
if fluentOutputSecret.Data == nil {
fluentOutputSecret.Data = make(map[string][]byte)
}
for _, secret := range *secrets {
fluentOutputSecret.Data[secret.MappedKey] = secret.Value

if secrets != nil {
for _, secret := range *secrets {
fluentOutputSecret.Data[secret.MappedKey] = secret.Value
}
}

return fluentOutputSecret, reconciler.StatePresent, nil
}

0 comments on commit e45bb86

Please sign in to comment.