fix: update flux model to include revision

This commit is contained in:
Bastien Riviere 2023-09-03 13:07:42 +02:00
parent d56873fc5d
commit f2b57e4c99
Signed by: babariviere
GPG key ID: 4E5F0839249F162E

View file

@ -9,24 +9,26 @@ import (
"time"
)
// TODO: use skaffold to see why the revision is not present
type FluxNotification struct {
InvolvedObject struct {
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Name string `json:"name"`
Namespace string `json:"namespace"`
Name string `json:"name"`
UID string `json:"uid"`
APIVersion string `json:"apiVersion"`
ResourceVersion string `json:"resourceVersion"`
} `json:"involvedObject"`
Metadata struct {
KustomizeToolkitFluxcdIoRevision string `json:"kustomize.toolkit.fluxcd.io/revision"`
} `json:"metadata"`
Severity string `json:"severity"`
Reason string `json:"reason"`
Timestamp time.Time `json:"timestamp"`
Message string `json:"message"`
Reason string `json:"reason"`
Metadata struct {
CommitStatus string `json:"commit_status"`
Revision string `json:"revision"`
Summary string `json:"summary"`
} `json:"metadata"`
ReportingController string `json:"reportingController"`
ReportingInstance string `json:"reportingInstance"`
Timestamp time.Time `json:"timestamp"`
}
type FluxHandler struct{}
@ -52,7 +54,7 @@ func (f FluxHandler) FormatNotification(r io.Reader) (Notification, error) {
title := fmt.Sprintf("[%s] %s %s/%s.%s", not.Severity, not.Reason,
strings.ToLower(not.InvolvedObject.Kind), not.InvolvedObject.Namespace, not.InvolvedObject.Name)
body := not.Message + "\n\n**revision**\n" + not.Metadata.KustomizeToolkitFluxcdIoRevision
body := not.Message + "\n\n**revision**\n" + not.Metadata.Revision
l.Debug("flux notification", slog.Group("notification",
slog.String("title", title),