Skip to content

Commit

Permalink
fix nil pointer reference
Browse files Browse the repository at this point in the history
Signed-off-by: juicer <[email protected]>
  • Loading branch information
cw-Guo committed Jul 4, 2024
1 parent cb16289 commit 072be47
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions controllers/fluentbitconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,16 +403,18 @@ func (r *FluentBitConfigReconciler) generateRewriteTagConfig(
md5.Sum([]byte(cfg.Namespace)),
),
)
if cfg.Spec.Service.EmitterName != "" {
buf.WriteString(fmt.Sprintf(" Emitter_Name %s\n", cfg.Spec.Service.EmitterName))
} else {
buf.WriteString(fmt.Sprintf(" Emitter_Name re_emitted_%x\n", md5.Sum([]byte(cfg.Namespace))))
}
if cfg.Spec.Service.EmitterStorageType != "" {
buf.WriteString(fmt.Sprintf(" Emitter_Storage.type %s\n", cfg.Spec.Service.EmitterStorageType))
}
if cfg.Spec.Service.EmitterMemBufLimit != "" {
buf.WriteString(fmt.Sprintf(" Emitter_Mem_Buf_Limit %s\n", cfg.Spec.Service.EmitterMemBufLimit))
if cfg.Spec.Service != nil {
if cfg.Spec.Service.EmitterName != "" {
buf.WriteString(fmt.Sprintf(" Emitter_Name %s\n", cfg.Spec.Service.EmitterName))
} else {
buf.WriteString(fmt.Sprintf(" Emitter_Name re_emitted_%x\n", md5.Sum([]byte(cfg.Namespace))))
}
if cfg.Spec.Service.EmitterStorageType != "" {
buf.WriteString(fmt.Sprintf(" Emitter_Storage.type %s\n", cfg.Spec.Service.EmitterStorageType))
}
if cfg.Spec.Service.EmitterMemBufLimit != "" {
buf.WriteString(fmt.Sprintf(" Emitter_Mem_Buf_Limit %s\n", cfg.Spec.Service.EmitterMemBufLimit))
}
}
return buf.String()
}
Expand Down

0 comments on commit 072be47

Please sign in to comment.