From 141b1d083977d36388c4b51ca8b3cd23593e106c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nils=20m=C3=A5s=C3=A9n?= Date: Tue, 20 Apr 2021 17:19:30 +0200 Subject: [PATCH 01/10] feat: make head pull failure warning toggleable --- cmd/root.go | 3 ++- pkg/container/client.go | 41 +++++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 6f84727d3..d35895ee8 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -144,7 +144,8 @@ func PreRun(cmd *cobra.Command, _ []string) { reviveStopped, removeVolumes, includeRestarting, - warnOnHeadPullFailed, + warnOnHeadPullFailed != "never", + warnOnHeadPullFailed == "always", ) notifier = notifications.NewNotifier(cmd) diff --git a/pkg/container/client.go b/pkg/container/client.go index 93eacb789..329f835fd 100644 --- a/pkg/container/client.go +++ b/pkg/container/client.go @@ -42,7 +42,7 @@ type Client interface { // * DOCKER_HOST the docker-engine host to send api requests to // * DOCKER_TLS_VERIFY whether to verify tls certificates // * DOCKER_API_VERSION the minimum docker api version to work with -func NewClient(pullImages, includeStopped, reviveStopped, removeVolumes, includeRestarting bool, warnOnHeadFailed string) Client { +func NewClient(pullImages, includeStopped, reviveStopped, removeVolumes, includeRestarting, warnOnHeadFailedKnownReg, warnOnHeadFailedAllReg bool) Client { cli, err := sdkClient.NewClientWithOpts(sdkClient.FromEnv) if err != nil { @@ -50,35 +50,36 @@ func NewClient(pullImages, includeStopped, reviveStopped, removeVolumes, include } return dockerClient{ - api: cli, - pullImages: pullImages, - removeVolumes: removeVolumes, - includeStopped: includeStopped, - reviveStopped: reviveStopped, - includeRestarting: includeRestarting, - warnOnHeadFailed: warnOnHeadFailed, + api: cli, + pullImages: pullImages, + removeVolumes: removeVolumes, + includeStopped: includeStopped, + reviveStopped: reviveStopped, + includeRestarting: includeRestarting, + warnOnHeadFailedKnownReg: warnOnHeadFailedKnownReg, + warnOnHeadFailedAllReg: warnOnHeadFailedAllReg, } } type dockerClient struct { - api sdkClient.CommonAPIClient - pullImages bool - removeVolumes bool - includeStopped bool - reviveStopped bool - includeRestarting bool - warnOnHeadFailed string + api sdkClient.CommonAPIClient + pullImages bool + removeVolumes bool + includeStopped bool + reviveStopped bool + includeRestarting bool + warnOnHeadFailedKnownReg bool + warnOnHeadFailedAllReg bool } func (client dockerClient) WarnOnHeadPullFailed(container Container) bool { - if client.warnOnHeadFailed == "always" { + if client.warnOnHeadFailedAllReg { return true } - if client.warnOnHeadFailed == "never" { - return false + if client.warnOnHeadFailedKnownReg && registry.WarnOnAPIConsumption(container) { + return true } - - return registry.WarnOnAPIConsumption(container) + return false } func (client dockerClient) ListContainers(fn t.Filter) ([]Container, error) { From 9f77a7530d4835103b0d48d89cd20fa44bd0504c Mon Sep 17 00:00:00 2001 From: Simon Aronsson Date: Tue, 20 Apr 2021 20:41:44 +0200 Subject: [PATCH 02/10] expect prometheus tests to go through EVENTUALLY --- pkg/api/metrics/metrics_test.go | 38 ++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/pkg/api/metrics/metrics_test.go b/pkg/api/metrics/metrics_test.go index 44379eed0..55934402f 100644 --- a/pkg/api/metrics/metrics_test.go +++ b/pkg/api/metrics/metrics_test.go @@ -48,32 +48,36 @@ var _ = Describe("the metrics", func() { Failed: 1, } metrics.RegisterScan(metric) - Eventually(metrics.Default().QueueIsEmpty).Should(BeTrue()) - c := http.Client{} + Eventually(func() { + c := http.Client{} + + res, err := getWithToken(c, "http://localhost:8080/v1/metrics") - res, err := getWithToken(c, "http://localhost:8080/v1/metrics") - Expect(err).ToNot(HaveOccurred()) + Expect(err).NotTo(HaveOccurred()) + contents, err := ioutil.ReadAll(res.Body) - contents, err := ioutil.ReadAll(res.Body) - Expect(err).ToNot(HaveOccurred()) - Expect(string(contents)).To(ContainSubstring("watchtower_containers_updated 3")) - Expect(string(contents)).To(ContainSubstring("watchtower_containers_failed 1")) - Expect(string(contents)).To(ContainSubstring("watchtower_containers_scanned 4")) - Expect(string(contents)).To(ContainSubstring("watchtower_scans_total 1")) - Expect(string(contents)).To(ContainSubstring("watchtower_scans_skipped 0")) + Expect(string(contents)).To(ContainSubstring("watchtower_containers_updated 3")) + Expect(string(contents)).To(ContainSubstring("watchtower_containers_failed 1")) + Expect(string(contents)).To(ContainSubstring("watchtower_containers_scanned 4")) + Expect(string(contents)).To(ContainSubstring("watchtower_scans_total 1")) + Expect(string(contents)).To(ContainSubstring("watchtower_scans_skipped 0")) + }) for i := 0; i < 3; i++ { metrics.RegisterScan(nil) } Eventually(metrics.Default().QueueIsEmpty).Should(BeTrue()) - res, err = getWithToken(c, "http://localhost:8080/v1/metrics") - Expect(err).ToNot(HaveOccurred()) + Eventually(func() { + c := http.Client{} + + res, err := getWithToken(c, "http://localhost:8080/v1/metrics") + Expect(err).NotTo(HaveOccurred()) + contents, err := ioutil.ReadAll(res.Body) - contents, err = ioutil.ReadAll(res.Body) - Expect(err).ToNot(HaveOccurred()) - Expect(string(contents)).To(ContainSubstring("watchtower_scans_total 4")) - Expect(string(contents)).To(ContainSubstring("watchtower_scans_skipped 3")) + Expect(string(contents)).To(ContainSubstring("watchtower_scans_total 4")) + Expect(string(contents)).To(ContainSubstring("watchtower_scans_skipped 3")) + }) }) }) From 34d9d3accc8884110d38499bb0dc7d3456f41cd0 Mon Sep 17 00:00:00 2001 From: Simon Aronsson Date: Tue, 20 Apr 2021 21:10:36 +0200 Subject: [PATCH 03/10] wait for queue to be empty before checking test conditions --- pkg/api/metrics/metrics_test.go | 38 +++++++++++++++------------------ pkg/metrics/metrics.go | 19 +++++++++++------ 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/pkg/api/metrics/metrics_test.go b/pkg/api/metrics/metrics_test.go index 55934402f..44379eed0 100644 --- a/pkg/api/metrics/metrics_test.go +++ b/pkg/api/metrics/metrics_test.go @@ -48,36 +48,32 @@ var _ = Describe("the metrics", func() { Failed: 1, } metrics.RegisterScan(metric) + Eventually(metrics.Default().QueueIsEmpty).Should(BeTrue()) - Eventually(func() { - c := http.Client{} - - res, err := getWithToken(c, "http://localhost:8080/v1/metrics") + c := http.Client{} - Expect(err).NotTo(HaveOccurred()) - contents, err := ioutil.ReadAll(res.Body) + res, err := getWithToken(c, "http://localhost:8080/v1/metrics") + Expect(err).ToNot(HaveOccurred()) - Expect(string(contents)).To(ContainSubstring("watchtower_containers_updated 3")) - Expect(string(contents)).To(ContainSubstring("watchtower_containers_failed 1")) - Expect(string(contents)).To(ContainSubstring("watchtower_containers_scanned 4")) - Expect(string(contents)).To(ContainSubstring("watchtower_scans_total 1")) - Expect(string(contents)).To(ContainSubstring("watchtower_scans_skipped 0")) - }) + contents, err := ioutil.ReadAll(res.Body) + Expect(err).ToNot(HaveOccurred()) + Expect(string(contents)).To(ContainSubstring("watchtower_containers_updated 3")) + Expect(string(contents)).To(ContainSubstring("watchtower_containers_failed 1")) + Expect(string(contents)).To(ContainSubstring("watchtower_containers_scanned 4")) + Expect(string(contents)).To(ContainSubstring("watchtower_scans_total 1")) + Expect(string(contents)).To(ContainSubstring("watchtower_scans_skipped 0")) for i := 0; i < 3; i++ { metrics.RegisterScan(nil) } Eventually(metrics.Default().QueueIsEmpty).Should(BeTrue()) - Eventually(func() { - c := http.Client{} - - res, err := getWithToken(c, "http://localhost:8080/v1/metrics") - Expect(err).NotTo(HaveOccurred()) - contents, err := ioutil.ReadAll(res.Body) + res, err = getWithToken(c, "http://localhost:8080/v1/metrics") + Expect(err).ToNot(HaveOccurred()) - Expect(string(contents)).To(ContainSubstring("watchtower_scans_total 4")) - Expect(string(contents)).To(ContainSubstring("watchtower_scans_skipped 3")) - }) + contents, err = ioutil.ReadAll(res.Body) + Expect(err).ToNot(HaveOccurred()) + Expect(string(contents)).To(ContainSubstring("watchtower_scans_total 4")) + Expect(string(contents)).To(ContainSubstring("watchtower_scans_skipped 3")) }) }) diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index d8761ba89..07c8ca97d 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -16,12 +16,17 @@ type Metric struct { // Metrics is the handler processing all individual scan metrics type Metrics struct { - channel chan *Metric - scanned prometheus.Gauge - updated prometheus.Gauge - failed prometheus.Gauge - total prometheus.Counter - skipped prometheus.Counter + channel chan *Metric + scanned prometheus.Gauge + updated prometheus.Gauge + failed prometheus.Gauge + total prometheus.Counter + skipped prometheus.Counter +} + +// QueueIsEmpty checks whether any messages are enqueued in the channel +func (metrics *Metrics) QueueIsEmpty() bool { + return len(metrics.channel) == 0 } // QueueIsEmpty checks whether any messages are enqueued in the channel @@ -61,7 +66,7 @@ func Default() *Metrics { Name: "watchtower_scans_skipped", Help: "Number of skipped scans since watchtower started", }), - channel: make(chan *Metric, 10), + channel: make(chan *Metric, 10), } go metrics.HandleUpdate(metrics.channel) From c18be01bde815e0bed003a1e4c07cb17670d822f Mon Sep 17 00:00:00 2001 From: Simon Aronsson Date: Tue, 20 Apr 2021 21:36:44 +0200 Subject: [PATCH 04/10] clean up new head failure toggle --- cmd/root.go | 3 +-- pkg/container/client.go | 17 ++++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index d35895ee8..6f84727d3 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -144,8 +144,7 @@ func PreRun(cmd *cobra.Command, _ []string) { reviveStopped, removeVolumes, includeRestarting, - warnOnHeadPullFailed != "never", - warnOnHeadPullFailed == "always", + warnOnHeadPullFailed, ) notifier = notifications.NewNotifier(cmd) diff --git a/pkg/container/client.go b/pkg/container/client.go index 329f835fd..12138be50 100644 --- a/pkg/container/client.go +++ b/pkg/container/client.go @@ -42,7 +42,7 @@ type Client interface { // * DOCKER_HOST the docker-engine host to send api requests to // * DOCKER_TLS_VERIFY whether to verify tls certificates // * DOCKER_API_VERSION the minimum docker api version to work with -func NewClient(pullImages, includeStopped, reviveStopped, removeVolumes, includeRestarting, warnOnHeadFailedKnownReg, warnOnHeadFailedAllReg bool) Client { +func NewClient(pullImages, includeStopped, reviveStopped, removeVolumes, includeRestarting bool, warnOnHeadFailed string) Client { cli, err := sdkClient.NewClientWithOpts(sdkClient.FromEnv) if err != nil { @@ -56,8 +56,7 @@ func NewClient(pullImages, includeStopped, reviveStopped, removeVolumes, include includeStopped: includeStopped, reviveStopped: reviveStopped, includeRestarting: includeRestarting, - warnOnHeadFailedKnownReg: warnOnHeadFailedKnownReg, - warnOnHeadFailedAllReg: warnOnHeadFailedAllReg, + warnOnHeadFailed: warnOnHeadFailed, } } @@ -68,18 +67,18 @@ type dockerClient struct { includeStopped bool reviveStopped bool includeRestarting bool - warnOnHeadFailedKnownReg bool - warnOnHeadFailedAllReg bool + warnOnHeadFailed string } func (client dockerClient) WarnOnHeadPullFailed(container Container) bool { - if client.warnOnHeadFailedAllReg { + if client.warnOnHeadFailed == "always" { return true } - if client.warnOnHeadFailedKnownReg && registry.WarnOnAPIConsumption(container) { - return true + if client.warnOnHeadFailed == "never" { + return false } - return false + + return registry.WarnOnAPIConsumption(container) } func (client dockerClient) ListContainers(fn t.Filter) ([]Container, error) { From 47f5f497bbf4428737899796ce6040948c17ac05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nils=20m=C3=A5s=C3=A9n?= Date: Wed, 21 Apr 2021 12:02:06 +0200 Subject: [PATCH 05/10] fixup! clean up new head failure toggle --- pkg/container/client.go | 28 ++++++++++++++-------------- pkg/metrics/metrics.go | 14 +++++++------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/pkg/container/client.go b/pkg/container/client.go index 12138be50..93eacb789 100644 --- a/pkg/container/client.go +++ b/pkg/container/client.go @@ -50,24 +50,24 @@ func NewClient(pullImages, includeStopped, reviveStopped, removeVolumes, include } return dockerClient{ - api: cli, - pullImages: pullImages, - removeVolumes: removeVolumes, - includeStopped: includeStopped, - reviveStopped: reviveStopped, - includeRestarting: includeRestarting, - warnOnHeadFailed: warnOnHeadFailed, + api: cli, + pullImages: pullImages, + removeVolumes: removeVolumes, + includeStopped: includeStopped, + reviveStopped: reviveStopped, + includeRestarting: includeRestarting, + warnOnHeadFailed: warnOnHeadFailed, } } type dockerClient struct { - api sdkClient.CommonAPIClient - pullImages bool - removeVolumes bool - includeStopped bool - reviveStopped bool - includeRestarting bool - warnOnHeadFailed string + api sdkClient.CommonAPIClient + pullImages bool + removeVolumes bool + includeStopped bool + reviveStopped bool + includeRestarting bool + warnOnHeadFailed string } func (client dockerClient) WarnOnHeadPullFailed(container Container) bool { diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 07c8ca97d..91be2e69a 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -16,12 +16,12 @@ type Metric struct { // Metrics is the handler processing all individual scan metrics type Metrics struct { - channel chan *Metric - scanned prometheus.Gauge - updated prometheus.Gauge - failed prometheus.Gauge - total prometheus.Counter - skipped prometheus.Counter + channel chan *Metric + scanned prometheus.Gauge + updated prometheus.Gauge + failed prometheus.Gauge + total prometheus.Counter + skipped prometheus.Counter } // QueueIsEmpty checks whether any messages are enqueued in the channel @@ -66,7 +66,7 @@ func Default() *Metrics { Name: "watchtower_scans_skipped", Help: "Number of skipped scans since watchtower started", }), - channel: make(chan *Metric, 10), + channel: make(chan *Metric, 10), } go metrics.HandleUpdate(metrics.channel) From 447ed3ecde2a8de5a6ec0b21ce1c9a5faf75f418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nils=20m=C3=A5s=C3=A9n?= Date: Thu, 22 Apr 2021 22:46:18 +0200 Subject: [PATCH 06/10] test: add warn on head failure tests --- pkg/container/container_test.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pkg/container/container_test.go b/pkg/container/container_test.go index 8ddeb8b64..13ff4465a 100644 --- a/pkg/container/container_test.go +++ b/pkg/container/container_test.go @@ -27,31 +27,32 @@ var _ = Describe("the container", func() { It("should return a client for the api", func() { Expect(client).NotTo(BeNil()) }) - Describe("WarnOnHeadPullFailed", func() { + + Describe("WarnOnHeadPullFailed", func(){ containerUnknown := *mockContainerWithImageName("unknown.repo/prefix/imagename:latest") containerKnown := *mockContainerWithImageName("docker.io/prefix/imagename:latest") When("warn on head failure is set to \"always\"", func() { - c := NewClient(false, false, false, false, false, "always") + clientWarnAlways := dockerClient{warnOnHeadFailed: "always"} It("should always return true", func() { - Expect(c.WarnOnHeadPullFailed(containerUnknown)).To(BeTrue()) - Expect(c.WarnOnHeadPullFailed(containerKnown)).To(BeTrue()) + Expect(clientWarnAlways.WarnOnHeadPullFailed(containerUnknown)).To(BeTrue()) + Expect(clientWarnAlways.WarnOnHeadPullFailed(containerKnown)).To(BeTrue()) }) }) When("warn on head failure is set to \"auto\"", func() { - c := NewClient(false, false, false, false, false, "auto") + clientWarnAuto := dockerClient{warnOnHeadFailed: "auto"} It("should always return true", func() { - Expect(c.WarnOnHeadPullFailed(containerUnknown)).To(BeFalse()) + Expect(clientWarnAuto.WarnOnHeadPullFailed(containerUnknown)).To(BeFalse()) }) It("should", func() { - Expect(c.WarnOnHeadPullFailed(containerKnown)).To(BeTrue()) + Expect(clientWarnAuto.WarnOnHeadPullFailed(containerKnown)).To(BeTrue()) }) }) When("warn on head failure is set to \"never\"", func() { - c := NewClient(false, false, false, false, false, "never") + clientWarnNever := dockerClient{warnOnHeadFailed: "never"} It("should never return true", func() { - Expect(c.WarnOnHeadPullFailed(containerUnknown)).To(BeFalse()) - Expect(c.WarnOnHeadPullFailed(containerKnown)).To(BeFalse()) + Expect(clientWarnNever.WarnOnHeadPullFailed(containerUnknown)).To(BeFalse()) + Expect(clientWarnNever.WarnOnHeadPullFailed(containerKnown)).To(BeFalse()) }) }) }) From ea0a38f6e3431c647c164eb94ffcb881dbb45412 Mon Sep 17 00:00:00 2001 From: Simon Aronsson Date: Fri, 23 Apr 2021 15:53:35 +0200 Subject: [PATCH 07/10] fix client interface and make tests hit more lines --- internal/actions/mocks/client.go | 1 - pkg/container/container_test.go | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/internal/actions/mocks/client.go b/internal/actions/mocks/client.go index b17c98708..bce02cc89 100644 --- a/internal/actions/mocks/client.go +++ b/internal/actions/mocks/client.go @@ -83,7 +83,6 @@ func (client MockClient) IsContainerStale(c container.Container) (bool, error) { return true, nil } -// WarnOnHeadPullFailed is always true for the mock client func (client MockClient) WarnOnHeadPullFailed(c container.Container) bool { return true } diff --git a/pkg/container/container_test.go b/pkg/container/container_test.go index 13ff4465a..9087b25ec 100644 --- a/pkg/container/container_test.go +++ b/pkg/container/container_test.go @@ -27,13 +27,11 @@ var _ = Describe("the container", func() { It("should return a client for the api", func() { Expect(client).NotTo(BeNil()) }) - Describe("WarnOnHeadPullFailed", func(){ containerUnknown := *mockContainerWithImageName("unknown.repo/prefix/imagename:latest") containerKnown := *mockContainerWithImageName("docker.io/prefix/imagename:latest") - When("warn on head failure is set to \"always\"", func() { - clientWarnAlways := dockerClient{warnOnHeadFailed: "always"} + clientWarnAlways := NewClient(false, false, false, false, false, "always") It("should always return true", func() { Expect(clientWarnAlways.WarnOnHeadPullFailed(containerUnknown)).To(BeTrue()) Expect(clientWarnAlways.WarnOnHeadPullFailed(containerKnown)).To(BeTrue()) From 0c0c79ed91a12f188869fc82c2a465bf57b5646b Mon Sep 17 00:00:00 2001 From: Simon Aronsson Date: Fri, 23 Apr 2021 16:00:36 +0200 Subject: [PATCH 08/10] make all tests use NewClient instead of creating a struct pointer --- pkg/container/container_test.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/container/container_test.go b/pkg/container/container_test.go index 9087b25ec..6d2789fce 100644 --- a/pkg/container/container_test.go +++ b/pkg/container/container_test.go @@ -30,27 +30,28 @@ var _ = Describe("the container", func() { Describe("WarnOnHeadPullFailed", func(){ containerUnknown := *mockContainerWithImageName("unknown.repo/prefix/imagename:latest") containerKnown := *mockContainerWithImageName("docker.io/prefix/imagename:latest") + When("warn on head failure is set to \"always\"", func() { - clientWarnAlways := NewClient(false, false, false, false, false, "always") + c := NewClient(false, false, false, false, false, "always") It("should always return true", func() { - Expect(clientWarnAlways.WarnOnHeadPullFailed(containerUnknown)).To(BeTrue()) - Expect(clientWarnAlways.WarnOnHeadPullFailed(containerKnown)).To(BeTrue()) + Expect(c.WarnOnHeadPullFailed(containerUnknown)).To(BeTrue()) + Expect(c.WarnOnHeadPullFailed(containerKnown)).To(BeTrue()) }) }) When("warn on head failure is set to \"auto\"", func() { - clientWarnAuto := dockerClient{warnOnHeadFailed: "auto"} + c := NewClient(false, false, false, false, false, "auto") It("should always return true", func() { - Expect(clientWarnAuto.WarnOnHeadPullFailed(containerUnknown)).To(BeFalse()) + Expect(c.WarnOnHeadPullFailed(containerUnknown)).To(BeFalse()) }) It("should", func() { - Expect(clientWarnAuto.WarnOnHeadPullFailed(containerKnown)).To(BeTrue()) + Expect(c.WarnOnHeadPullFailed(containerKnown)).To(BeTrue()) }) }) When("warn on head failure is set to \"never\"", func() { - clientWarnNever := dockerClient{warnOnHeadFailed: "never"} + c := NewClient(false, false, false, false, false, "never") It("should never return true", func() { - Expect(clientWarnNever.WarnOnHeadPullFailed(containerUnknown)).To(BeFalse()) - Expect(clientWarnNever.WarnOnHeadPullFailed(containerKnown)).To(BeFalse()) + Expect(c.WarnOnHeadPullFailed(containerUnknown)).To(BeFalse()) + Expect(c.WarnOnHeadPullFailed(containerKnown)).To(BeFalse()) }) }) }) From c0a7e616b46e939f731b12d33e21888174b405c8 Mon Sep 17 00:00:00 2001 From: Simon Aronsson Date: Fri, 23 Apr 2021 16:01:37 +0200 Subject: [PATCH 09/10] fix lint issues --- internal/actions/mocks/client.go | 1 + pkg/container/container_test.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/actions/mocks/client.go b/internal/actions/mocks/client.go index bce02cc89..b17c98708 100644 --- a/internal/actions/mocks/client.go +++ b/internal/actions/mocks/client.go @@ -83,6 +83,7 @@ func (client MockClient) IsContainerStale(c container.Container) (bool, error) { return true, nil } +// WarnOnHeadPullFailed is always true for the mock client func (client MockClient) WarnOnHeadPullFailed(c container.Container) bool { return true } diff --git a/pkg/container/container_test.go b/pkg/container/container_test.go index 6d2789fce..8ddeb8b64 100644 --- a/pkg/container/container_test.go +++ b/pkg/container/container_test.go @@ -27,7 +27,7 @@ var _ = Describe("the container", func() { It("should return a client for the api", func() { Expect(client).NotTo(BeNil()) }) - Describe("WarnOnHeadPullFailed", func(){ + Describe("WarnOnHeadPullFailed", func() { containerUnknown := *mockContainerWithImageName("unknown.repo/prefix/imagename:latest") containerKnown := *mockContainerWithImageName("docker.io/prefix/imagename:latest") From 05ad748561e4380f412e34649a27adf389d960ee Mon Sep 17 00:00:00 2001 From: Simon Aronsson Date: Fri, 23 Apr 2021 16:20:23 +0200 Subject: [PATCH 10/10] see if moving ubuntu out of the matrix solves test issue --- .github/workflows/pull-request.yml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 099e259d9..24bfe13fd 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -33,7 +33,6 @@ jobs: go-version: - 1.15.x platform: - - ubuntu-latest - macos-latest - windows-latest runs-on: ${{ matrix.platform }} @@ -53,7 +52,26 @@ jobs: uses: codecov/codecov-action@v1 with: token: ${{ secrets.CODECOV_TOKEN }} - + test-ubuntu: + name: Test (Ubuntu) + runs-on: ubuntu-latest + needs: test + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.x + - name: Run tests + run: | + go test -v -coverprofile coverage.out -covermode atomic ./... + - name: Publish coverage + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} build: name: Build runs-on: ubuntu-latest