Skip to content

Commit c486fa4

Browse files
committed
[memcached] add funcs to return quoted serverList and update test helpers
For tls, in openstack-k8s-operators#192 changed the server lists to contain the svc fqdn, but missed to update the test helpers.
1 parent 8b35d05 commit c486fa4

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

apis/memcached/v1beta1/memcached_funcs.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package v1beta1
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"strings"
2223

2324
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
@@ -62,10 +63,22 @@ func (instance *Memcached) GetMemcachedServerListString() string {
6263
return strings.Join(instance.Status.ServerList, ",")
6364
}
6465

66+
// GetMemcachedServerListQuotedString - return the memcached servers, each quoted, as comma separated list
67+
// to be used in OpenStack config.
68+
func (instance *Memcached) GetMemcachedServerListQuotedString() string {
69+
return fmt.Sprintf("'%s'", strings.Join(instance.Status.ServerList, ","))
70+
}
71+
6572
// GetMemcachedServerListWithInetString - return the memcached servers as comma separated list
6673
// to be used in OpenStack config.
6774
func (instance *Memcached) GetMemcachedServerListWithInetString() string {
68-
return strings.Join(instance.Status.ServerListWithInet, ",")
75+
return strings.Join(instance.Status.ServerListWithInet, "','")
76+
}
77+
78+
// GetMemcachedServerListWithInetQuotedString - return the memcached servers, each quoted, as comma separated list
79+
// to be used in OpenStack config.
80+
func (instance *Memcached) GetMemcachedServerListWithInetQuotedString() string {
81+
return fmt.Sprintf("'%s'", strings.Join(instance.Status.ServerListWithInet, ","))
6982
}
7083

7184
// GetMemcachedTLSSupport - return the TLS support of the memcached instance

apis/test/helpers/memcached.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ func (tc *TestHelper) SimulateMemcachedReady(name types.NamespacedName) {
112112
serverList := []string{}
113113
serverListWithInet := []string{}
114114
for i := 0; i < int(*mc.Spec.Replicas); i++ {
115-
serverList = append(serverList, fmt.Sprintf("%s-%d.%s:11211", mc.Name, i, mc.Name))
116-
serverListWithInet = append(serverListWithInet, fmt.Sprintf("inet:[%s-%d.%s]:11211", mc.Name, i, mc.Name))
115+
serverList = append(serverList, fmt.Sprintf("%s-%d.%s.%s.svc:11211", mc.Name, i, mc.Name, mc.Namespace))
116+
serverListWithInet = append(serverListWithInet, fmt.Sprintf("inet:[%s-%d.%s.%s.svc]:11211", mc.Name, i, mc.Name, mc.Namespace))
117117
}
118118
mc.Status.ServerList = serverList
119119
mc.Status.ServerListWithInet = serverListWithInet

0 commit comments

Comments
 (0)