feat: add porcelain output (#1337)

* feat: add porcaline output

* feat(du-cli): add create-stale action

add create-stale action

Signed-off-by: nils måsén

* test(flags): add alias tests

* fix stray format string ref

* fix shell liniting problems

* feat(du-cli): remove created images

* add test for common template

* fix interval/schedule logic

* use porcelain arg as template version

* fix editor save artifacts

* use simpler v1 template

Signed-off-by: nils måsén
This commit is contained in:
nils måsén 2022-08-14 10:11:31 +02:00 committed by GitHub
parent a429c373ff
commit 7900471f88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 344 additions and 63 deletions

View file

@ -73,6 +73,16 @@ var _ = Describe("Shoutrrr", func() {
})
})
When("passing a common template name", func() {
It("should format using that template", func() {
expected := `
updt1 (mock/updt1:latest): Updated
`[1:]
data := mockDataFromStates(s.UpdatedState)
Expect(getTemplatedResult(`porcelain.v1.summary-no-log`, false, data)).To(Equal(expected))
})
})
When("using legacy templates", func() {
When("no custom template is provided", func() {
@ -80,7 +90,7 @@ var _ = Describe("Shoutrrr", func() {
cmd := new(cobra.Command)
flags.RegisterNotificationFlags(cmd)
shoutrrr := createNotifier([]string{}, logrus.AllLevels, "", true, StaticData{})
shoutrrr := createNotifier([]string{}, logrus.AllLevels, "", true, StaticData{}, false)
entries := []*logrus.Entry{
{
@ -168,7 +178,6 @@ var _ = Describe("Shoutrrr", func() {
})
When("using report templates", func() {
When("no custom template is provided", func() {
It("should format the messages using the default template", func() {
expected := `4 Scanned, 2 Updated, 1 Failed
@ -236,7 +245,7 @@ Turns out everything is on fire
When("batching notifications", func() {
When("no messages are queued", func() {
It("should not send any notification", func() {
shoutrrr := newShoutrrrNotifier("", allButTrace, true, StaticData{}, time.Duration(0), "logger://")
shoutrrr := newShoutrrrNotifier("", allButTrace, true, StaticData{}, time.Duration(0), false, "logger://")
shoutrrr.StartNotification()
shoutrrr.SendNotification(nil)
Consistently(logBuffer).ShouldNot(gbytes.Say(`Shoutrrr:`))
@ -244,7 +253,7 @@ Turns out everything is on fire
})
When("at least one message is queued", func() {
It("should send a notification", func() {
shoutrrr := newShoutrrrNotifier("", allButTrace, true, StaticData{}, time.Duration(0), "logger://")
shoutrrr := newShoutrrrNotifier("", allButTrace, true, StaticData{}, time.Duration(0), false, "logger://")
shoutrrr.StartNotification()
logrus.Info("This log message is sponsored by ContainrrrVPN")
shoutrrr.SendNotification(nil)
@ -258,7 +267,7 @@ Turns out everything is on fire
shoutrrr := createNotifier([]string{"logger://"}, allButTrace, "", true, StaticData{
Host: "test.host",
Title: "",
})
}, false)
_, found := shoutrrr.params.Title()
Expect(found).ToNot(BeTrue())
})
@ -290,7 +299,7 @@ type blockingRouter struct {
}
func (b blockingRouter) Send(_ string, _ *types.Params) []error {
_ = <-b.unlock
<-b.unlock
b.sent <- true
return nil
}