From 6613bc390e46ddae283af0a878fb869a86f44d47 Mon Sep 17 00:00:00 2001 From: Lukas Paluch Date: Mon, 19 May 2025 16:16:50 +0200 Subject: [PATCH 1/4] chore: update checkly-go-sdk new version 1.11.0 --- go.mod | 6 +++--- go.sum | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 96b2193..0b0ac78 100644 --- a/go.mod +++ b/go.mod @@ -55,9 +55,9 @@ require ( require ( github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/checkly/checkly-go-sdk v1.8.1 - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/checkly/checkly-go-sdk v1.11.0 + github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/zapr v1.3.0 // indirect diff --git a/go.sum b/go.sum index 2210503..3c1eb19 100644 --- a/go.sum +++ b/go.sum @@ -12,7 +12,8 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/checkly/checkly-go-sdk v1.8.1 h1:s8TAlbruie1lxGVdkqwfimMBKnTrjso26yByJI1uoPI= github.com/checkly/checkly-go-sdk v1.8.1/go.mod h1:Pd6tBOggAe41NnCU5KwqA8JvD6J20/IctszT2E0AvHo= -github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/checkly/checkly-go-sdk v1.11.0 h1:rMlELoLEZNZzxqKLPCeptjBMdDeBcM4eV/NlGK+psik= +github.com/checkly/checkly-go-sdk v1.11.0/go.mod h1:Pd6tBOggAe41NnCU5KwqA8JvD6J20/IctszT2E0AvHo= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From d3385664f45845522b38b536be185b8837d389c9 Mon Sep 17 00:00:00 2001 From: Lukas Paluch Date: Mon, 19 May 2025 16:17:12 +0200 Subject: [PATCH 2/4] feat: add privateLocation field to operator and crd fixes checkly/checkly-operator#60 fixes checkly/checkly-operator#43 --- api/checkly/v1alpha1/group_types.go | 3 +++ .../crd/bases/k8s.checklyhq.com_groups.yaml | 7 ++++++ external/checkly/group.go | 22 +++++++++++++------ .../controller/checkly/group_controller.go | 15 +++++++------ 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/api/checkly/v1alpha1/group_types.go b/api/checkly/v1alpha1/group_types.go index a2b95af..634c223 100644 --- a/api/checkly/v1alpha1/group_types.go +++ b/api/checkly/v1alpha1/group_types.go @@ -31,6 +31,9 @@ type GroupSpec struct { // Locations determines the locations where the checks are run from, see https://www.checklyhq.com/docs/monitoring/global-locations/ for a list, use AWS Region codes, ex. eu-west-1 for Ireland Locations []string `json:"locations,omitempty"` + // Locations determines the locations where the checks are run from, see https://www.checklyhq.com/docs/monitoring/global-locations/ for a list, use AWS Region codes, ex. eu-west-1 for Ireland + PrivateLocations []string `json:"privateLocations,omitempty"` + // Activated determines if the created group is muted or not, default false Activated bool `json:"muted,omitempty"` diff --git a/config/crd/bases/k8s.checklyhq.com_groups.yaml b/config/crd/bases/k8s.checklyhq.com_groups.yaml index 01aa929..062b578 100644 --- a/config/crd/bases/k8s.checklyhq.com_groups.yaml +++ b/config/crd/bases/k8s.checklyhq.com_groups.yaml @@ -55,6 +55,13 @@ spec: description: Activated determines if the created group is muted or not, default false type: boolean + privateLocations: + description: Locations determines the locations where the checks are + run from, see https://www.checklyhq.com/docs/monitoring/global-locations/ + for a list, use AWS Region codes, ex. eu-west-1 for Ireland + items: + type: string + type: array type: object status: description: GroupStatus defines the observed state of Group diff --git a/external/checkly/group.go b/external/checkly/group.go index 1608b1c..9a3970f 100644 --- a/external/checkly/group.go +++ b/external/checkly/group.go @@ -24,12 +24,13 @@ import ( ) type Group struct { - Name string - ID int64 - Locations []string - Activated bool - AlertChannels []checkly.AlertChannelSubscription - Labels map[string]string + Name string + ID int64 + Locations []string + PrivateLocations []string + Activated bool + AlertChannels []checkly.AlertChannelSubscription + Labels map[string]string } func checklyGroup(group Group) (check checkly.Group) { @@ -54,6 +55,12 @@ func checklyGroup(group Group) (check checkly.Group) { }, } + locations := []string{} + + if len(group.PrivateLocations) != 0 { + checkValueArray(group.Locations, []string{"eu-west-1"}) + } + check = checkly.Group{ Name: group.Name, Activated: true, @@ -62,7 +69,8 @@ func checklyGroup(group Group) (check checkly.Group) { LocalSetupScript: "", LocalTearDownScript: "", Concurrency: 2, - Locations: checkValueArray(group.Locations, []string{"eu-west-1"}), + Locations: locations, + PrivateLocations: &group.PrivateLocations, Tags: tags, AlertSettings: alertSettings, UseGlobalAlertSettings: false, diff --git a/internal/controller/checkly/group_controller.go b/internal/controller/checkly/group_controller.go index c51f27a..5b8385a 100644 --- a/internal/controller/checkly/group_controller.go +++ b/internal/controller/checkly/group_controller.go @@ -20,6 +20,7 @@ import ( "context" "fmt" + "github.com/checkly/checkly-go-sdk" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" @@ -28,7 +29,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/checkly/checkly-go-sdk" checklyv1alpha1 "github.com/checkly/checkly-operator/api/checkly/v1alpha1" external "github.com/checkly/checkly-operator/external/checkly" ) @@ -141,12 +141,13 @@ func (r *GroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl // Create internal Check type internalCheck := external.Group{ - Name: group.Name, - Activated: group.Spec.Activated, - Locations: group.Spec.Locations, - AlertChannels: alertChannels, - ID: group.Status.ID, - Labels: group.Labels, + Name: group.Name, + Activated: group.Spec.Activated, + Locations: group.Spec.Locations, + PrivateLocations: group.Spec.PrivateLocations, + AlertChannels: alertChannels, + ID: group.Status.ID, + Labels: group.Labels, } // ///////////////////////////// From 4f9ac012080fac576b72a7b13ae3818ccdca22be Mon Sep 17 00:00:00 2001 From: Lukas Paluch Date: Thu, 22 May 2025 13:27:50 +0200 Subject: [PATCH 3/4] test(privateLocation): add privateLocation to test --- external/checkly/group_test.go | 5 ++-- .../checkly/group_controller_test.go | 23 ++++++++++++++++--- internal/controller/checkly/suite_test.go | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/external/checkly/group_test.go b/external/checkly/group_test.go index b229665..01e0e40 100644 --- a/external/checkly/group_test.go +++ b/external/checkly/group_test.go @@ -20,8 +20,9 @@ import "testing" func TestChecklyGroup(t *testing.T) { data := Group{ - Name: "foo", - Locations: []string{"basement"}, + Name: "foo", + Locations: []string{"basement"}, + PrivateLocations: []string{"ground-floor"}, } testData := checklyGroup(data) diff --git a/internal/controller/checkly/group_controller_test.go b/internal/controller/checkly/group_controller_test.go index d1e50d9..eba8f00 100644 --- a/internal/controller/checkly/group_controller_test.go +++ b/internal/controller/checkly/group_controller_test.go @@ -20,11 +20,12 @@ import ( "time" "github.com/checkly/checkly-go-sdk" - checklyv1alpha1 "github.com/checkly/checkly-operator/api/checkly/v1alpha1" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + + checklyv1alpha1 "github.com/checkly/checkly-operator/api/checkly/v1alpha1" ) var _ = Describe("ApiCheck Controller", func() { @@ -51,6 +52,7 @@ var _ = Describe("ApiCheck Controller", func() { It("Full reconciliation", func() { updatedLocations := []string{"eu-west-2", "eu-west-1"} + updatedPrivateLocations := []string{"ground-floor"} groupKey := types.NamespacedName{ Name: "test-group", } @@ -64,8 +66,9 @@ var _ = Describe("ApiCheck Controller", func() { Name: groupKey.Name, }, Spec: checklyv1alpha1.GroupSpec{ - Locations: []string{"eu-west-1"}, - AlertChannels: []string{alertChannelKey.Name}, + Locations: []string{"eu-west-1"}, + PrivateLocations: []string{}, + AlertChannels: []string{alertChannelKey.Name}, }, } @@ -140,6 +143,20 @@ var _ = Describe("ApiCheck Controller", func() { } }, timeout, interval).Should(BeTrue()) + updated.Spec.PrivateLocations = updatedPrivateLocations + Expect(k8sClient.Update(context.Background(), updated)).Should(Succeed()) + + By("Expecting update") + Eventually(func() bool { + f := &checklyv1alpha1.Group{} + err := k8sClient.Get(context.Background(), groupKey, f) + if len(f.Spec.PrivateLocations) == 1 && err == nil { + return true + } else { + return false + } + }, timeout, interval).Should(BeTrue()) + // Delete group By("Expecting to delete successfully") Eventually(func() error { diff --git a/internal/controller/checkly/suite_test.go b/internal/controller/checkly/suite_test.go index ea9c0b2..1879a1f 100644 --- a/internal/controller/checkly/suite_test.go +++ b/internal/controller/checkly/suite_test.go @@ -22,6 +22,7 @@ import ( "os" "path/filepath" "testing" + //+kubebuilder:scaffold:imports "github.com/checkly/checkly-go-sdk" . "github.com/onsi/ginkgo" @@ -35,7 +36,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" checklyv1alpha1 "github.com/checkly/checkly-operator/api/checkly/v1alpha1" - //+kubebuilder:scaffold:imports ) // These tests use Ginkgo (BDD-style Go testing framework). Refer to From d63607e52dded08c665a57955bf1ed9d0e154d59 Mon Sep 17 00:00:00 2001 From: Lukas Paluch Date: Mon, 2 Jun 2025 12:00:44 +0200 Subject: [PATCH 4/4] chore(dependencies): update dependencies --- go.mod | 4 ++-- go.sum | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 0b0ac78..103f4b3 100644 --- a/go.mod +++ b/go.mod @@ -55,9 +55,9 @@ require ( require ( github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/checkly/checkly-go-sdk v1.11.0 - github.com/davecgh/go-spew v1.1.1 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/zapr v1.3.0 // indirect diff --git a/go.sum b/go.sum index 3c1eb19..4493e09 100644 --- a/go.sum +++ b/go.sum @@ -10,10 +10,9 @@ github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK3 github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/checkly/checkly-go-sdk v1.8.1 h1:s8TAlbruie1lxGVdkqwfimMBKnTrjso26yByJI1uoPI= -github.com/checkly/checkly-go-sdk v1.8.1/go.mod h1:Pd6tBOggAe41NnCU5KwqA8JvD6J20/IctszT2E0AvHo= github.com/checkly/checkly-go-sdk v1.11.0 h1:rMlELoLEZNZzxqKLPCeptjBMdDeBcM4eV/NlGK+psik= github.com/checkly/checkly-go-sdk v1.11.0/go.mod h1:Pd6tBOggAe41NnCU5KwqA8JvD6J20/IctszT2E0AvHo= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=