Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions api/v1/mongodbcommunity_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/mongodb/mongodb-kubernetes-operator/pkg/kube/annotations"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"

"github.com/mongodb/mongodb-kubernetes-operator/pkg/automationconfig"
"github.com/mongodb/mongodb-kubernetes-operator/pkg/util/scale"
Expand Down Expand Up @@ -489,27 +490,18 @@ type TLS struct {
// Alternatively, an entry tls.pem, containing the concatenation of cert and key, can be provided.
// If all of tls.pem, tls.crt and tls.key are present, the tls.pem one needs to be equal to the concatenation of tls.crt and tls.key
// +optional
CertificateKeySecret LocalObjectReference `json:"certificateKeySecretRef"`
CertificateKeySecret corev1.LocalObjectReference `json:"certificateKeySecretRef"`

// CaCertificateSecret is a reference to a Secret containing the certificate for the CA which signed the server certificates
// The certificate is expected to be available under the key "ca.crt"
// +optional
CaCertificateSecret *LocalObjectReference `json:"caCertificateSecretRef,omitempty"`
CaCertificateSecret *corev1.LocalObjectReference `json:"caCertificateSecretRef,omitempty"`

// CaConfigMap is a reference to a ConfigMap containing the certificate for the CA which signed the server certificates
// The certificate is expected to be available under the key "ca.crt"
// This field is ignored when CaCertificateSecretRef is configured
// +optional
CaConfigMap *LocalObjectReference `json:"caConfigMapRef,omitempty"`
}

// LocalObjectReference is a reference to another Kubernetes object by name.
// TODO: Replace with a type from the K8s API. CoreV1 has an equivalent
//
// "LocalObjectReference" type but it contains a TODO in its
// description that we don't want in our CRD.
type LocalObjectReference struct {
Name string `json:"name"`
CaConfigMap *corev1.LocalObjectReference `json:"caConfigMapRef,omitempty"`
}

type Authentication struct {
Expand Down
20 changes: 3 additions & 17 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ spec:
under the key "ca.crt"
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
required:
- name
type: object
caConfigMapRef:
description: CaConfigMap is a reference to a ConfigMap containing
Expand All @@ -285,9 +285,9 @@ spec:
is configured
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
required:
- name
type: object
certificateKeySecretRef:
description: CertificateKeySecret is a reference to a Secret
Expand All @@ -302,9 +302,9 @@ spec:
and tls.key
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
required:
- name
type: object
enabled:
type: boolean
Expand Down
12 changes: 6 additions & 6 deletions controllers/mongodb_tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,25 +405,25 @@ func TestPemSupport(t *testing.T) {

func TestTLSConfig_ReferencesToCACertAreValidated(t *testing.T) {
type args struct {
caConfigMap *mdbv1.LocalObjectReference
caCertificateSecret *mdbv1.LocalObjectReference
caConfigMap *corev1.LocalObjectReference
caCertificateSecret *corev1.LocalObjectReference
expectedError error
}
tests := map[string]args{
"Success if reference to CA cert provided via secret": {
caConfigMap: &mdbv1.LocalObjectReference{
caConfigMap: &corev1.LocalObjectReference{
Name: "certificateKeySecret"},
caCertificateSecret: nil,
},
"Success if reference to CA cert provided via config map": {
caConfigMap: nil,
caCertificateSecret: &mdbv1.LocalObjectReference{
caCertificateSecret: &corev1.LocalObjectReference{
Name: "caConfigMap"},
},
"Succes if reference to CA cert provided both via secret and configMap": {
caConfigMap: &mdbv1.LocalObjectReference{
caConfigMap: &corev1.LocalObjectReference{
Name: "certificateKeySecret"},
caCertificateSecret: &mdbv1.LocalObjectReference{
caCertificateSecret: &corev1.LocalObjectReference{
Name: "caConfigMap"},
},
"Failure if reference to CA cert is missing": {
Expand Down
8 changes: 4 additions & 4 deletions controllers/replicaset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ func newScramReplicaSet(users ...mdbv1.MongoDBUser) mdbv1.MongoDBCommunity {
}

func newTestReplicaSetWithTLS() mdbv1.MongoDBCommunity {
return newTestReplicaSetWithTLSCaCertificateReferences(&mdbv1.LocalObjectReference{
return newTestReplicaSetWithTLSCaCertificateReferences(&corev1.LocalObjectReference{
Name: "caConfigMap",
},
&mdbv1.LocalObjectReference{
&corev1.LocalObjectReference{
Name: "certificateKeySecret",
})
}

func newTestReplicaSetWithTLSCaCertificateReferences(caConfigMap, caCertificateSecret *mdbv1.LocalObjectReference) mdbv1.MongoDBCommunity {
func newTestReplicaSetWithTLSCaCertificateReferences(caConfigMap, caCertificateSecret *corev1.LocalObjectReference) mdbv1.MongoDBCommunity {
return mdbv1.MongoDBCommunity{
ObjectMeta: metav1.ObjectMeta{
Name: "my-rs",
Expand All @@ -113,7 +113,7 @@ func newTestReplicaSetWithTLSCaCertificateReferences(caConfigMap, caCertificateS
Enabled: true,
CaConfigMap: caConfigMap,
CaCertificateSecret: caCertificateSecret,
CertificateKeySecret: mdbv1.LocalObjectReference{
CertificateKeySecret: corev1.LocalObjectReference{
Name: "certificateKeySecret",
},
},
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/e2eutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ func NewTestTLSConfig(optional bool) mdbv1.TLS {
return mdbv1.TLS{
Enabled: true,
Optional: optional,
CertificateKeySecret: mdbv1.LocalObjectReference{
CertificateKeySecret: corev1.LocalObjectReference{
Name: "tls-certificate",
},
CaCertificateSecret: &mdbv1.LocalObjectReference{
CaCertificateSecret: &corev1.LocalObjectReference{
Name: "tls-ca-key-pair",
},
}
Expand Down