diff --git a/controllers/common.go b/controllers/common.go index 67f0e1d3..24e2bfb6 100644 --- a/controllers/common.go +++ b/controllers/common.go @@ -50,7 +50,7 @@ var ( ) func checkServiceIsRunning(ctx context.Context, avn *aiven.Client, avnGen avngen.Client, project, serviceName string) (bool, error) { - s, err := avn.Services.Get(ctx, project, serviceName) + s, err := avnGen.ServiceGet(ctx, project, serviceName) if err != nil { // if service is not found, it is not running if aiven.IsNotFound(err) { diff --git a/controllers/serviceintegration_controller.go b/controllers/serviceintegration_controller.go index a71897a9..46a6b4df 100644 --- a/controllers/serviceintegration_controller.go +++ b/controllers/serviceintegration_controller.go @@ -53,25 +53,24 @@ func (h ServiceIntegrationHandler) createOrUpdate(ctx context.Context, avn *aive } var reason string - var integration *aiven.ServiceIntegration if si.Status.ID == "" { userConfigMap, err := CreateUserConfiguration(userConfig) if err != nil { return err } - integration, err = avn.ServiceIntegrations.Create( + integration, err := avnGen.ServiceIntegrationCreate( ctx, si.Spec.Project, - aiven.CreateServiceIntegrationRequest{ - DestinationEndpointID: anyOptional(si.Spec.DestinationEndpointID), - DestinationService: anyOptional(si.Spec.DestinationServiceName), - DestinationProject: anyOptional(si.Spec.DestinationProjectName), - IntegrationType: si.Spec.IntegrationType, - SourceEndpointID: anyOptional(si.Spec.SourceEndpointID), - SourceService: anyOptional(si.Spec.SourceServiceName), - SourceProject: anyOptional(si.Spec.SourceProjectName), - UserConfig: userConfigMap, + &serviceintegration.ServiceIntegrationCreateIn{ + DestEndpointId: si.Spec.DestinationEndpointID, + DestService: si.Spec.DestinationServiceName, + DestProject: si.Spec.DestinationProjectName, + IntegrationType: serviceintegration.IntegrationType(si.Spec.IntegrationType), + SourceEndpointId: si.Spec.SourceEndpointID, + SourceService: si.Spec.SourceServiceName, + SourceProject: si.Spec.SourceProjectName, + UserConfig: &userConfigMap, }, ) if err != nil { @@ -79,6 +78,7 @@ func (h ServiceIntegrationHandler) createOrUpdate(ctx context.Context, avn *aive } reason = "Created" + si.Status.ID = integration.ServiceIntegrationId } else { // Not all service integrations have user_config available; skip the update if user_config is unavailable. withUserConfig := []string{"clickhouse_kafka", "clickhouse_postgresql", "datadog", "kafka_connect", "kafka_logs", "kafka_mirrormaker", "logs", "metrics", "external_aws_cloudwatch_metrics"} @@ -91,11 +91,11 @@ func (h ServiceIntegrationHandler) createOrUpdate(ctx context.Context, avn *aive return err } - integration, err = avn.ServiceIntegrations.Update( + updatedIntegration, err := avnGen.ServiceIntegrationUpdate( ctx, si.Spec.Project, si.Status.ID, - aiven.UpdateServiceIntegrationRequest{ + &serviceintegration.ServiceIntegrationUpdateIn{ UserConfig: userConfigMap, }, ) @@ -106,10 +106,9 @@ func (h ServiceIntegrationHandler) createOrUpdate(ctx context.Context, avn *aive } return err } + si.Status.ID = updatedIntegration.ServiceIntegrationId } - si.Status.ID = integration.ServiceIntegrationID - meta.SetStatusCondition(&si.Status.Conditions, getInitializedCondition(reason, "Instance was created or update on Aiven side"))