Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Report the affected resources for each event #1050

Merged
merged 1 commit into from
Apr 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions daemon/loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ func (d *Daemon) doSync(logger log.Logger) (retErr error) {
changedFiles, err := working.ChangedFiles(ctx, oldTagRev)
if err == nil && len(changedFiles) > 0 {
// We had some changed files, we're syncing a diff
// FIXME(michael): this won't be accurate when a file can have more than one resource
changedResources, err = d.Manifests.LoadManifests(working.Dir(), changedFiles[0], changedFiles[1:]...)
}
cancel()
Expand Down Expand Up @@ -310,7 +311,7 @@ func (d *Daemon) doSync(logger log.Logger) (retErr error) {
case update.Images:
spec := n.Spec.Spec.(update.ReleaseSpec)
noteEvents = append(noteEvents, event.Event{
ServiceIDs: serviceIDs.ToSlice(),
ServiceIDs: n.Result.AffectedResources(),
Type: event.EventRelease,
StartedAt: started,
EndedAt: time.Now().UTC(),
Expand All @@ -329,7 +330,7 @@ func (d *Daemon) doSync(logger log.Logger) (retErr error) {
case update.Auto:
spec := n.Spec.Spec.(update.Automated)
noteEvents = append(noteEvents, event.Event{
ServiceIDs: serviceIDs.ToSlice(),
ServiceIDs: n.Result.AffectedResources(),
Type: event.EventAutoRelease,
StartedAt: started,
EndedAt: time.Now().UTC(),
Expand Down
14 changes: 10 additions & 4 deletions update/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ func (r Result) ServiceIDs() []string {
return result
}

func (r Result) AffectedResources() flux.ResourceIDs {
ids := flux.ResourceIDs{}
for id, result := range r {
if result.Status == ReleaseStatusSuccess {
ids = append(ids, id)
}
}
return ids
}

func (r Result) ChangedImages() []string {
images := map[image.Ref]struct{}{}
for _, serviceResult := range r {
Expand Down Expand Up @@ -74,10 +84,6 @@ type ControllerResult struct {
PerContainer []ContainerUpdate // what happened with each container
}

func (fr ControllerResult) Msg(id flux.ResourceID) string {
return fmt.Sprintf("%s service %s as it is %s", fr.Status, id.String(), fr.Error)
}

type ContainerUpdate struct {
Container string
Current image.Ref
Expand Down