func (redisServiceBroker *RedisServiceBroker) Bind(instanceID, bindingID string, details brokerapi.BindDetails) (brokerapi.Binding, error) { binding := brokerapi.Binding{} for _, repo := range redisServiceBroker.InstanceBinders { instanceExists, _ := repo.InstanceExists(instanceID) if instanceExists { instanceCredentials, err := repo.Bind(instanceID, bindingID) if err != nil { return binding, err } credentialsMap := map[string]interface{}{ "host": instanceCredentials.Host, "port": instanceCredentials.Port, "password": instanceCredentials.Password, } binding.Credentials = credentialsMap return binding, nil } } return brokerapi.Binding{}, brokerapi.ErrInstanceDoesNotExist }
func (b BindingInfoResource) BindingFor(rabbitmqConfig RabbitmqConfig, credentials Credentials, instanceID string, protocols map[string]rabbithole.Port) brokerapi.Binding { binding := brokerapi.Binding{} creds := map[string]interface{}{} creds["dashboard_url"] = fmt.Sprintf("https://%s/#/login/%s/%s", rabbitmqConfig.ManagementDomain, credentials.Username, credentials.Password) creds["hostname"] = rabbitmqConfig.Hosts[0] creds["hostnames"] = rabbitmqConfig.Hosts creds["http_api_uri"] = fmt.Sprintf("https://%s:%s@%s/api/", credentials.Username, credentials.Password, rabbitmqConfig.ManagementDomain) creds["http_api_uris"] = []string{creds["http_api_uri"].(string)} creds["password"] = credentials.Password creds["protocols"] = b.ProtocolInfo.ProtocolInfoFor(rabbitmqConfig, credentials, instanceID, protocols, false) creds["ssl"] = true creds["uri"] = fmt.Sprintf("amqp://%s:%s@%s/%s", credentials.Username, credentials.Password, rabbitmqConfig.Hosts[0], instanceID) uris := []string{} for _, host := range rabbitmqConfig.Hosts { uris = append(uris, fmt.Sprintf("amqp://%s:%s@%s/%s", credentials.Username, credentials.Password, host, instanceID)) } creds["uris"] = uris creds["username"] = credentials.Username creds["vhost"] = instanceID binding.Credentials = creds return binding }