@@ -20,7 +20,6 @@ import (
2020 "context"
2121 "errors"
2222 "fmt"
23- "net/url"
2423 "strings"
2524
2625 "go.uber.org/zap"
@@ -254,25 +253,25 @@ func isReady(conditions []rabbitv1beta1.Condition) bool {
254253 return numConditions == 0
255254}
256255
257- func (r * Rabbit ) RabbitMQURL (ctx context.Context , clusterRef * rabbitv1beta1.RabbitmqClusterReference ) (* url. URL , error ) {
256+ func (r * Rabbit ) RabbitMQURL (ctx context.Context , clusterRef * rabbitv1beta1.RabbitmqClusterReference ) (string , error ) {
258257 protocol := []byte ("amqp" )
259258 if clusterRef .ConnectionSecret != nil {
260259 s , err := r .kubeClientSet .CoreV1 ().Secrets (clusterRef .Namespace ).Get (ctx , clusterRef .ConnectionSecret .Name , metav1.GetOptions {})
261260 if err != nil {
262- return nil , err
261+ return "" , err
263262 }
264263 uri , ok := s .Data ["uri" ]
265264 if ! ok {
266- return nil , fmt .Errorf ("rabbit Secret missing key uri" )
265+ return "" , fmt .Errorf ("rabbit Secret missing key uri" )
267266 }
268267 uriString := string (uri )
269268 password , ok := s .Data ["password" ]
270269 if ! ok {
271- return nil , fmt .Errorf ("rabbit Secret missing key password" )
270+ return "" , fmt .Errorf ("rabbit Secret missing key password" )
272271 }
273272 username , ok := s .Data ["username" ]
274273 if ! ok {
275- return nil , fmt .Errorf ("rabbit Secret missing key username" )
274+ return "" , fmt .Errorf ("rabbit Secret missing key username" )
276275 }
277276 port , ok := s .Data ["port" ]
278277 if ! ok {
@@ -286,31 +285,31 @@ func (r *Rabbit) RabbitMQURL(ctx context.Context, clusterRef *rabbitv1beta1.Rabb
286285 }
287286 uriString = strings .TrimPrefix (uriString , prefix )
288287 splittedUri := strings .Split (uriString , ":" )
289- return url . Parse ( fmt .Sprintf ("%s://%s:%s@%s:%s" , protocol , username , password , splittedUri [0 ], port ))
288+ return fmt .Sprintf ("%s://%s:%s@%s:%s" , protocol , username , password , splittedUri [0 ], port ), nil
290289 }
291290
292291 rab , err := r .getClusterFromReference (ctx , clusterRef )
293292 if err != nil {
294- return nil , err
293+ return "" , err
295294 }
296295
297296 if rab .Status .DefaultUser == nil || rab .Status .DefaultUser .SecretReference == nil || rab .Status .DefaultUser .ServiceReference == nil {
298- return nil , fmt .Errorf ("rabbit \" %s/%s\" not ready" , rab .Namespace , rab .Name )
297+ return "" , fmt .Errorf ("rabbit \" %s/%s\" not ready" , rab .Namespace , rab .Name )
299298 }
300299
301300 _ = rab .Status .DefaultUser .SecretReference
302301
303302 s , err := r .kubeClientSet .CoreV1 ().Secrets (rab .Status .DefaultUser .SecretReference .Namespace ).Get (ctx , rab .Status .DefaultUser .SecretReference .Name , metav1.GetOptions {})
304303 if err != nil {
305- return nil , err
304+ return "" , err
306305 }
307306 password , ok := s .Data [rab .Status .DefaultUser .SecretReference .Keys ["password" ]]
308307 if ! ok {
309- return nil , fmt .Errorf ("rabbit Secret missing key %s" , rab .Status .DefaultUser .SecretReference .Keys ["password" ])
308+ return "" , fmt .Errorf ("rabbit Secret missing key %s" , rab .Status .DefaultUser .SecretReference .Keys ["password" ])
310309 }
311310 username , ok := s .Data [rab .Status .DefaultUser .SecretReference .Keys ["username" ]]
312311 if ! ok {
313- return nil , fmt .Errorf ("rabbit Secret missing key %s" , rab .Status .DefaultUser .SecretReference .Keys ["username" ])
312+ return "" , fmt .Errorf ("rabbit Secret missing key %s" , rab .Status .DefaultUser .SecretReference .Keys ["username" ])
314313 }
315314 port , ok := s .Data ["port" ]
316315 if ! ok {
@@ -320,7 +319,7 @@ func (r *Rabbit) RabbitMQURL(ctx context.Context, clusterRef *rabbitv1beta1.Rabb
320319 protocol = []byte ("amqps" )
321320 }
322321 host := network .GetServiceHostname (rab .Status .DefaultUser .ServiceReference .Name , rab .Status .DefaultUser .ServiceReference .Namespace )
323- return url . Parse ( fmt .Sprintf ("%s://%s:%s@%s:%s" , protocol , username , password , host , port ))
322+ return fmt .Sprintf ("%s://%s:%s@%s:%s" , protocol , username , password , host , port ), nil
324323}
325324
326325func (r * Rabbit ) GetRabbitMQCASecret (ctx context.Context , clusterRef * rabbitv1beta1.RabbitmqClusterReference ) (string , error ) {
0 commit comments