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

Commit

Permalink
Merge pull request #1050 from weaveworks/issue/1026-look-at-git-not-c…
Browse files Browse the repository at this point in the history
…luster

Report the affected resources for each event
  • Loading branch information
squaremo authored Apr 24, 2018
2 parents d5c374c + f5cd257 commit 1fc5294
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
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

0 comments on commit 1fc5294

Please sign in to comment.