Skip to content

Commit 20a784f

Browse files
committed
feat: add privateLocation field to operator and crd
fixes #60 fixes #43
1 parent bbaa293 commit 20a784f

4 files changed

Lines changed: 33 additions & 14 deletions

File tree

api/checkly/v1alpha1/group_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ type GroupSpec struct {
3131
// 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
3232
Locations []string `json:"locations,omitempty"`
3333

34+
// 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
35+
PrivateLocations []string `json:"privateLocations,omitempty"`
36+
3437
// Activated determines if the created group is muted or not, default false
3538
Activated bool `json:"muted,omitempty"`
3639

config/crd/bases/k8s.checklyhq.com_groups.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ spec:
5555
description: Activated determines if the created group is muted or
5656
not, default false
5757
type: boolean
58+
privateLocations:
59+
description: Locations determines the locations where the checks are
60+
run from, see https://www.checklyhq.com/docs/monitoring/global-locations/
61+
for a list, use AWS Region codes, ex. eu-west-1 for Ireland
62+
items:
63+
type: string
64+
type: array
5865
type: object
5966
status:
6067
description: GroupStatus defines the observed state of Group

external/checkly/group.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ import (
2424
)
2525

2626
type Group struct {
27-
Name string
28-
ID int64
29-
Locations []string
30-
Activated bool
31-
AlertChannels []checkly.AlertChannelSubscription
32-
Labels map[string]string
27+
Name string
28+
ID int64
29+
Locations []string
30+
PrivateLocations []string
31+
Activated bool
32+
AlertChannels []checkly.AlertChannelSubscription
33+
Labels map[string]string
3334
}
3435

3536
func checklyGroup(group Group) (check checkly.Group) {
@@ -54,6 +55,12 @@ func checklyGroup(group Group) (check checkly.Group) {
5455
},
5556
}
5657

58+
locations := []string{}
59+
60+
if len(group.PrivateLocations) != 0 {
61+
checkValueArray(group.Locations, []string{"eu-west-1"})
62+
}
63+
5764
check = checkly.Group{
5865
Name: group.Name,
5966
Activated: true,
@@ -62,7 +69,8 @@ func checklyGroup(group Group) (check checkly.Group) {
6269
LocalSetupScript: "",
6370
LocalTearDownScript: "",
6471
Concurrency: 2,
65-
Locations: checkValueArray(group.Locations, []string{"eu-west-1"}),
72+
Locations: locations,
73+
PrivateLocations: &group.PrivateLocations,
6674
Tags: tags,
6775
AlertSettings: alertSettings,
6876
UseGlobalAlertSettings: false,

internal/controller/checkly/group_controller.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"fmt"
2222

23+
"github.com/checkly/checkly-go-sdk"
2324
"k8s.io/apimachinery/pkg/api/errors"
2425
"k8s.io/apimachinery/pkg/runtime"
2526
"k8s.io/apimachinery/pkg/types"
@@ -28,7 +29,6 @@ import (
2829
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
2930
"sigs.k8s.io/controller-runtime/pkg/log"
3031

31-
"github.com/checkly/checkly-go-sdk"
3232
checklyv1alpha1 "github.com/checkly/checkly-operator/api/checkly/v1alpha1"
3333
external "github.com/checkly/checkly-operator/external/checkly"
3434
)
@@ -141,12 +141,13 @@ func (r *GroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
141141

142142
// Create internal Check type
143143
internalCheck := external.Group{
144-
Name: group.Name,
145-
Activated: group.Spec.Activated,
146-
Locations: group.Spec.Locations,
147-
AlertChannels: alertChannels,
148-
ID: group.Status.ID,
149-
Labels: group.Labels,
144+
Name: group.Name,
145+
Activated: group.Spec.Activated,
146+
Locations: group.Spec.Locations,
147+
PrivateLocations: group.Spec.PrivateLocations,
148+
AlertChannels: alertChannels,
149+
ID: group.Status.ID,
150+
Labels: group.Labels,
150151
}
151152

152153
// /////////////////////////////

0 commit comments

Comments
 (0)