From a593141d73e063fbff7fe9a44edb3dad7252b512 Mon Sep 17 00:00:00 2001 From: Roi Vazquez Date: Mon, 18 Dec 2023 13:36:38 +0100 Subject: [PATCH] Import revision and cleanup --- Makefile | 2 +- PROJECT | 26 +- README.md | 6 +- api/v1alpha1/apicast_types.go | 63 ++- api/v1alpha1/autossl_types.go | 55 ++- api/v1alpha1/backend_types.go | 93 ++-- api/v1alpha1/common_types.go | 6 +- api/v1alpha1/common_types_test.go | 457 +++++++++--------- api/v1alpha1/corsproxy_types.go | 33 +- api/v1alpha1/echoapi_types.go | 43 +- api/v1alpha1/mappingservice_types.go | 45 +- api/v1alpha1/marin3r_types.go | 2 +- api/v1alpha1/marin3r_types_test.go | 2 +- api/v1alpha1/redisshard_types.go | 9 +- api/v1alpha1/sentinel_types.go | 31 +- api/v1alpha1/sentinel_types_test.go | 8 +- api/v1alpha1/shardedredisbackup_types.go | 11 +- api/v1alpha1/system_types.go | 163 ++++--- api/v1alpha1/twemproxy_types.go | 28 +- api/v1alpha1/twemproxyconfig_types.go | 9 +- api/v1alpha1/zync_types.go | 81 ++-- .../saas-operator.clusterserviceversion.yaml | 20 +- config/manager/kustomization.yaml | 2 +- .../saas-operator.clusterserviceversion.yaml | 12 +- controllers/apicast_controller.go | 14 +- controllers/apicast_controller_suite_test.go | 38 +- controllers/autossl_controller.go | 14 +- controllers/autossl_controller_suite_test.go | 22 +- controllers/backend_controller.go | 14 +- controllers/backend_controller_suite_test.go | 62 +-- controllers/corsproxy_controller.go | 14 +- .../corsproxy_controller_suite_test.go | 14 +- controllers/echoapi_controller.go | 14 +- controllers/echoapi_controller_suite_test.go | 14 +- controllers/mappingservice_controller.go | 14 +- .../mappingservice_controller_suite_test.go | 14 +- controllers/reconciler_config.go | 2 +- controllers/redisshard_controller.go | 17 +- .../redisshard_controller_suite_test.go | 4 +- controllers/sentinel_controller.go | 19 +- controllers/sentinel_controller_suite_test.go | 4 +- controllers/shardedredisbackup_controller.go | 31 +- .../shardedredisbackup_controller_test.go | 37 +- controllers/suite_test.go | 8 +- controllers/system_controller.go | 14 +- controllers/system_controller_suite_test.go | 165 ++++--- controllers/twemproxyconfig_controller.go | 23 +- controllers/zync_controller.go | 14 +- controllers/zync_controller_suite_test.go | 32 +- go.mod | 7 +- go.sum | 2 + main.go | 18 +- pkg/generators/apicast/config/options.go | 4 +- pkg/generators/apicast/deployment.go | 13 +- pkg/generators/apicast/generator.go | 14 +- pkg/generators/apicast/services.go | 2 +- pkg/generators/autossl/config/options.go | 4 +- pkg/generators/autossl/deployment.go | 11 +- pkg/generators/autossl/generator.go | 12 +- pkg/generators/autossl/service.go | 2 +- pkg/generators/backend/config/cron_options.go | 4 +- .../backend/config/listener_options.go | 4 +- .../backend/config/worker_options.go | 4 +- pkg/generators/backend/cron_deployment.go | 11 +- pkg/generators/backend/generator.go | 28 +- pkg/generators/backend/listener_deployment.go | 15 +- pkg/generators/backend/services.go | 2 +- pkg/generators/backend/worker_deployment.go | 13 +- pkg/generators/base_options.go | 2 +- pkg/generators/corsproxy/config/options.go | 4 +- pkg/generators/corsproxy/deployment.go | 11 +- pkg/generators/corsproxy/generator.go | 18 +- pkg/generators/corsproxy/service.go | 2 +- pkg/generators/echoapi/deployment.go | 13 +- pkg/generators/echoapi/generator.go | 10 +- pkg/generators/echoapi/service.go | 2 +- .../mappingservice/config/options.go | 4 +- pkg/generators/mappingservice/deployment.go | 11 +- pkg/generators/mappingservice/generator.go | 16 +- pkg/generators/mappingservice/service.go | 2 +- pkg/generators/redisshard/generator.go | 4 +- pkg/generators/redisshard/statefulset.go | 17 +- pkg/generators/sentinel/config/options.go | 2 +- pkg/generators/sentinel/generator.go | 16 +- pkg/generators/sentinel/generator_test.go | 6 +- pkg/generators/sentinel/services.go | 2 +- pkg/generators/sentinel/statefulset.go | 17 +- pkg/generators/system/app_deployment.go | 8 +- pkg/generators/system/app_service.go | 2 +- pkg/generators/system/config/options.go | 8 +- pkg/generators/system/console_statefulset.go | 13 +- pkg/generators/system/generator.go | 16 +- pkg/generators/system/searchd_service.go | 2 +- pkg/generators/system/searchd_statefulset.go | 9 +- pkg/generators/system/sidekiq_deployment.go | 8 +- pkg/generators/system/tekton_task.go | 8 +- pkg/generators/twemproxyconfig/configmap.go | 4 +- .../twemproxyconfig/configmap_test.go | 6 +- pkg/generators/twemproxyconfig/generator.go | 12 +- .../twemproxyconfig/generator_test.go | 12 +- pkg/generators/zync/api_deployment.go | 11 +- pkg/generators/zync/config/api_options.go | 8 +- pkg/generators/zync/config/que_options.go | 8 +- pkg/generators/zync/console_statefulset.go | 9 +- pkg/generators/zync/generator.go | 21 +- pkg/generators/zync/que_deployment.go | 12 +- pkg/generators/zync/services.go | 2 +- pkg/reconcilers/threads/manager.go | 2 +- .../workloads/deployment_based_workload.go | 12 +- .../deployment_based_workload_test.go | 27 +- pkg/reconcilers/workloads/interfaces.go | 4 +- pkg/reconcilers/workloads/test/suite_test.go | 6 +- .../workloads/test/test_controller.go | 23 +- .../test/test_controller_suite_test.go | 4 +- pkg/redis/backup/check.go | 4 +- pkg/redis/backup/manager.go | 2 +- pkg/redis/backup/s3upload.go | 12 +- pkg/redis/events/watcher.go | 6 +- pkg/redis/metrics/cluster_status_metrics.go | 4 +- pkg/redis/metrics/sentinel_metrics.go | 8 +- pkg/redis/server/fake.go | 2 +- pkg/redis/server/pool_test.go | 2 +- pkg/redis/server/server.go | 2 +- pkg/redis/server/server_test.go | 2 +- pkg/redis/sharded/discover.go | 2 +- pkg/redis/sharded/discover_test.go | 4 +- pkg/redis/sharded/redis_server.go | 4 +- pkg/redis/sharded/redis_server_test.go | 6 +- pkg/redis/sharded/redis_shard.go | 14 +- pkg/redis/sharded/redis_shard_test.go | 6 +- pkg/redis/sharded/redis_sharded_cluster.go | 12 +- .../sharded/redis_sharded_cluster_test.go | 6 +- pkg/redis/sharded/sentinel_server.go | 10 +- pkg/redis/sharded/sentinel_server_test.go | 6 +- .../envoyconfig/auto/secrets.go | 6 +- .../envoyconfig/auto/secrets_test.go | 30 +- .../envoyconfig/factory/default.go | 2 +- .../envoyconfig/factory/factory.go | 2 +- .../envoyconfig/factory/factory_test.go | 2 +- pkg/resource_builders/envoyconfig/resource.go | 12 +- .../envoyconfig/resource_test.go | 34 +- .../envoyconfig/templates/clusters.go | 2 +- .../envoyconfig/templates/clusters_test.go | 8 +- .../envoyconfig/templates/listeners.go | 2 +- .../envoyconfig/templates/listeners_test.go | 31 +- .../envoyconfig/templates/rawconfig.go | 2 +- .../envoyconfig/templates/rawconfig_test.go | 2 +- .../templates/routeconfigurations.go | 6 +- .../templates/routeconfigurations_test.go | 2 +- .../envoyconfig/templates/runtimes.go | 2 +- .../envoyconfig/templates/runtimes_test.go | 2 +- .../grafanadashboard/resource.go | 4 +- pkg/resource_builders/hpa/resource.go | 2 +- pkg/resource_builders/marin3r/util.go | 4 +- pkg/resource_builders/marin3r/util_test.go | 12 +- pkg/resource_builders/pdb/resource.go | 2 +- pkg/resource_builders/pod/environment.go | 2 +- pkg/resource_builders/pod/environment_test.go | 10 +- .../pod/externalsecrets_test.go | 6 +- pkg/resource_builders/pod/util.go | 2 +- pkg/resource_builders/service/util.go | 2 +- pkg/resource_builders/twemproxy/config.go | 2 +- pkg/resource_builders/twemproxy/options.go | 4 +- pkg/resource_builders/twemproxy/util.go | 10 +- pkg/resource_builders/twemproxy/util_test.go | 58 +-- pkg/util/hash.go | 23 - pkg/util/k8s.go | 30 -- pkg/util/k8s_test.go | 59 --- pkg/util/maps.go | 11 - pkg/util/pointer.go | 21 - pkg/util/slice.go | 34 -- pkg/util/slice_test.go | 39 -- pkg/version/version.go | 2 +- test/e2e/sentinel_suite_test.go | 12 +- test/e2e/shardedredisbackup_suite_test.go | 11 +- test/e2e/suite_test.go | 6 +- test/e2e/twemproxyconfig_suite_test.go | 13 +- test/util/assert.go | 6 +- test/util/minio.go | 5 +- test/util/redis.go | 6 +- pkg/util/time.go => test/util/util.go | 0 181 files changed, 1408 insertions(+), 1662 deletions(-) delete mode 100644 pkg/util/hash.go delete mode 100644 pkg/util/k8s.go delete mode 100644 pkg/util/k8s_test.go delete mode 100644 pkg/util/maps.go delete mode 100644 pkg/util/pointer.go delete mode 100644 pkg/util/slice.go delete mode 100644 pkg/util/slice_test.go rename pkg/util/time.go => test/util/util.go (100%) diff --git a/Makefile b/Makefile index 680692ef..115fb565 100644 --- a/Makefile +++ b/Makefile @@ -122,7 +122,7 @@ test-e2e: manifests ginkgo kind-create kind-deploy kind-deploy-backup-assets ## assets: go-bindata ## assets: Generate embedded assets @echo Generate Go embedded assets files by processing source - PATH=$$PATH:$$PWD/bin go generate github.com/3scale/saas-operator/pkg/assets + PATH=$$PATH:$$PWD/bin go generate github.com/3scale-ops/saas-operator/pkg/assets ##@ Build diff --git a/PROJECT b/PROJECT index cc568257..66838566 100644 --- a/PROJECT +++ b/PROJECT @@ -5,7 +5,7 @@ plugins: manifests.sdk.operatorframework.io/v2: {} scorecard.sdk.operatorframework.io/v2: {} projectName: saas-operator -repo: github.com/3scale/saas-operator +repo: github.com/3scale-ops/saas-operator resources: - api: crdVersion: v1 @@ -14,7 +14,7 @@ resources: domain: 3scale.net group: saas kind: AutoSSL - path: github.com/3scale/saas-operator/api/v1alpha1 + path: github.com/3scale-ops/saas-operator/api/v1alpha1 version: v1alpha1 - api: crdVersion: v1 @@ -23,7 +23,7 @@ resources: domain: 3scale.net group: saas kind: Apicast - path: github.com/3scale/saas-operator/api/v1alpha1 + path: github.com/3scale-ops/saas-operator/api/v1alpha1 version: v1alpha1 - api: crdVersion: v1 @@ -32,7 +32,7 @@ resources: domain: 3scale.net group: saas kind: EchoAPI - path: github.com/3scale/saas-operator/api/v1alpha1 + path: github.com/3scale-ops/saas-operator/api/v1alpha1 version: v1alpha1 - api: crdVersion: v1 @@ -41,7 +41,7 @@ resources: domain: 3scale.net group: saas kind: MappingService - path: github.com/3scale/saas-operator/api/v1alpha1 + path: github.com/3scale-ops/saas-operator/api/v1alpha1 version: v1alpha1 - api: crdVersion: v1 @@ -50,7 +50,7 @@ resources: domain: 3scale.net group: saas kind: CORSProxy - path: github.com/3scale/saas-operator/api/v1alpha1 + path: github.com/3scale-ops/saas-operator/api/v1alpha1 version: v1alpha1 - api: crdVersion: v1 @@ -59,7 +59,7 @@ resources: domain: 3scale.net group: saas kind: Backend - path: github.com/3scale/saas-operator/api/v1alpha1 + path: github.com/3scale-ops/saas-operator/api/v1alpha1 version: v1alpha1 - api: crdVersion: v1 @@ -68,7 +68,7 @@ resources: domain: 3scale.net group: saas kind: System - path: github.com/3scale/saas-operator/api/v1alpha1 + path: github.com/3scale-ops/saas-operator/api/v1alpha1 version: v1alpha1 - api: crdVersion: v1 @@ -77,7 +77,7 @@ resources: domain: 3scale.net group: saas kind: Zync - path: github.com/3scale/saas-operator/api/v1alpha1 + path: github.com/3scale-ops/saas-operator/api/v1alpha1 version: v1alpha1 - api: crdVersion: v1 @@ -86,7 +86,7 @@ resources: domain: 3scale.net group: saas kind: Sentinel - path: github.com/3scale/saas-operator/api/v1alpha1 + path: github.com/3scale-ops/saas-operator/api/v1alpha1 version: v1alpha1 - api: crdVersion: v1 @@ -95,7 +95,7 @@ resources: domain: 3scale.net group: saas kind: RedisShard - path: github.com/3scale/saas-operator/api/v1alpha1 + path: github.com/3scale-ops/saas-operator/api/v1alpha1 version: v1alpha1 - api: crdVersion: v1 @@ -104,7 +104,7 @@ resources: domain: 3scale.net group: saas kind: TwemproxyConfig - path: github.com/3scale/saas-operator/api/v1alpha1 + path: github.com/3scale-ops/saas-operator/api/v1alpha1 version: v1alpha1 - api: crdVersion: v1 @@ -113,6 +113,6 @@ resources: domain: 3scale.net group: saas kind: ShardedRedisBackup - path: github.com/3scale/saas-operator/api/v1alpha1 + path: github.com/3scale-ops/saas-operator/api/v1alpha1 version: v1alpha1 version: "3" diff --git a/README.md b/README.md index 5c523621..85b68b80 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ ![3scale-saas](docs/logos/3scale-saas-logo.svg) -[![test](https://github.com/3scale/saas-operator/actions/workflows/test.yaml/badge.svg)](https://github.com/3scale/saas-operator/actions/workflows/test.yaml) -[![release](https://badgen.net/github/release/3scale/saas-operator)](https://github.com/3scale/saas-operator/releases) -[![license](https://badgen.net/github/license/3scale/saas-operator)](https://github.com/3scale/saas-operator/LICENSE) +[![test](https://github.com/3scale-ops/saas-operator/actions/workflows/test.yaml/badge.svg)](https://github.com/3scale-ops/saas-operator/actions/workflows/test.yaml) +[![release](https://badgen.net/github/release/3scale/saas-operator)](https://github.com/3scale-ops/saas-operator/releases) +[![license](https://badgen.net/github/license/3scale/saas-operator)](https://github.com/3scale-ops/saas-operator/LICENSE) A Kubernetes Operator based on the Operator SDK to manage 3scale SaaS (hosted version) on **Kubernetes/OpenShift**. diff --git a/api/v1alpha1/apicast_types.go b/api/v1alpha1/apicast_types.go index 9621bf77..0b2456a3 100644 --- a/api/v1alpha1/apicast_types.go +++ b/api/v1alpha1/apicast_types.go @@ -17,30 +17,29 @@ limitations under the License. package v1alpha1 import ( - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) var ( apicastDefaultReplicas int32 = 2 apicastDefaultImage defaultImageSpec = defaultImageSpec{ - Name: pointer.String("quay.io/3scale/apicast-cloud-hosted"), - Tag: pointer.String("latest"), - PullPolicy: (*corev1.PullPolicy)(pointer.String(string(corev1.PullIfNotPresent))), + Name: util.Pointer("quay.io/3scale/apicast-cloud-hosted"), + Tag: util.Pointer("latest"), + PullPolicy: (*corev1.PullPolicy)(util.Pointer(string(corev1.PullIfNotPresent))), } apicastDefaultLoadBalancer defaultLoadBalancerSpec = defaultLoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), - ConnectionDrainingEnabled: pointer.Bool(true), - ConnectionDrainingTimeout: pointer.Int32(60), - HealthcheckHealthyThreshold: pointer.Int32(2), - HealthcheckUnhealthyThreshold: pointer.Int32(2), - HealthcheckInterval: pointer.Int32(5), - HealthcheckTimeout: pointer.Int32(3), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), + ConnectionDrainingEnabled: util.Pointer(true), + ConnectionDrainingTimeout: util.Pointer[int32](60), + HealthcheckHealthyThreshold: util.Pointer[int32](2), + HealthcheckUnhealthyThreshold: util.Pointer[int32](2), + HealthcheckInterval: util.Pointer[int32](5), + HealthcheckTimeout: util.Pointer[int32](3), } apicastDefaultResources defaultResourceRequirementsSpec = defaultResourceRequirementsSpec{ Requests: corev1.ResourceList{ @@ -53,31 +52,31 @@ var ( }, } apicastDefaultHPA defaultHorizontalPodAutoscalerSpec = defaultHorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(2), - MaxReplicas: pointer.Int32(4), - ResourceUtilization: pointer.Int32(90), - ResourceName: pointer.String("cpu"), + MinReplicas: util.Pointer[int32](2), + MaxReplicas: util.Pointer[int32](4), + ResourceUtilization: util.Pointer[int32](90), + ResourceName: util.Pointer("cpu"), } apicastDefaultLivenessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(5), - TimeoutSeconds: pointer.Int32(5), - PeriodSeconds: pointer.Int32(10), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](5), + TimeoutSeconds: util.Pointer[int32](5), + PeriodSeconds: util.Pointer[int32](10), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } apicastDefaultReadinessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(5), - TimeoutSeconds: pointer.Int32(5), - PeriodSeconds: pointer.Int32(30), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](5), + TimeoutSeconds: util.Pointer[int32](5), + PeriodSeconds: util.Pointer[int32](30), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } apicastDefaultPDB defaultPodDisruptionBudgetSpec = defaultPodDisruptionBudgetSpec{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(1)), } apicastDefaultGrafanaDashboard defaultGrafanaDashboardSpec = defaultGrafanaDashboardSpec{ - SelectorKey: pointer.String("monitoring-key"), - SelectorValue: pointer.String("middleware"), + SelectorKey: util.Pointer("monitoring-key"), + SelectorValue: util.Pointer("middleware"), } apicastDefaultMarin3rSpec defaultMarin3rSidecarSpec = defaultMarin3rSidecarSpec{} apicastDefaultLogLevel string = "warn" @@ -227,8 +226,8 @@ type ApicastConfig struct { // Default sets default values for any value not specifically set in the ApicastConfig struct func (cfg *ApicastConfig) Default() { - cfg.LogLevel = stringOrDefault(cfg.LogLevel, pointer.String(apicastDefaultLogLevel)) - cfg.OIDCLogLevel = stringOrDefault(cfg.OIDCLogLevel, pointer.String(apicastDefaultOIDCLogLevel)) + cfg.LogLevel = stringOrDefault(cfg.LogLevel, util.Pointer(apicastDefaultLogLevel)) + cfg.OIDCLogLevel = stringOrDefault(cfg.OIDCLogLevel, util.Pointer(apicastDefaultOIDCLogLevel)) } diff --git a/api/v1alpha1/autossl_types.go b/api/v1alpha1/autossl_types.go index fb93d9b0..ad331ad5 100644 --- a/api/v1alpha1/autossl_types.go +++ b/api/v1alpha1/autossl_types.go @@ -17,30 +17,29 @@ limitations under the License. package v1alpha1 import ( - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) var ( autosslDefaultReplicas int32 = 2 autosslDefaultImage defaultImageSpec = defaultImageSpec{ - Name: pointer.String("quay.io/3scale/autossl"), - Tag: pointer.String("latest"), - PullPolicy: (*corev1.PullPolicy)(pointer.String(string(corev1.PullIfNotPresent))), + Name: util.Pointer("quay.io/3scale/autossl"), + Tag: util.Pointer("latest"), + PullPolicy: (*corev1.PullPolicy)(util.Pointer(string(corev1.PullIfNotPresent))), } autosslDefaultLoadBalancer defaultLoadBalancerSpec = defaultLoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), - ConnectionDrainingEnabled: pointer.Bool(true), - ConnectionDrainingTimeout: pointer.Int32(60), - HealthcheckHealthyThreshold: pointer.Int32(2), - HealthcheckUnhealthyThreshold: pointer.Int32(2), - HealthcheckInterval: pointer.Int32(5), - HealthcheckTimeout: pointer.Int32(3), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), + ConnectionDrainingEnabled: util.Pointer(true), + ConnectionDrainingTimeout: util.Pointer[int32](60), + HealthcheckHealthyThreshold: util.Pointer[int32](2), + HealthcheckUnhealthyThreshold: util.Pointer[int32](2), + HealthcheckInterval: util.Pointer[int32](5), + HealthcheckTimeout: util.Pointer[int32](3), } autosslDefaultResources defaultResourceRequirementsSpec = defaultResourceRequirementsSpec{ Requests: corev1.ResourceList{ @@ -53,25 +52,25 @@ var ( }, } autosslDefaultHPA defaultHorizontalPodAutoscalerSpec = defaultHorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(2), - MaxReplicas: pointer.Int32(4), - ResourceUtilization: pointer.Int32(90), - ResourceName: pointer.String("cpu"), + MinReplicas: util.Pointer[int32](2), + MaxReplicas: util.Pointer[int32](4), + ResourceUtilization: util.Pointer[int32](90), + ResourceName: util.Pointer("cpu"), } autosslDefaultProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(25), - TimeoutSeconds: pointer.Int32(1), - PeriodSeconds: pointer.Int32(10), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](25), + TimeoutSeconds: util.Pointer[int32](1), + PeriodSeconds: util.Pointer[int32](10), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } autosslDefaultPDB defaultPodDisruptionBudgetSpec = defaultPodDisruptionBudgetSpec{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(1)), } autosslDefaultGrafanaDashboard defaultGrafanaDashboardSpec = defaultGrafanaDashboardSpec{ - SelectorKey: pointer.String("monitoring-key"), - SelectorValue: pointer.String("middleware"), + SelectorKey: util.Pointer("monitoring-key"), + SelectorValue: util.Pointer("middleware"), } autosslDefaultACMEStaging bool = false autosslDefaultRedisPort int32 = 6379 @@ -208,9 +207,9 @@ type AutoSSLConfig struct { // Default sets default values for any value not specifically set in the AutoSSLConfig struct func (cfg *AutoSSLConfig) Default() { - cfg.ACMEStaging = boolOrDefault(cfg.ACMEStaging, pointer.Bool(autosslDefaultACMEStaging)) - cfg.RedisPort = intOrDefault(cfg.RedisPort, pointer.Int32(autosslDefaultRedisPort)) - cfg.LogLevel = stringOrDefault(cfg.LogLevel, pointer.String(autosslDefaultLogLevel)) + cfg.ACMEStaging = boolOrDefault(cfg.ACMEStaging, util.Pointer(autosslDefaultACMEStaging)) + cfg.RedisPort = intOrDefault(cfg.RedisPort, util.Pointer[int32](autosslDefaultRedisPort)) + cfg.LogLevel = stringOrDefault(cfg.LogLevel, util.Pointer(autosslDefaultLogLevel)) if cfg.DomainWhitelist == nil { cfg.DomainWhitelist = []string{} } diff --git a/api/v1alpha1/backend_types.go b/api/v1alpha1/backend_types.go index b98bf781..aa095ce1 100644 --- a/api/v1alpha1/backend_types.go +++ b/api/v1alpha1/backend_types.go @@ -17,38 +17,37 @@ limitations under the License. package v1alpha1 import ( - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) var ( backendDefaultImage defaultImageSpec = defaultImageSpec{ - Name: pointer.String("quay.io/3scale/apisonator"), - Tag: pointer.String("nightly"), - PullPolicy: (*corev1.PullPolicy)(pointer.String(string(corev1.PullIfNotPresent))), + Name: util.Pointer("quay.io/3scale/apisonator"), + Tag: util.Pointer("nightly"), + PullPolicy: (*corev1.PullPolicy)(util.Pointer(string(corev1.PullIfNotPresent))), } backendDefaultGrafanaDashboard defaultGrafanaDashboardSpec = defaultGrafanaDashboardSpec{ - SelectorKey: pointer.String("monitoring-key"), - SelectorValue: pointer.String("middleware"), + SelectorKey: util.Pointer("monitoring-key"), + SelectorValue: util.Pointer("middleware"), } backendDefaultConfigRackEnv string = "dev" backendDefaultConfigMasterServiceID int32 = 6 backendDefaultListenerHPA defaultHorizontalPodAutoscalerSpec = defaultHorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(2), - MaxReplicas: pointer.Int32(4), - ResourceUtilization: pointer.Int32(90), - ResourceName: pointer.String("cpu"), + MinReplicas: util.Pointer[int32](2), + MaxReplicas: util.Pointer[int32](4), + ResourceUtilization: util.Pointer[int32](90), + ResourceName: util.Pointer("cpu"), } backendDefaultListenerPDB defaultPodDisruptionBudgetSpec = defaultPodDisruptionBudgetSpec{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(1)), } backendDefaultListenerNLBLoadBalancer defaultNLBLoadBalancerSpec = defaultNLBLoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), } backendDefaultListenerReplicas int32 = 2 backendDefaultListenerResources defaultResourceRequirementsSpec = defaultResourceRequirementsSpec{ @@ -62,18 +61,18 @@ var ( }, } backendDefaultListenerLivenessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(30), - TimeoutSeconds: pointer.Int32(1), - PeriodSeconds: pointer.Int32(10), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](30), + TimeoutSeconds: util.Pointer[int32](1), + PeriodSeconds: util.Pointer[int32](10), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } backendDefaultListenerReadinessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(30), - TimeoutSeconds: pointer.Int32(5), - PeriodSeconds: pointer.Int32(10), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](30), + TimeoutSeconds: util.Pointer[int32](5), + PeriodSeconds: util.Pointer[int32](10), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } backendDefaultListenerMarin3rSpec defaultMarin3rSidecarSpec = defaultMarin3rSidecarSpec{} backendDefaultListenerConfigLogFormat string = "json" @@ -81,13 +80,13 @@ var ( backendDefaultListenerConfigListenerWorkers int32 = 16 backendDefaultListenerConfigLegacyReferrerFilters bool = true backendDefaultWorkerHPA defaultHorizontalPodAutoscalerSpec = defaultHorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(2), - MaxReplicas: pointer.Int32(4), - ResourceUtilization: pointer.Int32(90), - ResourceName: pointer.String("cpu"), + MinReplicas: util.Pointer[int32](2), + MaxReplicas: util.Pointer[int32](4), + ResourceUtilization: util.Pointer[int32](90), + ResourceName: util.Pointer("cpu"), } backendDefaultWorkerPDB defaultPodDisruptionBudgetSpec = defaultPodDisruptionBudgetSpec{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(1)), } backendDefaultWorkerReplicas int32 = 2 backendDefaultWorkerResources defaultResourceRequirementsSpec = defaultResourceRequirementsSpec{ @@ -101,18 +100,18 @@ var ( }, } backendDefaultWorkerLivenessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(10), - TimeoutSeconds: pointer.Int32(3), - PeriodSeconds: pointer.Int32(15), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](10), + TimeoutSeconds: util.Pointer[int32](3), + PeriodSeconds: util.Pointer[int32](15), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } backendDefaultWorkerReadinessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(10), - TimeoutSeconds: pointer.Int32(5), - PeriodSeconds: pointer.Int32(30), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](10), + TimeoutSeconds: util.Pointer[int32](5), + PeriodSeconds: util.Pointer[int32](30), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } backendDefaultWorkerConfigLogFormat string = "json" backendDefaultWorkerConfigRedisAsync bool = false @@ -407,8 +406,8 @@ type BackendConfig struct { // Default sets default values for any value not specifically set in the BackendConfig struct func (cfg *BackendConfig) Default() { - cfg.RackEnv = stringOrDefault(cfg.RackEnv, pointer.String(backendDefaultConfigRackEnv)) - cfg.MasterServiceID = intOrDefault(cfg.MasterServiceID, pointer.Int32(backendDefaultConfigMasterServiceID)) + cfg.RackEnv = stringOrDefault(cfg.RackEnv, util.Pointer(backendDefaultConfigRackEnv)) + cfg.MasterServiceID = intOrDefault(cfg.MasterServiceID, util.Pointer[int32](backendDefaultConfigMasterServiceID)) cfg.ExternalSecret.SecretStoreRef = InitializeExternalSecretSecretStoreReferenceSpec(cfg.ExternalSecret.SecretStoreRef, defaultExternalSecretSecretStoreReference) cfg.ExternalSecret.RefreshInterval = durationOrDefault(cfg.ExternalSecret.RefreshInterval, &defaultExternalSecretRefreshInterval) } @@ -436,10 +435,10 @@ type ListenerConfig struct { // Default sets default values for any value not specifically set in the ListenerConfig struct func (cfg *ListenerConfig) Default() { - cfg.LogFormat = stringOrDefault(cfg.LogFormat, pointer.String(backendDefaultListenerConfigLogFormat)) - cfg.RedisAsync = boolOrDefault(cfg.RedisAsync, pointer.Bool(backendDefaultListenerConfigRedisAsync)) - cfg.ListenerWorkers = intOrDefault(cfg.ListenerWorkers, pointer.Int32(backendDefaultListenerConfigListenerWorkers)) - cfg.LegacyReferrerFilters = boolOrDefault(cfg.LegacyReferrerFilters, pointer.Bool(backendDefaultListenerConfigLegacyReferrerFilters)) + cfg.LogFormat = stringOrDefault(cfg.LogFormat, util.Pointer(backendDefaultListenerConfigLogFormat)) + cfg.RedisAsync = boolOrDefault(cfg.RedisAsync, util.Pointer(backendDefaultListenerConfigRedisAsync)) + cfg.ListenerWorkers = intOrDefault(cfg.ListenerWorkers, util.Pointer[int32](backendDefaultListenerConfigListenerWorkers)) + cfg.LegacyReferrerFilters = boolOrDefault(cfg.LegacyReferrerFilters, util.Pointer(backendDefaultListenerConfigLegacyReferrerFilters)) } // WorkerConfig configures app behavior for Backend Worker @@ -457,8 +456,8 @@ type WorkerConfig struct { // Default sets default values for any value not specifically set in the WorkerConfig struct func (cfg *WorkerConfig) Default() { - cfg.LogFormat = stringOrDefault(cfg.LogFormat, pointer.String(backendDefaultWorkerConfigLogFormat)) - cfg.RedisAsync = boolOrDefault(cfg.RedisAsync, pointer.Bool(backendDefaultWorkerConfigRedisAsync)) + cfg.LogFormat = stringOrDefault(cfg.LogFormat, util.Pointer(backendDefaultWorkerConfigLogFormat)) + cfg.RedisAsync = boolOrDefault(cfg.RedisAsync, util.Pointer(backendDefaultWorkerConfigRedisAsync)) } // BackendStatus defines the observed state of Backend diff --git a/api/v1alpha1/common_types.go b/api/v1alpha1/common_types.go index 60bbf3ec..ec394032 100644 --- a/api/v1alpha1/common_types.go +++ b/api/v1alpha1/common_types.go @@ -22,13 +22,13 @@ import ( "reflect" "time" + "github.com/3scale-ops/basereconciler/util" jsonpatch "github.com/evanphx/json-patch" appsv1 "k8s.io/api/apps/v1" autoscalingv2 "k8s.io/api/autoscaling/v2" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) const ( @@ -42,8 +42,8 @@ const ( var ( defaultExternalSecretRefreshInterval metav1.Duration = metav1.Duration{Duration: 60 * time.Second} defaultExternalSecretSecretStoreReference defaultExternalSecretSecretStoreReferenceSpec = defaultExternalSecretSecretStoreReferenceSpec{ - Name: pointer.String("vault-mgmt"), - Kind: pointer.String("ClusterSecretStore"), + Name: util.Pointer("vault-mgmt"), + Kind: util.Pointer("ClusterSecretStore"), } ) diff --git a/api/v1alpha1/common_types_test.go b/api/v1alpha1/common_types_test.go index 6f58bebf..e9193f4c 100644 --- a/api/v1alpha1/common_types_test.go +++ b/api/v1alpha1/common_types_test.go @@ -20,12 +20,11 @@ import ( "reflect" "testing" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" "github.com/go-test/deep" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) func TestImageSpec_Default(t *testing.T) { @@ -48,34 +47,34 @@ func TestImageSpec_Default(t *testing.T) { name: "Sets defaults", fields: fields{}, args: args{def: defaultImageSpec{ - Name: pointer.String("name"), - Tag: pointer.String("tag"), - PullSecretName: pointer.String("pullSecret"), + Name: util.Pointer("name"), + Tag: util.Pointer("tag"), + PullSecretName: util.Pointer("pullSecret"), PullPolicy: func() *corev1.PullPolicy { p := corev1.PullIfNotPresent; return &p }(), }}, want: &ImageSpec{ - Name: pointer.String("name"), - Tag: pointer.String("tag"), - PullSecretName: pointer.String("pullSecret"), + Name: util.Pointer("name"), + Tag: util.Pointer("tag"), + PullSecretName: util.Pointer("pullSecret"), PullPolicy: func() *corev1.PullPolicy { p := corev1.PullIfNotPresent; return &p }(), }, }, { name: "Combines explicitely set values with defaults", fields: fields{ - Name: pointer.String("explicit"), + Name: util.Pointer("explicit"), PullPolicy: func() *corev1.PullPolicy { p := corev1.PullAlways; return &p }(), }, args: args{def: defaultImageSpec{ - Name: pointer.String("name"), - Tag: pointer.String("tag"), - PullSecretName: pointer.String("pullSecret"), + Name: util.Pointer("name"), + Tag: util.Pointer("tag"), + PullSecretName: util.Pointer("pullSecret"), PullPolicy: func() *corev1.PullPolicy { p := corev1.PullIfNotPresent; return &p }(), }}, want: &ImageSpec{ - Name: pointer.String("explicit"), - Tag: pointer.String("tag"), - PullSecretName: pointer.String("pullSecret"), + Name: util.Pointer("explicit"), + Tag: util.Pointer("tag"), + PullSecretName: util.Pointer("pullSecret"), PullPolicy: func() *corev1.PullPolicy { p := corev1.PullAlways; return &p }(), }, }, @@ -127,27 +126,27 @@ func TestInitializeImageSpec(t *testing.T) { { name: "Initializes the struct with appropriate defaults if nil", args: args{nil, defaultImageSpec{ - Name: pointer.String("name"), - Tag: pointer.String("tag"), - PullSecretName: pointer.String("pullSecret"), + Name: util.Pointer("name"), + Tag: util.Pointer("tag"), + PullSecretName: util.Pointer("pullSecret"), }}, want: &ImageSpec{ - Name: pointer.String("name"), - Tag: pointer.String("tag"), - PullSecretName: pointer.String("pullSecret"), + Name: util.Pointer("name"), + Tag: util.Pointer("tag"), + PullSecretName: util.Pointer("pullSecret"), }, }, { name: "Initializes the struct with appropriate defaults if empty", args: args{&ImageSpec{}, defaultImageSpec{ - Name: pointer.String("name"), - Tag: pointer.String("tag"), - PullSecretName: pointer.String("pullSecret"), + Name: util.Pointer("name"), + Tag: util.Pointer("tag"), + PullSecretName: util.Pointer("pullSecret"), }}, want: &ImageSpec{ - Name: pointer.String("name"), - Tag: pointer.String("tag"), - PullSecretName: pointer.String("pullSecret"), + Name: util.Pointer("name"), + Tag: util.Pointer("tag"), + PullSecretName: util.Pointer("pullSecret"), }, }, } @@ -181,38 +180,38 @@ func TestProbeSpec_Default(t *testing.T) { name: "Sets defaults", fields: fields{}, args: args{def: defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(1), - TimeoutSeconds: pointer.Int32(2), - PeriodSeconds: pointer.Int32(3), - SuccessThreshold: pointer.Int32(4), - FailureThreshold: pointer.Int32(5), + InitialDelaySeconds: util.Pointer[int32](1), + TimeoutSeconds: util.Pointer[int32](2), + PeriodSeconds: util.Pointer[int32](3), + SuccessThreshold: util.Pointer[int32](4), + FailureThreshold: util.Pointer[int32](5), }}, want: &ProbeSpec{ - InitialDelaySeconds: pointer.Int32(1), - TimeoutSeconds: pointer.Int32(2), - PeriodSeconds: pointer.Int32(3), - SuccessThreshold: pointer.Int32(4), - FailureThreshold: pointer.Int32(5), + InitialDelaySeconds: util.Pointer[int32](1), + TimeoutSeconds: util.Pointer[int32](2), + PeriodSeconds: util.Pointer[int32](3), + SuccessThreshold: util.Pointer[int32](4), + FailureThreshold: util.Pointer[int32](5), }, }, { name: "Combines explicitely set values with defaults", fields: fields{ - InitialDelaySeconds: pointer.Int32(9999), + InitialDelaySeconds: util.Pointer[int32](9999), }, args: args{def: defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(1), - TimeoutSeconds: pointer.Int32(2), - PeriodSeconds: pointer.Int32(3), - SuccessThreshold: pointer.Int32(4), - FailureThreshold: pointer.Int32(5), + InitialDelaySeconds: util.Pointer[int32](1), + TimeoutSeconds: util.Pointer[int32](2), + PeriodSeconds: util.Pointer[int32](3), + SuccessThreshold: util.Pointer[int32](4), + FailureThreshold: util.Pointer[int32](5), }}, want: &ProbeSpec{ - InitialDelaySeconds: pointer.Int32(9999), - TimeoutSeconds: pointer.Int32(2), - PeriodSeconds: pointer.Int32(3), - SuccessThreshold: pointer.Int32(4), - FailureThreshold: pointer.Int32(5), + InitialDelaySeconds: util.Pointer[int32](9999), + TimeoutSeconds: util.Pointer[int32](2), + PeriodSeconds: util.Pointer[int32](3), + SuccessThreshold: util.Pointer[int32](4), + FailureThreshold: util.Pointer[int32](5), }, }, } @@ -241,7 +240,7 @@ func TestProbeSpec_IsDeactivated(t *testing.T) { }{ {"Wants true if empty", &ProbeSpec{}, true}, {"Wants false if nil", nil, false}, - {"Wants false if other", &ProbeSpec{InitialDelaySeconds: pointer.Int32(1)}, false}, + {"Wants false if other", &ProbeSpec{InitialDelaySeconds: util.Pointer[int32](1)}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -265,18 +264,18 @@ func TestInitializeProbeSpec(t *testing.T) { { name: "Initializes the struct with appropriate defaults if nil", args: args{nil, defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(1), - TimeoutSeconds: pointer.Int32(2), - PeriodSeconds: pointer.Int32(3), - SuccessThreshold: pointer.Int32(4), - FailureThreshold: pointer.Int32(5), + InitialDelaySeconds: util.Pointer[int32](1), + TimeoutSeconds: util.Pointer[int32](2), + PeriodSeconds: util.Pointer[int32](3), + SuccessThreshold: util.Pointer[int32](4), + FailureThreshold: util.Pointer[int32](5), }}, want: &ProbeSpec{ - InitialDelaySeconds: pointer.Int32(1), - TimeoutSeconds: pointer.Int32(2), - PeriodSeconds: pointer.Int32(3), - SuccessThreshold: pointer.Int32(4), - FailureThreshold: pointer.Int32(5), + InitialDelaySeconds: util.Pointer[int32](1), + TimeoutSeconds: util.Pointer[int32](2), + PeriodSeconds: util.Pointer[int32](3), + SuccessThreshold: util.Pointer[int32](4), + FailureThreshold: util.Pointer[int32](5), }, }, { @@ -318,50 +317,50 @@ func TestLoadBalancerSpec_Default(t *testing.T) { name: "Sets defaults", fields: fields{}, args: args{def: defaultLoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), - ConnectionDrainingEnabled: pointer.Bool(true), - ConnectionDrainingTimeout: pointer.Int32(1), - HealthcheckHealthyThreshold: pointer.Int32(2), - HealthcheckUnhealthyThreshold: pointer.Int32(3), - HealthcheckInterval: pointer.Int32(4), - HealthcheckTimeout: pointer.Int32(5), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), + ConnectionDrainingEnabled: util.Pointer(true), + ConnectionDrainingTimeout: util.Pointer[int32](1), + HealthcheckHealthyThreshold: util.Pointer[int32](2), + HealthcheckUnhealthyThreshold: util.Pointer[int32](3), + HealthcheckInterval: util.Pointer[int32](4), + HealthcheckTimeout: util.Pointer[int32](5), }}, want: &LoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), - ConnectionDrainingEnabled: pointer.Bool(true), - ConnectionDrainingTimeout: pointer.Int32(1), - HealthcheckHealthyThreshold: pointer.Int32(2), - HealthcheckUnhealthyThreshold: pointer.Int32(3), - HealthcheckInterval: pointer.Int32(4), - HealthcheckTimeout: pointer.Int32(5), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), + ConnectionDrainingEnabled: util.Pointer(true), + ConnectionDrainingTimeout: util.Pointer[int32](1), + HealthcheckHealthyThreshold: util.Pointer[int32](2), + HealthcheckUnhealthyThreshold: util.Pointer[int32](3), + HealthcheckInterval: util.Pointer[int32](4), + HealthcheckTimeout: util.Pointer[int32](5), }, }, { name: "Combines explicitely set values with defaults", fields: fields{ - ProxyProtocol: pointer.Bool(false), + ProxyProtocol: util.Pointer(false), }, args: args{def: defaultLoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), - ConnectionDrainingEnabled: pointer.Bool(true), - ConnectionDrainingTimeout: pointer.Int32(1), - HealthcheckHealthyThreshold: pointer.Int32(2), - HealthcheckUnhealthyThreshold: pointer.Int32(3), - HealthcheckInterval: pointer.Int32(4), - HealthcheckTimeout: pointer.Int32(5), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), + ConnectionDrainingEnabled: util.Pointer(true), + ConnectionDrainingTimeout: util.Pointer[int32](1), + HealthcheckHealthyThreshold: util.Pointer[int32](2), + HealthcheckUnhealthyThreshold: util.Pointer[int32](3), + HealthcheckInterval: util.Pointer[int32](4), + HealthcheckTimeout: util.Pointer[int32](5), }}, want: &LoadBalancerSpec{ - ProxyProtocol: pointer.Bool(false), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), - ConnectionDrainingEnabled: pointer.Bool(true), - ConnectionDrainingTimeout: pointer.Int32(1), - HealthcheckHealthyThreshold: pointer.Int32(2), - HealthcheckUnhealthyThreshold: pointer.Int32(3), - HealthcheckInterval: pointer.Int32(4), - HealthcheckTimeout: pointer.Int32(5), + ProxyProtocol: util.Pointer(false), + CrossZoneLoadBalancingEnabled: util.Pointer(true), + ConnectionDrainingEnabled: util.Pointer(true), + ConnectionDrainingTimeout: util.Pointer[int32](1), + HealthcheckHealthyThreshold: util.Pointer[int32](2), + HealthcheckUnhealthyThreshold: util.Pointer[int32](3), + HealthcheckInterval: util.Pointer[int32](4), + HealthcheckTimeout: util.Pointer[int32](5), }, }, } @@ -393,7 +392,7 @@ func TestLoadBalancerSpec_IsDeactivated(t *testing.T) { }{ {"Wants false if empty", &LoadBalancerSpec{}, false}, {"Wants false if nil", nil, false}, - {"Wants false if other", &LoadBalancerSpec{ProxyProtocol: pointer.Bool(false)}, false}} + {"Wants false if other", &LoadBalancerSpec{ProxyProtocol: util.Pointer(false)}, false}} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := tt.spec.IsDeactivated(); got != tt.want { @@ -416,47 +415,47 @@ func TestInitializeLoadBalancerSpec(t *testing.T) { { name: "Initializes the struct with appropriate defaults if nil", args: args{nil, defaultLoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), - ConnectionDrainingEnabled: pointer.Bool(true), - ConnectionDrainingTimeout: pointer.Int32(1), - HealthcheckHealthyThreshold: pointer.Int32(2), - HealthcheckUnhealthyThreshold: pointer.Int32(3), - HealthcheckInterval: pointer.Int32(4), - HealthcheckTimeout: pointer.Int32(5), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), + ConnectionDrainingEnabled: util.Pointer(true), + ConnectionDrainingTimeout: util.Pointer[int32](1), + HealthcheckHealthyThreshold: util.Pointer[int32](2), + HealthcheckUnhealthyThreshold: util.Pointer[int32](3), + HealthcheckInterval: util.Pointer[int32](4), + HealthcheckTimeout: util.Pointer[int32](5), }}, want: &LoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), - ConnectionDrainingEnabled: pointer.Bool(true), - ConnectionDrainingTimeout: pointer.Int32(1), - HealthcheckHealthyThreshold: pointer.Int32(2), - HealthcheckUnhealthyThreshold: pointer.Int32(3), - HealthcheckInterval: pointer.Int32(4), - HealthcheckTimeout: pointer.Int32(5), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), + ConnectionDrainingEnabled: util.Pointer(true), + ConnectionDrainingTimeout: util.Pointer[int32](1), + HealthcheckHealthyThreshold: util.Pointer[int32](2), + HealthcheckUnhealthyThreshold: util.Pointer[int32](3), + HealthcheckInterval: util.Pointer[int32](4), + HealthcheckTimeout: util.Pointer[int32](5), }, }, { name: "Initializes the struct with appropriate defaults if empty", args: args{&LoadBalancerSpec{}, defaultLoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), - ConnectionDrainingEnabled: pointer.Bool(true), - ConnectionDrainingTimeout: pointer.Int32(1), - HealthcheckHealthyThreshold: pointer.Int32(2), - HealthcheckUnhealthyThreshold: pointer.Int32(3), - HealthcheckInterval: pointer.Int32(4), - HealthcheckTimeout: pointer.Int32(5), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), + ConnectionDrainingEnabled: util.Pointer(true), + ConnectionDrainingTimeout: util.Pointer[int32](1), + HealthcheckHealthyThreshold: util.Pointer[int32](2), + HealthcheckUnhealthyThreshold: util.Pointer[int32](3), + HealthcheckInterval: util.Pointer[int32](4), + HealthcheckTimeout: util.Pointer[int32](5), }}, want: &LoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), - ConnectionDrainingEnabled: pointer.Bool(true), - ConnectionDrainingTimeout: pointer.Int32(1), - HealthcheckHealthyThreshold: pointer.Int32(2), - HealthcheckUnhealthyThreshold: pointer.Int32(3), - HealthcheckInterval: pointer.Int32(4), - HealthcheckTimeout: pointer.Int32(5), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), + ConnectionDrainingEnabled: util.Pointer(true), + ConnectionDrainingTimeout: util.Pointer[int32](1), + HealthcheckHealthyThreshold: util.Pointer[int32](2), + HealthcheckUnhealthyThreshold: util.Pointer[int32](3), + HealthcheckInterval: util.Pointer[int32](4), + HealthcheckTimeout: util.Pointer[int32](5), }, }, } @@ -487,26 +486,26 @@ func TestNLBLoadBalancerSpec_Default(t *testing.T) { name: "Sets defaults", fields: fields{}, args: args{def: defaultNLBLoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), }}, want: &NLBLoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), }, }, { name: "Combines explicitely set values with defaults", fields: fields{ - ProxyProtocol: pointer.Bool(false), + ProxyProtocol: util.Pointer(false), }, args: args{def: defaultNLBLoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), }}, want: &NLBLoadBalancerSpec{ - ProxyProtocol: pointer.Bool(false), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), + ProxyProtocol: util.Pointer(false), + CrossZoneLoadBalancingEnabled: util.Pointer(true), }, }, } @@ -532,7 +531,7 @@ func TestNLBLoadBalancerSpec_IsDeactivated(t *testing.T) { }{ {"Wants false if empty", &NLBLoadBalancerSpec{}, false}, {"Wants false if nil", nil, false}, - {"Wants false if other", &NLBLoadBalancerSpec{ProxyProtocol: pointer.Bool(false)}, false}} + {"Wants false if other", &NLBLoadBalancerSpec{ProxyProtocol: util.Pointer(false)}, false}} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := tt.spec.IsDeactivated(); got != tt.want { @@ -555,23 +554,23 @@ func TestInitializeNLBLoadBalancerSpec(t *testing.T) { { name: "Initializes the struct with appropriate defaults if nil", args: args{nil, defaultNLBLoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), }}, want: &NLBLoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), }, }, { name: "Initializes the struct with appropriate defaults if empty", args: args{&NLBLoadBalancerSpec{}, defaultNLBLoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), }}, want: &NLBLoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), }, }, } @@ -602,26 +601,26 @@ func TestGrafanaDashboardSpec_Default(t *testing.T) { name: "Sets defaults", fields: fields{}, args: args{def: defaultGrafanaDashboardSpec{ - SelectorKey: pointer.String("key"), - SelectorValue: pointer.String("label"), + SelectorKey: util.Pointer("key"), + SelectorValue: util.Pointer("label"), }}, want: &GrafanaDashboardSpec{ - SelectorKey: pointer.String("key"), - SelectorValue: pointer.String("label"), + SelectorKey: util.Pointer("key"), + SelectorValue: util.Pointer("label"), }, }, { name: "Combines explicitely set values with defaults", fields: fields{ - SelectorKey: pointer.String("xxxx"), + SelectorKey: util.Pointer("xxxx"), }, args: args{def: defaultGrafanaDashboardSpec{ - SelectorKey: pointer.String("key"), - SelectorValue: pointer.String("label"), + SelectorKey: util.Pointer("key"), + SelectorValue: util.Pointer("label"), }}, want: &GrafanaDashboardSpec{ - SelectorKey: pointer.String("xxxx"), - SelectorValue: pointer.String("label"), + SelectorKey: util.Pointer("xxxx"), + SelectorValue: util.Pointer("label"), }, }, } @@ -647,7 +646,7 @@ func TestGrafanaDashboardSpec_IsDeactivated(t *testing.T) { }{ {"Wants true if empty", &GrafanaDashboardSpec{}, true}, {"Wants false if nil", nil, false}, - {"Wants false if other", &GrafanaDashboardSpec{SelectorKey: pointer.String("key")}, false}, + {"Wants false if other", &GrafanaDashboardSpec{SelectorKey: util.Pointer("key")}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -671,12 +670,12 @@ func TestInitializeGrafanaDashboardSpec(t *testing.T) { { name: "Initializes the struct with appropriate defaults if nil", args: args{nil, defaultGrafanaDashboardSpec{ - SelectorKey: pointer.String("key"), - SelectorValue: pointer.String("label"), + SelectorKey: util.Pointer("key"), + SelectorValue: util.Pointer("label"), }}, want: &GrafanaDashboardSpec{ - SelectorKey: pointer.String("key"), - SelectorValue: pointer.String("label"), + SelectorKey: util.Pointer("key"), + SelectorValue: util.Pointer("label"), }, }, { @@ -711,39 +710,39 @@ func TestPodDisruptionBudgetSpec_Default(t *testing.T) { name: "Sets defaults", fields: fields{}, args: args{def: defaultPodDisruptionBudgetSpec{ - MinAvailable: util.IntStrPtr(intstr.FromString("default")), + MinAvailable: util.Pointer(intstr.FromString("default")), MaxUnavailable: nil, }}, want: &PodDisruptionBudgetSpec{ - MinAvailable: util.IntStrPtr(intstr.FromString("default")), + MinAvailable: util.Pointer(intstr.FromString("default")), MaxUnavailable: nil, }, }, { name: "Combines explicitely set values with defaults", fields: fields{ - MinAvailable: util.IntStrPtr(intstr.FromString("explicit")), + MinAvailable: util.Pointer(intstr.FromString("explicit")), }, args: args{def: defaultPodDisruptionBudgetSpec{ - MinAvailable: util.IntStrPtr(intstr.FromString("default")), + MinAvailable: util.Pointer(intstr.FromString("default")), MaxUnavailable: nil, }}, want: &PodDisruptionBudgetSpec{ - MinAvailable: util.IntStrPtr(intstr.FromString("explicit")), + MinAvailable: util.Pointer(intstr.FromString("explicit")), MaxUnavailable: nil, }, }, { name: "Only one of MinAvailable or MaxUnavailable can be set", fields: fields{ - MinAvailable: util.IntStrPtr(intstr.FromString("explicit")), + MinAvailable: util.Pointer(intstr.FromString("explicit")), }, args: args{def: defaultPodDisruptionBudgetSpec{ MinAvailable: nil, - MaxUnavailable: util.IntStrPtr(intstr.FromString("default")), + MaxUnavailable: util.Pointer(intstr.FromString("default")), }}, want: &PodDisruptionBudgetSpec{ - MinAvailable: util.IntStrPtr(intstr.FromString("explicit")), + MinAvailable: util.Pointer(intstr.FromString("explicit")), MaxUnavailable: nil, }, }, @@ -751,11 +750,11 @@ func TestPodDisruptionBudgetSpec_Default(t *testing.T) { name: "Only one of MinAvailable or MaxUnavailable can be set (II)", fields: fields{}, args: args{def: defaultPodDisruptionBudgetSpec{ - MinAvailable: util.IntStrPtr(intstr.IntOrString{Type: intstr.String, StrVal: "defaultMin"}), - MaxUnavailable: util.IntStrPtr(intstr.IntOrString{Type: intstr.String, StrVal: "defaultMax"}), + MinAvailable: util.Pointer(intstr.IntOrString{Type: intstr.String, StrVal: "defaultMin"}), + MaxUnavailable: util.Pointer(intstr.IntOrString{Type: intstr.String, StrVal: "defaultMax"}), }}, want: &PodDisruptionBudgetSpec{ - MinAvailable: util.IntStrPtr(intstr.IntOrString{Type: intstr.String, StrVal: "defaultMin"}), + MinAvailable: util.Pointer(intstr.IntOrString{Type: intstr.String, StrVal: "defaultMin"}), MaxUnavailable: nil, }, }, @@ -782,7 +781,7 @@ func TestPodDisruptionBudgetSpec_IsDeactivated(t *testing.T) { }{ {"Wants true if empty", &PodDisruptionBudgetSpec{}, true}, {"Wants false if nil", nil, false}, - {"Wants false if other", &PodDisruptionBudgetSpec{MinAvailable: util.IntStrPtr(intstr.FromInt(1))}, false}, + {"Wants false if other", &PodDisruptionBudgetSpec{MinAvailable: util.Pointer(intstr.FromInt(1))}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -806,11 +805,11 @@ func TestInitializePodDisruptionBudgetSpec(t *testing.T) { { name: "Initializes the struct with appropriate defaults if nil", args: args{nil, defaultPodDisruptionBudgetSpec{ - MinAvailable: util.IntStrPtr(intstr.FromString("default")), + MinAvailable: util.Pointer(intstr.FromString("default")), MaxUnavailable: nil, }}, want: &PodDisruptionBudgetSpec{ - MinAvailable: util.IntStrPtr(intstr.FromString("default")), + MinAvailable: util.Pointer(intstr.FromString("default")), MaxUnavailable: nil, }, }, @@ -849,34 +848,34 @@ func TestHorizontalPodAutoscalerSpec_Default(t *testing.T) { name: "Sets defaults", fields: fields{}, args: args{def: defaultHorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(1), - MaxReplicas: pointer.Int32(2), - ResourceUtilization: pointer.Int32(3), - ResourceName: pointer.String("xxxx"), + MinReplicas: util.Pointer[int32](1), + MaxReplicas: util.Pointer[int32](2), + ResourceUtilization: util.Pointer[int32](3), + ResourceName: util.Pointer("xxxx"), }}, want: &HorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(1), - MaxReplicas: pointer.Int32(2), - ResourceUtilization: pointer.Int32(3), - ResourceName: pointer.String("xxxx"), + MinReplicas: util.Pointer[int32](1), + MaxReplicas: util.Pointer[int32](2), + ResourceUtilization: util.Pointer[int32](3), + ResourceName: util.Pointer("xxxx"), }, }, { name: "Combines explicitely set values with defaults", fields: fields{ - MinReplicas: pointer.Int32(9999), + MinReplicas: util.Pointer[int32](9999), }, args: args{def: defaultHorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(1), - MaxReplicas: pointer.Int32(2), - ResourceUtilization: pointer.Int32(3), - ResourceName: pointer.String("xxxx"), + MinReplicas: util.Pointer[int32](1), + MaxReplicas: util.Pointer[int32](2), + ResourceUtilization: util.Pointer[int32](3), + ResourceName: util.Pointer("xxxx"), }}, want: &HorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(9999), - MaxReplicas: pointer.Int32(2), - ResourceUtilization: pointer.Int32(3), - ResourceName: pointer.String("xxxx"), + MinReplicas: util.Pointer[int32](9999), + MaxReplicas: util.Pointer[int32](2), + ResourceUtilization: util.Pointer[int32](3), + ResourceName: util.Pointer("xxxx"), }, }, } @@ -904,7 +903,7 @@ func TestHorizontalPodAutoscalerSpec_IsDeactivated(t *testing.T) { }{ {"Wants true if empty", &HorizontalPodAutoscalerSpec{}, true}, {"Wants false if nil", nil, false}, - {"Wants false if other", &HorizontalPodAutoscalerSpec{MinReplicas: pointer.Int32(1)}, false}} + {"Wants false if other", &HorizontalPodAutoscalerSpec{MinReplicas: util.Pointer[int32](1)}, false}} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := tt.spec.IsDeactivated(); got != tt.want { @@ -927,16 +926,16 @@ func TestInitializeHorizontalPodAutoscalerSpec(t *testing.T) { { name: "Initializes the struct with appropriate defaults if nil", args: args{nil, defaultHorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(1), - MaxReplicas: pointer.Int32(2), - ResourceUtilization: pointer.Int32(3), - ResourceName: pointer.String("xxxx"), + MinReplicas: util.Pointer[int32](1), + MaxReplicas: util.Pointer[int32](2), + ResourceUtilization: util.Pointer[int32](3), + ResourceName: util.Pointer("xxxx"), }}, want: &HorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(1), - MaxReplicas: pointer.Int32(2), - ResourceUtilization: pointer.Int32(3), - ResourceName: pointer.String("xxxx"), + MinReplicas: util.Pointer[int32](1), + MaxReplicas: util.Pointer[int32](2), + ResourceUtilization: util.Pointer[int32](3), + ResourceName: util.Pointer("xxxx"), }, }, { @@ -1113,18 +1112,18 @@ func Test_stringOrDefault(t *testing.T) { { name: "Value explicitely set", args: args{ - value: pointer.String("value"), - defValue: pointer.String("default"), + value: util.Pointer("value"), + defValue: util.Pointer("default"), }, - want: pointer.String("value"), + want: util.Pointer("value"), }, { name: "Value not set", args: args{ value: nil, - defValue: pointer.String("default"), + defValue: util.Pointer("default"), }, - want: pointer.String("default"), + want: util.Pointer("default"), }, { name: "Nor value not default set", @@ -1158,18 +1157,18 @@ func Test_intOrDefault(t *testing.T) { { name: "Value explicitely set", args: args{ - value: pointer.Int32(100), - defValue: pointer.Int32(10), + value: util.Pointer[int32](100), + defValue: util.Pointer[int32](10), }, - want: pointer.Int32(100), + want: util.Pointer[int32](100), }, { name: "Value not set", args: args{ value: nil, - defValue: pointer.Int32(10), + defValue: util.Pointer[int32](10), }, - want: pointer.Int32(10), + want: util.Pointer[int32](10), }, { name: "Nor value not default set", @@ -1203,18 +1202,18 @@ func Test_boolOrDefault(t *testing.T) { { name: "Value explicitely set", args: args{ - value: pointer.Bool(true), - defValue: pointer.Bool(false), + value: util.Pointer(true), + defValue: util.Pointer(false), }, - want: pointer.Bool(true), + want: util.Pointer(true), }, { name: "Value not set", args: args{ value: nil, - defValue: pointer.Bool(false), + defValue: util.Pointer(false), }, - want: pointer.Bool(false), + want: util.Pointer(false), }, { name: "Nor value not default set", @@ -1263,16 +1262,16 @@ func TestCanary_CanarySpec(t *testing.T) { args: args{ spec: &BackendSpec{ Image: &ImageSpec{ - Name: pointer.String("old"), - Tag: pointer.String("tag"), + Name: util.Pointer("old"), + Tag: util.Pointer("tag"), }, }, canarySpec: &BackendSpec{}, }, want: &BackendSpec{ Image: &ImageSpec{ - Name: pointer.String("new"), - Tag: pointer.String("tag"), + Name: util.Pointer("new"), + Tag: util.Pointer("tag"), }, }, wantErr: false, @@ -1316,26 +1315,26 @@ func TestExternalSecretSecretStoreReferenceSpec_Default(t *testing.T) { name: "Sets defaults", fields: fields{}, args: args{def: defaultExternalSecretSecretStoreReferenceSpec{ - Name: pointer.String("vault-mgmt"), - Kind: pointer.String("ClusterSecretStore"), + Name: util.Pointer("vault-mgmt"), + Kind: util.Pointer("ClusterSecretStore"), }}, want: &ExternalSecretSecretStoreReferenceSpec{ - Name: pointer.String("vault-mgmt"), - Kind: pointer.String("ClusterSecretStore"), + Name: util.Pointer("vault-mgmt"), + Kind: util.Pointer("ClusterSecretStore"), }, }, { name: "Combines explicitely set values with defaults", fields: fields{ - Name: pointer.String("other-vault"), + Name: util.Pointer("other-vault"), }, args: args{def: defaultExternalSecretSecretStoreReferenceSpec{ - Name: pointer.String("vault-mgmt"), - Kind: pointer.String("ClusterSecretStore"), + Name: util.Pointer("vault-mgmt"), + Kind: util.Pointer("ClusterSecretStore"), }}, want: &ExternalSecretSecretStoreReferenceSpec{ - Name: pointer.String("other-vault"), - Kind: pointer.String("ClusterSecretStore"), + Name: util.Pointer("other-vault"), + Kind: util.Pointer("ClusterSecretStore"), }, }, } @@ -1366,12 +1365,12 @@ func TestInitializeVaultSecretStoreReferenceSpec(t *testing.T) { { name: "Initializes the struct with appropriate defaults if nil", args: args{nil, defaultExternalSecretSecretStoreReferenceSpec{ - Name: pointer.String("vault-mgmt"), - Kind: pointer.String("ClusterSecretStore"), + Name: util.Pointer("vault-mgmt"), + Kind: util.Pointer("ClusterSecretStore"), }}, want: &ExternalSecretSecretStoreReferenceSpec{ - Name: pointer.String("vault-mgmt"), - Kind: pointer.String("ClusterSecretStore"), + Name: util.Pointer("vault-mgmt"), + Kind: util.Pointer("ClusterSecretStore"), }, }, { diff --git a/api/v1alpha1/corsproxy_types.go b/api/v1alpha1/corsproxy_types.go index d51faefc..b28d712c 100644 --- a/api/v1alpha1/corsproxy_types.go +++ b/api/v1alpha1/corsproxy_types.go @@ -17,20 +17,19 @@ limitations under the License. package v1alpha1 import ( - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) var ( corsproxyDefaultReplicas int32 = 2 corsproxyDefaultImage defaultImageSpec = defaultImageSpec{ - Name: pointer.String("quay.io/3scale/cors-proxy"), - Tag: pointer.String("latest"), - PullPolicy: (*corev1.PullPolicy)(pointer.String(string(corev1.PullIfNotPresent))), + Name: util.Pointer("quay.io/3scale/cors-proxy"), + Tag: util.Pointer("latest"), + PullPolicy: (*corev1.PullPolicy)(util.Pointer(string(corev1.PullIfNotPresent))), } corsproxyDefaultResources defaultResourceRequirementsSpec = defaultResourceRequirementsSpec{ Requests: corev1.ResourceList{ @@ -43,25 +42,25 @@ var ( }, } corsproxyDefaultHPA defaultHorizontalPodAutoscalerSpec = defaultHorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(2), - MaxReplicas: pointer.Int32(4), - ResourceUtilization: pointer.Int32(90), - ResourceName: pointer.String("cpu"), + MinReplicas: util.Pointer[int32](2), + MaxReplicas: util.Pointer[int32](4), + ResourceUtilization: util.Pointer[int32](90), + ResourceName: util.Pointer("cpu"), } corsproxyDefaultProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(3), - TimeoutSeconds: pointer.Int32(1), - PeriodSeconds: pointer.Int32(10), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](3), + TimeoutSeconds: util.Pointer[int32](1), + PeriodSeconds: util.Pointer[int32](10), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } corsproxyDefaultPDB defaultPodDisruptionBudgetSpec = defaultPodDisruptionBudgetSpec{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(1)), } corsproxyDefaultGrafanaDashboard defaultGrafanaDashboardSpec = defaultGrafanaDashboardSpec{ - SelectorKey: pointer.String("monitoring-key"), - SelectorValue: pointer.String("middleware"), + SelectorKey: util.Pointer("monitoring-key"), + SelectorValue: util.Pointer("middleware"), } ) diff --git a/api/v1alpha1/echoapi_types.go b/api/v1alpha1/echoapi_types.go index 4d1d54bf..74b6916c 100644 --- a/api/v1alpha1/echoapi_types.go +++ b/api/v1alpha1/echoapi_types.go @@ -17,29 +17,28 @@ limitations under the License. package v1alpha1 import ( - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) var ( echoapiDefaultImage defaultImageSpec = defaultImageSpec{ - Name: pointer.String("quay.io/3scale/echoapi"), - Tag: pointer.String("v1.0.3"), - PullPolicy: (*corev1.PullPolicy)(pointer.String(string(corev1.PullIfNotPresent))), + Name: util.Pointer("quay.io/3scale/echoapi"), + Tag: util.Pointer("v1.0.3"), + PullPolicy: (*corev1.PullPolicy)(util.Pointer(string(corev1.PullIfNotPresent))), } echoapiDefaultReplicas int32 = 2 echoapiDefaultHPA defaultHorizontalPodAutoscalerSpec = defaultHorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(2), - MaxReplicas: pointer.Int32(4), - ResourceUtilization: pointer.Int32(90), - ResourceName: pointer.String("cpu"), + MinReplicas: util.Pointer[int32](2), + MaxReplicas: util.Pointer[int32](4), + ResourceUtilization: util.Pointer[int32](90), + ResourceName: util.Pointer("cpu"), } echoapiDefaultPDB defaultPodDisruptionBudgetSpec = defaultPodDisruptionBudgetSpec{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(1)), } echoapiDefaultResources defaultResourceRequirementsSpec = defaultResourceRequirementsSpec{ Requests: corev1.ResourceList{ @@ -52,23 +51,23 @@ var ( }, } echoapiDefaultLivenessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(25), - TimeoutSeconds: pointer.Int32(2), - PeriodSeconds: pointer.Int32(20), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(5), + InitialDelaySeconds: util.Pointer[int32](25), + TimeoutSeconds: util.Pointer[int32](2), + PeriodSeconds: util.Pointer[int32](20), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](5), } echoapiDefaultReadinessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(25), - TimeoutSeconds: pointer.Int32(2), - PeriodSeconds: pointer.Int32(20), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(5), + InitialDelaySeconds: util.Pointer[int32](25), + TimeoutSeconds: util.Pointer[int32](2), + PeriodSeconds: util.Pointer[int32](20), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](5), } echoapiDefaultMarin3rSpec defaultMarin3rSidecarSpec = defaultMarin3rSidecarSpec{} echoapiDefaultNLBLoadBalancer defaultNLBLoadBalancerSpec = defaultNLBLoadBalancerSpec{ - ProxyProtocol: pointer.Bool(true), - CrossZoneLoadBalancingEnabled: pointer.Bool(true), + ProxyProtocol: util.Pointer(true), + CrossZoneLoadBalancingEnabled: util.Pointer(true), } ) diff --git a/api/v1alpha1/mappingservice_types.go b/api/v1alpha1/mappingservice_types.go index c1711b24..e0f34cc9 100644 --- a/api/v1alpha1/mappingservice_types.go +++ b/api/v1alpha1/mappingservice_types.go @@ -17,20 +17,19 @@ limitations under the License. package v1alpha1 import ( - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) var ( mappingserviceDefaultReplicas int32 = 2 mappingserviceDefaultImage defaultImageSpec = defaultImageSpec{ - Name: pointer.String("quay.io/3scale/apicast-cloud-hosted"), - Tag: pointer.String("latest"), - PullPolicy: (*corev1.PullPolicy)(pointer.String(string(corev1.PullIfNotPresent))), + Name: util.Pointer("quay.io/3scale/apicast-cloud-hosted"), + Tag: util.Pointer("latest"), + PullPolicy: (*corev1.PullPolicy)(util.Pointer(string(corev1.PullIfNotPresent))), } mappingserviceDefaultResources defaultResourceRequirementsSpec = defaultResourceRequirementsSpec{ Requests: corev1.ResourceList{ @@ -43,32 +42,32 @@ var ( }, } mappingserviceDefaultHPA defaultHorizontalPodAutoscalerSpec = defaultHorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(2), - MaxReplicas: pointer.Int32(4), - ResourceUtilization: pointer.Int32(90), - ResourceName: pointer.String("cpu"), + MinReplicas: util.Pointer[int32](2), + MaxReplicas: util.Pointer[int32](4), + ResourceUtilization: util.Pointer[int32](90), + ResourceName: util.Pointer("cpu"), } mappingserviceLivenessDefaultProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(5), - TimeoutSeconds: pointer.Int32(5), - PeriodSeconds: pointer.Int32(10), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](5), + TimeoutSeconds: util.Pointer[int32](5), + PeriodSeconds: util.Pointer[int32](10), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } mappingserviceReadinessDefaultProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(5), - TimeoutSeconds: pointer.Int32(5), - PeriodSeconds: pointer.Int32(30), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](5), + TimeoutSeconds: util.Pointer[int32](5), + PeriodSeconds: util.Pointer[int32](30), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } mappingserviceDefaultPDB defaultPodDisruptionBudgetSpec = defaultPodDisruptionBudgetSpec{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(1)), } mappingserviceDefaultGrafanaDashboard defaultGrafanaDashboardSpec = defaultGrafanaDashboardSpec{ - SelectorKey: pointer.String("monitoring-key"), - SelectorValue: pointer.String("middleware"), + SelectorKey: util.Pointer("monitoring-key"), + SelectorValue: util.Pointer("middleware"), } mappingserviceDefaultLogLevel string = "warn" ) @@ -157,7 +156,7 @@ type MappingServiceConfig struct { // Default sets default values for any value not specifically set in the MappingServiceConfig struct func (cfg *MappingServiceConfig) Default() { - cfg.LogLevel = stringOrDefault(cfg.LogLevel, pointer.String(mappingserviceDefaultLogLevel)) + cfg.LogLevel = stringOrDefault(cfg.LogLevel, util.Pointer(mappingserviceDefaultLogLevel)) cfg.ExternalSecret.SecretStoreRef = InitializeExternalSecretSecretStoreReferenceSpec(cfg.ExternalSecret.SecretStoreRef, defaultExternalSecretSecretStoreReference) cfg.ExternalSecret.RefreshInterval = durationOrDefault(cfg.ExternalSecret.RefreshInterval, &defaultExternalSecretRefreshInterval) } diff --git a/api/v1alpha1/marin3r_types.go b/api/v1alpha1/marin3r_types.go index 3a1f0e23..3792d8d0 100644 --- a/api/v1alpha1/marin3r_types.go +++ b/api/v1alpha1/marin3r_types.go @@ -4,7 +4,7 @@ import ( "reflect" "sort" - envoyconfig "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/descriptor" + envoyconfig "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/descriptor" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) diff --git a/api/v1alpha1/marin3r_types_test.go b/api/v1alpha1/marin3r_types_test.go index 4f8779c8..28452f59 100644 --- a/api/v1alpha1/marin3r_types_test.go +++ b/api/v1alpha1/marin3r_types_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - envoyconfig "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/descriptor" + envoyconfig "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/descriptor" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" ) diff --git a/api/v1alpha1/redisshard_types.go b/api/v1alpha1/redisshard_types.go index a3a1e62a..fbcb008e 100644 --- a/api/v1alpha1/redisshard_types.go +++ b/api/v1alpha1/redisshard_types.go @@ -20,17 +20,16 @@ import ( "strconv" "strings" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" ) var ( redisShardDefaultImage defaultImageSpec = defaultImageSpec{ - Name: pointer.String("redis"), - Tag: pointer.String("4.0.11-alpine"), - PullPolicy: (*corev1.PullPolicy)(pointer.String(string(corev1.PullIfNotPresent))), + Name: util.Pointer("redis"), + Tag: util.Pointer("4.0.11-alpine"), + PullPolicy: (*corev1.PullPolicy)(util.Pointer(string(corev1.PullIfNotPresent))), } redisShardDefaultMasterIndex int32 = 0 redisShardDefaultCommand string = "redis-server /redis/redis.conf" diff --git a/api/v1alpha1/sentinel_types.go b/api/v1alpha1/sentinel_types.go index 5f6cd4b7..b8bb4cb4 100644 --- a/api/v1alpha1/sentinel_types.go +++ b/api/v1alpha1/sentinel_types.go @@ -21,15 +21,14 @@ import ( "sort" "time" - "github.com/3scale/saas-operator/pkg/redis/client" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/redis/sharded" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/redis/client" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" + "github.com/3scale-ops/saas-operator/pkg/redis/sharded" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) const ( @@ -42,9 +41,9 @@ var ( SentinelDefaultReplicas int32 = 3 SentinelDefaultQuorum int = 2 sentinelDefaultImage defaultImageSpec = defaultImageSpec{ - Name: pointer.String("bitnami/redis-sentinel"), - Tag: pointer.String("4.0.11-debian-9-r110"), - PullPolicy: (*corev1.PullPolicy)(pointer.String(string(corev1.PullIfNotPresent))), + Name: util.Pointer("bitnami/redis-sentinel"), + Tag: util.Pointer("4.0.11-debian-9-r110"), + PullPolicy: (*corev1.PullPolicy)(util.Pointer(string(corev1.PullIfNotPresent))), } sentinelDefaultResources defaultResourceRequirementsSpec = defaultResourceRequirementsSpec{ Requests: corev1.ResourceList{ @@ -57,19 +56,19 @@ var ( }, } sentinelDefaultProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(25), - TimeoutSeconds: pointer.Int32(1), - PeriodSeconds: pointer.Int32(10), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](25), + TimeoutSeconds: util.Pointer[int32](1), + PeriodSeconds: util.Pointer[int32](10), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } sentinelDefaultPDB defaultPodDisruptionBudgetSpec = defaultPodDisruptionBudgetSpec{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(1)), } sentinelDefaultGrafanaDashboard defaultGrafanaDashboardSpec = defaultGrafanaDashboardSpec{ - SelectorKey: pointer.String("monitoring-key"), - SelectorValue: pointer.String("middleware"), + SelectorKey: util.Pointer("monitoring-key"), + SelectorValue: util.Pointer("middleware"), } sentinelDefaultStorageSize string = "10Mi" sentinelDefaultMetricsRefreshInterval time.Duration = 30 * time.Second diff --git a/api/v1alpha1/sentinel_types_test.go b/api/v1alpha1/sentinel_types_test.go index 053c6c12..1a737555 100644 --- a/api/v1alpha1/sentinel_types_test.go +++ b/api/v1alpha1/sentinel_types_test.go @@ -20,10 +20,10 @@ import ( "context" "testing" - "github.com/3scale/saas-operator/pkg/redis/client" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/redis/sharded" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/redis/client" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" + "github.com/3scale-ops/saas-operator/pkg/redis/sharded" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" ) diff --git a/api/v1alpha1/shardedredisbackup_types.go b/api/v1alpha1/shardedredisbackup_types.go index f2e4400b..9ac919cf 100644 --- a/api/v1alpha1/shardedredisbackup_types.go +++ b/api/v1alpha1/shardedredisbackup_types.go @@ -22,7 +22,8 @@ import ( "sort" "time" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/samber/lo" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -189,11 +190,11 @@ func (status *ShardedRedisBackupStatus) ApplyHistoryLimit(limit int32, shards [] } } - var joint BackupStatusList = util.ConcatSlices(truncated) - sort.Sort(sort.Reverse(joint)) + var flat BackupStatusList = lo.Flatten(truncated) + sort.Sort(sort.Reverse(flat)) - if !reflect.DeepEqual(joint, status.Backups) { - status.Backups = joint + if !reflect.DeepEqual(flat, status.Backups) { + status.Backups = flat return true } diff --git a/api/v1alpha1/system_types.go b/api/v1alpha1/system_types.go index 36e49ec6..27cc2302 100644 --- a/api/v1alpha1/system_types.go +++ b/api/v1alpha1/system_types.go @@ -17,12 +17,11 @@ limitations under the License. package v1alpha1 import ( - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -48,21 +47,21 @@ var ( systemDefaultConfigFilesSecret string = "system-config" systemDefaultBugsnagSpec BugsnagSpec = BugsnagSpec{} systemDefaultImage defaultImageSpec = defaultImageSpec{ - Name: pointer.String("quay.io/3scale/porta"), - Tag: pointer.String("nightly"), - PullPolicy: (*corev1.PullPolicy)(pointer.String(string(corev1.PullIfNotPresent))), + Name: util.Pointer("quay.io/3scale/porta"), + Tag: util.Pointer("nightly"), + PullPolicy: (*corev1.PullPolicy)(util.Pointer(string(corev1.PullIfNotPresent))), } systemDefaultGrafanaDashboard defaultGrafanaDashboardSpec = defaultGrafanaDashboardSpec{ - SelectorKey: pointer.String("monitoring-key"), - SelectorValue: pointer.String("middleware"), + SelectorKey: util.Pointer("monitoring-key"), + SelectorValue: util.Pointer("middleware"), } - systemDefaultTerminationGracePeriodSeconds *int64 = pointer.Int64(60) + systemDefaultTerminationGracePeriodSeconds *int64 = util.Pointer[int64](60) systemDefaultSearchServer SearchServerSpec = SearchServerSpec{ AddressSpec: AddressSpec{ - Host: pointer.String("system-searchd"), - Port: pointer.Int32(9306), + Host: util.Pointer("system-searchd"), + Port: util.Pointer[int32](9306), }, - BatchSize: pointer.Int32(100), + BatchSize: util.Pointer[int32](100), } // App @@ -78,31 +77,31 @@ var ( }, } systemDefaultAppDeploymentStrategy defaultDeploymentRollingStrategySpec = defaultDeploymentRollingStrategySpec{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(0)), - MaxSurge: util.IntStrPtr(intstr.FromString("10%")), + MaxUnavailable: util.Pointer(intstr.FromInt(0)), + MaxSurge: util.Pointer(intstr.FromString("10%")), } systemDefaultAppHPA defaultHorizontalPodAutoscalerSpec = defaultHorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(2), - MaxReplicas: pointer.Int32(4), - ResourceUtilization: pointer.Int32(90), - ResourceName: pointer.String("cpu"), + MinReplicas: util.Pointer[int32](2), + MaxReplicas: util.Pointer[int32](4), + ResourceUtilization: util.Pointer[int32](90), + ResourceName: util.Pointer("cpu"), } systemDefaultAppLivenessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(30), - TimeoutSeconds: pointer.Int32(1), - PeriodSeconds: pointer.Int32(10), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](30), + TimeoutSeconds: util.Pointer[int32](1), + PeriodSeconds: util.Pointer[int32](10), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } systemDefaultAppReadinessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(30), - TimeoutSeconds: pointer.Int32(5), - PeriodSeconds: pointer.Int32(10), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](30), + TimeoutSeconds: util.Pointer[int32](5), + PeriodSeconds: util.Pointer[int32](10), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } systemDefaultAppPDB defaultPodDisruptionBudgetSpec = defaultPodDisruptionBudgetSpec{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(1)), } // Sidekiq @@ -118,31 +117,31 @@ var ( }, } systemDefaultSidekiqDeploymentStrategy defaultDeploymentRollingStrategySpec = defaultDeploymentRollingStrategySpec{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(0)), - MaxSurge: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(0)), + MaxSurge: util.Pointer(intstr.FromInt(1)), } systemDefaultSidekiqHPA defaultHorizontalPodAutoscalerSpec = defaultHorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(2), - MaxReplicas: pointer.Int32(4), - ResourceUtilization: pointer.Int32(90), - ResourceName: pointer.String("cpu"), + MinReplicas: util.Pointer[int32](2), + MaxReplicas: util.Pointer[int32](4), + ResourceUtilization: util.Pointer[int32](90), + ResourceName: util.Pointer("cpu"), } systemDefaultSidekiqLivenessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(10), - TimeoutSeconds: pointer.Int32(3), - PeriodSeconds: pointer.Int32(15), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(5), + InitialDelaySeconds: util.Pointer[int32](10), + TimeoutSeconds: util.Pointer[int32](3), + PeriodSeconds: util.Pointer[int32](15), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](5), } systemDefaultSidekiqReadinessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(10), - TimeoutSeconds: pointer.Int32(5), - PeriodSeconds: pointer.Int32(30), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(5), + InitialDelaySeconds: util.Pointer[int32](10), + TimeoutSeconds: util.Pointer[int32](5), + PeriodSeconds: util.Pointer[int32](30), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](5), } systemDefaultSidekiqPDB defaultPodDisruptionBudgetSpec = defaultPodDisruptionBudgetSpec{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(1)), } systemDefaultSidekiqConfigDefault defaultSidekiqConfig = defaultSidekiqConfig{ @@ -150,25 +149,25 @@ var ( "critical", "backend_sync", "events", "zync,40", "priority,25", "default,15", "web_hooks,10", "deletion,5", }, - MaxThreads: pointer.Int32(15), + MaxThreads: util.Pointer[int32](15), } systemDefaultSidekiqConfigBilling defaultSidekiqConfig = defaultSidekiqConfig{ Queues: []string{"billing"}, - MaxThreads: pointer.Int32(15), + MaxThreads: util.Pointer[int32](15), } systemDefaultSidekiqConfigLow defaultSidekiqConfig = defaultSidekiqConfig{ Queues: []string{ "mailers", "low", "bulk_indexing", }, - MaxThreads: pointer.Int32(15), + MaxThreads: util.Pointer[int32](15), } // Searchd systemDefaultSearchdEnabled bool = true systemDefaultSearchdImage defaultImageSpec = defaultImageSpec{ - Name: pointer.String("quay.io/3scale/searchd"), - Tag: pointer.String("latest"), - PullPolicy: (*corev1.PullPolicy)(pointer.String(string(corev1.PullIfNotPresent))), + Name: util.Pointer("quay.io/3scale/searchd"), + Tag: util.Pointer("latest"), + PullPolicy: (*corev1.PullPolicy)(util.Pointer(string(corev1.PullIfNotPresent))), } systemDefaultSearchdServiceName string = "system-searchd" systemDefaultSearchdPort int32 = 9306 @@ -185,18 +184,18 @@ var ( }, } systemDefaultSearchdLivenessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(60), - TimeoutSeconds: pointer.Int32(3), - PeriodSeconds: pointer.Int32(15), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(5), + InitialDelaySeconds: util.Pointer[int32](60), + TimeoutSeconds: util.Pointer[int32](3), + PeriodSeconds: util.Pointer[int32](15), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](5), } systemDefaultSearchdReadinessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(60), - TimeoutSeconds: pointer.Int32(5), - PeriodSeconds: pointer.Int32(30), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(5), + InitialDelaySeconds: util.Pointer[int32](60), + TimeoutSeconds: util.Pointer[int32](5), + PeriodSeconds: util.Pointer[int32](30), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](5), } systemDefaultRailsConsoleResources defaultResourceRequirementsSpec = defaultResourceRequirementsSpec{ Requests: corev1.ResourceList{ @@ -210,8 +209,8 @@ var ( } systemDefaultSystemTektonTasks []SystemTektonTaskSpec = []SystemTektonTaskSpec{ { - Name: pointer.String("system-backend-sync"), - Description: pointer.String("Runs the Backend Synchronization task"), + Name: util.Pointer("system-backend-sync"), + Description: util.Pointer("Runs the Backend Synchronization task"), Config: &SystemTektonTaskConfig{ Command: []string{"container-entrypoint"}, Args: []string{ @@ -223,8 +222,8 @@ var ( }, }, { - Name: pointer.String("system-db-migrate"), - Description: pointer.String("Runs the Database Migration task"), + Name: util.Pointer("system-db-migrate"), + Description: util.Pointer("Runs the Database Migration task"), Config: &SystemTektonTaskConfig{ Command: []string{"container-entrypoint"}, Args: []string{ @@ -236,8 +235,8 @@ var ( }, }, { - Name: pointer.String("system-searchd-reindex"), - Description: pointer.String("Runs the Searchd Rendexation task"), + Name: util.Pointer("system-searchd-reindex"), + Description: util.Pointer("Runs the Searchd Rendexation task"), Config: &SystemTektonTaskConfig{ Command: []string{"container-entrypoint"}, Args: []string{ @@ -492,17 +491,17 @@ func (sc *SystemConfig) Default() { } sc.Rails.Default() - sc.ConfigFilesSecret = stringOrDefault(sc.ConfigFilesSecret, pointer.String(systemDefaultConfigFilesSecret)) + sc.ConfigFilesSecret = stringOrDefault(sc.ConfigFilesSecret, util.Pointer(systemDefaultConfigFilesSecret)) if sc.Bugsnag == nil { sc.Bugsnag = &systemDefaultBugsnagSpec } - sc.SandboxProxyOpensslVerifyMode = stringOrDefault(sc.SandboxProxyOpensslVerifyMode, pointer.String(systemDefaultSandboxProxyOpensslVerifyMode)) - sc.ForceSSL = boolOrDefault(sc.ForceSSL, pointer.Bool(systemDefaultForceSSL)) - sc.SSLCertsDir = stringOrDefault(sc.SSLCertsDir, pointer.String(systemDefaultSSLCertsDir)) - sc.ThreescaleProviderPlan = stringOrDefault(sc.ThreescaleProviderPlan, pointer.String(systemDefaultThreescaleProviderPlan)) - sc.ThreescaleSuperdomain = stringOrDefault(sc.ThreescaleSuperdomain, pointer.String(systemDefaultThreescaleSuperdomain)) + sc.SandboxProxyOpensslVerifyMode = stringOrDefault(sc.SandboxProxyOpensslVerifyMode, util.Pointer(systemDefaultSandboxProxyOpensslVerifyMode)) + sc.ForceSSL = boolOrDefault(sc.ForceSSL, util.Pointer(systemDefaultForceSSL)) + sc.SSLCertsDir = stringOrDefault(sc.SSLCertsDir, util.Pointer(systemDefaultSSLCertsDir)) + sc.ThreescaleProviderPlan = stringOrDefault(sc.ThreescaleProviderPlan, util.Pointer(systemDefaultThreescaleProviderPlan)) + sc.ThreescaleSuperdomain = stringOrDefault(sc.ThreescaleSuperdomain, util.Pointer(systemDefaultThreescaleSuperdomain)) sc.ExternalSecret.SecretStoreRef = InitializeExternalSecretSecretStoreReferenceSpec(sc.ExternalSecret.SecretStoreRef, defaultExternalSecretSecretStoreReference) sc.ExternalSecret.RefreshInterval = durationOrDefault(sc.ExternalSecret.RefreshInterval, &defaultExternalSecretRefreshInterval) @@ -690,9 +689,9 @@ type SystemRailsSpec struct { // Default applies defaults for SystemRailsSpec func (srs *SystemRailsSpec) Default() { - srs.Console = boolOrDefault(srs.Console, pointer.Bool(systemDefaultRailsConsole)) - srs.Environment = stringOrDefault(srs.Environment, pointer.String(systemDefaultRailsEnvironment)) - srs.LogLevel = stringOrDefault(srs.LogLevel, pointer.String(systemDefaultRailsLogLevel)) + srs.Console = boolOrDefault(srs.Console, util.Pointer(systemDefaultRailsConsole)) + srs.Environment = stringOrDefault(srs.Environment, util.Pointer(systemDefaultRailsEnvironment)) + srs.LogLevel = stringOrDefault(srs.LogLevel, util.Pointer(systemDefaultRailsLogLevel)) } // SystemAppSpec configures the App component of System @@ -830,7 +829,7 @@ func (cfg *SidekiqConfig) Default(def defaultSidekiqConfig) { if cfg.Queues == nil { cfg.Queues = def.Queues } - cfg.MaxThreads = intOrDefault(cfg.MaxThreads, pointer.Int32(*def.MaxThreads)) + cfg.MaxThreads = intOrDefault(cfg.MaxThreads, util.Pointer[int32](*def.MaxThreads)) } // Default implements defaulting for the system Sidekiq component @@ -900,7 +899,7 @@ type SystemSearchdSpec struct { // Default implements defaulting for the system searchd component func (spec *SystemSearchdSpec) Default() { - spec.Enabled = boolOrDefault(spec.Enabled, pointer.Bool(systemDefaultSearchdEnabled)) + spec.Enabled = boolOrDefault(spec.Enabled, util.Pointer(systemDefaultSearchdEnabled)) spec.Image = InitializeImageSpec(spec.Image, defaultImageSpec(systemDefaultSearchdImage)) spec.Resources = InitializeResourceRequirementsSpec(spec.Resources, systemDefaultSearchdResources) spec.LivenessProbe = InitializeProbeSpec(spec.LivenessProbe, systemDefaultSearchdLivenessProbe) @@ -940,9 +939,9 @@ type SearchdConfig struct { // Default implements defaulting for SearchdConfig func (sc *SearchdConfig) Default() { - sc.ServiceName = stringOrDefault(sc.ServiceName, pointer.String(systemDefaultSearchdServiceName)) - sc.Port = intOrDefault(sc.Port, pointer.Int32(systemDefaultSearchdPort)) - sc.DatabasePath = stringOrDefault(sc.DatabasePath, pointer.String(systemDefaultSearchdDBPath)) + sc.ServiceName = stringOrDefault(sc.ServiceName, util.Pointer(systemDefaultSearchdServiceName)) + sc.Port = intOrDefault(sc.Port, util.Pointer[int32](systemDefaultSearchdPort)) + sc.DatabasePath = stringOrDefault(sc.DatabasePath, util.Pointer(systemDefaultSearchdDBPath)) if sc.DatabaseStorageSize == nil { size := resource.MustParse(systemDefaultSearchdDatabaseStorageSize) sc.DatabaseStorageSize = &size @@ -1124,7 +1123,7 @@ func (spec *SystemTektonTaskSpec) Default(systemDefaultImage *ImageSpec) { } spec.Description = stringOrDefault(spec.Description, spec.Name) - spec.Enabled = boolOrDefault(spec.Enabled, pointer.Bool(true)) + spec.Enabled = boolOrDefault(spec.Enabled, util.Pointer(true)) spec.Config.Default(systemDefaultImage) spec.Resources = InitializeResourceRequirementsSpec(spec.Resources, systemDefaultSystemTektonTaskResources) diff --git a/api/v1alpha1/twemproxy_types.go b/api/v1alpha1/twemproxy_types.go index 0a39779a..a0b61c84 100644 --- a/api/v1alpha1/twemproxy_types.go +++ b/api/v1alpha1/twemproxy_types.go @@ -3,33 +3,33 @@ package v1alpha1 import ( "time" + "github.com/3scale-ops/basereconciler/util" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" ) var ( // Twemproxy defaults defaultTwemproxyLivenessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(0), - TimeoutSeconds: pointer.Int32(1), - PeriodSeconds: pointer.Int32(5), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](0), + TimeoutSeconds: util.Pointer[int32](1), + PeriodSeconds: util.Pointer[int32](5), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } defaultTwemproxyReadinessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(0), - TimeoutSeconds: pointer.Int32(1), - PeriodSeconds: pointer.Int32(5), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](0), + TimeoutSeconds: util.Pointer[int32](1), + PeriodSeconds: util.Pointer[int32](5), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } // TODO: add requirements defaultTwemproxyResources defaultResourceRequirementsSpec = defaultResourceRequirementsSpec{} defaultTwemproxyImage defaultImageSpec = defaultImageSpec{ - Name: pointer.String("quay.io/3scale/twemproxy"), - Tag: pointer.String("v0.5.0"), - PullPolicy: (*corev1.PullPolicy)(pointer.String(string(corev1.PullIfNotPresent))), + Name: util.Pointer("quay.io/3scale/twemproxy"), + Tag: util.Pointer("v0.5.0"), + PullPolicy: (*corev1.PullPolicy)(util.Pointer(string(corev1.PullIfNotPresent))), } twemproxyDefaultLogLevel int32 = 6 twemproxyDefaultMetricsPort int32 = 9151 diff --git a/api/v1alpha1/twemproxyconfig_types.go b/api/v1alpha1/twemproxyconfig_types.go index a3ac8e6b..62646e57 100644 --- a/api/v1alpha1/twemproxyconfig_types.go +++ b/api/v1alpha1/twemproxyconfig_types.go @@ -19,9 +19,8 @@ package v1alpha1 import ( "fmt" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -30,8 +29,8 @@ var ( TwemproxySyncAnnotationKey string = fmt.Sprintf("%s/twemproxyconfig.configmap-hash", GroupVersion.Group) twemproxyDefaultGrafanaDashboard defaultGrafanaDashboardSpec = defaultGrafanaDashboardSpec{ - SelectorKey: pointer.String("monitoring-key"), - SelectorValue: pointer.String("middleware"), + SelectorKey: util.Pointer("monitoring-key"), + SelectorValue: util.Pointer("middleware"), } ) @@ -65,7 +64,7 @@ func (spec *TwemproxyConfigSpec) Default() { spec.ServerPools[idx].Default() } if spec.ReconcileServerPools == nil { - spec.ReconcileServerPools = pointer.Bool(true) + spec.ReconcileServerPools = util.Pointer(true) } spec.GrafanaDashboard = InitializeGrafanaDashboardSpec(spec.GrafanaDashboard, twemproxyDefaultGrafanaDashboard) } diff --git a/api/v1alpha1/zync_types.go b/api/v1alpha1/zync_types.go index 4df06327..5a23a325 100644 --- a/api/v1alpha1/zync_types.go +++ b/api/v1alpha1/zync_types.go @@ -17,23 +17,22 @@ limitations under the License. package v1alpha1 import ( - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) var ( zyncDefaultImage defaultImageSpec = defaultImageSpec{ - Name: pointer.String("quay.io/3scale/zync"), - Tag: pointer.String("nightly"), - PullPolicy: (*corev1.PullPolicy)(pointer.String(string(corev1.PullIfNotPresent))), + Name: util.Pointer("quay.io/3scale/zync"), + Tag: util.Pointer("nightly"), + PullPolicy: (*corev1.PullPolicy)(util.Pointer(string(corev1.PullIfNotPresent))), } zyncDefaultGrafanaDashboard defaultGrafanaDashboardSpec = defaultGrafanaDashboardSpec{ - SelectorKey: pointer.String("monitoring-key"), - SelectorValue: pointer.String("middleware"), + SelectorKey: util.Pointer("monitoring-key"), + SelectorValue: util.Pointer("middleware"), } zyncDefaultRailsConsoleEnabled bool = false zyncDefaultConfigRailsEnvironment string = "development" @@ -41,13 +40,13 @@ var ( zyncDefaultConfigRailsMaxThreads int32 = 10 zyncDefaultConfigBugsnagSpec BugsnagSpec = BugsnagSpec{} zyncDefaultAPIHPA defaultHorizontalPodAutoscalerSpec = defaultHorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(2), - MaxReplicas: pointer.Int32(4), - ResourceUtilization: pointer.Int32(90), - ResourceName: pointer.String("cpu"), + MinReplicas: util.Pointer[int32](2), + MaxReplicas: util.Pointer[int32](4), + ResourceUtilization: util.Pointer[int32](90), + ResourceName: util.Pointer("cpu"), } zyncDefaultAPIPDB defaultPodDisruptionBudgetSpec = defaultPodDisruptionBudgetSpec{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(1)), } zyncDefaultAPIReplicas int32 = 2 zyncDefaultAPIResources defaultResourceRequirementsSpec = defaultResourceRequirementsSpec{ @@ -61,27 +60,27 @@ var ( }, } zyncDefaultAPILivenessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(10), - TimeoutSeconds: pointer.Int32(30), - PeriodSeconds: pointer.Int32(10), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](10), + TimeoutSeconds: util.Pointer[int32](30), + PeriodSeconds: util.Pointer[int32](10), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } zyncDefaultAPIReadinessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(30), - TimeoutSeconds: pointer.Int32(10), - PeriodSeconds: pointer.Int32(10), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](30), + TimeoutSeconds: util.Pointer[int32](10), + PeriodSeconds: util.Pointer[int32](10), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } zyncDefaultQueHPA defaultHorizontalPodAutoscalerSpec = defaultHorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(2), - MaxReplicas: pointer.Int32(4), - ResourceUtilization: pointer.Int32(90), - ResourceName: pointer.String("cpu"), + MinReplicas: util.Pointer[int32](2), + MaxReplicas: util.Pointer[int32](4), + ResourceUtilization: util.Pointer[int32](90), + ResourceName: util.Pointer("cpu"), } zyncDefaultQuePDB defaultPodDisruptionBudgetSpec = defaultPodDisruptionBudgetSpec{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(1)), } zyncDefaultQueReplicas int32 = 2 zyncDefaultQueResources defaultResourceRequirementsSpec = defaultResourceRequirementsSpec{ @@ -95,18 +94,18 @@ var ( }, } zyncDefaultQueLivenessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(10), - TimeoutSeconds: pointer.Int32(30), - PeriodSeconds: pointer.Int32(10), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](10), + TimeoutSeconds: util.Pointer[int32](30), + PeriodSeconds: util.Pointer[int32](10), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } zyncDefaultQueReadinessProbe defaultProbeSpec = defaultProbeSpec{ - InitialDelaySeconds: pointer.Int32(30), - TimeoutSeconds: pointer.Int32(10), - PeriodSeconds: pointer.Int32(10), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](30), + TimeoutSeconds: util.Pointer[int32](10), + PeriodSeconds: util.Pointer[int32](10), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), } zyncDefaultRailsConsoleResources defaultResourceRequirementsSpec = defaultResourceRequirementsSpec{ Requests: corev1.ResourceList{ @@ -315,9 +314,9 @@ type ZyncRailsSpec struct { // Default applies defaults for ZyncRailsSpec func (zrs *ZyncRailsSpec) Default() { - zrs.Environment = stringOrDefault(zrs.Environment, pointer.String(zyncDefaultConfigRailsEnvironment)) - zrs.LogLevel = stringOrDefault(zrs.LogLevel, pointer.String(zyncDefaultConfigRailsLogLevel)) - zrs.MaxThreads = intOrDefault(zrs.MaxThreads, pointer.Int32(zyncDefaultConfigRailsMaxThreads)) + zrs.Environment = stringOrDefault(zrs.Environment, util.Pointer(zyncDefaultConfigRailsEnvironment)) + zrs.LogLevel = stringOrDefault(zrs.LogLevel, util.Pointer(zyncDefaultConfigRailsLogLevel)) + zrs.MaxThreads = intOrDefault(zrs.MaxThreads, util.Pointer[int32](zyncDefaultConfigRailsMaxThreads)) } // ZyncRailsConsoleSpec configures the Console component of Zync @@ -344,7 +343,7 @@ type ZyncRailsConsoleSpec struct { // Default implements defaulting for the Zync console component func (spec *ZyncRailsConsoleSpec) Default(zyncDefaultImage *ImageSpec) { - spec.Enabled = boolOrDefault(spec.Enabled, pointer.Bool(zyncDefaultRailsConsoleEnabled)) + spec.Enabled = boolOrDefault(spec.Enabled, util.Pointer(zyncDefaultRailsConsoleEnabled)) spec.Image = InitializeImageSpec(spec.Image, defaultImageSpec(*zyncDefaultImage)) spec.Resources = InitializeResourceRequirementsSpec(spec.Resources, zyncDefaultRailsConsoleResources) } diff --git a/bundle/manifests/saas-operator.clusterserviceversion.yaml b/bundle/manifests/saas-operator.clusterserviceversion.yaml index 6dbbc4f3..e9b448c5 100644 --- a/bundle/manifests/saas-operator.clusterserviceversion.yaml +++ b/bundle/manifests/saas-operator.clusterserviceversion.yaml @@ -598,15 +598,15 @@ metadata: capabilities: Basic Install categories: Integration & Delivery containerImage: quay.io/3scale/saas-operator - createdAt: "2023-12-15T15:34:26Z" + createdAt: "2023-12-15T16:09:07Z" description: |- The 3scale SaaS Operator creates and maintains a SaaS-ready deployment of the Red Hat 3scale API Management on OpenShift. operators.operatorframework.io/builder: operator-sdk-v1.27.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 - repository: https://github.com/3scale/saas-operator + repository: https://github.com/3scale-ops/saas-operator support: Red Hat - name: saas-operator.v0.21.0-alpha.13 + name: saas-operator.v0.21.0-alpha.14 namespace: placeholder spec: apiservicedefinitions: {} @@ -4440,13 +4440,13 @@ spec: ## Documentation - - [Getting started](https://github.com/3scale/saas-operator/blob/master/docs/getting-started.md) - - [Custom Resource Definitions reference](https://github.com/3scale/saas-operator/tree/master/docs/reference) - - [Development](https://github.com/3scale/saas-operator/blob/master/docs/development.md) + - [Getting started](https://github.com/3scale-ops/saas-operator/blob/master/docs/getting-started.md) + - [Custom Resource Definitions reference](https://github.com/3scale-ops/saas-operator/tree/master/docs/reference) + - [Development](https://github.com/3scale-ops/saas-operator/blob/master/docs/development.md) ## License - 3scale SaaS Operator is licensed under the [Apache 2.0 license](https://github.com/3scale/saas-operator/blob/master/LICENSE) + 3scale SaaS Operator is licensed under the [Apache 2.0 license](https://github.com/3scale-ops/saas-operator/blob/master/LICENSE) displayName: 3scale SaaS Operator icon: - base64data: | @@ -4481,7 +4481,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.annotations['olm.targetNamespaces'] - image: quay.io/3scale/saas-operator:v0.21.0-alpha.13 + image: quay.io/3scale/saas-operator:v0.21.0-alpha.14 livenessProbe: httpGet: path: /healthz @@ -5035,7 +5035,7 @@ spec: - operations links: - name: GitHub Repository - url: https://github.com/3scale/saas-operator + url: https://github.com/3scale-ops/saas-operator - name: 3scale url: https://3scale.net maintainers: @@ -5045,4 +5045,4 @@ spec: provider: name: Red Hat url: https://www.3scale.net/ - version: 0.21.0-alpha.13 + version: 0.21.0-alpha.14 diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index e92970d1..19ae93b5 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -13,4 +13,4 @@ kind: Kustomization images: - name: controller newName: quay.io/3scale/saas-operator - newTag: v0.21.0-alpha.13 + newTag: v0.21.0-alpha.14 diff --git a/config/manifests/bases/saas-operator.clusterserviceversion.yaml b/config/manifests/bases/saas-operator.clusterserviceversion.yaml index 2c23c03b..3b2c8de8 100644 --- a/config/manifests/bases/saas-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/saas-operator.clusterserviceversion.yaml @@ -12,7 +12,7 @@ metadata: of the Red Hat 3scale API Management on OpenShift. operators.operatorframework.io/builder: operator-sdk-v1.3.0 operators.operatorframework.io/project_layout: ansible.sdk.operatorframework.io/v1 - repository: https://github.com/3scale/saas-operator + repository: https://github.com/3scale-ops/saas-operator support: Red Hat name: saas-operator.v0.0.0 namespace: placeholder @@ -3981,13 +3981,13 @@ spec: ## Documentation - - [Getting started](https://github.com/3scale/saas-operator/blob/master/docs/getting-started.md) - - [Custom Resource Definitions reference](https://github.com/3scale/saas-operator/tree/master/docs/reference) - - [Development](https://github.com/3scale/saas-operator/blob/master/docs/development.md) + - [Getting started](https://github.com/3scale-ops/saas-operator/blob/master/docs/getting-started.md) + - [Custom Resource Definitions reference](https://github.com/3scale-ops/saas-operator/tree/master/docs/reference) + - [Development](https://github.com/3scale-ops/saas-operator/blob/master/docs/development.md) ## License - 3scale SaaS Operator is licensed under the [Apache 2.0 license](https://github.com/3scale/saas-operator/blob/master/LICENSE) + 3scale SaaS Operator is licensed under the [Apache 2.0 license](https://github.com/3scale-ops/saas-operator/blob/master/LICENSE) displayName: 3scale SaaS Operator icon: - base64data: | @@ -4012,7 +4012,7 @@ spec: - operations links: - name: GitHub Repository - url: https://github.com/3scale/saas-operator + url: https://github.com/3scale-ops/saas-operator - name: 3scale url: https://3scale.net maintainers: diff --git a/controllers/apicast_controller.go b/controllers/apicast_controller.go index 98a0fc63..185aeea5 100644 --- a/controllers/apicast_controller.go +++ b/controllers/apicast_controller.go @@ -19,10 +19,12 @@ package controllers import ( "context" + "github.com/3scale-ops/basereconciler/reconciler" + "github.com/3scale-ops/basereconciler/util" marin3rv1alpha1 "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators/apicast" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators/apicast" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" "github.com/go-logr/logr" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" @@ -58,14 +60,12 @@ func (r *ApicastReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct ctx = log.IntoContext(ctx, logger) instance := &saasv1alpha1.Apicast{} - result := r.ManageResourceLifecycle(ctx, req, instance) + result := r.ManageResourceLifecycle(ctx, req, instance, + reconciler.WithInMemoryInitializationFunc(util.ResourceDefaulter(instance))) if result.ShouldReturn() { return result.Values() } - // Apply defaults for reconcile but do not store them in the API - instance.Default() - gen, err := apicast.NewGenerator(instance.GetName(), instance.GetNamespace(), instance.Spec) if err != nil { return ctrl.Result{}, err diff --git a/controllers/apicast_controller_suite_test.go b/controllers/apicast_controller_suite_test.go index 243e0c93..f27f698b 100644 --- a/controllers/apicast_controller_suite_test.go +++ b/controllers/apicast_controller_suite_test.go @@ -4,9 +4,10 @@ import ( "context" "fmt" + "github.com/3scale-ops/basereconciler/util" marin3rv1alpha1 "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - testutil "github.com/3scale/saas-operator/test/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + testutil "github.com/3scale-ops/saas-operator/test/util" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -15,7 +16,6 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -253,15 +253,15 @@ var _ = Describe("Apicast controller", func() { DNS: []string{"updated-apicast-production.example.com"}, }, HPA: &saasv1alpha1.HorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(3), + MinReplicas: util.Pointer[int32](3), }, LivenessProbe: &saasv1alpha1.ProbeSpec{}, ReadinessProbe: &saasv1alpha1.ProbeSpec{}, Marin3r: &saasv1alpha1.Marin3rSidecarSpec{ - NodeID: pointer.String("apicast-production"), + NodeID: util.Pointer("apicast-production"), EnvoyDynamicConfig: saasv1alpha1.MapOfEnvoyDynamicConfig{ "http": { - GeneratorVersion: pointer.String("v1"), + GeneratorVersion: util.Pointer("v1"), ListenerHttp: &saasv1alpha1.ListenerHttp{ Port: 8080, RouteConfigName: "route", @@ -278,16 +278,16 @@ var _ = Describe("Apicast controller", func() { DNS: []string{"updated-apicast-staging.example.com"}, }, HPA: &saasv1alpha1.HorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(3), + MinReplicas: util.Pointer[int32](3), }, LivenessProbe: &saasv1alpha1.ProbeSpec{}, ReadinessProbe: &saasv1alpha1.ProbeSpec{}, Marin3r: &saasv1alpha1.Marin3rSidecarSpec{ - NodeID: pointer.String("apicast-production"), + NodeID: util.Pointer("apicast-production"), EnvoyDynamicConfig: saasv1alpha1.MapOfEnvoyDynamicConfig{ "http": { - GeneratorVersion: pointer.String("v1"), + GeneratorVersion: util.Pointer("v1"), ListenerHttp: &saasv1alpha1.ListenerHttp{ Port: 8080, RouteConfigName: "route", @@ -419,14 +419,14 @@ var _ = Describe("Apicast controller", func() { patch := client.MergeFrom(apicast.DeepCopy()) apicast.Spec.Production.Canary = &saasv1alpha1.Canary{ - ImageName: pointer.String("newImage"), - ImageTag: pointer.String("newTag"), - Replicas: pointer.Int32(1), + ImageName: util.Pointer("newImage"), + ImageTag: util.Pointer("newTag"), + Replicas: util.Pointer[int32](1), } apicast.Spec.Staging.Canary = &saasv1alpha1.Canary{ - ImageName: pointer.String("newImage"), - ImageTag: pointer.String("newTag"), - Replicas: pointer.Int32(1), + ImageName: util.Pointer("newImage"), + ImageTag: util.Pointer("newTag"), + Replicas: util.Pointer[int32](1), } if err := k8sClient.Patch(context.Background(), apicast, patch); err != nil { @@ -558,10 +558,10 @@ var _ = Describe("Apicast controller", func() { patch := client.MergeFrom(apicast.DeepCopy()) apicast.Spec.Production.Canary = &saasv1alpha1.Canary{ - SendTraffic: *pointer.Bool(true), + SendTraffic: *util.Pointer(true), } apicast.Spec.Staging.Canary = &saasv1alpha1.Canary{ - SendTraffic: *pointer.Bool(true), + SendTraffic: *util.Pointer(true), } return k8sClient.Patch(context.Background(), apicast, patch) }, timeout, poll).ShouldNot(HaveOccurred()) @@ -657,11 +657,11 @@ var _ = Describe("Apicast controller", func() { patch := client.MergeFrom(apicast.DeepCopy()) - apicast.Spec.Production.Replicas = pointer.Int32(0) + apicast.Spec.Production.Replicas = util.Pointer[int32](0) apicast.Spec.Production.HPA = &saasv1alpha1.HorizontalPodAutoscalerSpec{} apicast.Spec.Production.PDB = &saasv1alpha1.PodDisruptionBudgetSpec{} - apicast.Spec.Staging.Replicas = pointer.Int32(0) + apicast.Spec.Staging.Replicas = util.Pointer[int32](0) apicast.Spec.Staging.HPA = &saasv1alpha1.HorizontalPodAutoscalerSpec{} apicast.Spec.Staging.PDB = &saasv1alpha1.PodDisruptionBudgetSpec{} diff --git a/controllers/autossl_controller.go b/controllers/autossl_controller.go index 047a0264..69c486eb 100644 --- a/controllers/autossl_controller.go +++ b/controllers/autossl_controller.go @@ -19,10 +19,12 @@ package controllers import ( "context" + "github.com/3scale-ops/basereconciler/reconciler" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators/autossl" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators/autossl" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" "github.com/go-logr/logr" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" @@ -57,14 +59,12 @@ func (r *AutoSSLReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct ctx = log.IntoContext(ctx, logger) instance := &saasv1alpha1.AutoSSL{} - result := r.ManageResourceLifecycle(ctx, req, instance) + result := r.ManageResourceLifecycle(ctx, req, instance, + reconciler.WithInMemoryInitializationFunc(util.ResourceDefaulter(instance))) if result.ShouldReturn() { return result.Values() } - // Apply defaults for reconcile but do not store them in the API - instance.Default() - gen, err := autossl.NewGenerator( instance.GetName(), instance.GetNamespace(), diff --git a/controllers/autossl_controller_suite_test.go b/controllers/autossl_controller_suite_test.go index 2f718ee8..f07d3172 100644 --- a/controllers/autossl_controller_suite_test.go +++ b/controllers/autossl_controller_suite_test.go @@ -3,8 +3,9 @@ package controllers import ( "context" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - testutil "github.com/3scale/saas-operator/test/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + testutil "github.com/3scale-ops/saas-operator/test/util" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -13,7 +14,6 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -63,7 +63,7 @@ var _ = Describe("AutoSSL controller", func() { HPA: &saasv1alpha1.HorizontalPodAutoscalerSpec{ Behavior: &autoscalingv2.HorizontalPodAutoscalerBehavior{ ScaleDown: &autoscalingv2.HPAScalingRules{ - StabilizationWindowSeconds: pointer.Int32(45), + StabilizationWindowSeconds: util.Pointer[int32](45), Policies: []autoscalingv2.HPAScalingPolicy{ { Type: autoscalingv2.PodsScalingPolicy, @@ -123,7 +123,7 @@ var _ = Describe("AutoSSL controller", func() { (&testutil.ExpectedResource{Name: "autossl", Namespace: namespace}). Assert(k8sClient, hpa, timeout, poll)) - Expect(hpa.Spec.Behavior.ScaleDown.StabilizationWindowSeconds).To(Equal(pointer.Int32(45))) + Expect(hpa.Spec.Behavior.ScaleDown.StabilizationWindowSeconds).To(Equal(util.Pointer[int32](45))) Expect(hpa.Spec.Behavior.ScaleDown.Policies).To(Not(BeEmpty())) Expect(hpa.Spec.Behavior.ScaleDown.Policies[0].Type).To(Equal(autoscalingv2.PodsScalingPolicy)) Expect(hpa.Spec.Behavior.ScaleDown.Policies[0].Value).To(Equal(int32(4))) @@ -174,7 +174,7 @@ var _ = Describe("AutoSSL controller", func() { autossl.Spec.Config.ContactEmail = "updated-example@3scale.net" autossl.Spec.Config.VerificationEndpoint = "updated-example.com/verification" autossl.Spec.HPA = &saasv1alpha1.HorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(3), + MinReplicas: util.Pointer[int32](3), } autossl.Spec.GrafanaDashboard = &saasv1alpha1.GrafanaDashboardSpec{} autossl.Spec.LivenessProbe = &saasv1alpha1.ProbeSpec{} @@ -256,9 +256,9 @@ var _ = Describe("AutoSSL controller", func() { patch := client.MergeFrom(autossl.DeepCopy()) autossl.Spec.Canary = &saasv1alpha1.Canary{ - ImageName: pointer.String("newImage"), - ImageTag: pointer.String("newTag"), - Replicas: pointer.Int32(1), + ImageName: util.Pointer("newImage"), + ImageTag: util.Pointer("newTag"), + Replicas: util.Pointer[int32](1), } return k8sClient.Patch(context.Background(), autossl, patch) @@ -325,7 +325,7 @@ var _ = Describe("AutoSSL controller", func() { patch := client.MergeFrom(autossl.DeepCopy()) autossl.Spec.Canary = &saasv1alpha1.Canary{ - SendTraffic: *pointer.Bool(true), + SendTraffic: *util.Pointer(true), } return k8sClient.Patch(context.Background(), autossl, patch) }, timeout, poll).ShouldNot(HaveOccurred()) @@ -370,7 +370,7 @@ var _ = Describe("AutoSSL controller", func() { k8sClient, &appsv1.Deployment{}, "autossl", namespace, timeout, poll) patch := client.MergeFrom(autossl.DeepCopy()) - autossl.Spec.Replicas = pointer.Int32(0) + autossl.Spec.Replicas = util.Pointer[int32](0) autossl.Spec.HPA = &saasv1alpha1.HorizontalPodAutoscalerSpec{} autossl.Spec.PDB = &saasv1alpha1.PodDisruptionBudgetSpec{} diff --git a/controllers/backend_controller.go b/controllers/backend_controller.go index ba013254..3aeddac3 100644 --- a/controllers/backend_controller.go +++ b/controllers/backend_controller.go @@ -19,10 +19,12 @@ package controllers import ( "context" + "github.com/3scale-ops/basereconciler/reconciler" + "github.com/3scale-ops/basereconciler/util" marin3rv1alpha1 "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators/backend" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators/backend" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" "github.com/go-logr/logr" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" @@ -63,14 +65,12 @@ func (r *BackendReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct ctx = log.IntoContext(ctx, logger) instance := &saasv1alpha1.Backend{} - result := r.ManageResourceLifecycle(ctx, req, instance) + result := r.ManageResourceLifecycle(ctx, req, instance, + reconciler.WithInMemoryInitializationFunc(util.ResourceDefaulter(instance))) if result.ShouldReturn() { return result.Values() } - // Apply defaults for reconcile but do not store them in the API - instance.Default() - gen, err := backend.NewGenerator(instance.GetName(), instance.GetNamespace(), instance.Spec) if err != nil { return ctrl.Result{}, err diff --git a/controllers/backend_controller_suite_test.go b/controllers/backend_controller_suite_test.go index c6917022..09de54c4 100644 --- a/controllers/backend_controller_suite_test.go +++ b/controllers/backend_controller_suite_test.go @@ -5,9 +5,10 @@ import ( "fmt" "time" + "github.com/3scale-ops/basereconciler/util" marin3rv1alpha1 "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - testutil "github.com/3scale/saas-operator/test/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + testutil "github.com/3scale-ops/saas-operator/test/util" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" . "github.com/onsi/ginkgo/v2" @@ -18,7 +19,6 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -64,7 +64,7 @@ var _ = Describe("Backend controller", func() { Config: saasv1alpha1.BackendConfig{ RedisStorageDSN: "storageDSN", RedisQueuesDSN: "queuesDSN", - SystemEventsHookURL: saasv1alpha1.SecretReference{Override: pointer.String("system-app")}, + SystemEventsHookURL: saasv1alpha1.SecretReference{Override: util.Pointer("system-app")}, SystemEventsHookPassword: saasv1alpha1.SecretReference{ FromVault: &saasv1alpha1.VaultSecretReference{ Path: "some-path-hook-password", @@ -307,39 +307,39 @@ var _ = Describe("Backend controller", func() { patch := client.MergeFrom(backend.DeepCopy()) backend.Spec.Image = &saasv1alpha1.ImageSpec{ - Name: pointer.String("newImage"), - Tag: pointer.String("newTag"), + Name: util.Pointer("newImage"), + Tag: util.Pointer("newTag"), } - backend.Spec.Listener.Replicas = pointer.Int32(3) + backend.Spec.Listener.Replicas = util.Pointer[int32](3) backend.Spec.Listener.HPA = &saasv1alpha1.HorizontalPodAutoscalerSpec{} backend.Spec.Listener.Config = &saasv1alpha1.ListenerConfig{ - RedisAsync: pointer.Bool(true), + RedisAsync: util.Pointer(true), } backend.Spec.Worker = &saasv1alpha1.WorkerSpec{ HPA: &saasv1alpha1.HorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(3), + MinReplicas: util.Pointer[int32](3), }, } backend.Spec.Cron = &saasv1alpha1.CronSpec{ - Replicas: pointer.Int32(3), + Replicas: util.Pointer[int32](3), } backend.Spec.Listener.LoadBalancer = &saasv1alpha1.NLBLoadBalancerSpec{ - CrossZoneLoadBalancingEnabled: pointer.Bool(false), + CrossZoneLoadBalancingEnabled: util.Pointer(false), } backend.Spec.Config.ExternalSecret.RefreshInterval = &metav1.Duration{Duration: 1 * time.Second} backend.Spec.Config.ExternalSecret.SecretStoreRef = &saasv1alpha1.ExternalSecretSecretStoreReferenceSpec{ - Name: pointer.String("other-store"), - Kind: pointer.String("SecretStore"), + Name: util.Pointer("other-store"), + Kind: util.Pointer("SecretStore"), } backend.Spec.Config.InternalAPIUser.FromVault.Path = "secret/data/updated-path-api" backend.Spec.Config.SystemEventsHookPassword.FromVault.Path = "secret/data/updated-path-hook" backend.Spec.Config.ErrorMonitoringKey.FromVault.Path = "secret/data/updated-path-error" backend.Spec.Listener.Marin3r = &saasv1alpha1.Marin3rSidecarSpec{ - NodeID: pointer.String("backend-listener"), + NodeID: util.Pointer("backend-listener"), EnvoyDynamicConfig: saasv1alpha1.MapOfEnvoyDynamicConfig{ "http": { - GeneratorVersion: pointer.String("v1"), + GeneratorVersion: util.Pointer("v1"), ListenerHttp: &saasv1alpha1.ListenerHttp{ Port: 8080, RouteConfigName: "route", @@ -393,7 +393,7 @@ var _ = Describe("Backend controller", func() { LastVersion: rvs["hpa/backend-worker"], }).Assert(k8sClient, hpa, timeout, poll)) - Expect(hpa.Spec.MinReplicas).To(Equal(pointer.Int32(3))) + Expect(hpa.Spec.MinReplicas).To(Equal(util.Pointer[int32](3))) By("updating the backend-cron workload", (&testutil.ExpectedWorkload{ @@ -490,13 +490,13 @@ var _ = Describe("Backend controller", func() { patch := client.MergeFrom(backend.DeepCopy()) backend.Spec.Listener.Canary = &saasv1alpha1.Canary{ - ImageName: pointer.String("newImage"), - ImageTag: pointer.String("newTag"), + ImageName: util.Pointer("newImage"), + ImageTag: util.Pointer("newTag"), } backend.Spec.Worker = &saasv1alpha1.WorkerSpec{ Canary: &saasv1alpha1.Canary{ - ImageName: pointer.String("newImage"), - ImageTag: pointer.String("newTag"), + ImageName: util.Pointer("newImage"), + ImageTag: util.Pointer("newTag"), Patches: []string{ `[{"op": "add", "path": "/config/rackEnv", "value": "test"}]`, `[{"op": "replace", "path": "/config/redisStorageDSN", "value": "testDSN"}]`, @@ -600,16 +600,16 @@ var _ = Describe("Backend controller", func() { k8sClient, &appsv1.Deployment{}, "backend-worker-canary", namespace, timeout, poll) patch := client.MergeFrom(backend.DeepCopy()) - backend.Spec.Listener.Replicas = pointer.Int32(3) + backend.Spec.Listener.Replicas = util.Pointer[int32](3) backend.Spec.Listener.Canary = &saasv1alpha1.Canary{ - SendTraffic: *pointer.Bool(true), - Replicas: pointer.Int32(3), + SendTraffic: *util.Pointer(true), + Replicas: util.Pointer[int32](3), } backend.Spec.Worker = &saasv1alpha1.WorkerSpec{ - Replicas: pointer.Int32(3), + Replicas: util.Pointer[int32](3), } backend.Spec.Worker.Canary = &saasv1alpha1.Canary{ - Replicas: pointer.Int32(3), + Replicas: util.Pointer[int32](3), } return k8sClient.Patch(context.Background(), backend, patch) @@ -629,7 +629,7 @@ var _ = Describe("Backend controller", func() { LastVersion: rvs["deployment/backend-listener-canary"], }).Assert(k8sClient, dep, timeout, poll)) - Expect(dep.Spec.Replicas).To(Equal(pointer.Int32(3))) + Expect(dep.Spec.Replicas).To(Equal(util.Pointer[int32](3))) svc := &corev1.Service{} By("removing the backend-listener service deployment label selector", @@ -721,18 +721,18 @@ var _ = Describe("Backend controller", func() { k8sClient, &appsv1.Deployment{}, "backend-cron", namespace, timeout, poll) patch := client.MergeFrom(backend.DeepCopy()) - backend.Spec.Listener.Replicas = pointer.Int32(2) + backend.Spec.Listener.Replicas = util.Pointer[int32](2) backend.Spec.Listener.Canary = &saasv1alpha1.Canary{ - Replicas: pointer.Int32(2), + Replicas: util.Pointer[int32](2), Patches: []string{ `[{"op":"add","path":"/twemproxy","value":{"twemproxyConfigRef":"backend-canary-twemproxyconfig","options":{"logLevel":3}}}]`, }, } backend.Spec.Worker = &saasv1alpha1.WorkerSpec{ - Replicas: pointer.Int32(2), + Replicas: util.Pointer[int32](2), } backend.Spec.Worker.Canary = &saasv1alpha1.Canary{ - Replicas: pointer.Int32(2), + Replicas: util.Pointer[int32](2), Patches: []string{ `[{"op":"add","path":"/twemproxy/options","value":{"logLevel":4}}]`, }, @@ -740,7 +740,7 @@ var _ = Describe("Backend controller", func() { backend.Spec.Twemproxy = &saasv1alpha1.TwemproxySpec{ TwemproxyConfigRef: "backend-twemproxyconfig", Options: &saasv1alpha1.TwemproxyOptions{ - LogLevel: pointer.Int32(2), + LogLevel: util.Pointer[int32](2), }, } diff --git a/controllers/corsproxy_controller.go b/controllers/corsproxy_controller.go index 044827ce..c0255da8 100644 --- a/controllers/corsproxy_controller.go +++ b/controllers/corsproxy_controller.go @@ -19,10 +19,12 @@ package controllers import ( "context" + "github.com/3scale-ops/basereconciler/reconciler" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators/corsproxy" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators/corsproxy" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" "github.com/go-logr/logr" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" @@ -62,14 +64,12 @@ func (r *CORSProxyReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( ctx = log.IntoContext(ctx, logger) instance := &saasv1alpha1.CORSProxy{} - result := r.ManageResourceLifecycle(ctx, req, instance) + result := r.ManageResourceLifecycle(ctx, req, instance, + reconciler.WithInMemoryInitializationFunc(util.ResourceDefaulter(instance))) if result.ShouldReturn() { return result.Values() } - // Apply defaults for reconcile but do not store them in the API - instance.Default() - gen := corsproxy.NewGenerator( instance.GetName(), instance.GetNamespace(), diff --git a/controllers/corsproxy_controller_suite_test.go b/controllers/corsproxy_controller_suite_test.go index a88d8e83..beff2e86 100644 --- a/controllers/corsproxy_controller_suite_test.go +++ b/controllers/corsproxy_controller_suite_test.go @@ -4,8 +4,9 @@ import ( "context" "time" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - testutil "github.com/3scale/saas-operator/test/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + testutil "github.com/3scale-ops/saas-operator/test/util" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" . "github.com/onsi/ginkgo/v2" @@ -14,7 +15,6 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -159,14 +159,14 @@ var _ = Describe("CORSProxy controller", func() { patch := client.MergeFrom(corsproxy.DeepCopy()) corsproxy.Spec.HPA = &saasv1alpha1.HorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(3), + MinReplicas: util.Pointer[int32](3), } corsproxy.Spec.LivenessProbe = &saasv1alpha1.ProbeSpec{} corsproxy.Spec.ReadinessProbe = &saasv1alpha1.ProbeSpec{} corsproxy.Spec.Config.ExternalSecret.RefreshInterval = &metav1.Duration{Duration: 1 * time.Second} corsproxy.Spec.Config.ExternalSecret.SecretStoreRef = &saasv1alpha1.ExternalSecretSecretStoreReferenceSpec{ - Name: pointer.String("other-store"), - Kind: pointer.String("SecretStore"), + Name: util.Pointer("other-store"), + Kind: util.Pointer("SecretStore"), } corsproxy.Spec.Config.SystemDatabaseDSN.FromVault.Path = "secret/data/updated-path" corsproxy.Spec.GrafanaDashboard = &saasv1alpha1.GrafanaDashboardSpec{} @@ -246,7 +246,7 @@ var _ = Describe("CORSProxy controller", func() { k8sClient, &appsv1.Deployment{}, "cors-proxy", namespace, timeout, poll) patch := client.MergeFrom(corsproxy.DeepCopy()) - corsproxy.Spec.Replicas = pointer.Int32(0) + corsproxy.Spec.Replicas = util.Pointer[int32](0) corsproxy.Spec.HPA = &saasv1alpha1.HorizontalPodAutoscalerSpec{} corsproxy.Spec.PDB = &saasv1alpha1.PodDisruptionBudgetSpec{} diff --git a/controllers/echoapi_controller.go b/controllers/echoapi_controller.go index ad95c151..f591d333 100644 --- a/controllers/echoapi_controller.go +++ b/controllers/echoapi_controller.go @@ -19,10 +19,12 @@ package controllers import ( "context" + "github.com/3scale-ops/basereconciler/reconciler" + "github.com/3scale-ops/basereconciler/util" marin3rv1alpha1 "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators/echoapi" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators/echoapi" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" "github.com/go-logr/logr" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" @@ -57,14 +59,12 @@ func (r *EchoAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct ctx = log.IntoContext(ctx, logger) instance := &saasv1alpha1.EchoAPI{} - result := r.ManageResourceLifecycle(ctx, req, instance) + result := r.ManageResourceLifecycle(ctx, req, instance, + reconciler.WithInMemoryInitializationFunc(util.ResourceDefaulter(instance))) if result.ShouldReturn() { return result.Values() } - // Apply defaults for reconcile but do not store them in the API - instance.Default() - gen := echoapi.NewGenerator( instance.GetName(), instance.GetNamespace(), diff --git a/controllers/echoapi_controller_suite_test.go b/controllers/echoapi_controller_suite_test.go index 2ac06f56..b44e8dab 100644 --- a/controllers/echoapi_controller_suite_test.go +++ b/controllers/echoapi_controller_suite_test.go @@ -3,9 +3,10 @@ package controllers import ( "context" + "github.com/3scale-ops/basereconciler/util" marin3rv1alpha1 "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - testutil "github.com/3scale/saas-operator/test/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + testutil "github.com/3scale-ops/saas-operator/test/util" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" appsv1 "k8s.io/api/apps/v1" @@ -13,7 +14,6 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -141,16 +141,16 @@ var _ = Describe("EchoAPI controller", func() { patch := client.MergeFrom(echoapi.DeepCopy()) echoapi.Spec.HPA = &saasv1alpha1.HorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(3), + MinReplicas: util.Pointer[int32](3), } echoapi.Spec.LivenessProbe = &saasv1alpha1.ProbeSpec{} echoapi.Spec.ReadinessProbe = &saasv1alpha1.ProbeSpec{} echoapi.Spec.Marin3r = &saasv1alpha1.Marin3rSidecarSpec{ - NodeID: pointer.String("echo-api"), + NodeID: util.Pointer("echo-api"), EnvoyDynamicConfig: saasv1alpha1.MapOfEnvoyDynamicConfig{ "http": { - GeneratorVersion: pointer.String("v1"), + GeneratorVersion: util.Pointer("v1"), ListenerHttp: &saasv1alpha1.ListenerHttp{ Port: 8080, RouteConfigName: "route", @@ -207,7 +207,7 @@ var _ = Describe("EchoAPI controller", func() { k8sClient, &appsv1.Deployment{}, "echo-api", namespace, timeout, poll) patch := client.MergeFrom(echoapi.DeepCopy()) - echoapi.Spec.Replicas = pointer.Int32(0) + echoapi.Spec.Replicas = util.Pointer[int32](0) echoapi.Spec.HPA = &saasv1alpha1.HorizontalPodAutoscalerSpec{} echoapi.Spec.PDB = &saasv1alpha1.PodDisruptionBudgetSpec{} diff --git a/controllers/mappingservice_controller.go b/controllers/mappingservice_controller.go index 7bc624b3..75c712b3 100644 --- a/controllers/mappingservice_controller.go +++ b/controllers/mappingservice_controller.go @@ -19,10 +19,12 @@ package controllers import ( "context" + "github.com/3scale-ops/basereconciler/reconciler" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators/mappingservice" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators/mappingservice" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" "github.com/go-logr/logr" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" @@ -62,14 +64,12 @@ func (r *MappingServiceReconciler) Reconcile(ctx context.Context, req ctrl.Reque ctx = log.IntoContext(ctx, logger) instance := &saasv1alpha1.MappingService{} - result := r.ManageResourceLifecycle(ctx, req, instance) + result := r.ManageResourceLifecycle(ctx, req, instance, + reconciler.WithInMemoryInitializationFunc(util.ResourceDefaulter(instance))) if result.ShouldReturn() { return result.Values() } - // Apply defaults for reconcile but do not store them in the API - instance.Default() - gen := mappingservice.NewGenerator( instance.GetName(), instance.GetNamespace(), diff --git a/controllers/mappingservice_controller_suite_test.go b/controllers/mappingservice_controller_suite_test.go index c26cd087..63520a4a 100644 --- a/controllers/mappingservice_controller_suite_test.go +++ b/controllers/mappingservice_controller_suite_test.go @@ -4,8 +4,9 @@ import ( "context" "time" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - testutil "github.com/3scale/saas-operator/test/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + testutil "github.com/3scale-ops/saas-operator/test/util" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" . "github.com/onsi/ginkgo/v2" @@ -14,7 +15,6 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -158,12 +158,12 @@ var _ = Describe("MappingService controller", func() { mappingservice.Spec.Config.ExternalSecret.RefreshInterval = &metav1.Duration{Duration: 1 * time.Second} mappingservice.Spec.Config.ExternalSecret.SecretStoreRef = &saasv1alpha1.ExternalSecretSecretStoreReferenceSpec{ - Name: pointer.String("other-store"), - Kind: pointer.String("SecretStore"), + Name: util.Pointer("other-store"), + Kind: util.Pointer("SecretStore"), } mappingservice.Spec.Config.SystemAdminToken.FromVault.Path = "secret/data/updated-path" mappingservice.Spec.HPA = &saasv1alpha1.HorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(3), + MinReplicas: util.Pointer[int32](3), } mappingservice.Spec.LivenessProbe = &saasv1alpha1.ProbeSpec{} mappingservice.Spec.ReadinessProbe = &saasv1alpha1.ProbeSpec{} @@ -251,7 +251,7 @@ var _ = Describe("MappingService controller", func() { rvs["deployment/mappingservice"] = testutil.GetResourceVersion( k8sClient, &appsv1.Deployment{}, "mapping-service", namespace, timeout, poll) patch := client.MergeFrom(mappingservice.DeepCopy()) - mappingservice.Spec.Replicas = pointer.Int32(0) + mappingservice.Spec.Replicas = util.Pointer[int32](0) mappingservice.Spec.HPA = &saasv1alpha1.HorizontalPodAutoscalerSpec{} mappingservice.Spec.PDB = &saasv1alpha1.PodDisruptionBudgetSpec{} diff --git a/controllers/reconciler_config.go b/controllers/reconciler_config.go index a1f18e54..5a90adaf 100644 --- a/controllers/reconciler_config.go +++ b/controllers/reconciler_config.go @@ -2,7 +2,7 @@ package controllers import ( "github.com/3scale-ops/basereconciler/config" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" "k8s.io/apimachinery/pkg/runtime/schema" ) diff --git a/controllers/redisshard_controller.go b/controllers/redisshard_controller.go index 29abcd6e..c73ce1c6 100644 --- a/controllers/redisshard_controller.go +++ b/controllers/redisshard_controller.go @@ -22,11 +22,12 @@ import ( "time" "github.com/3scale-ops/basereconciler/reconciler" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators/redisshard" - "github.com/3scale/saas-operator/pkg/redis/client" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/redis/sharded" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators/redisshard" + "github.com/3scale-ops/saas-operator/pkg/redis/client" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" + "github.com/3scale-ops/saas-operator/pkg/redis/sharded" "github.com/go-logr/logr" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -57,14 +58,12 @@ func (r *RedisShardReconciler) Reconcile(ctx context.Context, req ctrl.Request) ctx = log.IntoContext(ctx, logger) instance := &saasv1alpha1.RedisShard{} - result := r.ManageResourceLifecycle(ctx, req, instance) + result := r.ManageResourceLifecycle(ctx, req, instance, + reconciler.WithInMemoryInitializationFunc(util.ResourceDefaulter(instance))) if result.ShouldReturn() { return result.Values() } - // Apply defaults for reconcile but do not store them in the API - instance.Default() - gen := redisshard.NewGenerator( instance.GetName(), instance.GetNamespace(), diff --git a/controllers/redisshard_controller_suite_test.go b/controllers/redisshard_controller_suite_test.go index 9acb7b2e..1721e03c 100644 --- a/controllers/redisshard_controller_suite_test.go +++ b/controllers/redisshard_controller_suite_test.go @@ -3,8 +3,8 @@ package controllers import ( "context" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - testutil "github.com/3scale/saas-operator/test/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + testutil "github.com/3scale-ops/saas-operator/test/util" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" appsv1 "k8s.io/api/apps/v1" diff --git a/controllers/sentinel_controller.go b/controllers/sentinel_controller.go index ab73d7d3..b19d3d13 100644 --- a/controllers/sentinel_controller.go +++ b/controllers/sentinel_controller.go @@ -22,13 +22,14 @@ import ( "time" "github.com/3scale-ops/basereconciler/reconciler" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators/sentinel" - "github.com/3scale/saas-operator/pkg/reconcilers/threads" - "github.com/3scale/saas-operator/pkg/redis/events" - "github.com/3scale/saas-operator/pkg/redis/metrics" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/redis/sharded" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators/sentinel" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/threads" + "github.com/3scale-ops/saas-operator/pkg/redis/events" + "github.com/3scale-ops/saas-operator/pkg/redis/metrics" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" + "github.com/3scale-ops/saas-operator/pkg/redis/sharded" "github.com/go-logr/logr" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" "golang.org/x/time/rate" @@ -71,6 +72,7 @@ func (r *SentinelReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c instance := &saasv1alpha1.Sentinel{} result := r.ManageResourceLifecycle(ctx, req, instance, + reconciler.WithInMemoryInitializationFunc(util.ResourceDefaulter(instance)), reconciler.WithFinalizer(saasv1alpha1.Finalizer), reconciler.WithFinalizationFunc(r.SentinelEvents.CleanupThreads(instance)), reconciler.WithFinalizationFunc(r.Metrics.CleanupThreads(instance)), @@ -79,9 +81,6 @@ func (r *SentinelReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c return result.Values() } - // Apply defaults for reconcile but do not store them in the API - instance.Default() - gen := sentinel.NewGenerator( instance.GetName(), instance.GetNamespace(), diff --git a/controllers/sentinel_controller_suite_test.go b/controllers/sentinel_controller_suite_test.go index 26bc6883..704a8c5c 100644 --- a/controllers/sentinel_controller_suite_test.go +++ b/controllers/sentinel_controller_suite_test.go @@ -3,8 +3,8 @@ package controllers import ( "context" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - testutil "github.com/3scale/saas-operator/test/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + testutil "github.com/3scale-ops/saas-operator/test/util" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/controllers/shardedredisbackup_controller.go b/controllers/shardedredisbackup_controller.go index 6d772b99..a77a94bf 100644 --- a/controllers/shardedredisbackup_controller.go +++ b/controllers/shardedredisbackup_controller.go @@ -21,6 +21,16 @@ import ( "fmt" "time" + "github.com/3scale-ops/basereconciler/reconciler" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/threads" + "github.com/3scale-ops/saas-operator/pkg/redis/backup" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" + "github.com/3scale-ops/saas-operator/pkg/redis/sharded" + operatorutils "github.com/3scale-ops/saas-operator/pkg/util" + "github.com/go-logr/logr" + "github.com/robfig/cron/v3" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" @@ -29,16 +39,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - - "github.com/3scale-ops/basereconciler/reconciler" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/reconcilers/threads" - "github.com/3scale/saas-operator/pkg/redis/backup" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/redis/sharded" - "github.com/3scale/saas-operator/pkg/util" - "github.com/go-logr/logr" - "github.com/robfig/cron/v3" ) // ShardedRedisBackupReconciler reconciles a ShardedRedisBackup object @@ -73,6 +73,7 @@ func (r *ShardedRedisBackupReconciler) Reconcile(ctx context.Context, req ctrl.R instance := &saasv1alpha1.ShardedRedisBackup{} result := r.ManageResourceLifecycle(ctx, req, instance, + reconciler.WithInMemoryInitializationFunc(util.ResourceDefaulter(instance)), reconciler.WithFinalizer(saasv1alpha1.Finalizer), reconciler.WithFinalizationFunc(r.BackupRunner.CleanupThreads(instance)), ) @@ -80,8 +81,6 @@ func (r *ShardedRedisBackupReconciler) Reconcile(ctx context.Context, req ctrl.R return result.Values() } - instance.Default() - // Get Sentinel status sentinel := &saasv1alpha1.Sentinel{ObjectMeta: metav1.ObjectMeta{Name: instance.Spec.SentinelRef, Namespace: req.Namespace}} if err := r.Client.Get(ctx, client.ObjectKeyFromObject(sentinel), sentinel); err != nil { @@ -112,11 +111,11 @@ func (r *ShardedRedisBackupReconciler) Reconcile(ctx context.Context, req ctrl.R if err := r.Client.Get(ctx, client.ObjectKeyFromObject(awsCredentials), awsCredentials); err != nil { return ctrl.Result{}, err } - if _, ok := awsCredentials.Data[util.AWSAccessKeyEnvvar]; !ok { - return ctrl.Result{}, fmt.Errorf("secret %s is missing %s key", awsCredentials.GetName(), util.AWSAccessKeyEnvvar) + if _, ok := awsCredentials.Data[operatorutils.AWSAccessKeyEnvvar]; !ok { + return ctrl.Result{}, fmt.Errorf("secret %s is missing %s key", awsCredentials.GetName(), operatorutils.AWSAccessKeyEnvvar) } - if _, ok := awsCredentials.Data[util.AWSSecretKeyEnvvar]; !ok { - return ctrl.Result{}, fmt.Errorf("secret %s is missing %s key", awsCredentials.GetName(), util.AWSSecretKeyEnvvar) + if _, ok := awsCredentials.Data[operatorutils.AWSSecretKeyEnvvar]; !ok { + return ctrl.Result{}, fmt.Errorf("secret %s is missing %s key", awsCredentials.GetName(), operatorutils.AWSSecretKeyEnvvar) } // ---------------------------------------- diff --git a/controllers/shardedredisbackup_controller_test.go b/controllers/shardedredisbackup_controller_test.go index f09fa39e..61feba3e 100644 --- a/controllers/shardedredisbackup_controller_test.go +++ b/controllers/shardedredisbackup_controller_test.go @@ -22,8 +22,9 @@ import ( "time" "github.com/3scale-ops/basereconciler/reconciler" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/util" + reconciler_util "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + testutil "github.com/3scale-ops/saas-operator/test/util" "github.com/go-logr/logr" "github.com/google/go-cmp/cmp" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -45,9 +46,9 @@ func TestShardedRedisBackupReconciler_reconcileBackupList(t *testing.T) { { name: "List is empty, adds a backup", args: args{ - nextRun: util.MustParseRFC3339("2023-09-01T00:01:00Z"), + nextRun: testutil.MustParseRFC3339("2023-09-01T00:01:00Z"), instance: &saasv1alpha1.ShardedRedisBackup{ - Spec: saasv1alpha1.ShardedRedisBackupSpec{HistoryLimit: util.Pointer(int32(10))}, + Spec: saasv1alpha1.ShardedRedisBackupSpec{HistoryLimit: reconciler_util.Pointer(int32(10))}, Status: saasv1alpha1.ShardedRedisBackupStatus{}, }, shards: []string{"shard01", "shard02"}, @@ -57,13 +58,13 @@ func TestShardedRedisBackupReconciler_reconcileBackupList(t *testing.T) { Backups: []saasv1alpha1.BackupStatus{ { Shard: "shard02", - ScheduledFor: metav1.NewTime(util.MustParseRFC3339("2023-09-01T00:01:00Z")), + ScheduledFor: metav1.NewTime(testutil.MustParseRFC3339("2023-09-01T00:01:00Z")), Message: "backup scheduled", State: saasv1alpha1.BackupPendingState, }, { Shard: "shard01", - ScheduledFor: metav1.NewTime(util.MustParseRFC3339("2023-09-01T00:01:00Z")), + ScheduledFor: metav1.NewTime(testutil.MustParseRFC3339("2023-09-01T00:01:00Z")), Message: "backup scheduled", State: saasv1alpha1.BackupPendingState, }, @@ -74,20 +75,20 @@ func TestShardedRedisBackupReconciler_reconcileBackupList(t *testing.T) { { name: "No changes", args: args{ - nextRun: util.MustParseRFC3339("2023-09-01T00:01:00Z"), + nextRun: testutil.MustParseRFC3339("2023-09-01T00:01:00Z"), instance: &saasv1alpha1.ShardedRedisBackup{ - Spec: saasv1alpha1.ShardedRedisBackupSpec{HistoryLimit: util.Pointer(int32(10))}, + Spec: saasv1alpha1.ShardedRedisBackupSpec{HistoryLimit: reconciler_util.Pointer(int32(10))}, Status: saasv1alpha1.ShardedRedisBackupStatus{ Backups: []saasv1alpha1.BackupStatus{ { Shard: "shard02", - ScheduledFor: metav1.NewTime(util.MustParseRFC3339("2023-09-01T00:01:00Z")), + ScheduledFor: metav1.NewTime(testutil.MustParseRFC3339("2023-09-01T00:01:00Z")), Message: "backup scheduled", State: saasv1alpha1.BackupPendingState, }, { Shard: "shard01", - ScheduledFor: metav1.NewTime(util.MustParseRFC3339("2023-09-01T00:01:00Z")), + ScheduledFor: metav1.NewTime(testutil.MustParseRFC3339("2023-09-01T00:01:00Z")), Message: "backup scheduled", State: saasv1alpha1.BackupPendingState, }, @@ -100,13 +101,13 @@ func TestShardedRedisBackupReconciler_reconcileBackupList(t *testing.T) { Backups: []saasv1alpha1.BackupStatus{ { Shard: "shard02", - ScheduledFor: metav1.NewTime(util.MustParseRFC3339("2023-09-01T00:01:00Z")), + ScheduledFor: metav1.NewTime(testutil.MustParseRFC3339("2023-09-01T00:01:00Z")), Message: "backup scheduled", State: saasv1alpha1.BackupPendingState, }, { Shard: "shard01", - ScheduledFor: metav1.NewTime(util.MustParseRFC3339("2023-09-01T00:01:00Z")), + ScheduledFor: metav1.NewTime(testutil.MustParseRFC3339("2023-09-01T00:01:00Z")), Message: "backup scheduled", State: saasv1alpha1.BackupPendingState, }, @@ -117,20 +118,20 @@ func TestShardedRedisBackupReconciler_reconcileBackupList(t *testing.T) { { name: "Adds new backups", args: args{ - nextRun: util.MustParseRFC3339("2023-09-01T00:02:00Z"), + nextRun: testutil.MustParseRFC3339("2023-09-01T00:02:00Z"), instance: &saasv1alpha1.ShardedRedisBackup{ - Spec: saasv1alpha1.ShardedRedisBackupSpec{HistoryLimit: util.Pointer(int32(10))}, + Spec: saasv1alpha1.ShardedRedisBackupSpec{HistoryLimit: reconciler_util.Pointer(int32(10))}, Status: saasv1alpha1.ShardedRedisBackupStatus{ Backups: []saasv1alpha1.BackupStatus{ { Shard: "shard02", - ScheduledFor: metav1.NewTime(util.MustParseRFC3339("2023-09-01T00:01:00Z")), + ScheduledFor: metav1.NewTime(testutil.MustParseRFC3339("2023-09-01T00:01:00Z")), Message: "backup scheduled", State: saasv1alpha1.BackupPendingState, }, { Shard: "shard01", - ScheduledFor: metav1.NewTime(util.MustParseRFC3339("2023-09-01T00:01:00Z")), + ScheduledFor: metav1.NewTime(testutil.MustParseRFC3339("2023-09-01T00:01:00Z")), Message: "backup scheduled", State: saasv1alpha1.BackupPendingState, }, @@ -143,13 +144,13 @@ func TestShardedRedisBackupReconciler_reconcileBackupList(t *testing.T) { Backups: []saasv1alpha1.BackupStatus{ { Shard: "shard02", - ScheduledFor: metav1.NewTime(util.MustParseRFC3339("2023-09-01T00:02:00Z")), + ScheduledFor: metav1.NewTime(testutil.MustParseRFC3339("2023-09-01T00:02:00Z")), Message: "backup scheduled", State: saasv1alpha1.BackupPendingState, }, { Shard: "shard01", - ScheduledFor: metav1.NewTime(util.MustParseRFC3339("2023-09-01T00:02:00Z")), + ScheduledFor: metav1.NewTime(testutil.MustParseRFC3339("2023-09-01T00:02:00Z")), Message: "backup scheduled", State: saasv1alpha1.BackupPendingState, }, diff --git a/controllers/suite_test.go b/controllers/suite_test.go index e2b093e7..b39498d0 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -26,9 +26,9 @@ import ( "github.com/3scale-ops/basereconciler/reconciler" marin3rv1alpha1 "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1" - "github.com/3scale/saas-operator/pkg/reconcilers/threads" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" - redis "github.com/3scale/saas-operator/pkg/redis/server" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/threads" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" "github.com/goombaio/namegenerator" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -41,7 +41,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" diff --git a/controllers/system_controller.go b/controllers/system_controller.go index 8fda7ab0..c7a1558c 100644 --- a/controllers/system_controller.go +++ b/controllers/system_controller.go @@ -19,10 +19,12 @@ package controllers import ( "context" + "github.com/3scale-ops/basereconciler/reconciler" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators/system" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators/system" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" "github.com/go-logr/logr" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" @@ -65,14 +67,12 @@ func (r *SystemReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr ctx = log.IntoContext(ctx, logger) instance := &saasv1alpha1.System{} - result := r.ManageResourceLifecycle(ctx, req, instance) + result := r.ManageResourceLifecycle(ctx, req, instance, + reconciler.WithInMemoryInitializationFunc(util.ResourceDefaulter(instance))) if result.ShouldReturn() { return result.Values() } - // Apply defaults for reconcile but do not store them in the API - instance.Default() - gen, err := system.NewGenerator( instance.GetName(), instance.GetNamespace(), diff --git a/controllers/system_controller_suite_test.go b/controllers/system_controller_suite_test.go index 5e7c1113..7dc382d4 100644 --- a/controllers/system_controller_suite_test.go +++ b/controllers/system_controller_suite_test.go @@ -5,9 +5,9 @@ import ( "fmt" "time" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/util" - testutil "github.com/3scale/saas-operator/test/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + testutil "github.com/3scale-ops/saas-operator/test/util" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" . "github.com/onsi/ginkgo/v2" @@ -21,7 +21,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -65,79 +64,79 @@ var _ = Describe("System controller", func() { Key: "some-key-db", }, }, - EventsSharedSecret: saasv1alpha1.SecretReference{Override: pointer.String("override")}, + EventsSharedSecret: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, Recaptcha: saasv1alpha1.SystemRecaptchaSpec{ - PublicKey: saasv1alpha1.SecretReference{Override: pointer.String("override")}, - PrivateKey: saasv1alpha1.SecretReference{Override: pointer.String("override")}, + PublicKey: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, + PrivateKey: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, }, - SecretKeyBase: saasv1alpha1.SecretReference{Override: pointer.String("override")}, - AccessCode: &saasv1alpha1.SecretReference{Override: pointer.String("override")}, + SecretKeyBase: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, + AccessCode: &saasv1alpha1.SecretReference{Override: util.Pointer("override")}, Segment: saasv1alpha1.SegmentSpec{ DeletionWorkspace: "value", - DeletionToken: saasv1alpha1.SecretReference{Override: pointer.String("override")}, - WriteKey: saasv1alpha1.SecretReference{Override: pointer.String("override")}, + DeletionToken: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, + WriteKey: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, }, Github: saasv1alpha1.GithubSpec{ - ClientID: saasv1alpha1.SecretReference{Override: pointer.String("override")}, - ClientSecret: saasv1alpha1.SecretReference{Override: pointer.String("override")}, + ClientID: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, + ClientSecret: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, }, RedHatCustomerPortal: saasv1alpha1.RedHatCustomerPortalSpec{ - ClientID: saasv1alpha1.SecretReference{Override: pointer.String("override")}, - ClientSecret: saasv1alpha1.SecretReference{Override: pointer.String("override")}, - Realm: pointer.String("sso.example.net"), + ClientID: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, + ClientSecret: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, + Realm: util.Pointer("sso.example.net"), }, Bugsnag: &saasv1alpha1.BugsnagSpec{ - ReleaseStage: pointer.String("staging"), - APIKey: saasv1alpha1.SecretReference{Override: pointer.String("override")}, + ReleaseStage: util.Pointer("staging"), + APIKey: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, }, - DatabaseSecret: saasv1alpha1.SecretReference{Override: pointer.String("override")}, + DatabaseSecret: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, MemcachedServers: "value", Redis: saasv1alpha1.RedisSpec{ QueuesDSN: "value", }, SMTP: saasv1alpha1.SMTPSpec{ Address: "value", - User: saasv1alpha1.SecretReference{Override: pointer.String("override")}, - Password: saasv1alpha1.SecretReference{Override: pointer.String("override")}, + User: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, + Password: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, Port: 1000, AuthProtocol: "value", OpenSSLVerifyMode: "value", - STARTTLS: pointer.Bool(false), + STARTTLS: util.Pointer(false), }, - MappingServiceAccessToken: saasv1alpha1.SecretReference{Override: pointer.String("override")}, + MappingServiceAccessToken: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, Zync: &saasv1alpha1.SystemZyncSpec{ - AuthToken: saasv1alpha1.SecretReference{Override: pointer.String("override")}, + AuthToken: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, Endpoint: "value", }, Backend: saasv1alpha1.SystemBackendSpec{ ExternalEndpoint: "value", InternalEndpoint: "value", - InternalAPIUser: saasv1alpha1.SecretReference{Override: pointer.String("override")}, - InternalAPIPassword: saasv1alpha1.SecretReference{Override: pointer.String("override")}, + InternalAPIUser: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, + InternalAPIPassword: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, RedisDSN: "value", }, Assets: saasv1alpha1.AssetsSpec{ - Host: pointer.String("test.cloudfront.net"), + Host: util.Pointer("test.cloudfront.net"), Bucket: "bucket", Region: "us-east-1", - AccessKey: saasv1alpha1.SecretReference{Override: pointer.String("override")}, - SecretKey: saasv1alpha1.SecretReference{Override: pointer.String("override")}, + AccessKey: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, + SecretKey: saasv1alpha1.SecretReference{Override: util.Pointer("override")}, }, }, App: &saasv1alpha1.SystemAppSpec{ DeploymentStrategy: &saasv1alpha1.DeploymentStrategySpec{ Type: appsv1.RollingUpdateDeploymentStrategyType, RollingUpdate: &appsv1.RollingUpdateDeployment{ - MaxSurge: util.IntStrPtr(intstr.FromString("20%")), - MaxUnavailable: util.IntStrPtr(intstr.FromInt(0)), + MaxSurge: util.Pointer(intstr.FromString("20%")), + MaxUnavailable: util.Pointer(intstr.FromInt(0)), }, }}, SidekiqDefault: &saasv1alpha1.SystemSidekiqSpec{ DeploymentStrategy: &saasv1alpha1.DeploymentStrategySpec{ Type: appsv1.RollingUpdateDeploymentStrategyType, RollingUpdate: &appsv1.RollingUpdateDeployment{ - MaxSurge: util.IntStrPtr(intstr.FromString("15%")), - MaxUnavailable: util.IntStrPtr(intstr.FromString("5%")), + MaxSurge: util.Pointer(intstr.FromString("15%")), + MaxUnavailable: util.Pointer(intstr.FromString("5%")), }, }, HPA: &saasv1alpha1.HorizontalPodAutoscalerSpec{ @@ -198,8 +197,8 @@ var _ = Describe("System controller", func() { Expect(dep.Spec.Template.Spec.Volumes[0].Secret.SecretName).To(Equal("system-config")) Expect(dep.Spec.Strategy.Type).To(Equal(appsv1.RollingUpdateDeploymentStrategyType)) - Expect(dep.Spec.Strategy.RollingUpdate.MaxSurge).To(Equal(util.IntStrPtr(intstr.FromString("20%")))) - Expect(dep.Spec.Strategy.RollingUpdate.MaxUnavailable).To(Equal(util.IntStrPtr(intstr.FromInt(0)))) + Expect(dep.Spec.Strategy.RollingUpdate.MaxSurge).To(Equal(util.Pointer(intstr.FromString("20%")))) + Expect(dep.Spec.Strategy.RollingUpdate.MaxUnavailable).To(Equal(util.Pointer(intstr.FromInt(0)))) svc := &corev1.Service{} By("deploying the system-app service", @@ -207,7 +206,7 @@ var _ = Describe("System controller", func() { Assert(k8sClient, svc, timeout, poll)) Expect(svc.Spec.Selector["deployment"]).To(Equal("system-app")) - Expect(dep.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(pointer.Int64(60))) + Expect(dep.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(util.Pointer[int64](60))) }) @@ -233,10 +232,10 @@ var _ = Describe("System controller", func() { Expect(dep.Spec.Template.Spec.Volumes[0].Name).To(Equal("system-tmp")) Expect(dep.Spec.Template.Spec.Volumes[1].Secret.SecretName).To(Equal("system-config")) - Expect(dep.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(pointer.Int64(60))) + Expect(dep.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(util.Pointer[int64](60))) Expect(dep.Spec.Strategy.Type).To(Equal(appsv1.RollingUpdateDeploymentStrategyType)) - Expect(dep.Spec.Strategy.RollingUpdate.MaxSurge).To(Equal(util.IntStrPtr(intstr.FromString("15%")))) - Expect(dep.Spec.Strategy.RollingUpdate.MaxUnavailable).To(Equal(util.IntStrPtr(intstr.FromString("5%")))) + Expect(dep.Spec.Strategy.RollingUpdate.MaxSurge).To(Equal(util.Pointer(intstr.FromString("15%")))) + Expect(dep.Spec.Strategy.RollingUpdate.MaxUnavailable).To(Equal(util.Pointer(intstr.FromString("5%")))) hpa := &autoscalingv2.HorizontalPodAutoscaler{} By("updates system-sidekiq-default hpa behaviour", @@ -260,10 +259,10 @@ var _ = Describe("System controller", func() { Expect(dep.Spec.Template.Spec.Volumes[0].Name).To(Equal("system-tmp")) Expect(dep.Spec.Template.Spec.Volumes[1].Secret.SecretName).To(Equal("system-config")) - Expect(dep.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(pointer.Int64(60))) + Expect(dep.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(util.Pointer[int64](60))) Expect(dep.Spec.Strategy.Type).To(Equal(appsv1.RollingUpdateDeploymentStrategyType)) - Expect(dep.Spec.Strategy.RollingUpdate.MaxSurge).To(Equal(util.IntStrPtr(intstr.FromInt(1)))) - Expect(dep.Spec.Strategy.RollingUpdate.MaxUnavailable).To(Equal(util.IntStrPtr(intstr.FromInt(0)))) + Expect(dep.Spec.Strategy.RollingUpdate.MaxSurge).To(Equal(util.Pointer(intstr.FromInt(1)))) + Expect(dep.Spec.Strategy.RollingUpdate.MaxUnavailable).To(Equal(util.Pointer(intstr.FromInt(0)))) By("deploying a system-sidekiq-low workload", (&testutil.ExpectedWorkload{ @@ -279,7 +278,7 @@ var _ = Describe("System controller", func() { Expect(dep.Spec.Template.Spec.Volumes[0].Name).To(Equal("system-tmp")) Expect(dep.Spec.Template.Spec.Volumes[1].Secret.SecretName).To(Equal("system-config")) - Expect(dep.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(pointer.Int64(60))) + Expect(dep.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(util.Pointer[int64](60))) }) @@ -291,7 +290,7 @@ var _ = Describe("System controller", func() { Assert(k8sClient, sts, timeout, poll)) Expect(sts.Spec.Template.Spec.Containers[0].Args).To(BeEmpty()) - Expect(sts.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(pointer.Int64(60))) + Expect(sts.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(util.Pointer[int64](60))) Expect(sts.Spec.Template.Spec.Containers[0].Env).To(BeEmpty()) svc := &corev1.Service{} @@ -405,7 +404,7 @@ var _ = Describe("System controller", func() { patch := client.MergeFrom(system.DeepCopy()) system.Spec.Searchd = &saasv1alpha1.SystemSearchdSpec{ - Enabled: pointer.Bool(false), + Enabled: util.Pointer(false), } return k8sClient.Patch(context.Background(), system, patch) }, timeout, poll).ShouldNot(HaveOccurred()) @@ -433,12 +432,12 @@ var _ = Describe("System controller", func() { Expect(err).ToNot(HaveOccurred()) patch := client.MergeFrom(system.DeepCopy()) system.Spec.Config.Rails = &saasv1alpha1.SystemRailsSpec{ - Console: pointer.Bool(true), + Console: util.Pointer(true), } system.Spec.Console = &saasv1alpha1.SystemRailsConsoleSpec{ Image: &saasv1alpha1.ImageSpec{ - Name: pointer.String("newImage"), - Tag: pointer.String("newTag"), + Name: util.Pointer("newImage"), + Tag: util.Pointer("newTag"), }, } return k8sClient.Patch(context.Background(), system, patch) @@ -493,27 +492,27 @@ var _ = Describe("System controller", func() { patch := client.MergeFrom(system.DeepCopy()) system.Spec.App = &saasv1alpha1.SystemAppSpec{ Canary: &saasv1alpha1.Canary{ - ImageName: pointer.String("newImage"), - ImageTag: pointer.String("newTag"), - Replicas: pointer.Int32(2)}, + ImageName: util.Pointer("newImage"), + ImageTag: util.Pointer("newTag"), + Replicas: util.Pointer[int32](2)}, } system.Spec.SidekiqDefault = &saasv1alpha1.SystemSidekiqSpec{ Canary: &saasv1alpha1.Canary{ - ImageName: pointer.String("newImage"), - ImageTag: pointer.String("newTag"), - Replicas: pointer.Int32(2)}, + ImageName: util.Pointer("newImage"), + ImageTag: util.Pointer("newTag"), + Replicas: util.Pointer[int32](2)}, } system.Spec.SidekiqBilling = &saasv1alpha1.SystemSidekiqSpec{ Canary: &saasv1alpha1.Canary{ - ImageName: pointer.String("newImage"), - ImageTag: pointer.String("newTag"), - Replicas: pointer.Int32(2)}, + ImageName: util.Pointer("newImage"), + ImageTag: util.Pointer("newTag"), + Replicas: util.Pointer[int32](2)}, } system.Spec.SidekiqLow = &saasv1alpha1.SystemSidekiqSpec{ Canary: &saasv1alpha1.Canary{ - ImageName: pointer.String("newImage"), - ImageTag: pointer.String("newTag"), - Replicas: pointer.Int32(2)}, + ImageName: util.Pointer("newImage"), + ImageTag: util.Pointer("newTag"), + Replicas: util.Pointer[int32](2)}, } // return k8sClient.Patch(context.Background(), system, patch) @@ -547,7 +546,7 @@ var _ = Describe("System controller", func() { }).Assert(k8sClient, dep, timeout, poll)) Expect(dep.Spec.Template.Spec.Volumes[0].Secret.SecretName).To(Equal("system-config")) - Expect(dep.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(pointer.Int64(60))) + Expect(dep.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(util.Pointer[int64](60))) svc := &corev1.Service{} By("keeps the system-app service deployment label selector", @@ -574,7 +573,7 @@ var _ = Describe("System controller", func() { Expect(dep.Spec.Template.Spec.Volumes[0].Name).To(Equal("system-tmp")) Expect(dep.Spec.Template.Spec.Volumes[1].Secret.SecretName).To(Equal("system-config")) - Expect(dep.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(pointer.Int64(60))) + Expect(dep.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(util.Pointer[int64](60))) By("deploying a system-sidekiq-billing-canary workload", (&testutil.ExpectedWorkload{ @@ -588,7 +587,7 @@ var _ = Describe("System controller", func() { Expect(dep.Spec.Template.Spec.Volumes[0].Name).To(Equal("system-tmp")) Expect(dep.Spec.Template.Spec.Volumes[1].Secret.SecretName).To(Equal("system-config")) - Expect(dep.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(pointer.Int64(60))) + Expect(dep.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(util.Pointer[int64](60))) By("deploying a system-sidekiq-low-canary workload", (&testutil.ExpectedWorkload{ @@ -602,7 +601,7 @@ var _ = Describe("System controller", func() { Expect(dep.Spec.Template.Spec.Volumes[0].Name).To(Equal("system-tmp")) Expect(dep.Spec.Template.Spec.Volumes[1].Secret.SecretName).To(Equal("system-config")) - Expect(dep.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(pointer.Int64(60))) + Expect(dep.Spec.Template.Spec.TerminationGracePeriodSeconds).To(Equal(util.Pointer[int64](60))) }) @@ -624,7 +623,7 @@ var _ = Describe("System controller", func() { patch := client.MergeFrom(system.DeepCopy()) system.Spec.App = &saasv1alpha1.SystemAppSpec{ Canary: &saasv1alpha1.Canary{ - SendTraffic: *pointer.Bool(true), + SendTraffic: *util.Pointer(true), }, } return k8sClient.Patch(context.Background(), system, patch) @@ -732,19 +731,19 @@ var _ = Describe("System controller", func() { patch := client.MergeFrom(system.DeepCopy()) system.Spec.Config.Rails = &saasv1alpha1.SystemRailsSpec{ - Console: pointer.Bool(true), + Console: util.Pointer(true), } system.Spec.Twemproxy = &saasv1alpha1.TwemproxySpec{ TwemproxyConfigRef: "system-twemproxyconfig", Options: &saasv1alpha1.TwemproxyOptions{ - LogLevel: pointer.Int32(2), + LogLevel: util.Pointer[int32](2), }, } system.Spec.App = &saasv1alpha1.SystemAppSpec{ Canary: &saasv1alpha1.Canary{ - Replicas: pointer.Int32(2), + Replicas: util.Pointer[int32](2), Patches: []string{ `[{"op":"add","path":"/twemproxy","value":{"twemproxyConfigRef":"system-canary-twemproxyconfig","options":{"logLevel":2}}}]`, }, @@ -753,7 +752,7 @@ var _ = Describe("System controller", func() { system.Spec.SidekiqBilling = &saasv1alpha1.SystemSidekiqSpec{ Canary: &saasv1alpha1.Canary{ - Replicas: pointer.Int32(3), + Replicas: util.Pointer[int32](3), Patches: []string{ `[{"op":"add","path":"/twemproxy","value":{"twemproxyConfigRef":"system-canary-twemproxyconfig","options":{"logLevel":3}}}]`, }, @@ -761,9 +760,9 @@ var _ = Describe("System controller", func() { } system.Spec.SidekiqDefault = &saasv1alpha1.SystemSidekiqSpec{ - Replicas: pointer.Int32(2), + Replicas: util.Pointer[int32](2), Canary: &saasv1alpha1.Canary{ - Replicas: pointer.Int32(4), + Replicas: util.Pointer[int32](4), Patches: []string{ `[{"op":"add","path":"/twemproxy/options","value":{"logLevel":4}}]`, }, @@ -771,9 +770,9 @@ var _ = Describe("System controller", func() { } system.Spec.SidekiqLow = &saasv1alpha1.SystemSidekiqSpec{ - Replicas: pointer.Int32(2), + Replicas: util.Pointer[int32](2), Canary: &saasv1alpha1.Canary{ - Replicas: pointer.Int32(5), + Replicas: util.Pointer[int32](5), Patches: []string{ `[{"op":"add","path":"/twemproxy/options","value":{"logLevel":5}}]`, }, @@ -960,8 +959,8 @@ var _ = Describe("System controller", func() { system.Spec.Config.ExternalSecret.RefreshInterval = &metav1.Duration{Duration: 1 * time.Second} system.Spec.Config.ExternalSecret.SecretStoreRef = &saasv1alpha1.ExternalSecretSecretStoreReferenceSpec{ - Name: pointer.String("other-store"), - Kind: pointer.String("SecretStore"), + Name: util.Pointer("other-store"), + Kind: util.Pointer("SecretStore"), } system.Spec.Config.DatabaseDSN.FromVault.Path = "secret/data/updated-path" @@ -1021,20 +1020,20 @@ var _ = Describe("System controller", func() { patch := client.MergeFrom(system.DeepCopy()) system.Spec.Config.Rails = &saasv1alpha1.SystemRailsSpec{ - LogLevel: pointer.String("debug"), + LogLevel: util.Pointer("debug"), } system.Spec.Tasks = []saasv1alpha1.SystemTektonTaskSpec{ { - Name: pointer.String("system-db-migrate"), - Enabled: pointer.Bool(false), + Name: util.Pointer("system-db-migrate"), + Enabled: util.Pointer(false), }, { - Name: pointer.String("system-searchd-reindex"), + Name: util.Pointer("system-searchd-reindex"), Config: &saasv1alpha1.SystemTektonTaskConfig{ Image: &saasv1alpha1.ImageSpec{ - Name: pointer.String("newImage"), - Tag: pointer.String("newTag"), + Name: util.Pointer("newImage"), + Tag: util.Pointer("newTag"), }, Command: []string{"cmd"}, Args: []string{"arg1", "arg1"}, @@ -1045,8 +1044,8 @@ var _ = Describe("System controller", func() { }, }, { - Name: pointer.String("test-task"), - Description: pointer.String("Test task"), + Name: util.Pointer("test-task"), + Description: util.Pointer("Test task"), Config: &saasv1alpha1.SystemTektonTaskConfig{ Command: []string{"cmd"}, Args: []string{"arg1", "arg1"}, diff --git a/controllers/twemproxyconfig_controller.go b/controllers/twemproxyconfig_controller.go index d8c94937..3c519193 100644 --- a/controllers/twemproxyconfig_controller.go +++ b/controllers/twemproxyconfig_controller.go @@ -25,12 +25,13 @@ import ( "github.com/3scale-ops/basereconciler/reconciler" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators/twemproxyconfig" - "github.com/3scale/saas-operator/pkg/reconcilers/threads" - "github.com/3scale/saas-operator/pkg/redis/events" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators/twemproxyconfig" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/threads" + "github.com/3scale-ops/saas-operator/pkg/redis/events" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" + operatorutils "github.com/3scale-ops/saas-operator/pkg/util" "github.com/go-logr/logr" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" corev1 "k8s.io/api/core/v1" @@ -68,6 +69,7 @@ func (r *TwemproxyConfigReconciler) Reconcile(ctx context.Context, req ctrl.Requ instance := &saasv1alpha1.TwemproxyConfig{} result := r.ManageResourceLifecycle(ctx, req, instance, + reconciler.WithInMemoryInitializationFunc(util.ResourceDefaulter(instance)), reconciler.WithFinalizer(saasv1alpha1.Finalizer), reconciler.WithFinalizationFunc(r.SentinelEvents.CleanupThreads(instance)), ) @@ -75,9 +77,6 @@ func (r *TwemproxyConfigReconciler) Reconcile(ctx context.Context, req ctrl.Requ return result.Values() } - // Apply defaults for reconcile but do not store them in the API - instance.Default() - // Generate the ConfigMap gen, err := twemproxyconfig.NewGenerator( ctx, instance, r.Client, r.Pool, logger.WithName("generator"), @@ -134,7 +133,7 @@ func (r *TwemproxyConfigReconciler) reconcileConfigMap(ctx context.Context, owne logger := log.WithValues("kind", "ConfigMap", "resource", desired.GetName()) current := &corev1.ConfigMap{} - err := r.Client.Get(ctx, util.ObjectKey(desired), current) + err := r.Client.Get(ctx, client.ObjectKeyFromObject(desired), current) if err != nil { if apierrors.IsNotFound(err) { // Create @@ -177,7 +176,7 @@ func (r *TwemproxyConfigReconciler) reconcileSyncAnnotations(ctx context.Context return err } - failures := util.MultiError{} + failures := operatorutils.MultiError{} errCh := make(chan error) innerCtx, cancel := context.WithTimeout(ctx, 5*time.Second) var wg sync.WaitGroup @@ -227,7 +226,7 @@ func (r *TwemproxyConfigReconciler) syncPod(ctx context.Context, pod corev1.Pod, if err := r.Client.Patch(ctx, &pod, patch); err != nil { errCh <- err } - log.V(1).Info(fmt.Sprintf("configmap re-sync forced in target pod %s", util.ObjectKey(&pod))) + log.V(1).Info(fmt.Sprintf("configmap re-sync forced in target pod %s", client.ObjectKeyFromObject(&pod))) } } diff --git a/controllers/zync_controller.go b/controllers/zync_controller.go index 2364a5cd..4641329c 100644 --- a/controllers/zync_controller.go +++ b/controllers/zync_controller.go @@ -19,9 +19,11 @@ package controllers import ( "context" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators/zync" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" + "github.com/3scale-ops/basereconciler/reconciler" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators/zync" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" "github.com/go-logr/logr" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" @@ -61,14 +63,12 @@ func (r *ZyncReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl. ctx = log.IntoContext(ctx, logger) instance := &saasv1alpha1.Zync{} - result := r.ManageResourceLifecycle(ctx, req, instance) + result := r.ManageResourceLifecycle(ctx, req, instance, + reconciler.WithInMemoryInitializationFunc(util.ResourceDefaulter(instance))) if result.ShouldReturn() { return result.Values() } - // Apply defaults for reconcile but do not store them in the API - instance.Default() - gen := zync.NewGenerator( instance.GetName(), instance.GetNamespace(), diff --git a/controllers/zync_controller_suite_test.go b/controllers/zync_controller_suite_test.go index 234734f3..3429b248 100644 --- a/controllers/zync_controller_suite_test.go +++ b/controllers/zync_controller_suite_test.go @@ -4,8 +4,9 @@ import ( "context" "time" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - testutil "github.com/3scale/saas-operator/test/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + testutil "github.com/3scale-ops/saas-operator/test/util" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" . "github.com/onsi/ginkgo/v2" @@ -16,7 +17,6 @@ import ( policyv1 "k8s.io/api/policy/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -74,7 +74,7 @@ var _ = Describe("Zync controller", func() { }, }, Bugsnag: &saasv1alpha1.BugsnagSpec{ - ReleaseStage: pointer.String("staging"), + ReleaseStage: util.Pointer("staging"), APIKey: saasv1alpha1.SecretReference{ FromVault: &saasv1alpha1.VaultSecretReference{ Path: "some-path-bugsnag", @@ -220,27 +220,27 @@ var _ = Describe("Zync controller", func() { patch := client.MergeFrom(zync.DeepCopy()) zync.Spec.API = &saasv1alpha1.APISpec{ HPA: &saasv1alpha1.HorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(3), + MinReplicas: util.Pointer[int32](3), }, LivenessProbe: &saasv1alpha1.ProbeSpec{}, ReadinessProbe: &saasv1alpha1.ProbeSpec{}, } zync.Spec.Que = &saasv1alpha1.QueSpec{ HPA: &saasv1alpha1.HorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(3), + MinReplicas: util.Pointer[int32](3), }, LivenessProbe: &saasv1alpha1.ProbeSpec{}, ReadinessProbe: &saasv1alpha1.ProbeSpec{}, } zync.Spec.Config.Rails = &saasv1alpha1.ZyncRailsSpec{ - Environment: pointer.String("production"), - MaxThreads: pointer.Int32(12), - LogLevel: pointer.String("debug"), + Environment: util.Pointer("production"), + MaxThreads: util.Pointer[int32](12), + LogLevel: util.Pointer("debug"), } zync.Spec.Config.ExternalSecret.RefreshInterval = &metav1.Duration{Duration: 1 * time.Second} zync.Spec.Config.ExternalSecret.SecretStoreRef = &saasv1alpha1.ExternalSecretSecretStoreReferenceSpec{ - Name: pointer.String("other-store"), - Kind: pointer.String("SecretStore"), + Name: util.Pointer("other-store"), + Kind: util.Pointer("SecretStore"), } zync.Spec.Config.SecretKeyBase.FromVault.Path = "secret/data/updated-path" @@ -351,10 +351,10 @@ var _ = Describe("Zync controller", func() { Expect(err).ToNot(HaveOccurred()) patch := client.MergeFrom(zync.DeepCopy()) zync.Spec.Console = &saasv1alpha1.ZyncRailsConsoleSpec{ - Enabled: pointer.Bool(true), + Enabled: util.Pointer(true), Image: &saasv1alpha1.ImageSpec{ - Name: pointer.String("newImage"), - Tag: pointer.String("newTag"), + Name: util.Pointer("newImage"), + Tag: util.Pointer("newTag"), }, } return k8sClient.Patch(context.Background(), zync, patch) @@ -409,13 +409,13 @@ var _ = Describe("Zync controller", func() { patch := client.MergeFrom(zync.DeepCopy()) zync.Spec.API = &saasv1alpha1.APISpec{ - Replicas: pointer.Int32(0), + Replicas: util.Pointer[int32](0), HPA: &saasv1alpha1.HorizontalPodAutoscalerSpec{}, PDB: &saasv1alpha1.PodDisruptionBudgetSpec{}, } zync.Spec.Que = &saasv1alpha1.QueSpec{ - Replicas: pointer.Int32(0), + Replicas: util.Pointer[int32](0), HPA: &saasv1alpha1.HorizontalPodAutoscalerSpec{}, PDB: &saasv1alpha1.PodDisruptionBudgetSpec{}, } diff --git a/go.mod b/go.mod index 1e361ca9..41ae0e34 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/3scale/saas-operator +module github.com/3scale-ops/saas-operator go 1.20 @@ -10,7 +10,6 @@ require ( github.com/aws/aws-sdk-go-v2/config v1.18.37 github.com/aws/aws-sdk-go-v2/credentials v1.13.35 github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5 - github.com/davecgh/go-spew v1.1.1 github.com/envoyproxy/go-control-plane v0.11.1-0.20230524094728-9239064ad72f github.com/evanphx/json-patch v5.6.0+incompatible github.com/external-secrets/external-secrets v0.8.1 @@ -29,6 +28,7 @@ require ( github.com/prometheus/client_golang v1.14.0 github.com/prometheus/client_model v0.3.0 github.com/robfig/cron/v3 v3.0.1 + github.com/samber/lo v1.39.0 github.com/tektoncd/pipeline v0.49.0 go.uber.org/zap v1.24.0 golang.org/x/crypto v0.14.0 @@ -37,7 +37,6 @@ require ( k8s.io/api v0.26.2 k8s.io/apimachinery v0.26.5 k8s.io/client-go v0.26.2 - k8s.io/utils v0.0.0-20230313181309-38a27ef9d749 sigs.k8s.io/controller-runtime v0.14.5 sigs.k8s.io/yaml v1.3.0 ) @@ -67,6 +66,7 @@ require ( github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/emicklei/go-restful/v3 v3.10.2 // indirect github.com/envoyproxy/protoc-gen-validate v0.10.1 // indirect @@ -132,6 +132,7 @@ require ( k8s.io/component-base v0.26.2 // indirect k8s.io/klog/v2 v2.90.1 // indirect k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a // indirect + k8s.io/utils v0.0.0-20230313181309-38a27ef9d749 // indirect knative.dev/pkg v0.0.0-20230221145627-8efb3485adcf // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect diff --git a/go.sum b/go.sum index bd8286e7..588b3d16 100644 --- a/go.sum +++ b/go.sum @@ -448,6 +448,8 @@ github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzG github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA= +github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= diff --git a/main.go b/main.go index 3f3ba8d3..1a99d1c3 100644 --- a/main.go +++ b/main.go @@ -30,6 +30,7 @@ import ( "github.com/3scale-ops/basereconciler/reconciler" marin3rv1alpha1 "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1" + operatorutils "github.com/3scale-ops/saas-operator/pkg/util" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" @@ -41,13 +42,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/healthz" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/controllers" - "github.com/3scale/saas-operator/pkg/reconcilers/threads" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/util" - "github.com/3scale/saas-operator/pkg/version" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/controllers" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/threads" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" + "github.com/3scale-ops/saas-operator/pkg/version" // +kubebuilder:scaffold:imports ) @@ -86,11 +86,11 @@ func main() { "Enable leader election for controller manager. "+ "Enabling this will ensure there is only one active controller manager.") - ctrl.SetLogger((util.Logger{}).New()) + ctrl.SetLogger((operatorutils.Logger{}).New()) printVersion() - if err := (&util.ProfilerConfig{ + if err := (&operatorutils.ProfilerConfig{ Log: ctrl.Log.WithName("profiler"), }).Setup(); err != nil { setupLog.Error(err, "unable to start the Profiler") diff --git a/pkg/generators/apicast/config/options.go b/pkg/generators/apicast/config/options.go index f2e026af..77604a7b 100644 --- a/pkg/generators/apicast/config/options.go +++ b/pkg/generators/apicast/config/options.go @@ -3,8 +3,8 @@ package config import ( "fmt" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" ) // EnvOptions holds configuration for the apicasts pods diff --git a/pkg/generators/apicast/deployment.go b/pkg/generators/apicast/deployment.go index 53fcdbdb..ba3e71cb 100644 --- a/pkg/generators/apicast/deployment.go +++ b/pkg/generators/apicast/deployment.go @@ -3,13 +3,12 @@ package apicast import ( "fmt" - "github.com/3scale/saas-operator/pkg/resource_builders/marin3r" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/marin3r" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) // Deployment returns a function that will return a Deployment @@ -22,8 +21,8 @@ func (gen *EnvGenerator) deployment() *appsv1.Deployment { Strategy: appsv1.DeploymentStrategy{ Type: appsv1.RollingUpdateDeploymentStrategyType, RollingUpdate: &appsv1.RollingUpdateDeployment{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(0)), - MaxSurge: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(0)), + MaxSurge: util.Pointer(intstr.FromInt(1)), }, }, Template: corev1.PodTemplateSpec{ @@ -52,7 +51,7 @@ func (gen *EnvGenerator) deployment() *appsv1.Deployment { }, Affinity: pod.Affinity(gen.GetSelector(), gen.Spec.NodeAffinity), Tolerations: gen.Spec.Tolerations, - TerminationGracePeriodSeconds: pointer.Int64(30), + TerminationGracePeriodSeconds: util.Pointer[int64](30), }, }, }, diff --git a/pkg/generators/apicast/generator.go b/pkg/generators/apicast/generator.go index afe5f153..4aaad917 100644 --- a/pkg/generators/apicast/generator.go +++ b/pkg/generators/apicast/generator.go @@ -5,13 +5,13 @@ import ( mutators "github.com/3scale-ops/basereconciler/mutators" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators" - "github.com/3scale/saas-operator/pkg/generators/apicast/config" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" - descriptor "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/descriptor" - "github.com/3scale/saas-operator/pkg/resource_builders/grafanadashboard" - "github.com/3scale/saas-operator/pkg/resource_builders/podmonitor" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators" + "github.com/3scale-ops/saas-operator/pkg/generators/apicast/config" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" + descriptor "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/descriptor" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/grafanadashboard" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/podmonitor" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" appsv1 "k8s.io/api/apps/v1" diff --git a/pkg/generators/apicast/services.go b/pkg/generators/apicast/services.go index a513078f..c43879c1 100644 --- a/pkg/generators/apicast/services.go +++ b/pkg/generators/apicast/services.go @@ -1,7 +1,7 @@ package apicast import ( - "github.com/3scale/saas-operator/pkg/resource_builders/service" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/service" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" diff --git a/pkg/generators/autossl/config/options.go b/pkg/generators/autossl/config/options.go index 4e4a8cdf..b8d57575 100644 --- a/pkg/generators/autossl/config/options.go +++ b/pkg/generators/autossl/config/options.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" ) const ( diff --git a/pkg/generators/autossl/deployment.go b/pkg/generators/autossl/deployment.go index 8d0da6e2..dd1fe06a 100644 --- a/pkg/generators/autossl/deployment.go +++ b/pkg/generators/autossl/deployment.go @@ -3,12 +3,11 @@ package autossl import ( "fmt" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) // deployment returns a function that will return a *appsv1.Deployment for autossl @@ -19,8 +18,8 @@ func (gen *Generator) deployment() *appsv1.Deployment { Strategy: appsv1.DeploymentStrategy{ Type: appsv1.RollingUpdateDeploymentStrategyType, RollingUpdate: &appsv1.RollingUpdateDeployment{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(0)), - MaxSurge: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(0)), + MaxSurge: util.Pointer(intstr.FromInt(1)), }, }, Template: corev1.PodTemplateSpec{ @@ -75,7 +74,7 @@ func (gen *Generator) deployment() *appsv1.Deployment { }, Affinity: pod.Affinity(gen.GetSelector(), gen.Spec.NodeAffinity), Tolerations: gen.Spec.Tolerations, - TerminationGracePeriodSeconds: pointer.Int64(30), + TerminationGracePeriodSeconds: util.Pointer[int64](30), }, }, }, diff --git a/pkg/generators/autossl/generator.go b/pkg/generators/autossl/generator.go index 96474cf0..e0b3cb9b 100644 --- a/pkg/generators/autossl/generator.go +++ b/pkg/generators/autossl/generator.go @@ -6,12 +6,12 @@ import ( "github.com/3scale-ops/basereconciler/mutators" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators" - "github.com/3scale/saas-operator/pkg/generators/autossl/config" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" - "github.com/3scale/saas-operator/pkg/resource_builders/grafanadashboard" - "github.com/3scale/saas-operator/pkg/resource_builders/podmonitor" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators" + "github.com/3scale-ops/saas-operator/pkg/generators/autossl/config" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/grafanadashboard" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/podmonitor" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" appsv1 "k8s.io/api/apps/v1" diff --git a/pkg/generators/autossl/service.go b/pkg/generators/autossl/service.go index 5abcdd70..63a3cad1 100644 --- a/pkg/generators/autossl/service.go +++ b/pkg/generators/autossl/service.go @@ -1,7 +1,7 @@ package autossl import ( - "github.com/3scale/saas-operator/pkg/resource_builders/service" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/service" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" diff --git a/pkg/generators/backend/config/cron_options.go b/pkg/generators/backend/config/cron_options.go index 01ed4248..33f990ad 100644 --- a/pkg/generators/backend/config/cron_options.go +++ b/pkg/generators/backend/config/cron_options.go @@ -1,8 +1,8 @@ package config import ( - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" ) // CronOptions holds configuration for the cron pods diff --git a/pkg/generators/backend/config/listener_options.go b/pkg/generators/backend/config/listener_options.go index 6ddfc300..147b5722 100644 --- a/pkg/generators/backend/config/listener_options.go +++ b/pkg/generators/backend/config/listener_options.go @@ -4,8 +4,8 @@ import ( "fmt" "strconv" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" ) // ListenerOptions holds configuration for the listener pods diff --git a/pkg/generators/backend/config/worker_options.go b/pkg/generators/backend/config/worker_options.go index 2e34a339..36563846 100644 --- a/pkg/generators/backend/config/worker_options.go +++ b/pkg/generators/backend/config/worker_options.go @@ -4,8 +4,8 @@ import ( "fmt" "strconv" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" ) // WorkerOptions holds configuration for the worker pods diff --git a/pkg/generators/backend/cron_deployment.go b/pkg/generators/backend/cron_deployment.go index 9c35cde7..6c47f1b9 100644 --- a/pkg/generators/backend/cron_deployment.go +++ b/pkg/generators/backend/cron_deployment.go @@ -3,12 +3,11 @@ package backend import ( "strings" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) // Deployment returns a function that will return a Deployment @@ -20,8 +19,8 @@ func (gen *CronGenerator) deployment() *appsv1.Deployment { Strategy: appsv1.DeploymentStrategy{ Type: appsv1.RollingUpdateDeploymentStrategyType, RollingUpdate: &appsv1.RollingUpdateDeployment{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(0)), - MaxSurge: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(0)), + MaxSurge: util.Pointer(intstr.FromInt(1)), }, }, Template: corev1.PodTemplateSpec{ @@ -39,7 +38,7 @@ func (gen *CronGenerator) deployment() *appsv1.Deployment { }, Affinity: pod.Affinity(gen.GetSelector(), gen.CronSpec.NodeAffinity), Tolerations: gen.CronSpec.Tolerations, - TerminationGracePeriodSeconds: pointer.Int64(30), + TerminationGracePeriodSeconds: util.Pointer[int64](30), }, }, }, diff --git a/pkg/generators/backend/generator.go b/pkg/generators/backend/generator.go index 8fd92353..c35fc944 100644 --- a/pkg/generators/backend/generator.go +++ b/pkg/generators/backend/generator.go @@ -6,20 +6,20 @@ import ( "github.com/3scale-ops/basereconciler/mutators" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators" - "github.com/3scale/saas-operator/pkg/generators/backend/config" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" - descriptor "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/descriptor" - "github.com/3scale/saas-operator/pkg/resource_builders/grafanadashboard" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/resource_builders/podmonitor" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators" + "github.com/3scale-ops/saas-operator/pkg/generators/backend/config" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" + descriptor "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/descriptor" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/grafanadashboard" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/podmonitor" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/pointer" ) const ( @@ -214,8 +214,8 @@ func (gen *ListenerGenerator) Labels() map[string]string { func (gen *ListenerGenerator) Deployment() *resource.Template[*appsv1.Deployment] { return resource.NewTemplateFromObjectFunction(gen.deployment). WithMutation(mutators.SetDeploymentReplicas(gen.ListenerSpec.HPA.IsDeactivated())). - WithMutation(mutators.RolloutTrigger{Name: "backend-internal-api", SecretName: pointer.String("backend-internal-api")}.Add()). - WithMutation(mutators.RolloutTrigger{Name: "backend-error-monitoring", SecretName: pointer.String("backend-error-monitoring")}.Add()) + WithMutation(mutators.RolloutTrigger{Name: "backend-internal-api", SecretName: util.Pointer("backend-internal-api")}.Add()). + WithMutation(mutators.RolloutTrigger{Name: "backend-error-monitoring", SecretName: util.Pointer("backend-error-monitoring")}.Add()) } func (gen *ListenerGenerator) HPASpec() *saasv1alpha1.HorizontalPodAutoscalerSpec { @@ -268,8 +268,8 @@ var _ workloads.DeploymentWorkload = &WorkerGenerator{} func (gen *WorkerGenerator) Deployment() *resource.Template[*appsv1.Deployment] { return resource.NewTemplateFromObjectFunction(gen.deployment). WithMutation(mutators.SetDeploymentReplicas(gen.WorkerSpec.HPA.IsDeactivated())). - WithMutation(mutators.RolloutTrigger{Name: "backend-system-events-hook", SecretName: pointer.String("backend-system-events-hook")}.Add()). - WithMutation(mutators.RolloutTrigger{Name: "backend-error-monitoring", SecretName: pointer.String("backend-error-monitoring")}.Add()) + WithMutation(mutators.RolloutTrigger{Name: "backend-system-events-hook", SecretName: util.Pointer("backend-system-events-hook")}.Add()). + WithMutation(mutators.RolloutTrigger{Name: "backend-error-monitoring", SecretName: util.Pointer("backend-error-monitoring")}.Add()) } func (gen *WorkerGenerator) HPASpec() *saasv1alpha1.HorizontalPodAutoscalerSpec { return gen.WorkerSpec.HPA @@ -302,7 +302,7 @@ var _ workloads.DeploymentWorkload = &CronGenerator{} func (gen *CronGenerator) Deployment() *resource.Template[*appsv1.Deployment] { return resource.NewTemplateFromObjectFunction(gen.deployment). WithMutation(mutators.SetDeploymentReplicas(true)). - WithMutation(mutators.RolloutTrigger{Name: "backend-error-monitoring", SecretName: pointer.String("backend-error-monitoring")}.Add()) + WithMutation(mutators.RolloutTrigger{Name: "backend-error-monitoring", SecretName: util.Pointer("backend-error-monitoring")}.Add()) } func (gen *CronGenerator) HPASpec() *saasv1alpha1.HorizontalPodAutoscalerSpec { return &saasv1alpha1.HorizontalPodAutoscalerSpec{} diff --git a/pkg/generators/backend/listener_deployment.go b/pkg/generators/backend/listener_deployment.go index 37a59f1c..6e349694 100644 --- a/pkg/generators/backend/listener_deployment.go +++ b/pkg/generators/backend/listener_deployment.go @@ -3,14 +3,13 @@ package backend import ( "strings" - "github.com/3scale/saas-operator/pkg/resource_builders/marin3r" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/resource_builders/twemproxy" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/marin3r" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/twemproxy" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) // Deployment returns a function that will return a Deployment @@ -22,8 +21,8 @@ func (gen *ListenerGenerator) deployment() *appsv1.Deployment { Strategy: appsv1.DeploymentStrategy{ Type: appsv1.RollingUpdateDeploymentStrategyType, RollingUpdate: &appsv1.RollingUpdateDeployment{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(0)), - MaxSurge: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(0)), + MaxSurge: util.Pointer(intstr.FromInt(1)), }, }, Template: corev1.PodTemplateSpec{ @@ -56,7 +55,7 @@ func (gen *ListenerGenerator) deployment() *appsv1.Deployment { RestartPolicy: corev1.RestartPolicyAlways, Affinity: pod.Affinity(gen.GetSelector(), gen.ListenerSpec.NodeAffinity), Tolerations: gen.ListenerSpec.Tolerations, - TerminationGracePeriodSeconds: pointer.Int64(30), + TerminationGracePeriodSeconds: util.Pointer[int64](30), }, }, }, diff --git a/pkg/generators/backend/services.go b/pkg/generators/backend/services.go index 869c4930..54c4f6d5 100644 --- a/pkg/generators/backend/services.go +++ b/pkg/generators/backend/services.go @@ -1,7 +1,7 @@ package backend import ( - "github.com/3scale/saas-operator/pkg/resource_builders/service" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/service" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" diff --git a/pkg/generators/backend/worker_deployment.go b/pkg/generators/backend/worker_deployment.go index b01fb2f6..17be6906 100644 --- a/pkg/generators/backend/worker_deployment.go +++ b/pkg/generators/backend/worker_deployment.go @@ -3,13 +3,12 @@ package backend import ( "strings" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/resource_builders/twemproxy" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/twemproxy" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) // Deployment returns a function that will return a Deployment @@ -21,8 +20,8 @@ func (gen *WorkerGenerator) deployment() *appsv1.Deployment { Strategy: appsv1.DeploymentStrategy{ Type: appsv1.RollingUpdateDeploymentStrategyType, RollingUpdate: &appsv1.RollingUpdateDeployment{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(0)), - MaxSurge: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(0)), + MaxSurge: util.Pointer(intstr.FromInt(1)), }, }, Template: corev1.PodTemplateSpec{ @@ -45,7 +44,7 @@ func (gen *WorkerGenerator) deployment() *appsv1.Deployment { }, Affinity: pod.Affinity(gen.GetSelector(), gen.WorkerSpec.NodeAffinity), Tolerations: gen.WorkerSpec.Tolerations, - TerminationGracePeriodSeconds: pointer.Int64(30), + TerminationGracePeriodSeconds: util.Pointer[int64](30), }, }, }, diff --git a/pkg/generators/base_options.go b/pkg/generators/base_options.go index 6492bc52..2a3eba97 100644 --- a/pkg/generators/base_options.go +++ b/pkg/generators/base_options.go @@ -1,7 +1,7 @@ package generators import ( - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" "k8s.io/apimachinery/pkg/types" ) diff --git a/pkg/generators/corsproxy/config/options.go b/pkg/generators/corsproxy/config/options.go index 311c2a46..fe8db3d2 100644 --- a/pkg/generators/corsproxy/config/options.go +++ b/pkg/generators/corsproxy/config/options.go @@ -1,8 +1,8 @@ package config import ( - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" ) // Options holds configuration for the cors-proxy pod diff --git a/pkg/generators/corsproxy/deployment.go b/pkg/generators/corsproxy/deployment.go index 6457e5fd..f5d3ca6b 100644 --- a/pkg/generators/corsproxy/deployment.go +++ b/pkg/generators/corsproxy/deployment.go @@ -3,12 +3,11 @@ package corsproxy import ( "fmt" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) // deployment returns a function that will return a *appsv1.Deployment for echo-api @@ -19,8 +18,8 @@ func (gen *Generator) deployment() *appsv1.Deployment { Strategy: appsv1.DeploymentStrategy{ Type: appsv1.RollingUpdateDeploymentStrategyType, RollingUpdate: &appsv1.RollingUpdateDeployment{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(0)), - MaxSurge: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(0)), + MaxSurge: util.Pointer(intstr.FromInt(1)), }, }, Template: corev1.PodTemplateSpec{ @@ -48,7 +47,7 @@ func (gen *Generator) deployment() *appsv1.Deployment { }, Affinity: pod.Affinity(gen.GetSelector(), gen.Spec.NodeAffinity), Tolerations: gen.Spec.Tolerations, - TerminationGracePeriodSeconds: pointer.Int64(30), + TerminationGracePeriodSeconds: util.Pointer[int64](30), }, }, }, diff --git a/pkg/generators/corsproxy/generator.go b/pkg/generators/corsproxy/generator.go index 7b152ec5..c4b0ed54 100644 --- a/pkg/generators/corsproxy/generator.go +++ b/pkg/generators/corsproxy/generator.go @@ -5,19 +5,19 @@ import ( "github.com/3scale-ops/basereconciler/mutators" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators" - "github.com/3scale/saas-operator/pkg/generators/corsproxy/config" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" - "github.com/3scale/saas-operator/pkg/resource_builders/grafanadashboard" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/resource_builders/podmonitor" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators" + "github.com/3scale-ops/saas-operator/pkg/generators/corsproxy/config" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/grafanadashboard" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/podmonitor" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/pointer" ) const ( @@ -74,7 +74,7 @@ var _ workloads.DeploymentWorkload = &Generator{} func (gen *Generator) Deployment() *resource.Template[*appsv1.Deployment] { return resource.NewTemplateFromObjectFunction(gen.deployment). WithMutation(mutators.SetDeploymentReplicas(gen.Spec.HPA.IsDeactivated())). - WithMutation(mutators.RolloutTrigger{Name: "cors-proxy-system-database", SecretName: pointer.String("cors-proxy-system-database")}.Add()) + WithMutation(mutators.RolloutTrigger{Name: "cors-proxy-system-database", SecretName: util.Pointer("cors-proxy-system-database")}.Add()) } func (gen *Generator) HPASpec() *saasv1alpha1.HorizontalPodAutoscalerSpec { diff --git a/pkg/generators/corsproxy/service.go b/pkg/generators/corsproxy/service.go index f9c89367..7ae1d578 100644 --- a/pkg/generators/corsproxy/service.go +++ b/pkg/generators/corsproxy/service.go @@ -1,7 +1,7 @@ package corsproxy import ( - "github.com/3scale/saas-operator/pkg/resource_builders/service" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/service" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" diff --git a/pkg/generators/echoapi/deployment.go b/pkg/generators/echoapi/deployment.go index dc9a57cf..de39db2a 100644 --- a/pkg/generators/echoapi/deployment.go +++ b/pkg/generators/echoapi/deployment.go @@ -3,13 +3,12 @@ package echoapi import ( "fmt" - "github.com/3scale/saas-operator/pkg/resource_builders/marin3r" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/marin3r" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) // deployment returns a function that will return a *appsv1.Deployment for echo-api @@ -21,8 +20,8 @@ func (gen *Generator) deployment() *appsv1.Deployment { Strategy: appsv1.DeploymentStrategy{ Type: appsv1.RollingUpdateDeploymentStrategyType, RollingUpdate: &appsv1.RollingUpdateDeployment{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(0)), - MaxSurge: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(0)), + MaxSurge: util.Pointer(intstr.FromInt(1)), }, }, Template: corev1.PodTemplateSpec{ @@ -48,7 +47,7 @@ func (gen *Generator) deployment() *appsv1.Deployment { }, Affinity: pod.Affinity(gen.GetSelector(), gen.Spec.NodeAffinity), Tolerations: gen.Spec.Tolerations, - TerminationGracePeriodSeconds: pointer.Int64(30), + TerminationGracePeriodSeconds: util.Pointer[int64](30), }, }, }, diff --git a/pkg/generators/echoapi/generator.go b/pkg/generators/echoapi/generator.go index a44c631e..c5010820 100644 --- a/pkg/generators/echoapi/generator.go +++ b/pkg/generators/echoapi/generator.go @@ -5,11 +5,11 @@ import ( "github.com/3scale-ops/basereconciler/mutators" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" - descriptor "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/descriptor" - "github.com/3scale/saas-operator/pkg/resource_builders/podmonitor" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" + descriptor "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/descriptor" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/podmonitor" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" diff --git a/pkg/generators/echoapi/service.go b/pkg/generators/echoapi/service.go index 3152bd9d..321ee07d 100644 --- a/pkg/generators/echoapi/service.go +++ b/pkg/generators/echoapi/service.go @@ -1,7 +1,7 @@ package echoapi import ( - "github.com/3scale/saas-operator/pkg/resource_builders/service" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/service" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" diff --git a/pkg/generators/mappingservice/config/options.go b/pkg/generators/mappingservice/config/options.go index 151b3b8f..04c9394c 100644 --- a/pkg/generators/mappingservice/config/options.go +++ b/pkg/generators/mappingservice/config/options.go @@ -1,8 +1,8 @@ package config import ( - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" ) // Options holds configuration for the mapping-service pod diff --git a/pkg/generators/mappingservice/deployment.go b/pkg/generators/mappingservice/deployment.go index 4b9fa36b..87ca3849 100644 --- a/pkg/generators/mappingservice/deployment.go +++ b/pkg/generators/mappingservice/deployment.go @@ -3,12 +3,11 @@ package mappingservice import ( "fmt" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) // deployment returns a function that will return a *appsv1.Deployment for echo-api @@ -19,8 +18,8 @@ func (gen *Generator) deployment() *appsv1.Deployment { Strategy: appsv1.DeploymentStrategy{ Type: appsv1.RollingUpdateDeploymentStrategyType, RollingUpdate: &appsv1.RollingUpdateDeployment{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(0)), - MaxSurge: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(0)), + MaxSurge: util.Pointer(intstr.FromInt(1)), }, }, Template: corev1.PodTemplateSpec{ @@ -49,7 +48,7 @@ func (gen *Generator) deployment() *appsv1.Deployment { }, Affinity: pod.Affinity(gen.GetSelector(), gen.Spec.NodeAffinity), Tolerations: gen.Spec.Tolerations, - TerminationGracePeriodSeconds: pointer.Int64(30), + TerminationGracePeriodSeconds: util.Pointer[int64](30), }, }, }, diff --git a/pkg/generators/mappingservice/generator.go b/pkg/generators/mappingservice/generator.go index 8fb56d92..c2ce638b 100644 --- a/pkg/generators/mappingservice/generator.go +++ b/pkg/generators/mappingservice/generator.go @@ -5,14 +5,14 @@ import ( "github.com/3scale-ops/basereconciler/mutators" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators" - "github.com/3scale/saas-operator/pkg/generators/mappingservice/config" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" - "github.com/3scale/saas-operator/pkg/resource_builders/grafanadashboard" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/resource_builders/podmonitor" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators" + "github.com/3scale-ops/saas-operator/pkg/generators/mappingservice/config" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/grafanadashboard" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/podmonitor" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" diff --git a/pkg/generators/mappingservice/service.go b/pkg/generators/mappingservice/service.go index 79d0b425..729ff97f 100644 --- a/pkg/generators/mappingservice/service.go +++ b/pkg/generators/mappingservice/service.go @@ -1,7 +1,7 @@ package mappingservice import ( - "github.com/3scale/saas-operator/pkg/resource_builders/service" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/service" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" diff --git a/pkg/generators/redisshard/generator.go b/pkg/generators/redisshard/generator.go index 95290768..ccafc61a 100644 --- a/pkg/generators/redisshard/generator.go +++ b/pkg/generators/redisshard/generator.go @@ -4,8 +4,8 @@ import ( "fmt" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" ) diff --git a/pkg/generators/redisshard/statefulset.go b/pkg/generators/redisshard/statefulset.go index 24e9713a..0f1f097b 100644 --- a/pkg/generators/redisshard/statefulset.go +++ b/pkg/generators/redisshard/statefulset.go @@ -4,12 +4,11 @@ import ( "fmt" "strings" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" ) // StatefulSet returns a function that will return @@ -23,8 +22,8 @@ func (gen *Generator) statefulSet() *appsv1.StatefulSet { }, Spec: appsv1.StatefulSetSpec{ PodManagementPolicy: appsv1.ParallelPodManagement, - Replicas: pointer.Int32(gen.Replicas), - RevisionHistoryLimit: pointer.Int32(1), + Replicas: util.Pointer[int32](gen.Replicas), + RevisionHistoryLimit: util.Pointer[int32](1), Selector: &metav1.LabelSelector{MatchLabels: gen.GetSelector()}, ServiceName: gen.ServiceName(), Template: corev1.PodTemplateSpec{ @@ -65,20 +64,20 @@ func (gen *Generator) statefulSet() *appsv1.StatefulSet { }, }, }, - TerminationGracePeriodSeconds: pointer.Int64(0), + TerminationGracePeriodSeconds: util.Pointer[int64](0), Volumes: []corev1.Volume{ { Name: "redis-config", VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ - DefaultMode: pointer.Int32(420), + DefaultMode: util.Pointer[int32](420), LocalObjectReference: corev1.LocalObjectReference{Name: "redis-config-" + gen.GetInstanceName()}}, }}, { Name: "redis-readiness-script", VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ - DefaultMode: pointer.Int32(484), + DefaultMode: util.Pointer[int32](484), LocalObjectReference: corev1.LocalObjectReference{Name: "redis-readiness-script-" + gen.GetInstanceName()}}, }}, { @@ -92,7 +91,7 @@ func (gen *Generator) statefulSet() *appsv1.StatefulSet { UpdateStrategy: appsv1.StatefulSetUpdateStrategy{ Type: appsv1.RollingUpdateStatefulSetStrategyType, RollingUpdate: &appsv1.RollingUpdateStatefulSetStrategy{ - Partition: pointer.Int32(0), + Partition: util.Pointer[int32](0), }, }, }, diff --git a/pkg/generators/sentinel/config/options.go b/pkg/generators/sentinel/config/options.go index 7f308e83..9ee67f19 100644 --- a/pkg/generators/sentinel/config/options.go +++ b/pkg/generators/sentinel/config/options.go @@ -1,7 +1,7 @@ package config import ( - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" ) // Options holds configuration for the pods diff --git a/pkg/generators/sentinel/generator.go b/pkg/generators/sentinel/generator.go index 1e581410..dbc5e6cc 100644 --- a/pkg/generators/sentinel/generator.go +++ b/pkg/generators/sentinel/generator.go @@ -9,12 +9,12 @@ import ( "github.com/3scale-ops/basereconciler/mutators" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators" - "github.com/3scale/saas-operator/pkg/generators/sentinel/config" - "github.com/3scale/saas-operator/pkg/resource_builders/grafanadashboard" - "github.com/3scale/saas-operator/pkg/resource_builders/pdb" - "github.com/3scale/saas-operator/pkg/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators" + "github.com/3scale-ops/saas-operator/pkg/generators/sentinel/config" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/grafanadashboard" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pdb" + operatorutils "github.com/3scale-ops/saas-operator/pkg/util" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -87,7 +87,7 @@ func (gen *Generator) ClusterTopology(ctx context.Context) (map[string]map[strin if err != nil { return nil, err } - ip, err := util.LookupIPv4(ctx, u.Hostname()) + ip, err := operatorutils.LookupIPv4(ctx, u.Hostname()) if err != nil { return nil, err } @@ -112,7 +112,7 @@ func (gen *Generator) ClusterTopology(ctx context.Context) (map[string]map[strin return nil, err } alias := u.Host - ip, err := util.LookupIPv4(ctx, u.Hostname()) + ip, err := operatorutils.LookupIPv4(ctx, u.Hostname()) if err != nil { return nil, err } diff --git a/pkg/generators/sentinel/generator_test.go b/pkg/generators/sentinel/generator_test.go index 85ab788c..88f40947 100644 --- a/pkg/generators/sentinel/generator_test.go +++ b/pkg/generators/sentinel/generator_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" "github.com/go-test/deep" "k8s.io/apimachinery/pkg/types" ) @@ -26,7 +26,7 @@ func TestGenerator_ClusterTopology(t *testing.T) { name: "Generates a correct cluster topology from 'spec.config.monitoredShards'", key: types.NamespacedName{Name: "test", Namespace: "test"}, spec: saasv1alpha1.SentinelSpec{ - Replicas: util.Pointer(int32(3)), + Replicas: util.Pointer[int32](3), Config: &saasv1alpha1.SentinelConfig{ MonitoredShards: map[string][]string{ "shard01": { diff --git a/pkg/generators/sentinel/services.go b/pkg/generators/sentinel/services.go index f5315aab..b1626b3c 100644 --- a/pkg/generators/sentinel/services.go +++ b/pkg/generators/sentinel/services.go @@ -3,7 +3,7 @@ package sentinel import ( "fmt" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" diff --git a/pkg/generators/sentinel/statefulset.go b/pkg/generators/sentinel/statefulset.go index 5979c670..1737df67 100644 --- a/pkg/generators/sentinel/statefulset.go +++ b/pkg/generators/sentinel/statefulset.go @@ -4,13 +4,12 @@ import ( "fmt" "strings" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" ) var ( @@ -37,7 +36,7 @@ func (gen *Generator) statefulSet() *appsv1.StatefulSet { }, Spec: corev1.PodSpec{ Affinity: pod.Affinity(gen.GetSelector(), gen.Spec.NodeAffinity), - AutomountServiceAccountToken: pointer.Bool(false), + AutomountServiceAccountToken: util.Pointer(false), DNSPolicy: corev1.DNSClusterFirst, ImagePullSecrets: func() []corev1.LocalObjectReference { if gen.Spec.Image.PullSecretName != nil { @@ -100,13 +99,13 @@ func (gen *Generator) statefulSet() *appsv1.StatefulSet { }, }, Tolerations: gen.Spec.Tolerations, - TerminationGracePeriodSeconds: pointer.Int64(30), + TerminationGracePeriodSeconds: util.Pointer[int64](30), Volumes: []corev1.Volume{ { Name: gen.GetComponent() + "-gen-config", VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ - DefaultMode: pointer.Int32(484), + DefaultMode: util.Pointer[int32](484), LocalObjectReference: corev1.LocalObjectReference{Name: gen.GetComponent() + "-gen-config"}}, }}, }}, @@ -114,7 +113,7 @@ func (gen *Generator) statefulSet() *appsv1.StatefulSet { UpdateStrategy: appsv1.StatefulSetUpdateStrategy{ Type: appsv1.RollingUpdateStatefulSetStrategyType, RollingUpdate: &appsv1.RollingUpdateStatefulSetStrategy{ - Partition: pointer.Int32(0), + Partition: util.Pointer[int32](0), }, }, VolumeClaimTemplates: []corev1.PersistentVolumeClaim{{ @@ -125,7 +124,7 @@ func (gen *Generator) statefulSet() *appsv1.StatefulSet { AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}, Resources: corev1.ResourceRequirements{Requests: corev1.ResourceList{corev1.ResourceStorage: *gen.Spec.Config.StorageSize}}, StorageClassName: gen.Spec.Config.StorageClass, - VolumeMode: (*corev1.PersistentVolumeMode)(pointer.String(string(corev1.PersistentVolumeFilesystem))), + VolumeMode: (*corev1.PersistentVolumeMode)(util.Pointer(string(corev1.PersistentVolumeFilesystem))), DataSource: &corev1.TypedLocalObjectReference{}, }, Status: corev1.PersistentVolumeClaimStatus{ diff --git a/pkg/generators/system/app_deployment.go b/pkg/generators/system/app_deployment.go index 1a31beb6..92c4c5c0 100644 --- a/pkg/generators/system/app_deployment.go +++ b/pkg/generators/system/app_deployment.go @@ -4,12 +4,12 @@ import ( "fmt" "strings" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/resource_builders/twemproxy" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/twemproxy" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) // Deployment returns a function that will return a Deployment @@ -78,7 +78,7 @@ func (gen *AppGenerator) deployment() *appsv1.Deployment { Name: "system-config", VolumeSource: corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ - DefaultMode: pointer.Int32(420), + DefaultMode: util.Pointer[int32](420), SecretName: gen.ConfigFilesSecret, }, }, diff --git a/pkg/generators/system/app_service.go b/pkg/generators/system/app_service.go index 0a3a3fae..38bbe74a 100644 --- a/pkg/generators/system/app_service.go +++ b/pkg/generators/system/app_service.go @@ -1,7 +1,7 @@ package system import ( - "github.com/3scale/saas-operator/pkg/resource_builders/service" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/service" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" diff --git a/pkg/generators/system/config/options.go b/pkg/generators/system/config/options.go index 795757f9..ead99060 100644 --- a/pkg/generators/system/config/options.go +++ b/pkg/generators/system/config/options.go @@ -3,9 +3,9 @@ package config import ( "fmt" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "k8s.io/utils/pointer" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" ) // Options holds configuration for system app and sidekiq pods @@ -155,7 +155,7 @@ func NewOptions(spec saasv1alpha1.SystemSpec) Options { } } else { - opts.BugsnagAPIKey = &pod.SecretValue{Value: saasv1alpha1.SecretReference{Override: pointer.String("")}} + opts.BugsnagAPIKey = &pod.SecretValue{Value: saasv1alpha1.SecretReference{Override: util.Pointer("")}} } if spec.Config.Assets.Host == nil { diff --git a/pkg/generators/system/console_statefulset.go b/pkg/generators/system/console_statefulset.go index fed3abf6..287184be 100644 --- a/pkg/generators/system/console_statefulset.go +++ b/pkg/generators/system/console_statefulset.go @@ -4,13 +4,12 @@ import ( "fmt" "strings" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/resource_builders/twemproxy" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/twemproxy" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" ) // StatefulSet returns a basereconciler.GeneratorFunction function that will return @@ -23,7 +22,7 @@ func (gen *ConsoleGenerator) statefulset() *appsv1.StatefulSet { Labels: gen.GetLabels(), }, Spec: appsv1.StatefulSetSpec{ - Replicas: pointer.Int32(1), + Replicas: util.Pointer[int32](1), Selector: &metav1.LabelSelector{MatchLabels: gen.GetSelector()}, UpdateStrategy: appsv1.StatefulSetUpdateStrategy{ Type: appsv1.RollingUpdateStatefulSetStrategyType, @@ -55,7 +54,7 @@ func (gen *ConsoleGenerator) statefulset() *appsv1.StatefulSet { }, }, Tolerations: gen.Spec.Tolerations, - TerminationGracePeriodSeconds: pointer.Int64(30), + TerminationGracePeriodSeconds: util.Pointer[int64](30), }, }, }, @@ -66,7 +65,7 @@ func (gen *ConsoleGenerator) statefulset() *appsv1.StatefulSet { Name: "system-config", VolumeSource: corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ - DefaultMode: pointer.Int32(420), + DefaultMode: util.Pointer[int32](420), SecretName: gen.ConfigFilesSecret, }, }, diff --git a/pkg/generators/system/generator.go b/pkg/generators/system/generator.go index 7ea2e093..e66accea 100644 --- a/pkg/generators/system/generator.go +++ b/pkg/generators/system/generator.go @@ -6,14 +6,14 @@ import ( "github.com/3scale-ops/basereconciler/mutators" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators" - "github.com/3scale/saas-operator/pkg/generators/system/config" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" - "github.com/3scale/saas-operator/pkg/resource_builders/grafanadashboard" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/resource_builders/podmonitor" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators" + "github.com/3scale-ops/saas-operator/pkg/generators/system/config" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/grafanadashboard" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/podmonitor" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" diff --git a/pkg/generators/system/searchd_service.go b/pkg/generators/system/searchd_service.go index 4ca7ae01..d6a0d580 100644 --- a/pkg/generators/system/searchd_service.go +++ b/pkg/generators/system/searchd_service.go @@ -1,7 +1,7 @@ package system import ( - "github.com/3scale/saas-operator/pkg/resource_builders/service" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/service" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" diff --git a/pkg/generators/system/searchd_statefulset.go b/pkg/generators/system/searchd_statefulset.go index d8920ab2..2445bd48 100644 --- a/pkg/generators/system/searchd_statefulset.go +++ b/pkg/generators/system/searchd_statefulset.go @@ -4,13 +4,12 @@ import ( "fmt" "strings" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) // StatefulSet returns a basereconciler.GeneratorFunction function that will return @@ -23,7 +22,7 @@ func (gen *SearchdGenerator) statefulset() *appsv1.StatefulSet { Labels: gen.GetLabels(), }, Spec: appsv1.StatefulSetSpec{ - Replicas: pointer.Int32(1), + Replicas: util.Pointer[int32](1), Selector: &metav1.LabelSelector{MatchLabels: gen.GetSelector()}, UpdateStrategy: appsv1.StatefulSetUpdateStrategy{ Type: appsv1.RollingUpdateStatefulSetStrategyType, @@ -74,7 +73,7 @@ func (gen *SearchdGenerator) statefulset() *appsv1.StatefulSet { AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}, Resources: corev1.ResourceRequirements{Requests: corev1.ResourceList{corev1.ResourceStorage: gen.DatabaseStorageSize}}, StorageClassName: gen.DatabaseStorageClass, - VolumeMode: (*corev1.PersistentVolumeMode)(pointer.String(string(corev1.PersistentVolumeFilesystem))), + VolumeMode: (*corev1.PersistentVolumeMode)(util.Pointer(string(corev1.PersistentVolumeFilesystem))), DataSource: &corev1.TypedLocalObjectReference{}, }, }}, diff --git a/pkg/generators/system/sidekiq_deployment.go b/pkg/generators/system/sidekiq_deployment.go index 44668a5e..9a18bd6d 100644 --- a/pkg/generators/system/sidekiq_deployment.go +++ b/pkg/generators/system/sidekiq_deployment.go @@ -4,12 +4,12 @@ import ( "fmt" "strings" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/resource_builders/twemproxy" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/twemproxy" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) // Deployment returns a basereconciler.GeneratorFunction function that will return a Deployment @@ -82,7 +82,7 @@ func (gen *SidekiqGenerator) deployment() *appsv1.Deployment { Name: "system-config", VolumeSource: corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ - DefaultMode: pointer.Int32(420), + DefaultMode: util.Pointer[int32](420), SecretName: gen.ConfigFilesSecret, }, }, diff --git a/pkg/generators/system/tekton_task.go b/pkg/generators/system/tekton_task.go index bcd3202b..c6f90425 100644 --- a/pkg/generators/system/tekton_task.go +++ b/pkg/generators/system/tekton_task.go @@ -3,12 +3,12 @@ package system import ( "fmt" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/resource_builders/twemproxy" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/twemproxy" pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" ) // task returns a basereconciler.GeneratorFunction function that will return a @@ -86,7 +86,7 @@ func (gen *SystemTektonGenerator) task() *pipelinev1beta1.Task { Name: "system-config", VolumeSource: corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ - DefaultMode: pointer.Int32(420), + DefaultMode: util.Pointer[int32](420), SecretName: gen.ConfigFilesSecret, }, }, diff --git a/pkg/generators/twemproxyconfig/configmap.go b/pkg/generators/twemproxyconfig/configmap.go index 67b542dd..9c98fd51 100644 --- a/pkg/generators/twemproxyconfig/configmap.go +++ b/pkg/generators/twemproxyconfig/configmap.go @@ -3,8 +3,8 @@ package twemproxyconfig import ( "encoding/json" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/twemproxy" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/twemproxy" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/yaml" diff --git a/pkg/generators/twemproxyconfig/configmap_test.go b/pkg/generators/twemproxyconfig/configmap_test.go index 226a1aa3..1cb4d002 100644 --- a/pkg/generators/twemproxyconfig/configmap_test.go +++ b/pkg/generators/twemproxyconfig/configmap_test.go @@ -3,9 +3,9 @@ package twemproxyconfig import ( "testing" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators" - "github.com/3scale/saas-operator/pkg/resource_builders/twemproxy" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/twemproxy" "github.com/go-test/deep" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/generators/twemproxyconfig/generator.go b/pkg/generators/twemproxyconfig/generator.go index 124dc51e..814e1d10 100644 --- a/pkg/generators/twemproxyconfig/generator.go +++ b/pkg/generators/twemproxyconfig/generator.go @@ -8,12 +8,12 @@ import ( "strings" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators" - "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/redis/sharded" - "github.com/3scale/saas-operator/pkg/resource_builders/grafanadashboard" - "github.com/3scale/saas-operator/pkg/resource_builders/twemproxy" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators" + "github.com/3scale-ops/saas-operator/pkg/redis/server" + "github.com/3scale-ops/saas-operator/pkg/redis/sharded" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/grafanadashboard" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/twemproxy" "github.com/go-logr/logr" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" "github.com/prometheus/client_golang/prometheus" diff --git a/pkg/generators/twemproxyconfig/generator_test.go b/pkg/generators/twemproxyconfig/generator_test.go index b02ec814..217d9f14 100644 --- a/pkg/generators/twemproxyconfig/generator_test.go +++ b/pkg/generators/twemproxyconfig/generator_test.go @@ -5,12 +5,12 @@ import ( "fmt" "testing" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators" - redis_client "github.com/3scale/saas-operator/pkg/redis/client" - "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/resource_builders/twemproxy" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators" + redis_client "github.com/3scale-ops/saas-operator/pkg/redis/client" + "github.com/3scale-ops/saas-operator/pkg/redis/server" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/twemproxy" "github.com/go-logr/logr" "github.com/go-test/deep" "github.com/google/go-cmp/cmp" diff --git a/pkg/generators/zync/api_deployment.go b/pkg/generators/zync/api_deployment.go index 16207c0e..5289d902 100644 --- a/pkg/generators/zync/api_deployment.go +++ b/pkg/generators/zync/api_deployment.go @@ -3,13 +3,12 @@ package zync import ( "fmt" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) // deployment returns a function that will return a *appsv1.Deployment for zync @@ -20,8 +19,8 @@ func (gen *APIGenerator) deployment() *appsv1.Deployment { Strategy: appsv1.DeploymentStrategy{ Type: appsv1.RollingUpdateDeploymentStrategyType, RollingUpdate: &appsv1.RollingUpdateDeployment{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(0)), - MaxSurge: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(0)), + MaxSurge: util.Pointer(intstr.FromInt(1)), }, }, Template: corev1.PodTemplateSpec{ @@ -72,7 +71,7 @@ func (gen *APIGenerator) deployment() *appsv1.Deployment { }, Affinity: pod.Affinity(gen.GetSelector(), gen.APISpec.NodeAffinity), Tolerations: gen.APISpec.Tolerations, - TerminationGracePeriodSeconds: pointer.Int64(30), + TerminationGracePeriodSeconds: util.Pointer[int64](30), }, }, }, diff --git a/pkg/generators/zync/config/api_options.go b/pkg/generators/zync/config/api_options.go index 3ec18d03..60aa10ab 100644 --- a/pkg/generators/zync/config/api_options.go +++ b/pkg/generators/zync/config/api_options.go @@ -3,9 +3,9 @@ package config import ( "fmt" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "k8s.io/utils/pointer" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" ) // APIOptions holds configuration for the api pods @@ -42,7 +42,7 @@ func NewAPIOptions(spec saasv1alpha1.ZyncSpec) APIOptions { } } else { - opts.BugsnagAPIKey = &pod.SecretValue{Value: saasv1alpha1.SecretReference{Override: pointer.String("")}} + opts.BugsnagAPIKey = &pod.SecretValue{Value: saasv1alpha1.SecretReference{Override: util.Pointer("")}} } return opts diff --git a/pkg/generators/zync/config/que_options.go b/pkg/generators/zync/config/que_options.go index 80b789a7..6815ae86 100644 --- a/pkg/generators/zync/config/que_options.go +++ b/pkg/generators/zync/config/que_options.go @@ -1,9 +1,9 @@ package config import ( - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "k8s.io/utils/pointer" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" ) // QueOptions holds configuration for the que pods @@ -38,7 +38,7 @@ func NewQueOptions(spec saasv1alpha1.ZyncSpec) QueOptions { } } else { - opts.BugsnagAPIKey = &pod.SecretValue{Value: saasv1alpha1.SecretReference{Override: pointer.String("")}} + opts.BugsnagAPIKey = &pod.SecretValue{Value: saasv1alpha1.SecretReference{Override: util.Pointer("")}} } return opts diff --git a/pkg/generators/zync/console_statefulset.go b/pkg/generators/zync/console_statefulset.go index 4ab9d67b..55e6664c 100644 --- a/pkg/generators/zync/console_statefulset.go +++ b/pkg/generators/zync/console_statefulset.go @@ -3,13 +3,12 @@ package zync import ( "fmt" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" ) // StatefulSet returns a basereconciler.GeneratorFunction function that will return @@ -22,7 +21,7 @@ func (gen *ConsoleGenerator) statefulset() *appsv1.StatefulSet { Labels: gen.GetLabels(), }, Spec: appsv1.StatefulSetSpec{ - Replicas: pointer.Int32(1), + Replicas: util.Pointer[int32](1), Selector: &metav1.LabelSelector{MatchLabels: gen.GetSelector()}, UpdateStrategy: appsv1.StatefulSetUpdateStrategy{ Type: appsv1.RollingUpdateStatefulSetStrategyType, @@ -81,7 +80,7 @@ func (gen *ConsoleGenerator) statefulset() *appsv1.StatefulSet { }, Affinity: pod.Affinity(gen.GetSelector(), gen.Spec.NodeAffinity), Tolerations: gen.Spec.Tolerations, - TerminationGracePeriodSeconds: pointer.Int64(30), + TerminationGracePeriodSeconds: util.Pointer[int64](30), }, }, }, diff --git a/pkg/generators/zync/generator.go b/pkg/generators/zync/generator.go index 312adfbb..e146c567 100644 --- a/pkg/generators/zync/generator.go +++ b/pkg/generators/zync/generator.go @@ -6,20 +6,19 @@ import ( "github.com/3scale-ops/basereconciler/mutators" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/generators" - "github.com/3scale/saas-operator/pkg/generators/zync/config" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" - "github.com/3scale/saas-operator/pkg/resource_builders/grafanadashboard" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/resource_builders/podmonitor" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/generators" + "github.com/3scale-ops/saas-operator/pkg/generators/zync/config" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/grafanadashboard" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/podmonitor" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/pointer" ) const ( @@ -181,7 +180,7 @@ var _ workloads.DeploymentWorkload = &QueGenerator{} func (gen *QueGenerator) Deployment() *resource.Template[*appsv1.Deployment] { return resource.NewTemplateFromObjectFunction(gen.deployment). WithMutation(mutators.SetDeploymentReplicas(gen.QueSpec.HPA.IsDeactivated())). - WithMutation(mutators.RolloutTrigger{Name: "zync", SecretName: pointer.String("zync")}.Add()) + WithMutation(mutators.RolloutTrigger{Name: "zync", SecretName: util.Pointer("zync")}.Add()) } func (gen *QueGenerator) HPASpec() *saasv1alpha1.HorizontalPodAutoscalerSpec { return gen.QueSpec.HPA @@ -208,5 +207,5 @@ func (gen *ConsoleGenerator) StatefulSet() *resource.Template[*appsv1.StatefulSe return resource.NewTemplateFromObjectFunction(gen.statefulset). WithEnabled(gen.Enabled). WithMutation(mutators.SetDeploymentReplicas(true)). - WithMutation(mutators.RolloutTrigger{Name: "zync", SecretName: pointer.String("zync")}.Add()) + WithMutation(mutators.RolloutTrigger{Name: "zync", SecretName: util.Pointer("zync")}.Add()) } diff --git a/pkg/generators/zync/que_deployment.go b/pkg/generators/zync/que_deployment.go index 52a8611e..72f60453 100644 --- a/pkg/generators/zync/que_deployment.go +++ b/pkg/generators/zync/que_deployment.go @@ -3,14 +3,12 @@ package zync import ( "fmt" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ) // deployment returns a function that will return a *appsv1.Deployment for zync-que @@ -21,8 +19,8 @@ func (gen *QueGenerator) deployment() *appsv1.Deployment { Strategy: appsv1.DeploymentStrategy{ Type: appsv1.RollingUpdateDeploymentStrategyType, RollingUpdate: &appsv1.RollingUpdateDeployment{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(0)), - MaxSurge: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(0)), + MaxSurge: util.Pointer(intstr.FromInt(1)), }, }, Template: corev1.PodTemplateSpec{ @@ -77,7 +75,7 @@ func (gen *QueGenerator) deployment() *appsv1.Deployment { }, Affinity: pod.Affinity(gen.GetSelector(), gen.QueSpec.NodeAffinity), Tolerations: gen.QueSpec.Tolerations, - TerminationGracePeriodSeconds: pointer.Int64(30), + TerminationGracePeriodSeconds: util.Pointer[int64](30), }, }, }, diff --git a/pkg/generators/zync/services.go b/pkg/generators/zync/services.go index bd44deef..8afc9cda 100644 --- a/pkg/generators/zync/services.go +++ b/pkg/generators/zync/services.go @@ -1,7 +1,7 @@ package zync import ( - "github.com/3scale/saas-operator/pkg/resource_builders/service" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/service" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/reconcilers/threads/manager.go b/pkg/reconcilers/threads/manager.go index 6ce63591..09610cf5 100644 --- a/pkg/reconcilers/threads/manager.go +++ b/pkg/reconcilers/threads/manager.go @@ -5,7 +5,7 @@ import ( "strings" "sync" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" "github.com/go-logr/logr" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/event" diff --git a/pkg/reconcilers/workloads/deployment_based_workload.go b/pkg/reconcilers/workloads/deployment_based_workload.go index 27decf19..6d38b2be 100644 --- a/pkg/reconcilers/workloads/deployment_based_workload.go +++ b/pkg/reconcilers/workloads/deployment_based_workload.go @@ -5,13 +5,13 @@ import ( "github.com/3scale-ops/basereconciler/reconciler" "github.com/3scale-ops/basereconciler/resource" + "github.com/3scale-ops/basereconciler/util" marin3rv1alpha1 "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig" - "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/factory" - "github.com/3scale/saas-operator/pkg/resource_builders/hpa" - "github.com/3scale/saas-operator/pkg/resource_builders/pdb" - "github.com/3scale/saas-operator/pkg/resource_builders/podmonitor" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/factory" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/hpa" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pdb" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/podmonitor" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" appsv1 "k8s.io/api/apps/v1" autoscalingv2 "k8s.io/api/autoscaling/v2" diff --git a/pkg/reconcilers/workloads/deployment_based_workload_test.go b/pkg/reconcilers/workloads/deployment_based_workload_test.go index 5fc46e8c..cb81687b 100644 --- a/pkg/reconcilers/workloads/deployment_based_workload_test.go +++ b/pkg/reconcilers/workloads/deployment_based_workload_test.go @@ -8,13 +8,13 @@ import ( "github.com/3scale-ops/basereconciler/mutators" "github.com/3scale-ops/basereconciler/reconciler" "github.com/3scale-ops/basereconciler/resource" + "github.com/3scale-ops/basereconciler/util" reconcilerutil "github.com/3scale-ops/basereconciler/util" marin3rv1alpha1 "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1" "github.com/3scale-ops/marin3r/pkg/envoy" envoy_serializer "github.com/3scale-ops/marin3r/pkg/envoy/serializer" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - descriptor "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/descriptor" - "github.com/3scale/saas-operator/pkg/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + descriptor "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/descriptor" "github.com/google/go-cmp/cmp" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" appsv1 "k8s.io/api/apps/v1" @@ -25,7 +25,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" ) @@ -49,7 +48,7 @@ func (gen *TestWorkloadGenerator) Deployment() *resource.Template[*appsv1.Deploy TemplateBuilder: func(client.Object) (*appsv1.Deployment, error) { return &appsv1.Deployment{ Spec: appsv1.DeploymentSpec{ - Replicas: pointer.Int32(1), + Replicas: util.Pointer[int32](1), Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{"orig-key": "orig-value"}, @@ -70,7 +69,7 @@ func (gen *TestWorkloadGenerator) Deployment() *resource.Template[*appsv1.Deploy TemplateMutations: []resource.TemplateMutationFunction{ mutators.RolloutTrigger{ Name: "secret", - SecretName: pointer.String("secret"), + SecretName: util.Pointer("secret"), }.Add(), mutators.SetDeploymentReplicas(true), }, @@ -87,15 +86,15 @@ func (gen *TestWorkloadGenerator) GetSelector() map[string]string { } func (gen *TestWorkloadGenerator) HPASpec() *saasv1alpha1.HorizontalPodAutoscalerSpec { return &saasv1alpha1.HorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(1), - MaxReplicas: pointer.Int32(2), - ResourceUtilization: pointer.Int32(90), - ResourceName: pointer.String("cpu"), + MinReplicas: util.Pointer[int32](1), + MaxReplicas: util.Pointer[int32](2), + ResourceUtilization: util.Pointer[int32](90), + ResourceName: util.Pointer("cpu"), } } func (gen *TestWorkloadGenerator) PDBSpec() *saasv1alpha1.PodDisruptionBudgetSpec { return &saasv1alpha1.PodDisruptionBudgetSpec{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(1)), } } func (gen *TestWorkloadGenerator) SendTraffic() bool { return gen.TTraffic } @@ -171,7 +170,7 @@ func TestWorkloadReconciler_NewDeploymentWorkload(t *testing.T) { Name: "my-workload", Namespace: "ns", Labels: map[string]string{"l-key": "l-value"}}, Spec: appsv1.DeploymentSpec{ - Replicas: pointer.Int32(1), + Replicas: util.Pointer[int32](1), Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"sel-key": "sel-value"}}, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ @@ -196,7 +195,7 @@ func TestWorkloadReconciler_NewDeploymentWorkload(t *testing.T) { }, Spec: policyv1.PodDisruptionBudgetSpec{ Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"sel-key": "sel-value"}}, - MaxUnavailable: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(1)), }}, &autoscalingv2.HorizontalPodAutoscaler{ ObjectMeta: metav1.ObjectMeta{ @@ -209,7 +208,7 @@ func TestWorkloadReconciler_NewDeploymentWorkload(t *testing.T) { Kind: "Deployment", Name: "my-workload", }, - MinReplicas: pointer.Int32(1), + MinReplicas: util.Pointer[int32](1), MaxReplicas: 2, Metrics: []autoscalingv2.MetricSpec{{ Type: autoscalingv2.ResourceMetricSourceType, diff --git a/pkg/reconcilers/workloads/interfaces.go b/pkg/reconcilers/workloads/interfaces.go index c1484893..2d495fe9 100644 --- a/pkg/reconcilers/workloads/interfaces.go +++ b/pkg/reconcilers/workloads/interfaces.go @@ -2,8 +2,8 @@ package workloads import ( "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - descriptor "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/descriptor" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + descriptor "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/descriptor" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" diff --git a/pkg/reconcilers/workloads/test/suite_test.go b/pkg/reconcilers/workloads/test/suite_test.go index ecf7e4a9..1b087a36 100644 --- a/pkg/reconcilers/workloads/test/suite_test.go +++ b/pkg/reconcilers/workloads/test/suite_test.go @@ -24,9 +24,9 @@ import ( "testing" "time" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads/test/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads/test/api/v1alpha1" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" "github.com/goombaio/namegenerator" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" diff --git a/pkg/reconcilers/workloads/test/test_controller.go b/pkg/reconcilers/workloads/test/test_controller.go index ecfe81c7..59861c96 100644 --- a/pkg/reconcilers/workloads/test/test_controller.go +++ b/pkg/reconcilers/workloads/test/test_controller.go @@ -22,10 +22,10 @@ import ( "github.com/3scale-ops/basereconciler/config" "github.com/3scale-ops/basereconciler/mutators" "github.com/3scale-ops/basereconciler/resource" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads/test/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads/test/api/v1alpha1" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" "github.com/go-logr/logr" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" @@ -36,7 +36,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" @@ -156,7 +155,7 @@ func (gen *TestWorkloadGenerator) Deployment() *resource.Template[*appsv1.Deploy func(client.Object) (*appsv1.Deployment, error) { return &appsv1.Deployment{ Spec: appsv1.DeploymentSpec{ - Replicas: pointer.Int32(1), + Replicas: util.Pointer[int32](1), Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{"orig-key": "orig-value"}, @@ -174,7 +173,7 @@ func (gen *TestWorkloadGenerator) Deployment() *resource.Template[*appsv1.Deploy }, }, nil }). - WithMutation(mutators.RolloutTrigger{Name: "secret", SecretName: pointer.String("secret")}.Add()). + WithMutation(mutators.RolloutTrigger{Name: "secret", SecretName: util.Pointer("secret")}.Add()). WithMutation(mutators.SetDeploymentReplicas(true)) } @@ -188,15 +187,15 @@ func (gen *TestWorkloadGenerator) GetSelector() map[string]string { } func (gen *TestWorkloadGenerator) HPASpec() *saasv1alpha1.HorizontalPodAutoscalerSpec { return &saasv1alpha1.HorizontalPodAutoscalerSpec{ - MinReplicas: pointer.Int32(1), - MaxReplicas: pointer.Int32(2), - ResourceUtilization: pointer.Int32(90), - ResourceName: pointer.String("cpu"), + MinReplicas: util.Pointer[int32](1), + MaxReplicas: util.Pointer[int32](2), + ResourceUtilization: util.Pointer[int32](90), + ResourceName: util.Pointer("cpu"), } } func (gen *TestWorkloadGenerator) PDBSpec() *saasv1alpha1.PodDisruptionBudgetSpec { return &saasv1alpha1.PodDisruptionBudgetSpec{ - MaxUnavailable: util.IntStrPtr(intstr.FromInt(1)), + MaxUnavailable: util.Pointer(intstr.FromInt(1)), } } func (gen *TestWorkloadGenerator) SendTraffic() bool { return gen.TTraffic } diff --git a/pkg/reconcilers/workloads/test/test_controller_suite_test.go b/pkg/reconcilers/workloads/test/test_controller_suite_test.go index a50aec7b..9359ea52 100644 --- a/pkg/reconcilers/workloads/test/test_controller_suite_test.go +++ b/pkg/reconcilers/workloads/test/test_controller_suite_test.go @@ -4,8 +4,8 @@ import ( "context" "reflect" - "github.com/3scale/saas-operator/pkg/reconcilers/workloads/test/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/workloads/test/api/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" appsv1 "k8s.io/api/apps/v1" diff --git a/pkg/redis/backup/check.go b/pkg/redis/backup/check.go index a48edcfb..dd159731 100644 --- a/pkg/redis/backup/check.go +++ b/pkg/redis/backup/check.go @@ -5,7 +5,7 @@ import ( "fmt" "sort" - "github.com/3scale/saas-operator/pkg/util" + operatorutils "github.com/3scale-ops/saas-operator/pkg/util" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3" "sigs.k8s.io/controller-runtime/pkg/log" @@ -14,7 +14,7 @@ import ( func (br *Runner) CheckBackup(ctx context.Context) error { logger := log.FromContext(ctx, "function", "(br *Runner) CheckBackup()") - awsconfig, err := util.AWSConfig(ctx, br.AWSAccessKeyID, br.AWSSecretAccessKey, br.AWSRegion, br.AWSS3Endpoint) + awsconfig, err := operatorutils.AWSConfig(ctx, br.AWSAccessKeyID, br.AWSSecretAccessKey, br.AWSRegion, br.AWSS3Endpoint) if err != nil { return err } diff --git a/pkg/redis/backup/manager.go b/pkg/redis/backup/manager.go index f7dea29f..97014ce2 100644 --- a/pkg/redis/backup/manager.go +++ b/pkg/redis/backup/manager.go @@ -5,7 +5,7 @@ import ( "fmt" "time" - "github.com/3scale/saas-operator/pkg/redis/sharded" + "github.com/3scale-ops/saas-operator/pkg/redis/sharded" "github.com/go-logr/logr" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/event" diff --git a/pkg/redis/backup/s3upload.go b/pkg/redis/backup/s3upload.go index f428e291..75635f7d 100644 --- a/pkg/redis/backup/s3upload.go +++ b/pkg/redis/backup/s3upload.go @@ -10,8 +10,8 @@ import ( "text/template" "time" - "github.com/3scale/saas-operator/pkg/ssh" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/saas-operator/pkg/ssh" + operatorutils "github.com/3scale-ops/saas-operator/pkg/util" "github.com/MakeNowJust/heredoc" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3" @@ -73,9 +73,9 @@ func (br *Runner) UploadBackup(ctx context.Context) error { ssh.NewCommand(fmt.Sprintf("mv %s %s/%s", br.RedisDBFile, path.Dir(br.RedisDBFile), br.BackupFile())), ssh.NewCommand(fmt.Sprintf("gzip -1 %s/%s", path.Dir(br.RedisDBFile), br.BackupFile())), ssh.NewScript(fmt.Sprintf("%s=%s %s=%s %s=%s python -", - util.AWSRegionEnvvar, br.AWSRegion, - util.AWSAccessKeyEnvvar, br.AWSAccessKeyID, - util.AWSSecretKeyEnvvar, br.AWSSecretAccessKey), + operatorutils.AWSRegionEnvvar, br.AWSRegion, + operatorutils.AWSAccessKeyEnvvar, br.AWSAccessKeyID, + operatorutils.AWSSecretKeyEnvvar, br.AWSSecretAccessKey), uploadScript, br.AWSSecretAccessKey, ), @@ -95,7 +95,7 @@ func (br *Runner) resolveTags(ctx context.Context) (string, error) { logger := log.FromContext(ctx, "function", "(br *Runner) ResolveTags()") var retention Retention - awsconfig, err := util.AWSConfig(ctx, br.AWSAccessKeyID, br.AWSSecretAccessKey, br.AWSRegion, br.AWSS3Endpoint) + awsconfig, err := operatorutils.AWSConfig(ctx, br.AWSAccessKeyID, br.AWSSecretAccessKey, br.AWSRegion, br.AWSS3Endpoint) if err != nil { return "{}", err } diff --git a/pkg/redis/events/watcher.go b/pkg/redis/events/watcher.go index 12ec6c43..d25b95a6 100644 --- a/pkg/redis/events/watcher.go +++ b/pkg/redis/events/watcher.go @@ -4,9 +4,9 @@ import ( "context" "fmt" - "github.com/3scale/saas-operator/pkg/reconcilers/threads" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/redis/sharded" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/threads" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" + "github.com/3scale-ops/saas-operator/pkg/redis/sharded" "github.com/go-logr/logr" "github.com/prometheus/client_golang/prometheus" "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/pkg/redis/metrics/cluster_status_metrics.go b/pkg/redis/metrics/cluster_status_metrics.go index 1ab14b64..78a4a3a8 100644 --- a/pkg/redis/metrics/cluster_status_metrics.go +++ b/pkg/redis/metrics/cluster_status_metrics.go @@ -3,8 +3,8 @@ package metrics import ( "context" - "github.com/3scale/saas-operator/pkg/redis/client" - "github.com/3scale/saas-operator/pkg/redis/sharded" + "github.com/3scale-ops/saas-operator/pkg/redis/client" + "github.com/3scale-ops/saas-operator/pkg/redis/sharded" "github.com/prometheus/client_golang/prometheus" "sigs.k8s.io/controller-runtime/pkg/metrics" ) diff --git a/pkg/redis/metrics/sentinel_metrics.go b/pkg/redis/metrics/sentinel_metrics.go index 9e17c9fe..1011b412 100644 --- a/pkg/redis/metrics/sentinel_metrics.go +++ b/pkg/redis/metrics/sentinel_metrics.go @@ -5,10 +5,10 @@ import ( "fmt" "time" - "github.com/3scale/saas-operator/pkg/reconcilers/threads" - "github.com/3scale/saas-operator/pkg/redis/client" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/redis/sharded" + "github.com/3scale-ops/saas-operator/pkg/reconcilers/threads" + "github.com/3scale-ops/saas-operator/pkg/redis/client" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" + "github.com/3scale-ops/saas-operator/pkg/redis/sharded" "github.com/go-logr/logr" "github.com/prometheus/client_golang/prometheus" "sigs.k8s.io/controller-runtime/pkg/event" diff --git a/pkg/redis/server/fake.go b/pkg/redis/server/fake.go index b6219b79..7986f9b9 100644 --- a/pkg/redis/server/fake.go +++ b/pkg/redis/server/fake.go @@ -1,6 +1,6 @@ package server -import "github.com/3scale/saas-operator/pkg/redis/client" +import "github.com/3scale-ops/saas-operator/pkg/redis/client" // NewFakeServerWithFakeClient returns a fake server with a fake client that will return the // provided responses when called. This is only intended for testing. diff --git a/pkg/redis/server/pool_test.go b/pkg/redis/server/pool_test.go index f68691c7..bd618fb6 100644 --- a/pkg/redis/server/pool_test.go +++ b/pkg/redis/server/pool_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" ) func TestServerPool_GetServer(t *testing.T) { diff --git a/pkg/redis/server/server.go b/pkg/redis/server/server.go index 79d4d383..656fddbf 100644 --- a/pkg/redis/server/server.go +++ b/pkg/redis/server/server.go @@ -9,7 +9,7 @@ import ( "sync" "time" - "github.com/3scale/saas-operator/pkg/redis/client" + "github.com/3scale-ops/saas-operator/pkg/redis/client" "github.com/go-redis/redis/v8" ) diff --git a/pkg/redis/server/server_test.go b/pkg/redis/server/server_test.go index 274339a4..228a9030 100644 --- a/pkg/redis/server/server_test.go +++ b/pkg/redis/server/server_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/3scale/saas-operator/pkg/redis/client" + "github.com/3scale-ops/saas-operator/pkg/redis/client" "github.com/go-redis/redis/v8" "github.com/go-test/deep" ) diff --git a/pkg/redis/sharded/discover.go b/pkg/redis/sharded/discover.go index e758a578..ce57a120 100644 --- a/pkg/redis/sharded/discover.go +++ b/pkg/redis/sharded/discover.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/3scale/saas-operator/pkg/redis/client" + "github.com/3scale-ops/saas-operator/pkg/redis/client" "sigs.k8s.io/controller-runtime/pkg/log" ) diff --git a/pkg/redis/sharded/discover_test.go b/pkg/redis/sharded/discover_test.go index 2381d574..c1ffa533 100644 --- a/pkg/redis/sharded/discover_test.go +++ b/pkg/redis/sharded/discover_test.go @@ -5,8 +5,8 @@ import ( "errors" "testing" - "github.com/3scale/saas-operator/pkg/redis/client" - redis "github.com/3scale/saas-operator/pkg/redis/server" + "github.com/3scale-ops/saas-operator/pkg/redis/client" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" "github.com/go-test/deep" ) diff --git a/pkg/redis/sharded/redis_server.go b/pkg/redis/sharded/redis_server.go index 24c8c9df..d0a96461 100644 --- a/pkg/redis/sharded/redis_server.go +++ b/pkg/redis/sharded/redis_server.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/3scale/saas-operator/pkg/redis/client" - redis "github.com/3scale/saas-operator/pkg/redis/server" + "github.com/3scale-ops/saas-operator/pkg/redis/client" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" "sigs.k8s.io/controller-runtime/pkg/log" ) diff --git a/pkg/redis/sharded/redis_server_test.go b/pkg/redis/sharded/redis_server_test.go index 36f6ece4..011fc310 100644 --- a/pkg/redis/sharded/redis_server_test.go +++ b/pkg/redis/sharded/redis_server_test.go @@ -3,9 +3,9 @@ package sharded import ( "testing" - "github.com/3scale/saas-operator/pkg/redis/client" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/redis/client" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" "github.com/go-test/deep" ) diff --git a/pkg/redis/sharded/redis_shard.go b/pkg/redis/sharded/redis_shard.go index 85757f25..d47614d6 100644 --- a/pkg/redis/sharded/redis_shard.go +++ b/pkg/redis/sharded/redis_shard.go @@ -8,9 +8,9 @@ import ( "strconv" "strings" - "github.com/3scale/saas-operator/pkg/redis/client" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/saas-operator/pkg/redis/client" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" + operatorutils "github.com/3scale-ops/saas-operator/pkg/util" "sigs.k8s.io/controller-runtime/pkg/log" ) @@ -31,7 +31,7 @@ func NewShardFromServers(name string, pool *redis.ServerPool, servers ...*RedisS // NewShardFromTopology returns a Shard object given the passed redis server URLs func NewShardFromTopology(name string, servers map[string]string, pool *redis.ServerPool) (*Shard, error) { - var merr util.MultiError + var merr operatorutils.MultiError shard := &Shard{Name: name, pool: pool} shard.Servers = make([]*RedisServer, 0, len(servers)) @@ -59,7 +59,7 @@ func NewShardFromTopology(name string, servers map[string]string, pool *redis.Se // Discover retrieves the options for all the servers in the shard // If a SentinelServer is provided, it will be used to autodiscover servers and roles in the shard func (shard *Shard) Discover(ctx context.Context, sentinel *SentinelServer, options ...DiscoveryOption) error { - var merr util.MultiError + var merr operatorutils.MultiError logger := log.FromContext(ctx, "function", "(*Shard).Discover", "shard", shard.Name) switch sentinel { @@ -186,7 +186,7 @@ func (shard *Shard) GetMaster() (*RedisServer, error) { } if len(master) != 1 { - return nil, util.WrapError("(*Shard).GetMasterAddr", fmt.Errorf("wrong number of masters: %d != 1", len(master))) + return nil, operatorutils.WrapError("(*Shard).GetMasterAddr", fmt.Errorf("wrong number of masters: %d != 1", len(master))) } return master[0], nil @@ -247,7 +247,7 @@ func (shard *Shard) GetServerByID(hostport string) (*RedisServer, error) { // Init initializes the shard if not already initialized func (shard *Shard) Init(ctx context.Context, masterHostPort string) ([]string, error) { - merr := util.MultiError{} + merr := operatorutils.MultiError{} listChanged := []string{} var master *RedisServer diff --git a/pkg/redis/sharded/redis_shard_test.go b/pkg/redis/sharded/redis_shard_test.go index fb33243f..e9740c6a 100644 --- a/pkg/redis/sharded/redis_shard_test.go +++ b/pkg/redis/sharded/redis_shard_test.go @@ -7,9 +7,9 @@ import ( "reflect" "testing" - "github.com/3scale/saas-operator/pkg/redis/client" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/redis/client" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" "github.com/go-test/deep" ) diff --git a/pkg/redis/sharded/redis_sharded_cluster.go b/pkg/redis/sharded/redis_sharded_cluster.go index bbf22ac8..fb068e2e 100644 --- a/pkg/redis/sharded/redis_sharded_cluster.go +++ b/pkg/redis/sharded/redis_sharded_cluster.go @@ -6,8 +6,8 @@ import ( "sort" "time" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/util" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" + operatorutils "github.com/3scale-ops/saas-operator/pkg/util" "sigs.k8s.io/controller-runtime/pkg/log" ) @@ -104,7 +104,7 @@ func (cluster Cluster) LookupServerByID(hostport string) *RedisServer { } func (cluster *Cluster) Discover(ctx context.Context, options ...DiscoveryOption) error { - var merr util.MultiError + var merr operatorutils.MultiError for _, shard := range cluster.Shards { if err := shard.Discover(ctx, nil, options...); err != nil { @@ -117,7 +117,7 @@ func (cluster *Cluster) Discover(ctx context.Context, options ...DiscoveryOption // Updates the status of the cluster as seen from sentinel func (cluster *Cluster) SentinelDiscover(ctx context.Context, opts ...DiscoveryOption) error { - merr := util.MultiError{} + merr := operatorutils.MultiError{} // Get a healthy sentinel server sentinel := cluster.GetSentinel(ctx) @@ -146,7 +146,7 @@ func (cluster *Cluster) SentinelDiscover(ctx context.Context, opts ...DiscoveryO } if err := shard.Discover(ctx, sentinel, opts...); err != nil { - merr = append(merr, ShardDiscoveryError{ShardName: master.Name, Errors: err.(util.MultiError)}) + merr = append(merr, ShardDiscoveryError{ShardName: master.Name, Errors: err.(operatorutils.MultiError)}) // keep going with the other shards continue } @@ -186,7 +186,7 @@ func (cluster *Cluster) GetSentinel(pctx context.Context) *SentinelServer { type ShardDiscoveryError struct { ShardName string - Errors util.MultiError + Errors operatorutils.MultiError } func (e ShardDiscoveryError) Error() string { diff --git a/pkg/redis/sharded/redis_sharded_cluster_test.go b/pkg/redis/sharded/redis_sharded_cluster_test.go index df6ee268..19e41199 100644 --- a/pkg/redis/sharded/redis_sharded_cluster_test.go +++ b/pkg/redis/sharded/redis_sharded_cluster_test.go @@ -6,9 +6,9 @@ import ( "reflect" "testing" - "github.com/3scale/saas-operator/pkg/redis/client" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/redis/client" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" "github.com/go-test/deep" ) diff --git a/pkg/redis/sharded/sentinel_server.go b/pkg/redis/sharded/sentinel_server.go index d60fcc54..d5acf1d7 100644 --- a/pkg/redis/sharded/sentinel_server.go +++ b/pkg/redis/sharded/sentinel_server.go @@ -4,8 +4,8 @@ import ( "context" "sort" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/util" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" + operatorutils "github.com/3scale-ops/saas-operator/pkg/util" ) const ( @@ -35,7 +35,7 @@ func NewSentinelServerFromParams(srv *redis.Server) *SentinelServer { } func NewHighAvailableSentinel(servers map[string]string, pool *redis.ServerPool) ([]*SentinelServer, error) { - var merr util.MultiError + var merr operatorutils.MultiError sentinels := make([]*SentinelServer, 0, len(servers)) for key, connectionString := range servers { @@ -105,14 +105,14 @@ func (sentinel *SentinelServer) Monitor(ctx context.Context, cluster *Cluster, q err = sentinel.SentinelMonitor(ctx, name, master.GetHost(), master.GetPort(), quorum) if err != nil { - return changed, util.WrapError("redis-sentinel/SentinelServer.Monitor", err) + return changed, operatorutils.WrapError("redis-sentinel/SentinelServer.Monitor", err) } // even if the next call fails, there has already been a write operation to sentinel changed = append(changed, name) err = sentinel.SentinelSet(ctx, name, "down-after-milliseconds", "5000") if err != nil { - return changed, util.WrapError("redis-sentinel/SentinelServer.Monitor", err) + return changed, operatorutils.WrapError("redis-sentinel/SentinelServer.Monitor", err) } // TODO: change the default failover timeout. // TODO: maybe add a generic mechanism to set/modify parameters diff --git a/pkg/redis/sharded/sentinel_server_test.go b/pkg/redis/sharded/sentinel_server_test.go index f35f3ac0..9faf8bec 100644 --- a/pkg/redis/sharded/sentinel_server_test.go +++ b/pkg/redis/sharded/sentinel_server_test.go @@ -6,9 +6,9 @@ import ( "reflect" "testing" - "github.com/3scale/saas-operator/pkg/redis/client" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/pkg/redis/client" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" "github.com/go-test/deep" ) diff --git a/pkg/resource_builders/envoyconfig/auto/secrets.go b/pkg/resource_builders/envoyconfig/auto/secrets.go index 8bcc1dfe..8f317d03 100644 --- a/pkg/resource_builders/envoyconfig/auto/secrets.go +++ b/pkg/resource_builders/envoyconfig/auto/secrets.go @@ -3,9 +3,9 @@ package auto import ( marin3rv1alpha1 "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1" "github.com/3scale-ops/marin3r/pkg/envoy" - "github.com/3scale/saas-operator/pkg/util" envoy_config_listener_v3 "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" envoy_extensions_transport_sockets_tls_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3" + "github.com/samber/lo" ) func GenerateSecrets(resources []envoy.Resource) ([]marin3rv1alpha1.EnvoySecretResource, error) { @@ -27,7 +27,7 @@ func GenerateSecrets(resources []envoy.Resource) ([]marin3rv1alpha1.EnvoySecretR } secrets := []marin3rv1alpha1.EnvoySecretResource{} - for _, ref := range util.Unique(refs) { + for _, ref := range lo.Uniq(refs) { secrets = append(secrets, marin3rv1alpha1.EnvoySecretResource{Name: ref}) } @@ -50,5 +50,5 @@ func secretRefsFromListener(listener *envoy_config_listener_v3.Listener) ([]stri secrets = append(secrets, sdsConfig.Name) } - return util.Unique(secrets), nil + return lo.Uniq(secrets), nil } diff --git a/pkg/resource_builders/envoyconfig/auto/secrets_test.go b/pkg/resource_builders/envoyconfig/auto/secrets_test.go index a035ca69..ffe7cb3f 100644 --- a/pkg/resource_builders/envoyconfig/auto/secrets_test.go +++ b/pkg/resource_builders/envoyconfig/auto/secrets_test.go @@ -4,12 +4,12 @@ import ( "reflect" "testing" + "github.com/3scale-ops/basereconciler/util" marin3rv1alpha1 "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1" "github.com/3scale-ops/marin3r/pkg/envoy" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/templates" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/templates" envoy_config_listener_v3 "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" - "k8s.io/utils/pointer" ) func Test_secretRefsFromListener(t *testing.T) { @@ -29,9 +29,9 @@ func Test_secretRefsFromListener(t *testing.T) { l, _ := templates.ListenerHTTP_v1("test", &saasv1alpha1.ListenerHttp{ Port: 8080, RouteConfigName: "my_route", - CertificateSecretName: pointer.String("my_certificate"), - EnableHttp2: pointer.Bool(false), - ProxyProtocol: pointer.Bool(false), + CertificateSecretName: util.Pointer("my_certificate"), + EnableHttp2: util.Pointer(false), + ProxyProtocol: util.Pointer(false), }) return l.(*envoy_config_listener_v3.Listener) }(), @@ -72,9 +72,9 @@ func TestGenerateSecrets(t *testing.T) { l, _ := templates.ListenerHTTP_v1("test1", &saasv1alpha1.ListenerHttp{ Port: 8080, RouteConfigName: "my_route", - CertificateSecretName: pointer.String("cert1"), - EnableHttp2: pointer.Bool(false), - ProxyProtocol: pointer.Bool(false), + CertificateSecretName: util.Pointer("cert1"), + EnableHttp2: util.Pointer(false), + ProxyProtocol: util.Pointer(false), }) return l }(), @@ -82,9 +82,9 @@ func TestGenerateSecrets(t *testing.T) { l, _ := templates.ListenerHTTP_v1("test2", &saasv1alpha1.ListenerHttp{ Port: 8081, RouteConfigName: "my_route", - CertificateSecretName: pointer.String("cert2"), - EnableHttp2: pointer.Bool(false), - ProxyProtocol: pointer.Bool(false), + CertificateSecretName: util.Pointer("cert2"), + EnableHttp2: util.Pointer(false), + ProxyProtocol: util.Pointer(false), }) return l }(), @@ -92,9 +92,9 @@ func TestGenerateSecrets(t *testing.T) { l, _ := templates.ListenerHTTP_v1("test3", &saasv1alpha1.ListenerHttp{ Port: 8082, RouteConfigName: "my_route", - CertificateSecretName: pointer.String("cert1"), - EnableHttp2: pointer.Bool(false), - ProxyProtocol: pointer.Bool(false), + CertificateSecretName: util.Pointer("cert1"), + EnableHttp2: util.Pointer(false), + ProxyProtocol: util.Pointer(false), }) return l }(), diff --git a/pkg/resource_builders/envoyconfig/factory/default.go b/pkg/resource_builders/envoyconfig/factory/default.go index 2792236d..67278d22 100644 --- a/pkg/resource_builders/envoyconfig/factory/default.go +++ b/pkg/resource_builders/envoyconfig/factory/default.go @@ -1,7 +1,7 @@ package factory import ( - "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/templates" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/templates" envoy_config_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" envoy_config_listener_v3 "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" envoy_config_route_v3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" diff --git a/pkg/resource_builders/envoyconfig/factory/factory.go b/pkg/resource_builders/envoyconfig/factory/factory.go index a43faf9e..e2f229b2 100644 --- a/pkg/resource_builders/envoyconfig/factory/factory.go +++ b/pkg/resource_builders/envoyconfig/factory/factory.go @@ -5,7 +5,7 @@ import ( "reflect" "github.com/3scale-ops/marin3r/pkg/envoy" - descriptor "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/descriptor" + descriptor "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/descriptor" ) // EnvoyDynamicConfigClass contains properties to generate specific types diff --git a/pkg/resource_builders/envoyconfig/factory/factory_test.go b/pkg/resource_builders/envoyconfig/factory/factory_test.go index 628d2ffd..51a10abe 100644 --- a/pkg/resource_builders/envoyconfig/factory/factory_test.go +++ b/pkg/resource_builders/envoyconfig/factory/factory_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/3scale-ops/marin3r/pkg/envoy" - descriptor "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/descriptor" + descriptor "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/descriptor" envoy_service_runtime_v3 "github.com/envoyproxy/go-control-plane/envoy/service/runtime/v3" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/structpb" diff --git a/pkg/resource_builders/envoyconfig/resource.go b/pkg/resource_builders/envoyconfig/resource.go index 60291eba..9bdf2944 100644 --- a/pkg/resource_builders/envoyconfig/resource.go +++ b/pkg/resource_builders/envoyconfig/resource.go @@ -3,14 +3,14 @@ package envoyconfig import ( "fmt" + "github.com/3scale-ops/basereconciler/util" marin3rv1alpha1 "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1" "github.com/3scale-ops/marin3r/pkg/envoy" envoy_serializer "github.com/3scale-ops/marin3r/pkg/envoy/serializer" envoy_serializer_v3 "github.com/3scale-ops/marin3r/pkg/envoy/serializer/v3" - marin3r_pointer "github.com/3scale-ops/marin3r/pkg/util/pointer" - "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/auto" - descriptor "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/descriptor" - "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/factory" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/auto" + descriptor "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/descriptor" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/factory" envoy_config_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" envoy_config_listener_v3 "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" envoy_config_route_v3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" @@ -93,9 +93,9 @@ func newFromProtos(key types.NamespacedName, nodeID string, resources []envoy.Re Namespace: key.Namespace, }, Spec: marin3rv1alpha1.EnvoyConfigSpec{ - EnvoyAPI: marin3r_pointer.New(envoy.APIv3), + EnvoyAPI: util.Pointer(envoy.APIv3), NodeID: nodeID, - Serialization: marin3r_pointer.New(envoy_serializer.YAML), + Serialization: util.Pointer(envoy_serializer.YAML), EnvoyResources: &marin3rv1alpha1.EnvoyResources{ Clusters: clusters, Routes: routes, diff --git a/pkg/resource_builders/envoyconfig/resource_test.go b/pkg/resource_builders/envoyconfig/resource_test.go index c1a743d3..674eab9d 100644 --- a/pkg/resource_builders/envoyconfig/resource_test.go +++ b/pkg/resource_builders/envoyconfig/resource_test.go @@ -4,14 +4,13 @@ import ( "testing" "time" + "github.com/3scale-ops/basereconciler/util" marin3rv1alpha1 "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1" "github.com/3scale-ops/marin3r/pkg/envoy" envoy_serializer "github.com/3scale-ops/marin3r/pkg/envoy/serializer" - marin3r_pointer "github.com/3scale-ops/marin3r/pkg/util/pointer" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - descriptor "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/descriptor" - "github.com/3scale/saas-operator/pkg/resource_builders/envoyconfig/factory" - "github.com/3scale/saas-operator/pkg/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + descriptor "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/descriptor" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/envoyconfig/factory" "github.com/MakeNowJust/heredoc" envoy_config_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" envoy_config_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" @@ -24,7 +23,6 @@ import ( "google.golang.org/protobuf/types/known/durationpb" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" ) func TestNew(t *testing.T) { @@ -48,23 +46,23 @@ func TestNew(t *testing.T) { factory: factory.Default(), resources: saasv1alpha1.MapOfEnvoyDynamicConfig{ "my_cluster": { - GeneratorVersion: pointer.String("v1"), + GeneratorVersion: util.Pointer("v1"), Cluster: &saasv1alpha1.Cluster{ Host: "localhost", Port: 8080, - IsHttp2: pointer.Bool(false), + IsHttp2: util.Pointer(false), }, }, "my_listener": { - GeneratorVersion: pointer.String("v1"), + GeneratorVersion: util.Pointer("v1"), ListenerHttp: &saasv1alpha1.ListenerHttp{ Port: 0, RouteConfigName: "routeconfig", - CertificateSecretName: pointer.String("certificate"), - EnableHttp2: pointer.Bool(false), - AllowHeadersWithUnderscores: pointer.Bool(true), - MaxConnectionDuration: util.Metav1DurationPtr(900 * time.Second), - ProxyProtocol: pointer.Bool(true), + CertificateSecretName: util.Pointer("certificate"), + EnableHttp2: util.Pointer(false), + AllowHeadersWithUnderscores: util.Pointer(true), + MaxConnectionDuration: util.Pointer(metav1.Duration{Duration: 900 * time.Second}), + ProxyProtocol: util.Pointer(true), }, }, }.AsList(), @@ -76,8 +74,8 @@ func TestNew(t *testing.T) { }, Spec: marin3rv1alpha1.EnvoyConfigSpec{ NodeID: "test", - Serialization: marin3r_pointer.New(envoy_serializer.YAML), - EnvoyAPI: marin3r_pointer.New(envoy.APIv3), + Serialization: util.Pointer(envoy_serializer.YAML), + EnvoyAPI: util.Pointer(envoy.APIv3), EnvoyResources: &marin3rv1alpha1.EnvoyResources{ Clusters: []marin3rv1alpha1.EnvoyResource{{ Value: heredoc.Doc(` @@ -260,8 +258,8 @@ func Test_newFromProtos(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "ns"}, Spec: marin3rv1alpha1.EnvoyConfigSpec{ NodeID: "test", - Serialization: marin3r_pointer.New(envoy_serializer.YAML), - EnvoyAPI: marin3r_pointer.New(envoy.APIv3), + Serialization: util.Pointer(envoy_serializer.YAML), + EnvoyAPI: util.Pointer(envoy.APIv3), EnvoyResources: &marin3rv1alpha1.EnvoyResources{ Clusters: []marin3rv1alpha1.EnvoyResource{{ Value: heredoc.Doc(` diff --git a/pkg/resource_builders/envoyconfig/templates/clusters.go b/pkg/resource_builders/envoyconfig/templates/clusters.go index 73ee2046..573ddc1a 100644 --- a/pkg/resource_builders/envoyconfig/templates/clusters.go +++ b/pkg/resource_builders/envoyconfig/templates/clusters.go @@ -4,7 +4,7 @@ import ( "time" "github.com/3scale-ops/marin3r/pkg/envoy" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" envoy_config_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" envoy_config_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" envoy_config_endpoint_v3 "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3" diff --git a/pkg/resource_builders/envoyconfig/templates/clusters_test.go b/pkg/resource_builders/envoyconfig/templates/clusters_test.go index 3f194906..954698e5 100644 --- a/pkg/resource_builders/envoyconfig/templates/clusters_test.go +++ b/pkg/resource_builders/envoyconfig/templates/clusters_test.go @@ -3,10 +3,10 @@ package templates import ( "testing" + "github.com/3scale-ops/basereconciler/util" envoy_serializer_v3 "github.com/3scale-ops/marin3r/pkg/envoy/serializer/v3" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" "github.com/MakeNowJust/heredoc" - "k8s.io/utils/pointer" "sigs.k8s.io/yaml" ) @@ -27,7 +27,7 @@ func TestCluster_v1(t *testing.T) { opts: &saasv1alpha1.Cluster{ Host: "localhost", Port: 8080, - IsHttp2: pointer.Bool(false), + IsHttp2: util.Pointer(false), }, }, want: heredoc.Doc(` @@ -53,7 +53,7 @@ func TestCluster_v1(t *testing.T) { opts: &saasv1alpha1.Cluster{ Host: "localhost", Port: 8080, - IsHttp2: pointer.Bool(true), + IsHttp2: util.Pointer(true), }, }, want: heredoc.Doc(` diff --git a/pkg/resource_builders/envoyconfig/templates/listeners.go b/pkg/resource_builders/envoyconfig/templates/listeners.go index 0e89f117..72b212b9 100644 --- a/pkg/resource_builders/envoyconfig/templates/listeners.go +++ b/pkg/resource_builders/envoyconfig/templates/listeners.go @@ -4,7 +4,7 @@ import ( "time" "github.com/3scale-ops/marin3r/pkg/envoy" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" envoy_config_accesslog_v3 "github.com/envoyproxy/go-control-plane/envoy/config/accesslog/v3" envoy_config_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" envoy_config_listener_v3 "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" diff --git a/pkg/resource_builders/envoyconfig/templates/listeners_test.go b/pkg/resource_builders/envoyconfig/templates/listeners_test.go index e306c21f..82dfc752 100644 --- a/pkg/resource_builders/envoyconfig/templates/listeners_test.go +++ b/pkg/resource_builders/envoyconfig/templates/listeners_test.go @@ -4,12 +4,11 @@ import ( "testing" "time" + "github.com/3scale-ops/basereconciler/util" envoy_serializer_v3 "github.com/3scale-ops/marin3r/pkg/envoy/serializer/v3" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" "github.com/MakeNowJust/heredoc" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" "sigs.k8s.io/yaml" ) @@ -30,18 +29,18 @@ func TestListenerHTTP_v1(t *testing.T) { opts: &saasv1alpha1.ListenerHttp{ Port: 8080, RouteConfigName: "my_route", - CertificateSecretName: pointer.String("my_certificate"), + CertificateSecretName: util.Pointer("my_certificate"), RateLimitOptions: &saasv1alpha1.RateLimitOptions{ Domain: "test_domain", - FailureModeDeny: pointer.Bool(true), + FailureModeDeny: util.Pointer(true), Timeout: metav1.Duration{Duration: 10 * time.Millisecond}, RateLimitCluster: "ratelimit", }, - DefaultHostForHttp10: pointer.String("example.com"), - EnableHttp2: pointer.Bool(false), - AllowHeadersWithUnderscores: pointer.Bool(true), - MaxConnectionDuration: util.Metav1DurationPtr(900 * time.Second), - ProxyProtocol: pointer.Bool(true), + DefaultHostForHttp10: util.Pointer("example.com"), + EnableHttp2: util.Pointer(false), + AllowHeadersWithUnderscores: util.Pointer(true), + MaxConnectionDuration: util.Pointer(metav1.Duration{Duration: 900 * time.Second}), + ProxyProtocol: util.Pointer(true), }, }, want: heredoc.Doc(` @@ -140,15 +139,15 @@ func TestListenerHTTP_v1(t *testing.T) { RouteConfigName: "my_route", RateLimitOptions: &saasv1alpha1.RateLimitOptions{ Domain: "test_domain", - FailureModeDeny: pointer.Bool(false), + FailureModeDeny: util.Pointer(false), Timeout: metav1.Duration{Duration: 10 * time.Millisecond}, RateLimitCluster: "ratelimit", }, - DefaultHostForHttp10: pointer.String("example.com"), - EnableHttp2: pointer.Bool(false), - AllowHeadersWithUnderscores: pointer.Bool(true), - MaxConnectionDuration: util.Metav1DurationPtr(900 * time.Second), - ProxyProtocol: pointer.Bool(true), + DefaultHostForHttp10: util.Pointer("example.com"), + EnableHttp2: util.Pointer(false), + AllowHeadersWithUnderscores: util.Pointer(true), + MaxConnectionDuration: util.Pointer(metav1.Duration{Duration: 900 * time.Second}), + ProxyProtocol: util.Pointer(true), }, }, want: heredoc.Doc(` diff --git a/pkg/resource_builders/envoyconfig/templates/rawconfig.go b/pkg/resource_builders/envoyconfig/templates/rawconfig.go index 6cee7004..f92e60d4 100644 --- a/pkg/resource_builders/envoyconfig/templates/rawconfig.go +++ b/pkg/resource_builders/envoyconfig/templates/rawconfig.go @@ -3,7 +3,7 @@ package templates import ( "github.com/3scale-ops/marin3r/pkg/envoy" envoy_serializer_v3 "github.com/3scale-ops/marin3r/pkg/envoy/serializer/v3" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" envoy_config_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" envoy_config_listener_v3 "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" envoy_config_route_v3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" diff --git a/pkg/resource_builders/envoyconfig/templates/rawconfig_test.go b/pkg/resource_builders/envoyconfig/templates/rawconfig_test.go index 89ad8e52..fe96bfe8 100644 --- a/pkg/resource_builders/envoyconfig/templates/rawconfig_test.go +++ b/pkg/resource_builders/envoyconfig/templates/rawconfig_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/3scale-ops/marin3r/pkg/envoy" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" "github.com/MakeNowJust/heredoc" envoy_config_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" envoy_config_endpoint_v3 "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3" diff --git a/pkg/resource_builders/envoyconfig/templates/routeconfigurations.go b/pkg/resource_builders/envoyconfig/templates/routeconfigurations.go index 76465ab6..e8269683 100644 --- a/pkg/resource_builders/envoyconfig/templates/routeconfigurations.go +++ b/pkg/resource_builders/envoyconfig/templates/routeconfigurations.go @@ -3,8 +3,8 @@ package templates import ( "github.com/3scale-ops/marin3r/pkg/envoy" envoy_serializer_v3 "github.com/3scale-ops/marin3r/pkg/envoy/serializer/v3" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + operatorutils "github.com/3scale-ops/saas-operator/pkg/util" envoy_config_route_v3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" ) @@ -16,7 +16,7 @@ func RouteConfiguration_v1(name string, opts interface{}) (envoy.Resource, error VirtualHosts: []*envoy_config_route_v3.VirtualHost{}, } - merr := util.MultiError{} + merr := operatorutils.MultiError{} for _, vhost := range o.VirtualHosts { vh := &envoy_config_route_v3.VirtualHost{} err := envoy_serializer_v3.JSON{}.Unmarshal(string(vhost.Raw), vh) diff --git a/pkg/resource_builders/envoyconfig/templates/routeconfigurations_test.go b/pkg/resource_builders/envoyconfig/templates/routeconfigurations_test.go index aa72b222..5878df26 100644 --- a/pkg/resource_builders/envoyconfig/templates/routeconfigurations_test.go +++ b/pkg/resource_builders/envoyconfig/templates/routeconfigurations_test.go @@ -4,7 +4,7 @@ import ( "testing" envoy_serializer_v3 "github.com/3scale-ops/marin3r/pkg/envoy/serializer/v3" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" "github.com/MakeNowJust/heredoc" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/yaml" diff --git a/pkg/resource_builders/envoyconfig/templates/runtimes.go b/pkg/resource_builders/envoyconfig/templates/runtimes.go index ab489e19..a940c557 100644 --- a/pkg/resource_builders/envoyconfig/templates/runtimes.go +++ b/pkg/resource_builders/envoyconfig/templates/runtimes.go @@ -2,7 +2,7 @@ package templates import ( "github.com/3scale-ops/marin3r/pkg/envoy" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" envoy_service_runtime_v3 "github.com/envoyproxy/go-control-plane/envoy/service/runtime/v3" "google.golang.org/protobuf/types/known/structpb" ) diff --git a/pkg/resource_builders/envoyconfig/templates/runtimes_test.go b/pkg/resource_builders/envoyconfig/templates/runtimes_test.go index 1ac49441..3c2f6879 100644 --- a/pkg/resource_builders/envoyconfig/templates/runtimes_test.go +++ b/pkg/resource_builders/envoyconfig/templates/runtimes_test.go @@ -4,7 +4,7 @@ import ( "testing" envoy_serializer_v3 "github.com/3scale-ops/marin3r/pkg/envoy/serializer/v3" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" "github.com/MakeNowJust/heredoc" "sigs.k8s.io/yaml" ) diff --git a/pkg/resource_builders/grafanadashboard/resource.go b/pkg/resource_builders/grafanadashboard/resource.go index 38a8e842..1e973e30 100644 --- a/pkg/resource_builders/grafanadashboard/resource.go +++ b/pkg/resource_builders/grafanadashboard/resource.go @@ -1,8 +1,8 @@ package grafanadashboard import ( - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/assets" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/assets" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" diff --git a/pkg/resource_builders/hpa/resource.go b/pkg/resource_builders/hpa/resource.go index 32aa9514..c4740255 100644 --- a/pkg/resource_builders/hpa/resource.go +++ b/pkg/resource_builders/hpa/resource.go @@ -1,7 +1,7 @@ package hpa import ( - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" appsv1 "k8s.io/api/apps/v1" autoscalingv2 "k8s.io/api/autoscaling/v2" corev1 "k8s.io/api/core/v1" diff --git a/pkg/resource_builders/marin3r/util.go b/pkg/resource_builders/marin3r/util.go index f51ddd3a..295c537a 100644 --- a/pkg/resource_builders/marin3r/util.go +++ b/pkg/resource_builders/marin3r/util.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" ) diff --git a/pkg/resource_builders/marin3r/util_test.go b/pkg/resource_builders/marin3r/util_test.go index 23f37abf..869c1be5 100644 --- a/pkg/resource_builders/marin3r/util_test.go +++ b/pkg/resource_builders/marin3r/util_test.go @@ -4,12 +4,12 @@ import ( "reflect" "testing" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" ) func TestEnableSidecar(t *testing.T) { @@ -33,9 +33,9 @@ func TestEnableSidecar(t *testing.T) { }, }, spec: saasv1alpha1.Marin3rSidecarSpec{ - EnvoyAPIVersion: pointer.String("xx"), - EnvoyImage: pointer.String("image"), - NodeID: pointer.String("node-id"), + EnvoyAPIVersion: util.Pointer("xx"), + EnvoyImage: util.Pointer("image"), + NodeID: util.Pointer("node-id"), ShutdownManagerPort: func() *uint32 { var v uint32 = 5000; return &v }(), ShutdownManagerExtraLifecycleHooks: []string{"container1", "container2"}, Ports: []saasv1alpha1.SidecarPort{ @@ -123,7 +123,7 @@ func TestEnableSidecar(t *testing.T) { }, }, spec: saasv1alpha1.Marin3rSidecarSpec{ - EnvoyImage: pointer.String("image"), + EnvoyImage: util.Pointer("image"), ExtraPodAnnotations: map[string]string{ "marin3r.3scale.net/envoy-image": "override", }, diff --git a/pkg/resource_builders/pdb/resource.go b/pkg/resource_builders/pdb/resource.go index 92342e6f..94f96331 100644 --- a/pkg/resource_builders/pdb/resource.go +++ b/pkg/resource_builders/pdb/resource.go @@ -1,7 +1,7 @@ package pdb import ( - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" policyv1 "k8s.io/api/policy/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" diff --git a/pkg/resource_builders/pod/environment.go b/pkg/resource_builders/pod/environment.go index a674667c..a11d6315 100644 --- a/pkg/resource_builders/pod/environment.go +++ b/pkg/resource_builders/pod/environment.go @@ -5,7 +5,7 @@ import ( "reflect" "strings" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" corev1 "k8s.io/api/core/v1" ) diff --git a/pkg/resource_builders/pod/environment_test.go b/pkg/resource_builders/pod/environment_test.go index f04af3c3..1960843c 100644 --- a/pkg/resource_builders/pod/environment_test.go +++ b/pkg/resource_builders/pod/environment_test.go @@ -4,10 +4,10 @@ import ( "reflect" "testing" - "github.com/3scale/saas-operator/api/v1alpha1" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + "github.com/3scale-ops/basereconciler/util" + "github.com/3scale-ops/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/pointer" ) func TestClearTextValue_ToEnvVar(t *testing.T) { @@ -73,7 +73,7 @@ func TestSecretValue_ToEnvVar(t *testing.T) { }, { name: "Returns EnvVar from an overrided Secret", - fields: fields{Value: saasv1alpha1.SecretReference{Override: pointer.String("override")}}, + fields: fields{Value: saasv1alpha1.SecretReference{Override: util.Pointer("override")}}, args: args{key: "key:my-secret"}, want: corev1.EnvVar{Name: "key", Value: "override"}, }, @@ -145,7 +145,7 @@ func TestBuildEnvironment(t *testing.T) { Option3 EnvVarValue `env:"OPTION3" secret:"my-secret"` }{ Option1: &ClearTextValue{Value: "value1"}, - Option2: &SecretValue{Value: v1alpha1.SecretReference{Override: pointer.String("override")}}, + Option2: &SecretValue{Value: v1alpha1.SecretReference{Override: util.Pointer("override")}}, Option3: &SecretValue{Value: v1alpha1.SecretReference{}}, }, }, diff --git a/pkg/resource_builders/pod/externalsecrets_test.go b/pkg/resource_builders/pod/externalsecrets_test.go index ef34ecf1..4c6ac34c 100644 --- a/pkg/resource_builders/pod/externalsecrets_test.go +++ b/pkg/resource_builders/pod/externalsecrets_test.go @@ -5,11 +5,11 @@ import ( "testing" "time" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" "github.com/go-test/deep" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" ) func TestGenerateExternalSecretFn(t *testing.T) { @@ -216,7 +216,7 @@ func Test_keysSlice(t *testing.T) { Option2: &SecretValue{Value: saasv1alpha1.SecretReference{ FromVault: &saasv1alpha1.VaultSecretReference{Key: "key2", Path: "path2"}}}, Option3: &SecretValue{Value: saasv1alpha1.SecretReference{ - Override: pointer.String("override")}}, + Override: util.Pointer("override")}}, Option4: &SecretValue{Value: saasv1alpha1.SecretReference{ FromVault: &saasv1alpha1.VaultSecretReference{Key: "key4", Path: "path4"}}}, }, diff --git a/pkg/resource_builders/pod/util.go b/pkg/resource_builders/pod/util.go index 04b371ad..a90b886b 100644 --- a/pkg/resource_builders/pod/util.go +++ b/pkg/resource_builders/pod/util.go @@ -3,7 +3,7 @@ package pod import ( "strings" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" diff --git a/pkg/resource_builders/service/util.go b/pkg/resource_builders/service/util.go index f09488ae..7dc106fb 100644 --- a/pkg/resource_builders/service/util.go +++ b/pkg/resource_builders/service/util.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" ) diff --git a/pkg/resource_builders/twemproxy/config.go b/pkg/resource_builders/twemproxy/config.go index 7960445d..d24ae0e6 100644 --- a/pkg/resource_builders/twemproxy/config.go +++ b/pkg/resource_builders/twemproxy/config.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" ) const ( diff --git a/pkg/resource_builders/twemproxy/options.go b/pkg/resource_builders/twemproxy/options.go index 0d0185ca..0e93d949 100644 --- a/pkg/resource_builders/twemproxy/options.go +++ b/pkg/resource_builders/twemproxy/options.go @@ -3,8 +3,8 @@ package twemproxy import ( "fmt" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" ) const ( diff --git a/pkg/resource_builders/twemproxy/util.go b/pkg/resource_builders/twemproxy/util.go index a5102bb8..5a648d3f 100644 --- a/pkg/resource_builders/twemproxy/util.go +++ b/pkg/resource_builders/twemproxy/util.go @@ -3,13 +3,11 @@ package twemproxy import ( "path/filepath" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" - "github.com/3scale/saas-operator/pkg/util" - + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/pointer" ) const ( @@ -56,7 +54,7 @@ func TwemproxyContainerVolume(twemproxySpec *saasv1alpha1.TwemproxySpec) corev1. LocalObjectReference: corev1.LocalObjectReference{ Name: twemproxySpec.ConfigMapName(), }, - DefaultMode: pointer.Int32(420), + DefaultMode: util.Pointer[int32](420), }, }, } diff --git a/pkg/resource_builders/twemproxy/util_test.go b/pkg/resource_builders/twemproxy/util_test.go index d18af668..6ae20554 100644 --- a/pkg/resource_builders/twemproxy/util_test.go +++ b/pkg/resource_builders/twemproxy/util_test.go @@ -6,13 +6,13 @@ import ( "testing" "time" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/pod" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/pod" "github.com/go-test/deep" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" ) func Test_AddTwemproxySidecar(t *testing.T) { @@ -42,30 +42,30 @@ func Test_AddTwemproxySidecar(t *testing.T) { }, spec: &saasv1alpha1.TwemproxySpec{ Image: &saasv1alpha1.ImageSpec{ - Name: pointer.String("twemproxy"), - Tag: pointer.String("latest"), - PullPolicy: (*corev1.PullPolicy)(pointer.String(string(corev1.PullIfNotPresent))), + Name: util.Pointer("twemproxy"), + Tag: util.Pointer("latest"), + PullPolicy: (*corev1.PullPolicy)(util.Pointer(string(corev1.PullIfNotPresent))), }, Resources: &saasv1alpha1.ResourceRequirementsSpec{}, LivenessProbe: &saasv1alpha1.ProbeSpec{ - InitialDelaySeconds: pointer.Int32(1), - TimeoutSeconds: pointer.Int32(3), - PeriodSeconds: pointer.Int32(5), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](1), + TimeoutSeconds: util.Pointer[int32](3), + PeriodSeconds: util.Pointer[int32](5), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), }, ReadinessProbe: &saasv1alpha1.ProbeSpec{ - InitialDelaySeconds: pointer.Int32(1), - TimeoutSeconds: pointer.Int32(3), - PeriodSeconds: pointer.Int32(5), - SuccessThreshold: pointer.Int32(1), - FailureThreshold: pointer.Int32(3), + InitialDelaySeconds: util.Pointer[int32](1), + TimeoutSeconds: util.Pointer[int32](3), + PeriodSeconds: util.Pointer[int32](5), + SuccessThreshold: util.Pointer[int32](1), + FailureThreshold: util.Pointer[int32](3), }, TwemproxyConfigRef: "twem-config", Options: &saasv1alpha1.TwemproxyOptions{ - LogLevel: pointer.Int32(6), + LogLevel: util.Pointer[int32](6), StatsInterval: &metav1.Duration{Duration: 20 * time.Second}, - MetricsPort: pointer.Int32(5555), + MetricsPort: util.Pointer[int32](5555), }, }, }, @@ -99,21 +99,21 @@ func Test_AddTwemproxySidecar(t *testing.T) { ProbeHandler: corev1.ProbeHandler{Exec: &corev1.ExecAction{ Command: strings.Split(healthCommand, " "), }}, - InitialDelaySeconds: *pointer.Int32(1), - TimeoutSeconds: *pointer.Int32(3), - PeriodSeconds: *pointer.Int32(5), - SuccessThreshold: *pointer.Int32(1), - FailureThreshold: *pointer.Int32(3), + InitialDelaySeconds: *util.Pointer[int32](1), + TimeoutSeconds: *util.Pointer[int32](3), + PeriodSeconds: *util.Pointer[int32](5), + SuccessThreshold: *util.Pointer[int32](1), + FailureThreshold: *util.Pointer[int32](3), }, ReadinessProbe: &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{Exec: &corev1.ExecAction{ Command: strings.Split(healthCommand, " "), }}, - InitialDelaySeconds: *pointer.Int32(1), - TimeoutSeconds: *pointer.Int32(3), - PeriodSeconds: *pointer.Int32(5), - SuccessThreshold: *pointer.Int32(1), - FailureThreshold: *pointer.Int32(3), + InitialDelaySeconds: *util.Pointer[int32](1), + TimeoutSeconds: *util.Pointer[int32](3), + PeriodSeconds: *util.Pointer[int32](5), + SuccessThreshold: *util.Pointer[int32](1), + FailureThreshold: *util.Pointer[int32](3), }, Lifecycle: &corev1.Lifecycle{ PreStop: &corev1.LifecycleHandler{ @@ -136,7 +136,7 @@ func Test_AddTwemproxySidecar(t *testing.T) { VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ LocalObjectReference: corev1.LocalObjectReference{Name: "twem-config"}, - DefaultMode: pointer.Int32(420), + DefaultMode: util.Pointer[int32](420), }, }, }, diff --git a/pkg/util/hash.go b/pkg/util/hash.go deleted file mode 100644 index 300c1744..00000000 --- a/pkg/util/hash.go +++ /dev/null @@ -1,23 +0,0 @@ -package util - -import ( - "fmt" - "hash/fnv" - - "github.com/davecgh/go-spew/spew" - "k8s.io/apimachinery/pkg/util/rand" -) - -// Hash returns a hash of the passed object -func Hash(o interface{}) string { - hasher := fnv.New32a() - hasher.Reset() - printer := spew.ConfigState{ - Indent: " ", - SortKeys: true, - DisableMethods: true, - SpewKeys: true, - } - printer.Fprintf(hasher, "%#v", o) - return rand.SafeEncodeString(fmt.Sprint(hasher.Sum32())) -} diff --git a/pkg/util/k8s.go b/pkg/util/k8s.go deleted file mode 100644 index 6730099c..00000000 --- a/pkg/util/k8s.go +++ /dev/null @@ -1,30 +0,0 @@ -package util - -import ( - "reflect" - - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -func ObjectKey(o client.Object) types.NamespacedName { - return types.NamespacedName{Name: o.GetName(), Namespace: o.GetNamespace()} -} - -// this is an ugly function to retrieve the list of Items from a -// client.ObjectList because the interface doesn't have a GetItems -// method -func GetItems(list client.ObjectList) []client.Object { - items := []client.Object{} - values := reflect.ValueOf(list).Elem().FieldByName("Items") - for i := 0; i < values.Len(); i++ { - item := values.Index(i) - if item.Kind() == reflect.Pointer { - items = append(items, item.Interface().(client.Object)) - } else { - items = append(items, item.Addr().Interface().(client.Object)) - } - } - - return items -} diff --git a/pkg/util/k8s_test.go b/pkg/util/k8s_test.go deleted file mode 100644 index 61966068..00000000 --- a/pkg/util/k8s_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package util - -import ( - "reflect" - "testing" - - monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -func TestGetItems(t *testing.T) { - type args struct { - list client.ObjectList - } - tests := []struct { - name string - args args - want []client.Object - }{ - { - name: "Returns items of a corev1.ServiceList as []client.Object", - args: args{ - list: &corev1.ServiceList{ - Items: []corev1.Service{ - {ObjectMeta: metav1.ObjectMeta{Name: "one"}}, - {ObjectMeta: metav1.ObjectMeta{Name: "two"}}, - }, - }, - }, - want: []client.Object{ - &corev1.Service{ObjectMeta: metav1.ObjectMeta{Name: "one"}}, - &corev1.Service{ObjectMeta: metav1.ObjectMeta{Name: "two"}}, - }, - }, - { - name: "Returns items of a monitoringv1.PodMonitorList as []client.Object", - args: args{ - list: &monitoringv1.PodMonitorList{ - Items: []*monitoringv1.PodMonitor{ - {ObjectMeta: metav1.ObjectMeta{Name: "one"}}, - {ObjectMeta: metav1.ObjectMeta{Name: "two"}}, - }, - }, - }, - want: []client.Object{ - &monitoringv1.PodMonitor{ObjectMeta: metav1.ObjectMeta{Name: "one"}}, - &monitoringv1.PodMonitor{ObjectMeta: metav1.ObjectMeta{Name: "two"}}, - }, - }} - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := GetItems(tt.args.list); !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetItems() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/pkg/util/maps.go b/pkg/util/maps.go deleted file mode 100644 index 6695279d..00000000 --- a/pkg/util/maps.go +++ /dev/null @@ -1,11 +0,0 @@ -package util - -// MergeMaps merges a list maps into the first one. B overrides A if keys collide. -func MergeMaps(base map[string]string, merges ...map[string]string) map[string]string { - for _, m := range merges { - for key, value := range m { - base[key] = value - } - } - return base -} diff --git a/pkg/util/pointer.go b/pkg/util/pointer.go deleted file mode 100644 index 20781858..00000000 --- a/pkg/util/pointer.go +++ /dev/null @@ -1,21 +0,0 @@ -package util - -import ( - "time" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" -) - -func IntStrPtr(value intstr.IntOrString) *intstr.IntOrString { - return &value -} - -func Metav1DurationPtr(value time.Duration) *metav1.Duration { - d := &metav1.Duration{Duration: value} - return d -} - -func Pointer[T any](t T) *T { - return &t -} diff --git a/pkg/util/slice.go b/pkg/util/slice.go deleted file mode 100644 index d529a591..00000000 --- a/pkg/util/slice.go +++ /dev/null @@ -1,34 +0,0 @@ -package util - -import "sort" - -func Unique(stringSlice []string) []string { - keys := make(map[string]bool) - list := []string{} - for _, entry := range stringSlice { - if _, ok := keys[entry]; !ok { - keys[entry] = true - list = append(list, entry) - } - } - sort.Strings(list) - return list -} - -func ConcatSlices[T any](slices [][]T) []T { - var totalLen int - - for _, s := range slices { - totalLen += len(s) - } - - result := make([]T, totalLen) - - var i int - - for _, s := range slices { - i += copy(result[i:], s) - } - - return result -} diff --git a/pkg/util/slice_test.go b/pkg/util/slice_test.go deleted file mode 100644 index 74a80bf8..00000000 --- a/pkg/util/slice_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package util - -import ( - "reflect" - "testing" -) - -func TestUnique(t *testing.T) { - type args struct { - stringSlice []string - } - tests := []struct { - name string - args args - want []string - }{ - { - name: "removes duplicates and sorts the list", - args: args{ - stringSlice: []string{"z", "d", "r", "d", "z", "e"}, - }, - want: []string{"d", "e", "r", "z"}, - }, - { - name: "just sorts the list", - args: args{ - stringSlice: []string{"f", "c", "d", "x"}, - }, - want: []string{"c", "d", "f", "x"}, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := Unique(tt.args.stringSlice); !reflect.DeepEqual(got, tt.want) { - t.Errorf("Unique() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/pkg/version/version.go b/pkg/version/version.go index 50b4f68a..91908b54 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -1,7 +1,7 @@ package version const ( - version string = "v0.21.0-alpha.13" + version string = "v0.21.0-alpha.14" ) // Current returns the current marin3r operator version diff --git a/test/e2e/sentinel_suite_test.go b/test/e2e/sentinel_suite_test.go index ddab085b..18274228 100644 --- a/test/e2e/sentinel_suite_test.go +++ b/test/e2e/sentinel_suite_test.go @@ -7,16 +7,16 @@ import ( "strings" "time" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - redisclient "github.com/3scale/saas-operator/pkg/redis/client" - testutil "github.com/3scale/saas-operator/test/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + redisclient "github.com/3scale-ops/saas-operator/pkg/redis/client" + testutil "github.com/3scale-ops/saas-operator/test/util" "github.com/google/go-cmp/cmp" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -46,11 +46,11 @@ var _ = Describe("sentinel e2e suite", func() { shards = []saasv1alpha1.RedisShard{ { ObjectMeta: metav1.ObjectMeta{Name: "rs0", Namespace: ns}, - Spec: saasv1alpha1.RedisShardSpec{MasterIndex: pointer.Int32(0), SlaveCount: pointer.Int32(2)}, + Spec: saasv1alpha1.RedisShardSpec{MasterIndex: util.Pointer[int32](0), SlaveCount: util.Pointer[int32](2)}, }, { ObjectMeta: metav1.ObjectMeta{Name: "rs1", Namespace: ns}, - Spec: saasv1alpha1.RedisShardSpec{MasterIndex: pointer.Int32(2), SlaveCount: pointer.Int32(2)}, + Spec: saasv1alpha1.RedisShardSpec{MasterIndex: util.Pointer[int32](2), SlaveCount: util.Pointer[int32](2)}, }, } diff --git a/test/e2e/shardedredisbackup_suite_test.go b/test/e2e/shardedredisbackup_suite_test.go index d9e7abcc..67d3baca 100644 --- a/test/e2e/shardedredisbackup_suite_test.go +++ b/test/e2e/shardedredisbackup_suite_test.go @@ -8,9 +8,9 @@ import ( "strings" "time" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/util" - testutil "github.com/3scale/saas-operator/test/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + testutil "github.com/3scale-ops/saas-operator/test/util" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3" . "github.com/onsi/ginkgo/v2" @@ -18,7 +18,6 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -58,8 +57,8 @@ var _ = Describe("shardedredisbackup e2e suite", func() { { ObjectMeta: metav1.ObjectMeta{Name: "rs0", Namespace: ns}, Spec: saasv1alpha1.RedisShardSpec{ - MasterIndex: pointer.Int32(0), - SlaveCount: pointer.Int32(2), + MasterIndex: util.Pointer[int32](0), + SlaveCount: util.Pointer[int32](2), Command: util.Pointer("/entrypoint.sh"), Image: &saasv1alpha1.ImageSpec{ Name: util.Pointer("redis-with-ssh"), diff --git a/test/e2e/suite_test.go b/test/e2e/suite_test.go index 0beff8fe..a5a04eb5 100644 --- a/test/e2e/suite_test.go +++ b/test/e2e/suite_test.go @@ -27,13 +27,13 @@ import ( . "github.com/onsi/gomega" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" externalsecretsv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1" grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" @@ -67,7 +67,7 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - UseExistingCluster: pointer.Bool(true), + UseExistingCluster: util.Pointer(true), } // cfg is defined in this file globally. diff --git a/test/e2e/twemproxyconfig_suite_test.go b/test/e2e/twemproxyconfig_suite_test.go index f3360bba..7809f710 100644 --- a/test/e2e/twemproxyconfig_suite_test.go +++ b/test/e2e/twemproxyconfig_suite_test.go @@ -6,10 +6,10 @@ import ( "sort" "time" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - "github.com/3scale/saas-operator/pkg/resource_builders/twemproxy" - "github.com/3scale/saas-operator/pkg/util" - testutil "github.com/3scale/saas-operator/test/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + "github.com/3scale-ops/saas-operator/pkg/resource_builders/twemproxy" + testutil "github.com/3scale-ops/saas-operator/test/util" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" . "github.com/onsi/ginkgo/v2" @@ -17,7 +17,6 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/yaml" ) @@ -48,11 +47,11 @@ var _ = Describe("twemproxyconfig e2e suite", func() { shards = []saasv1alpha1.RedisShard{ { ObjectMeta: metav1.ObjectMeta{Name: "rs0", Namespace: ns}, - Spec: saasv1alpha1.RedisShardSpec{MasterIndex: pointer.Int32(0), SlaveCount: pointer.Int32(2)}, + Spec: saasv1alpha1.RedisShardSpec{MasterIndex: util.Pointer[int32](0), SlaveCount: util.Pointer[int32](2)}, }, { ObjectMeta: metav1.ObjectMeta{Name: "rs1", Namespace: ns}, - Spec: saasv1alpha1.RedisShardSpec{MasterIndex: pointer.Int32(0), SlaveCount: pointer.Int32(2)}, + Spec: saasv1alpha1.RedisShardSpec{MasterIndex: util.Pointer[int32](0), SlaveCount: util.Pointer[int32](2)}, }, } diff --git a/test/util/assert.go b/test/util/assert.go index 4bb62233..721036e5 100644 --- a/test/util/assert.go +++ b/test/util/assert.go @@ -5,6 +5,7 @@ import ( "fmt" "time" + "github.com/3scale-ops/basereconciler/util" marin3rv1alpha1 "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -13,7 +14,6 @@ import ( autoscalingv2 "k8s.io/api/autoscaling/v2" policyv1 "k8s.io/api/policy/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -71,9 +71,9 @@ func (ew *ExpectedWorkload) Assert(c client.Client, dep *appsv1.Deployment, time if ew.HPA { Expect(hpa.Spec.ScaleTargetRef.Kind).Should(Equal("Deployment")) Expect(hpa.Spec.ScaleTargetRef.Name).Should(Equal(ew.Name)) - Expect(hpa.Spec.MinReplicas).Should(Equal(pointer.Int32(ew.Replicas))) + Expect(hpa.Spec.MinReplicas).Should(Equal(util.Pointer[int32](ew.Replicas))) } else { - Expect(dep.Spec.Replicas).To(Equal(pointer.Int32(ew.Replicas))) + Expect(dep.Spec.Replicas).To(Equal(util.Pointer[int32](ew.Replicas))) } pdb := &policyv1.PodDisruptionBudget{} diff --git a/test/util/minio.go b/test/util/minio.go index 6e085ad9..b11b2735 100644 --- a/test/util/minio.go +++ b/test/util/minio.go @@ -4,7 +4,8 @@ import ( "context" "fmt" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + operatorutils "github.com/3scale-ops/saas-operator/pkg/util" "github.com/aws/aws-sdk-go-v2/service/s3" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/rest" @@ -22,7 +23,7 @@ func MinioClient(ctx context.Context, cfg *rest.Config, podKey types.NamespacedN return nil, nil, err } - awsconfig, err := util.AWSConfig(ctx, user, passwd, region, util.Pointer(fmt.Sprintf("http://localhost:%d", localPort))) + awsconfig, err := operatorutils.AWSConfig(ctx, user, passwd, region, util.Pointer(fmt.Sprintf("http://localhost:%d", localPort))) if err != nil { return nil, nil, err } diff --git a/test/util/redis.go b/test/util/redis.go index 02bbe7f6..ee8bd569 100644 --- a/test/util/redis.go +++ b/test/util/redis.go @@ -9,9 +9,9 @@ import ( "os" "strings" - saasv1alpha1 "github.com/3scale/saas-operator/api/v1alpha1" - redis "github.com/3scale/saas-operator/pkg/redis/server" - "github.com/3scale/saas-operator/pkg/util" + "github.com/3scale-ops/basereconciler/util" + saasv1alpha1 "github.com/3scale-ops/saas-operator/api/v1alpha1" + redis "github.com/3scale-ops/saas-operator/pkg/redis/server" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/rest" ) diff --git a/pkg/util/time.go b/test/util/util.go similarity index 100% rename from pkg/util/time.go rename to test/util/util.go