Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Add deDot for receiver: file #184

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/sinks/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type FileConfig struct {
MaxSize int `yaml:"maxsize"`
MaxAge int `yaml:"maxage"`
MaxBackups int `yaml:"maxbackups"`
DeDot bool `yaml:"deDot"`
}

func (f *FileConfig) Validate() error {
Expand All @@ -25,6 +26,7 @@ type File struct {
writer io.WriteCloser
encoder *json.Encoder
layout map[string]interface{}
DeDot bool
}

func NewFileSink(config *FileConfig) (*File, error) {
Expand All @@ -39,6 +41,7 @@ func NewFileSink(config *FileConfig) (*File, error) {
writer: writer,
encoder: json.NewEncoder(writer),
layout: config.Layout,
DeDot: config.DeDot,
}, nil
}

Expand All @@ -47,6 +50,10 @@ func (f *File) Close() {
}

func (f *File) Send(ctx context.Context, ev *kube.EnhancedEvent) error {
if f.DeDot {
de := ev.DeDot()
ev = &de
}
if f.layout == nil {
return f.encoder.Encode(ev)
}
Expand Down