@@ -48,7 +48,7 @@ type AtlasProjectSpec struct {
4848 // ConnectionSecret is the name of the Kubernetes Secret which contains the information about the way to connect to
4949 // Atlas (organization ID, API keys). The default Operator connection configuration will be used if not provided.
5050 // +optional
51- ConnectionSecret * common.ResourceRef `json:"connectionSecretRef,omitempty"`
51+ ConnectionSecret * common.ResourceRefNamespaced `json:"connectionSecretRef,omitempty"`
5252
5353 // ProjectIPAccessList allows to enable the IP Access List for the Project. See more information at
5454 // https://docs.atlas.mongodb.com/reference/api/ip-access-list/add-entries-to-access-list/
@@ -142,7 +142,12 @@ func (p AtlasProject) ID() string {
142142
143143func (p * AtlasProject ) ConnectionSecretObjectKey () * client.ObjectKey {
144144 if p .Spec .ConnectionSecret != nil {
145- key := kube .ObjectKey (p .Namespace , p .Spec .ConnectionSecret .Name )
145+ var key client.ObjectKey
146+ if p .Spec .ConnectionSecret .Namespace != "" {
147+ key = kube .ObjectKey (p .Spec .ConnectionSecret .Namespace , p .Spec .ConnectionSecret .Name )
148+ } else {
149+ key = kube .ObjectKey (p .Namespace , p .Spec .ConnectionSecret .Name )
150+ }
146151 return & key
147152 }
148153 return nil
@@ -203,7 +208,14 @@ func (p *AtlasProject) WithAtlasName(name string) *AtlasProject {
203208
204209func (p * AtlasProject ) WithConnectionSecret (name string ) * AtlasProject {
205210 if name != "" {
206- p .Spec .ConnectionSecret = & common.ResourceRef {Name : name }
211+ p .Spec .ConnectionSecret = & common.ResourceRefNamespaced {Name : name , Namespace : p .Namespace }
212+ }
213+ return p
214+ }
215+
216+ func (p * AtlasProject ) WithConnectionSecretNamespaced (name , namespace string ) * AtlasProject {
217+ if name != "" {
218+ p .Spec .ConnectionSecret = & common.ResourceRefNamespaced {Name : name , Namespace : namespace }
207219 }
208220 return p
209221}
0 commit comments