Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/go-logr/zapr"
"github.com/pdok/smooth-operator/pkg/integrations/logging"
"github.com/pdok/smooth-operator/pkg/reloader"
"github.com/peterbourgon/ff"
"go.uber.org/zap/zapcore"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
Expand Down Expand Up @@ -108,6 +109,7 @@ func main() {
flag.StringVar(&slackWebhookURL, "slack-webhook-url", "", "The webhook url for sending slack messages. Disabled if left empty")
flag.IntVar(&logLevel, "log-level", 0, "The zapcore loglevel. 0 = info, 1 = warn, 2 = error")
flag.BoolVar(&setUptimeOperatorAnnotations, "set-uptime-operator-annotations", true, "When enabled IngressRoutes get annotations that are used by the pdok/uptime-operator.")
reloader.BindFlag(flag.CommandLine)
flag.StringVar(&storageClassName, "storage-class-name", "", "The name of the storage class to use when using an ephemeral volume.")

opts := zap.Options{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/pdok/featureinfo-generator v1.5.0
github.com/pdok/ogc-capabilities-generator v1.0.4
github.com/pdok/ogc-specifications v1.0.7
github.com/pdok/smooth-operator v1.2.10
github.com/pdok/smooth-operator v1.3.0
github.com/peterbourgon/ff v1.7.1
github.com/stretchr/testify v1.12.1
github.com/traefik/traefik/v3 v3.7.16
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ github.com/pdok/ogc-capabilities-generator v1.0.4 h1:SPTQjlITPK7xrOU6Y6bLK4I1MSk
github.com/pdok/ogc-capabilities-generator v1.0.4/go.mod h1:/ryq2/xD1ulgop21OwPVtXYHgKEcRQQ+64HYo20ZHWs=
github.com/pdok/ogc-specifications v1.0.7 h1:ZWmDr7mjfhvCT5okKYNl7MqSm9k2zkJRnPLj/bnbMUY=
github.com/pdok/ogc-specifications v1.0.7/go.mod h1:GYFKRtWDDKS/elBRXQvGoMLL97yrtdRqyCFmnb4iPTA=
github.com/pdok/smooth-operator v1.2.10 h1:X3B+WsRFOsbDg3xexlr1BsPOx5/GcqBhLnFaGRRoLJ0=
github.com/pdok/smooth-operator v1.2.10/go.mod h1:Z87CdfxCKTvb7lkd19w1q+bGK0XaqHfa/ppDD8Zpnq0=
github.com/pdok/smooth-operator v1.3.0 h1:STIrzo1n3mY38RxD899sfzFiYkeyWHuIpQ6jcdQVtzI=
github.com/pdok/smooth-operator v1.3.0/go.mod h1:Z87CdfxCKTvb7lkd19w1q+bGK0XaqHfa/ppDD8Zpnq0=
github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys=
github.com/peterbourgon/ff v1.7.1 h1:xt1lxTG+Nr2+tFtysY7abFgPoH3Lug8CwYJMOmJRXhk=
github.com/peterbourgon/ff v1.7.1/go.mod h1:fYI5YA+3RDqQRExmFbHnBjEeWzh9TrS8rnRpEq7XIg0=
Expand Down
2 changes: 2 additions & 0 deletions internal/controller/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/pdok/mapserver-operator/internal/controller/mapserver"
"github.com/pdok/mapserver-operator/internal/controller/ogcwebserviceproxy"
"github.com/pdok/mapserver-operator/internal/controller/types"
"github.com/pdok/smooth-operator/pkg/reloader"
smoothoperatorutils "github.com/pdok/smooth-operator/pkg/util"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -42,6 +43,7 @@ func getBareDeployment[O pdoknlv3.WMSWFS](obj O) *appsv1.Deployment {
func mutateDeployment[R Reconciler, O pdoknlv3.WMSWFS](r R, obj O, deployment *appsv1.Deployment, configMapNames types.HashedConfigMapNames) error {
reconcilerClient := getReconcilerClient(r)
deployment.Labels = getObjectLabels(obj, deployment.Labels)
reloader.SetAnnotation(deployment)

deployment.Spec.Selector = getLabelSelector(obj)

Expand Down
21 changes: 21 additions & 0 deletions internal/controller/shared_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/pdok/mapserver-operator/api/v2beta1"
"github.com/pdok/mapserver-operator/internal/controller/types"
smoothoperatorv1 "github.com/pdok/smooth-operator/api/v1"
"github.com/pdok/smooth-operator/pkg/reloader"
smoothoperatorvalidation "github.com/pdok/smooth-operator/pkg/validation"
traefikiov1alpha1 "github.com/traefik/traefik/v3/pkg/provider/kubernetes/crd/traefikio/v1alpha1"
v2 "k8s.io/api/autoscaling/v2"
Expand Down Expand Up @@ -325,6 +326,26 @@ func testMutates[R Reconciler, O pdoknlv3.WMSWFS](reconcilerFn func() R, resourc
})
})

It("Should set or remove the Deployment Reloader annotation according to the flag", func() {
originalEnabled := reloader.IsEnabled()
DeferCleanup(func() {
reloader.SetReloaderAnnotations(originalEnabled)
})
deployment := getBareDeployment(resource)

for _, enabled := range []bool{false, true, false} {
By(fmt.Sprintf("Mutating the Deployment with Reloader annotations enabled: %t", enabled))
reloader.SetReloaderAnnotations(enabled)
Expect(mutateDeployment(reconcilerFn(), resource, deployment, configMapNames)).To(Succeed())

if enabled {
Expect(deployment.Annotations).To(HaveKeyWithValue(reloader.AutoAnnotation, reloader.AutoAnnotationValue))
} else {
Expect(deployment.Annotations).NotTo(HaveKey(reloader.AutoAnnotation))
}
}
})

It("Should generate a correct Service", func() {
testMutate("Service", getBareService(resource), outputPath+"service.yaml", func(s *corev1.Service) error {
return mutateService(reconcilerFn(), resource, s)
Expand Down
Loading