Skip to content

Commit

Permalink
fix: nil ptr panic on empty secrets slice during cfg-check
Browse files Browse the repository at this point in the history
Signed-off-by: Bence Csati <[email protected]>
  • Loading branch information
csatib02 committed Nov 28, 2024
1 parent eae0264 commit cf21662
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 cf21662

Please sign in to comment.