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
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) {

View File

@ -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

View File

@ -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