Skip to content

Commit 5d715a2

Browse files
Merge pull request #198 from stuggi/fix_memcached_helper
[memcached] add funcs to return quoted serverList and update test helpers
2 parents 8b35d05 + 041b81b commit 5d715a2

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

apis/memcached/v1beta1/memcached_funcs.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,22 @@ func (instance *Memcached) GetMemcachedServerListString() string {
6262
return strings.Join(instance.Status.ServerList, ",")
6363
}
6464

65+
// GetMemcachedServerListQuotedString - return the memcached servers, each quoted, as comma separated list
66+
// to be used in OpenStack config.
67+
func (instance *Memcached) GetMemcachedServerListQuotedString() string {
68+
return "'" + strings.Join(instance.Status.ServerList, "','") + "'"
69+
}
70+
6571
// GetMemcachedServerListWithInetString - return the memcached servers as comma separated list
6672
// to be used in OpenStack config.
6773
func (instance *Memcached) GetMemcachedServerListWithInetString() string {
68-
return strings.Join(instance.Status.ServerListWithInet, ",")
74+
return strings.Join(instance.Status.ServerListWithInet, "','")
75+
}
76+
77+
// GetMemcachedServerListWithInetQuotedString - return the memcached servers, each quoted, as comma separated list
78+
// to be used in OpenStack config.
79+
func (instance *Memcached) GetMemcachedServerListWithInetQuotedString() string {
80+
return "'" + strings.Join(instance.Status.ServerListWithInet, "','") + "'"
6981
}
7082

7183
// 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)