Skip to content

Commit 3dcf495

Browse files
committed
Move more security fields
1 parent e049b9c commit 3dcf495

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

api/v1/mdb/mongodb_security_types.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ type Security struct {
1919
CertificatesSecretsPrefix string `json:"certsSecretPrefix"`
2020
}
2121

22+
func newSecurity() *Security {
23+
return &Security{TLSConfig: &TLSConfig{}}
24+
}
25+
26+
func EnsureSecurity(sec *Security) *Security {
27+
if sec == nil {
28+
sec = newSecurity()
29+
}
30+
if sec.TLSConfig == nil {
31+
sec.TLSConfig = &TLSConfig{}
32+
}
33+
if sec.Roles == nil {
34+
sec.Roles = make([]MongoDbRole, 0)
35+
}
36+
return sec
37+
}
38+
2239
// MemberCertificateSecretName returns the name of the secret containing the member TLS certs.
2340
func (s *Security) MemberCertificateSecretName(defaultName string) string {
2441
if s.CertificatesSecretsPrefix != "" {
@@ -170,6 +187,10 @@ type Authentication struct {
170187
RequiresClientTLSAuthentication bool `json:"requireClientTLSAuthentication,omitempty"`
171188
}
172189

190+
func newAuthentication() *Authentication {
191+
return &Authentication{Modes: []AuthMode{}}
192+
}
193+
173194
// +kubebuilder:validation:Enum=X509;SCRAM;SCRAM-SHA-1;MONGODB-CR;SCRAM-SHA-256;LDAP;OIDC
174195
type AuthMode string
175196

@@ -455,3 +476,7 @@ func (m *MongoDB) IsOIDCEnabled() bool {
455476
}
456477
return m.Spec.Security.Authentication.IsOIDCEnabled()
457478
}
479+
480+
func (m *MongoDB) GetAuthenticationModes() []string {
481+
return m.Spec.Security.Authentication.GetModes()
482+
}

api/v1/mdb/mongodb_types.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -935,37 +935,12 @@ func NewOpsManagerConfig() *PrivateCloudConfig {
935935
return &PrivateCloudConfig{}
936936
}
937937

938-
func EnsureSecurity(sec *Security) *Security {
939-
if sec == nil {
940-
sec = newSecurity()
941-
}
942-
if sec.TLSConfig == nil {
943-
sec.TLSConfig = &TLSConfig{}
944-
}
945-
if sec.Roles == nil {
946-
sec.Roles = make([]MongoDbRole, 0)
947-
}
948-
return sec
949-
}
950-
951-
func newAuthentication() *Authentication {
952-
return &Authentication{Modes: []AuthMode{}}
953-
}
954-
955-
func newSecurity() *Security {
956-
return &Security{TLSConfig: &TLSConfig{}}
957-
}
958-
959938
// BuildConnectionString returns a string with a connection string for this resource.
960939
func (m *MongoDB) BuildConnectionString(username, password string, scheme connectionstring.Scheme, connectionParams map[string]string) string {
961940
builder := NewMongoDBConnectionStringBuilder(*m, nil)
962941
return builder.BuildConnectionString(username, password, scheme, connectionParams)
963942
}
964943

965-
func (m *MongoDB) GetAuthenticationModes() []string {
966-
return m.Spec.Security.Authentication.GetModes()
967-
}
968-
969944
func (m *MongoDB) CalculateFeatureCompatibilityVersion() string {
970945
return fcv.CalculateFeatureCompatibilityVersion(m.Spec.Version, m.Status.FeatureCompatibilityVersion, m.Spec.FeatureCompatibilityVersion)
971946
}

0 commit comments

Comments
 (0)