diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 7e565075..455ed3ae 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -103,7 +103,8 @@ jobs: pull: true push: true build-args: BUILD_PARAMETERS=${{ env.BUILD_PARAMETERS }} - cache-to: type=inline + cache-from: type=gha + cache-to: type=gha,mode=max platforms: linux/amd64,linux/arm,linux/arm64 tags: | ${{ env.IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_TAG }} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 317729c6..c1f70651 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -43,7 +43,7 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v3 with: - version: v1.50.1 + version: v1.54 only-new-issues: false args: --timeout 10m @@ -113,7 +113,8 @@ jobs: pull: true push: true build-args: BUILD_PARAMETERS=${{ env.BUILD_PARAMETERS }} - cache-to: type=inline + cache-from: type=gha + cache-to: type=gha,mode=max platforms: linux/amd64,linux/arm,linux/arm64 tags: | ${{ env.IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.new_tag }} diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 8fd92b7c..9bf9f395 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -2,9 +2,17 @@ package config import ( "reflect" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/log/zap" "testing" ) +func init() { + // To allow normal logging to be printed if tests fails + // Dev mode is an extra feature to make output more readable + ctrl.SetLogger(zap.New(zap.UseDevMode(true))) +} + const ( configFilePath = "../../examples/configs/test-config-uptimerobot.yaml" correctTestConfigName = "UptimeRobot" diff --git a/pkg/http/httpClient_test.go b/pkg/http/httpClient_test.go index 5cefda1e..032b6a03 100644 --- a/pkg/http/httpClient_test.go +++ b/pkg/http/httpClient_test.go @@ -2,9 +2,17 @@ package http import ( "net/http" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/log/zap" "testing" ) +func init() { + // To allow normal logging to be printed if tests fails + // Dev mode is an extra feature to make output more readable + ctrl.SetLogger(zap.New(zap.UseDevMode(true))) +} + func TestCreateHttpClient(t *testing.T) { url := "https://google.com" client := CreateHttpClient(url) diff --git a/pkg/kube/wrappers/ingress-wrapper_test.go b/pkg/kube/wrappers/ingress-wrapper_test.go index 9e83ebe4..4a7557f7 100644 --- a/pkg/kube/wrappers/ingress-wrapper_test.go +++ b/pkg/kube/wrappers/ingress-wrapper_test.go @@ -5,10 +5,18 @@ import ( "github.com/stakater/IngressMonitorController/v2/pkg/util" v1 "k8s.io/api/networking/v1" + ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" fakekubeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" + "sigs.k8s.io/controller-runtime/pkg/log/zap" ) +func init() { + // To allow normal logging to be printed if tests fails + // Dev mode is an extra feature to make output more readable + ctrl.SetLogger(zap.New(zap.UseDevMode(true))) +} + const ( testUrl = "testurl.stackator.com" ) diff --git a/pkg/kube/wrappers/routeWrapper_test.go b/pkg/kube/wrappers/routeWrapper_test.go index 34d2dabb..cfd5fee4 100644 --- a/pkg/kube/wrappers/routeWrapper_test.go +++ b/pkg/kube/wrappers/routeWrapper_test.go @@ -5,10 +5,18 @@ import ( routev1 "github.com/openshift/api/route/v1" "github.com/stakater/IngressMonitorController/v2/pkg/util" + ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" fakekubeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" + "sigs.k8s.io/controller-runtime/pkg/log/zap" ) +func init() { + // To allow normal logging to be printed if tests fails + // Dev mode is an extra feature to make output more readable + ctrl.SetLogger(zap.New(zap.UseDevMode(true))) +} + const ( routeTestUrl = "testurl.stackator.com/" ) diff --git a/pkg/monitors/appinsights/appinsights-monitor_test.go b/pkg/monitors/appinsights/appinsights-monitor_test.go index 27b05eaf..e6078e6d 100644 --- a/pkg/monitors/appinsights/appinsights-monitor_test.go +++ b/pkg/monitors/appinsights/appinsights-monitor_test.go @@ -11,8 +11,16 @@ import ( insightsAlert "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights" endpointmonitorv1alpha1 "github.com/stakater/IngressMonitorController/v2/api/v1alpha1" "github.com/stakater/IngressMonitorController/v2/pkg/models" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/log/zap" ) +func init() { + // To allow normal logging to be printed if tests fails + // Dev mode is an extra feature to make output more readable + ctrl.SetLogger(zap.New(zap.UseDevMode(true))) +} + func TestAppinsightsMonitorService_createWebTest(t *testing.T) { location := "westeurope" diff --git a/pkg/monitors/grafana/grafana-monitor_test.go b/pkg/monitors/grafana/grafana-monitor_test.go index ab97c727..ec048d7d 100644 --- a/pkg/monitors/grafana/grafana-monitor_test.go +++ b/pkg/monitors/grafana/grafana-monitor_test.go @@ -5,9 +5,17 @@ import ( "github.com/stakater/IngressMonitorController/v2/pkg/config" "github.com/stakater/IngressMonitorController/v2/pkg/models" "github.com/stakater/IngressMonitorController/v2/pkg/util" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/log/zap" "testing" ) +func init() { + // To allow normal logging to be printed if tests fails + // Dev mode is an extra feature to make output more readable + ctrl.SetLogger(zap.New(zap.UseDevMode(true))) +} + func TestAddMonitorWithCorrectValues(t *testing.T) { config := config.GetControllerConfigTest() diff --git a/pkg/monitors/monitor-proxy_test.go b/pkg/monitors/monitor-proxy_test.go index 9557bb2d..2ce711df 100644 --- a/pkg/monitors/monitor-proxy_test.go +++ b/pkg/monitors/monitor-proxy_test.go @@ -4,8 +4,16 @@ import ( "testing" "github.com/stakater/IngressMonitorController/v2/pkg/util" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/log/zap" ) +func init() { + // To allow normal logging to be printed if tests fails + // Dev mode is an extra feature to make output more readable + ctrl.SetLogger(zap.New(zap.UseDevMode(true))) +} + func TestMonitorServiceProxyOfTypeWithCorrectType(t *testing.T) { monitorType := "UptimeRobot" uptime := (&MonitorServiceProxy{}).OfType(monitorType) diff --git a/pkg/monitors/pingdom/pingdom-monitor_test.go b/pkg/monitors/pingdom/pingdom-monitor_test.go index 90311113..b2723e27 100644 --- a/pkg/monitors/pingdom/pingdom-monitor_test.go +++ b/pkg/monitors/pingdom/pingdom-monitor_test.go @@ -7,8 +7,16 @@ import ( "github.com/stakater/IngressMonitorController/v2/pkg/config" "github.com/stakater/IngressMonitorController/v2/pkg/models" "github.com/stakater/IngressMonitorController/v2/pkg/util" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/log/zap" ) +func init() { + // To allow normal logging to be printed if tests fails + // Dev mode is an extra feature to make output more readable + ctrl.SetLogger(zap.New(zap.UseDevMode(true))) +} + func TestAddMonitorWithCorrectValues(t *testing.T) { config := config.GetControllerConfigTest() diff --git a/pkg/monitors/statuscake/statuscake-monitor_test.go b/pkg/monitors/statuscake/statuscake-monitor_test.go index d8aae128..11572cd4 100644 --- a/pkg/monitors/statuscake/statuscake-monitor_test.go +++ b/pkg/monitors/statuscake/statuscake-monitor_test.go @@ -10,8 +10,16 @@ import ( "github.com/stakater/IngressMonitorController/v2/pkg/models" "github.com/stakater/IngressMonitorController/v2/pkg/util" "gotest.tools/assert" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/log/zap" ) +func init() { + // To allow normal logging to be printed if tests fails + // Dev mode is an extra feature to make output more readable + ctrl.SetLogger(zap.New(zap.UseDevMode(true))) +} + func TestAddMonitorWithCorrectValues(t *testing.T) { config := config.GetControllerConfigTest() diff --git a/pkg/monitors/updown/updown-monitor_test.go b/pkg/monitors/updown/updown-monitor_test.go index 87e34040..59589319 100644 --- a/pkg/monitors/updown/updown-monitor_test.go +++ b/pkg/monitors/updown/updown-monitor_test.go @@ -9,8 +9,16 @@ import ( "github.com/stakater/IngressMonitorController/v2/pkg/models" "github.com/stakater/IngressMonitorController/v2/pkg/util" "github.com/stretchr/testify/assert" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/log/zap" ) +func init() { + // To allow normal logging to be printed if tests fails + // Dev mode is an extra feature to make output more readable + ctrl.SetLogger(zap.New(zap.UseDevMode(true))) +} + type Block struct { Try func() Catch func(Exception) diff --git a/pkg/monitors/uptime/uptime-mappers_test.go b/pkg/monitors/uptime/uptime-mappers_test.go index b0262768..9a87f3eb 100644 --- a/pkg/monitors/uptime/uptime-mappers_test.go +++ b/pkg/monitors/uptime/uptime-mappers_test.go @@ -7,8 +7,16 @@ import ( endpointmonitorv1alpha1 "github.com/stakater/IngressMonitorController/v2/api/v1alpha1" "github.com/stakater/IngressMonitorController/v2/pkg/models" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/log/zap" ) +func init() { + // To allow normal logging to be printed if tests fails + // Dev mode is an extra feature to make output more readable + ctrl.SetLogger(zap.New(zap.UseDevMode(true))) +} + func TestUptimeMonitorMonitorToBaseMonitorMapper(t *testing.T) { uptimeMonitorObject := UptimeMonitorMonitor{Name: "Test Monitor", PK: 124, diff --git a/pkg/monitors/uptime/uptime-monitor_test.go b/pkg/monitors/uptime/uptime-monitor_test.go index 917e333d..d92ee2b6 100644 --- a/pkg/monitors/uptime/uptime-monitor_test.go +++ b/pkg/monitors/uptime/uptime-monitor_test.go @@ -7,8 +7,16 @@ import ( "github.com/stakater/IngressMonitorController/v2/pkg/config" "github.com/stakater/IngressMonitorController/v2/pkg/models" "github.com/stakater/IngressMonitorController/v2/pkg/util" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/log/zap" ) +func init() { + // To allow normal logging to be printed if tests fails + // Dev mode is an extra feature to make output more readable + ctrl.SetLogger(zap.New(zap.UseDevMode(true))) +} + func TestGetAllMonitors(t *testing.T) { config := config.GetControllerConfigTest() diff --git a/pkg/monitors/uptimerobot/uptime-mappers_test.go b/pkg/monitors/uptimerobot/uptime-mappers_test.go index 0dfa8d31..d9e37947 100644 --- a/pkg/monitors/uptimerobot/uptime-mappers_test.go +++ b/pkg/monitors/uptimerobot/uptime-mappers_test.go @@ -9,8 +9,16 @@ import ( endpointmonitorv1alpha1 "github.com/stakater/IngressMonitorController/v2/api/v1alpha1" "github.com/stakater/IngressMonitorController/v2/pkg/models" "github.com/stakater/IngressMonitorController/v2/pkg/util" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/log/zap" ) +func init() { + // To allow normal logging to be printed if tests fails + // Dev mode is an extra feature to make output more readable + ctrl.SetLogger(zap.New(zap.UseDevMode(true))) +} + func TestUptimeMonitorMonitorToBaseMonitorMapper(t *testing.T) { uptimeMonitorObject := UptimeMonitorMonitor{FriendlyName: "Test Monitor", ID: 124, URL: "https://stakater.com", Interval: 900} diff --git a/pkg/monitors/uptimerobot/uptime-monitor_test.go b/pkg/monitors/uptimerobot/uptime-monitor_test.go index f108945c..bbeb8809 100644 --- a/pkg/monitors/uptimerobot/uptime-monitor_test.go +++ b/pkg/monitors/uptimerobot/uptime-monitor_test.go @@ -8,8 +8,16 @@ import ( "github.com/stakater/IngressMonitorController/v2/pkg/config" "github.com/stakater/IngressMonitorController/v2/pkg/models" "github.com/stakater/IngressMonitorController/v2/pkg/util" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/log/zap" ) +func init() { + // To allow normal logging to be printed if tests fails + // Dev mode is an extra feature to make output more readable + ctrl.SetLogger(zap.New(zap.UseDevMode(true))) +} + // Not a test case. Cleanup to remove added dummy Monitors func TestRemoveDanglingMonitors(t *testing.T) { config := config.GetControllerConfigTest()