-
Notifications
You must be signed in to change notification settings - Fork 891
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Session report collection and report templates (#981)
* wip: notification stats * make report notifications optional * linting/documentation fixes * linting/documentation fixes * merge types.Container and container.Interface * smaller naming/format fixes * use typed image/container IDs * simplify notifier and update tests * add missed doc comments * lint fixes * remove unused constructors * rename old/new current/latest
- Loading branch information
Showing
32 changed files
with
849 additions
and
594 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package mocks | ||
|
||
import ( | ||
"errors" | ||
"github.com/containrrr/watchtower/pkg/session" | ||
wt "github.com/containrrr/watchtower/pkg/types" | ||
) | ||
|
||
// CreateMockProgressReport creates a mock report from a given set of container states | ||
// All containers will be given a unique ID and name based on its state and index | ||
func CreateMockProgressReport(states ...session.State) wt.Report { | ||
|
||
stateNums := make(map[session.State]int) | ||
progress := session.Progress{} | ||
failed := make(map[wt.ContainerID]error) | ||
|
||
for _, state := range states { | ||
index := stateNums[state] | ||
|
||
switch state { | ||
case session.SkippedState: | ||
c, _ := CreateContainerForProgress(index, 41, "skip%d") | ||
progress.AddSkipped(c, errors.New("unpossible")) | ||
break | ||
case session.FreshState: | ||
c, _ := CreateContainerForProgress(index, 31, "frsh%d") | ||
progress.AddScanned(c, c.ImageID()) | ||
break | ||
case session.UpdatedState: | ||
c, newImage := CreateContainerForProgress(index, 11, "updt%d") | ||
progress.AddScanned(c, newImage) | ||
progress.MarkForUpdate(c.ID()) | ||
break | ||
case session.FailedState: | ||
c, newImage := CreateContainerForProgress(index, 21, "fail%d") | ||
progress.AddScanned(c, newImage) | ||
failed[c.ID()] = errors.New("accidentally the whole container") | ||
} | ||
|
||
stateNums[state] = index + 1 | ||
} | ||
progress.UpdateFailed(failed) | ||
|
||
return progress.Report() | ||
|
||
} |
Oops, something went wrong.