Update runtime.Event struct

This commit is contained in:
Ben Toogood 2020-05-19 10:14:07 +01:00
parent 14155c7e02
commit c19b349e96
3 changed files with 12 additions and 10 deletions

View File

@ -260,9 +260,9 @@ func (r *runtime) run(events <-chan Event) {
// NOTE: we only handle Update events for now // NOTE: we only handle Update events for now
switch event.Type { switch event.Type {
case Update: case Update:
if len(event.Service) > 0 { if event.Service != nil {
r.RLock() 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() r.RUnlock()
if !ok { if !ok {
if logger.V(logger.DebugLevel, logger.DefaultLogger) { if logger.V(logger.DebugLevel, logger.DefaultLogger) {

View File

@ -252,12 +252,12 @@ func (k *kubernetes) run(events <-chan runtime.Event) {
case runtime.Update: case runtime.Update:
// only process if there's an actual service // only process if there's an actual service
// we do not update all the things individually // we do not update all the things individually
if len(event.Service) == 0 { if event.Service == nil {
continue continue
} }
// format the name // format the name
name := client.Format(event.Service) name := client.Format(event.Service.Name)
// set the default labels // set the default labels
labels := map[string]string{ labels := map[string]string{
@ -265,8 +265,8 @@ func (k *kubernetes) run(events <-chan runtime.Event) {
"name": name, "name": name,
} }
if len(event.Version) > 0 { if len(event.Service.Version) > 0 {
labels["version"] = event.Version labels["version"] = event.Service.Version
} }
// get the deployment status // get the deployment status

View File

@ -86,14 +86,16 @@ func (t EventType) String() string {
// Event is notification event // Event is notification event
type Event struct { type Event struct {
// ID of the event
ID string
// Type is event type // Type is event type
Type EventType Type EventType
// Timestamp is event timestamp // Timestamp is event timestamp
Timestamp time.Time Timestamp time.Time
// Service is the name of the service // Service the event relates to
Service string Service *Service
// Version of the build // Options to use when processing the event
Version string Options *CreateOptions
} }
// Service is runtime service // Service is runtime service