Skip to content

Commit 799a8dc

Browse files
committed
post-merge fixes
1 parent bd72b91 commit 799a8dc

File tree

3 files changed

+58
-42
lines changed

3 files changed

+58
-42
lines changed

controllers/search_controller/community_search_source.go

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package search_controller
22

33
import (
4+
"fmt"
45
"strings"
56

67
"github.com/blang/semver"
@@ -19,38 +20,22 @@ type CommunitySearchSource struct {
1920
*mdbcv1.MongoDBCommunity
2021
}
2122

22-
func (r *CommunitySearchSource) Members() int {
23-
return r.Spec.Members
24-
}
25-
26-
func (r *CommunitySearchSource) GetName() string {
27-
return r.Name
28-
}
29-
30-
func (r *CommunitySearchSource) NamespacedName() types.NamespacedName {
31-
return r.MongoDBCommunity.NamespacedName()
23+
func (r *CommunitySearchSource) HostSeeds() []string {
24+
seeds := make([]string, r.Spec.Members)
25+
for i := range seeds {
26+
seeds[i] = fmt.Sprintf("%s-%d.%s.%s.svc.cluster.local:%d", r.Name, i, r.ServiceName(), r.Namespace, r.GetMongodConfiguration().GetDBPort())
27+
}
28+
return seeds
3229
}
3330

3431
func (r *CommunitySearchSource) KeyfileSecretName() string {
3532
return r.MongoDBCommunity.GetAgentKeyfileSecretNamespacedName().Name
3633
}
3734

38-
func (r *CommunitySearchSource) GetNamespace() string {
39-
return r.Namespace
40-
}
41-
42-
func (r *CommunitySearchSource) DatabaseServiceName() string {
43-
return r.ServiceName()
44-
}
45-
4635
func (r *CommunitySearchSource) IsSecurityTLSConfigEnabled() bool {
4736
return r.Spec.Security.TLS.Enabled
4837
}
4938

50-
func (r *CommunitySearchSource) DatabasePort() int {
51-
return r.MongoDBCommunity.GetMongodConfiguration().GetDBPort()
52-
}
53-
5439
func (r *CommunitySearchSource) TLSOperatorCASecretNamespacedName() types.NamespacedName {
5540
return r.MongoDBCommunity.TLSOperatorCASecretNamespacedName()
5641
}

controllers/search_controller/enterprise_search_source.go

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,12 @@ func NewEnterpriseResourceSearchSource(mdb *mdbv1.MongoDB) SearchSourceDBResourc
2020
return EnterpriseResourceSearchSource{mdb}
2121
}
2222

23-
func (r EnterpriseResourceSearchSource) NamespacedName() types.NamespacedName {
24-
return types.NamespacedName{
25-
Name: r.Name,
26-
Namespace: r.Namespace,
23+
func (r EnterpriseResourceSearchSource) HostSeeds() []string {
24+
seeds := make([]string, r.Spec.Members)
25+
for i := range seeds {
26+
seeds[i] = fmt.Sprintf("%s-%d.%s.%s.svc.cluster.local:%d", r.Name, i, r.ServiceName(), r.Namespace, r.Spec.GetAdditionalMongodConfig().GetPortOrDefault())
2727
}
28-
}
29-
30-
func (r EnterpriseResourceSearchSource) Members() int {
31-
return r.Spec.Replicas()
32-
}
33-
34-
func (r EnterpriseResourceSearchSource) GetMongoDBVersion() string {
35-
return r.Spec.GetMongoDBVersion()
36-
}
37-
38-
func (r EnterpriseResourceSearchSource) DatabasePort() int {
39-
return int(r.MongoDB.Spec.GetAdditionalMongodConfig().GetPortOrDefault())
40-
}
41-
42-
func (r EnterpriseResourceSearchSource) DatabaseServiceName() string {
43-
return r.ServiceName()
28+
return seeds
4429
}
4530

4631
func (r EnterpriseResourceSearchSource) KeyfileSecretName() string {
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package search_controller
2+
3+
import (
4+
"k8s.io/apimachinery/pkg/types"
5+
6+
searchv1 "github.com/mongodb/mongodb-kubernetes/api/v1/search"
7+
)
8+
9+
func NewExternalSearchSource(namespace string, spec *searchv1.ExternalMongoDBSource) SearchSourceDBResource {
10+
return &externalSearchResource{namespace: namespace, spec: spec}
11+
}
12+
13+
// externalSearchResource implements SearchSourceDBResource for deployments managed outside the operator.
14+
type externalSearchResource struct {
15+
namespace string
16+
spec *searchv1.ExternalMongoDBSource
17+
}
18+
19+
func (r *externalSearchResource) Validate() error {
20+
return nil
21+
}
22+
23+
func (r *externalSearchResource) KeyfileSecretName() string {
24+
if r.spec.KeyFileSecretKeyRef != nil {
25+
return r.spec.KeyFileSecretKeyRef.Name
26+
}
27+
28+
return ""
29+
}
30+
31+
func (r *externalSearchResource) IsSecurityTLSConfigEnabled() bool {
32+
return r.spec.TLS != nil && r.spec.TLS.Enabled
33+
}
34+
35+
func (r *externalSearchResource) TLSOperatorCASecretNamespacedName() types.NamespacedName {
36+
if r.spec.TLS != nil && r.spec.TLS.CA != nil {
37+
return types.NamespacedName{
38+
Name: r.spec.TLS.CA.Name,
39+
Namespace: r.namespace,
40+
}
41+
}
42+
43+
return types.NamespacedName{}
44+
}
45+
46+
func (r *externalSearchResource) HostSeeds() []string { return r.spec.HostAndPorts }

0 commit comments

Comments
 (0)