Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Labarussias <issif+github@gadz.org>
  • Loading branch information
Issif committed Oct 26, 2023
1 parent 05cd816 commit b84274d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
8 changes: 6 additions & 2 deletions actionners/kubernetes/labelize/labelize.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ type patch struct {
Value string `json:"value,omitempty"`
}

const (
metadataLabels = "/metadata/labels/"
)

var Labelize = func(rule *rules.Rule, event *events.Event) (utils.LogLine, error) {
pod := event.GetPodName()
namespace := event.GetNamespaceName()
Expand All @@ -38,7 +42,7 @@ var Labelize = func(rule *rules.Rule, event *events.Event) (utils.LogLine, error
}
payload = append(payload, patch{
Op: "replace",
Path: "/metadata/labels/" + i,
Path: metadataLabels + i,
Value: fmt.Sprintf("%v", j),
})
}
Expand All @@ -64,7 +68,7 @@ var Labelize = func(rule *rules.Rule, event *events.Event) (utils.LogLine, error
}
payload = append(payload, patch{
Op: "remove",
Path: "/metadata/labels/" + i,
Path: metadataLabels + i,
})
}

Expand Down
3 changes: 3 additions & 0 deletions mageFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (
)

func Lint() error {
if err := sh.RunV("golangci-lint", "--version"); err != nil {
return err
}
if err := sh.RunV("golangci-lint", "run", "--timeout", "3m"); err != nil {
return err
}
Expand Down
16 changes: 10 additions & 6 deletions notifiers/k8sevents/k8sevents.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import (
"github.com/Issif/falco-talon/utils"
)

const (
falcoTalon = "falco-talon"
)

var plaintextTmpl = `Status: {{ .Status }}
Action: {{ .Action }}
Rule: {{ .Rule }}
Expand Down Expand Up @@ -60,23 +64,23 @@ var Notify = func(log utils.LogLine) error {
APIVersion: "v1beta1",
},
ObjectMeta: metav1.ObjectMeta{
GenerateName: "falco-talon.",
GenerateName: falcoTalon + ".",
},
InvolvedObject: corev1.ObjectReference{
Kind: "Pod",
Namespace: log.Objects["Namespace"],
Name: log.Objects["Pod"],
},
Reason: "falco-talon:" + log.Action + ":" + log.Status,
Reason: falcoTalon + ":" + log.Action + ":" + log.Status,
Message: strings.ReplaceAll(message, `'`, `"`),
Source: corev1.EventSource{
Component: "falco-talon",
Component: falcoTalon,
},
Type: corev1.EventTypeNormal,
EventTime: metav1.NowMicro(),
ReportingController: "falcosecurity.org/falco-talon",
ReportingInstance: "falco-talon",
Action: "falco-talon:" + log.Action,
ReportingController: "falcosecurity.org/" + falcoTalon,
ReportingInstance: falcoTalon,
Action: falcoTalon + ":" + log.Action,
}
k8sclient := kubernetes.GetClient()
_, err = k8sclient.CoreV1().Events(log.Objects["Namespace"]).Create(context.TODO(), k8sevent, metav1.CreateOptions{})
Expand Down

0 comments on commit b84274d

Please sign in to comment.