@@ -18,36 +18,33 @@ import (
1818const ConnectionSecretsEnsuredEvent = "ConnectionSecretsEnsured"
1919
2020func CreateOrUpdateConnectionSecrets (ctx * workflow.Context , k8sClient client.Client , recorder record.EventRecorder , project mdbv1.AtlasProject , dbUser mdbv1.AtlasDatabaseUser ) workflow.Result {
21- deployments , _ , err := ctx .Client .Clusters .List (context .Background (), project .ID (), & mongodbatlas.ListOptions {})
22- if err != nil {
23- return workflow .Terminate (workflow .DatabaseUserConnectionSecretsNotCreated , err .Error ())
24- }
25-
2621 advancedDeployments , _ , err := ctx .Client .AdvancedClusters .List (context .Background (), project .ID (), & mongodbatlas.ListOptions {})
2722 if err != nil {
2823 return workflow .Terminate (workflow .DatabaseUserConnectionSecretsNotCreated , err .Error ())
2924 }
3025
3126 var deploymentSecrets []deploymentSecret
32- for _ , c := range deployments {
27+ for _ , c := range advancedDeployments . Results {
3328 deploymentSecrets = append (deploymentSecrets , deploymentSecret {
3429 name : c .Name ,
3530 connectionStrings : c .ConnectionStrings ,
3631 })
3732 }
3833
39- for _ , c := range advancedDeployments .Results {
40- // based on configuration settings, some advanced deployments also show up in the regular deployments API.
41- // For these deployments, we don't want to duplicate the secret so we skip them.
34+ serverlessDeployments , _ , err := ctx .Client .ServerlessInstances .List (context .Background (), project .ID (), & mongodbatlas.ListOptions {})
35+ if err != nil {
36+ return workflow .Terminate (workflow .DatabaseUserConnectionSecretsNotCreated , err .Error ())
37+ }
38+ for _ , c := range serverlessDeployments .Results {
4239 found := false
43- for _ , regularDeployment := range deployments {
44- if regularDeployment .Name == c .Name {
40+
41+ for _ , advancedDeployment := range advancedDeployments .Results {
42+ if advancedDeployment .Name == c .Name {
4543 found = true
4644 break
4745 }
4846 }
4947
50- // we only include secrets which have not been handled by the regular deployment API.
5148 if ! found {
5249 deploymentSecrets = append (deploymentSecrets , deploymentSecret {
5350 name : c .Name ,
0 commit comments