Skip to content

Commit

Permalink
fix: import service_integrations field (#1820)
Browse files Browse the repository at this point in the history
  • Loading branch information
rriski committed Oct 8, 2024
1 parent 7b8dd00 commit 05f4f95
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions internal/schemautil/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,20 @@ func getTechnicalEmailsForTerraform(s *service.ServiceGetOut) *schema.Set {
return schema.NewSet(schema.HashResource(TechEmailsResourceSchema), techEmails)
}

func getReadReplicaIntegrationsForTerraform(integrations []service.ServiceIntegrationOut) ([]map[string]interface{}, error) {
var readReplicaIntegrations []map[string]interface{}
for _, integration := range integrations {
if integration.IntegrationType == "read_replica" {
integrationMap := map[string]interface{}{
"integration_type": integration.IntegrationType,
"source_service_name": integration.SourceService,
}
readReplicaIntegrations = append(readReplicaIntegrations, integrationMap)
}
}
return readReplicaIntegrations, nil
}

func ResourceServiceDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
client := m.(*aiven.Client)

Expand Down Expand Up @@ -745,6 +759,15 @@ func copyServicePropertiesFromAPIResponseToTerraform(
return fmt.Errorf("cannot set `components` : %w", err)
}

// Handle read_replica service integrations
readReplicaIntegrations, err := getReadReplicaIntegrationsForTerraform(s.ServiceIntegrations)
if err != nil {
return err
}
if err := d.Set("service_integrations", readReplicaIntegrations); err != nil {
return err
}

return copyConnectionInfoFromAPIResponseToTerraform(d, serviceType, s.ConnectionInfo, s.Metadata)
}

Expand Down

0 comments on commit 05f4f95

Please sign in to comment.