From c19b349e961366de7495931c548bd120828c235b Mon Sep 17 00:00:00 2001 From: Ben Toogood Date: Tue, 19 May 2020 10:14:07 +0100 Subject: [PATCH] Update runtime.Event struct --- runtime/default.go | 4 ++-- runtime/kubernetes/kubernetes.go | 8 ++++---- runtime/runtime.go | 10 ++++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/runtime/default.go b/runtime/default.go index 869070fa..1be03e2f 100644 --- a/runtime/default.go +++ b/runtime/default.go @@ -260,9 +260,9 @@ func (r *runtime) run(events <-chan Event) { // NOTE: we only handle Update events for now switch event.Type { case Update: - if len(event.Service) > 0 { + if event.Service != nil { r.RLock() - service, ok := r.services[fmt.Sprintf("%v:%v", event.Service, event.Version)] + service, ok := r.services[fmt.Sprintf("%v:%v", event.Service.Name, event.Service.Version)] r.RUnlock() if !ok { if logger.V(logger.DebugLevel, logger.DefaultLogger) { diff --git a/runtime/kubernetes/kubernetes.go b/runtime/kubernetes/kubernetes.go index 01f61769..5ce110c6 100644 --- a/runtime/kubernetes/kubernetes.go +++ b/runtime/kubernetes/kubernetes.go @@ -252,12 +252,12 @@ func (k *kubernetes) run(events <-chan runtime.Event) { case runtime.Update: // only process if there's an actual service // we do not update all the things individually - if len(event.Service) == 0 { + if event.Service == nil { continue } // format the name - name := client.Format(event.Service) + name := client.Format(event.Service.Name) // set the default labels labels := map[string]string{ @@ -265,8 +265,8 @@ func (k *kubernetes) run(events <-chan runtime.Event) { "name": name, } - if len(event.Version) > 0 { - labels["version"] = event.Version + if len(event.Service.Version) > 0 { + labels["version"] = event.Service.Version } // get the deployment status diff --git a/runtime/runtime.go b/runtime/runtime.go index 62813973..288604ba 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -86,14 +86,16 @@ func (t EventType) String() string { // Event is notification event type Event struct { + // ID of the event + ID string // Type is event type Type EventType // Timestamp is event timestamp Timestamp time.Time - // Service is the name of the service - Service string - // Version of the build - Version string + // Service the event relates to + Service *Service + // Options to use when processing the event + Options *CreateOptions } // Service is runtime service