From 7ab38f8bd61c9a8409f8c251dc82962f93835e32 Mon Sep 17 00:00:00 2001
From: Timo Riski <timo.riski@aiven.io>
Date: Mon, 28 Oct 2024 17:13:26 +0200
Subject: [PATCH] feat: add `autoscaler` to api types

---
 api/v1alpha1/serviceintegration_types.go         | 5 +++++
 api/v1alpha1/serviceintegrationendpoint_types.go | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/api/v1alpha1/serviceintegration_types.go b/api/v1alpha1/serviceintegration_types.go
index 2519496a..a3c8e20d 100644
--- a/api/v1alpha1/serviceintegration_types.go
+++ b/api/v1alpha1/serviceintegration_types.go
@@ -9,6 +9,7 @@ import (
 	"github.com/aiven/go-client-codegen/handler/service"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
+	autoscalerintegration "github.com/aiven/aiven-operator/api/v1alpha1/userconfig/integration/autoscaler"
 	clickhousekafkauserconfig "github.com/aiven/aiven-operator/api/v1alpha1/userconfig/integration/clickhouse_kafka"
 	clickhousepostgresqluserconfig "github.com/aiven/aiven-operator/api/v1alpha1/userconfig/integration/clickhouse_postgresql"
 	datadogintegration "github.com/aiven/aiven-operator/api/v1alpha1/userconfig/integration/datadog"
@@ -59,6 +60,9 @@ type ServiceIntegrationSpec struct {
 	// Destination project for the integration (if any)
 	DestinationProjectName string `json:"destinationProjectName,omitempty"`
 
+	// Autoscaler specific user configuration options
+	AutoscalerUserConfig *autoscalerintegration.AutoscalerUserConfig `json:"autoscaler,omitempty"`
+
 	// Datadog specific user configuration options
 	DatadogUserConfig *datadogintegration.DatadogUserConfig `json:"datadog,omitempty"`
 
@@ -130,6 +134,7 @@ func (in *ServiceIntegration) Conditions() *[]metav1.Condition {
 
 func (in *ServiceIntegration) getUserConfigFields() map[service.IntegrationType]any {
 	return map[service.IntegrationType]any{
+		service.IntegrationTypeAutoscaler:                   in.Spec.AutoscalerUserConfig,
 		service.IntegrationTypeClickhouseKafka:              in.Spec.ClickhouseKafkaUserConfig,
 		service.IntegrationTypeClickhousePostgresql:         in.Spec.ClickhousePostgreSQLUserConfig,
 		service.IntegrationTypeDatadog:                      in.Spec.DatadogUserConfig,
diff --git a/api/v1alpha1/serviceintegrationendpoint_types.go b/api/v1alpha1/serviceintegrationendpoint_types.go
index c24e3627..de3349b2 100644
--- a/api/v1alpha1/serviceintegrationendpoint_types.go
+++ b/api/v1alpha1/serviceintegrationendpoint_types.go
@@ -8,6 +8,7 @@ import (
 
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
+	autoscaleruserconfig "github.com/aiven/aiven-operator/api/v1alpha1/userconfig/integrationendpoints/autoscaler"
 	datadoguserconfig "github.com/aiven/aiven-operator/api/v1alpha1/userconfig/integrationendpoints/datadog"
 	externalawscloudwatchlogsuserconfig "github.com/aiven/aiven-operator/api/v1alpha1/userconfig/integrationendpoints/external_aws_cloudwatch_logs"
 	externalawscloudwatchmetricsuserconfig "github.com/aiven/aiven-operator/api/v1alpha1/userconfig/integrationendpoints/external_aws_cloudwatch_metrics"
@@ -37,6 +38,9 @@ type ServiceIntegrationEndpointSpec struct {
 	// Source endpoint for the integration (if any)
 	EndpointName string `json:"endpointName,omitempty"`
 
+	// Autoscaler configuration values
+	Autoscaler *autoscaleruserconfig.AutoscalerUserConfig `json:"autoscaler,omitempty"`
+
 	// Datadog configuration values
 	Datadog *datadoguserconfig.DatadogUserConfig `json:"datadog,omitempty"`
 
@@ -118,6 +122,7 @@ func (in *ServiceIntegrationEndpoint) Conditions() *[]metav1.Condition {
 
 func (in *ServiceIntegrationEndpoint) getUserConfigFields() map[string]any {
 	return map[string]any{
+		"autoscaler":                      in.Spec.Autoscaler,
 		"datadog":                         in.Spec.Datadog,
 		"external_aws_cloudwatch_logs":    in.Spec.ExternalAwsCloudwatchLogs,
 		"external_aws_cloudwatch_metrics": in.Spec.ExternalAwsCloudwatchMetrics,