77 "fmt"
88 "io/ioutil"
99 "os"
10+ "strings"
1011 "time"
1112
1213 "github.com/mongodb/mongodb-kubernetes-operator/pkg/util/envvar"
@@ -56,6 +57,8 @@ const (
5657 agentImageEnv = "AGENT_IMAGE"
5758 versionUpgradeHookImageEnv = "VERSION_UPGRADE_HOOK_IMAGE"
5859 agentHealthStatusFilePathEnv = "AGENT_STATUS_FILEPATH"
60+ mongodbImageEnv = "MONGODB_IMAGE"
61+ mongodbRepoUrl = "MONGODB_REPO_URL"
5962 mongodbToolsVersionEnv = "MONGODB_TOOLS_VERSION"
6063
6164 AutomationConfigKey = "automation-config"
@@ -505,7 +508,7 @@ func getMongodConfigModification(mdb mdbv1.MongoDB) automationconfig.Modificatio
505508 return func (ac * automationconfig.AutomationConfig ) {
506509 for i := range ac .Processes {
507510 // Mergo requires both objects to have the same type
508- // TODO: proper error handling
511+ // TODO: handle this error gracefully, we may need to add an error as second argument for all modification functions
509512 _ = mergo .Merge (& ac .Processes [i ].Args26 , objx .New (mdb .Spec .AdditionalMongodConfig .Object ), mergo .WithOverride )
510513 }
511514 }
@@ -572,6 +575,15 @@ func versionUpgradeHookInit(volumeMount []corev1.VolumeMount) container.Modifica
572575 )
573576}
574577
578+ func getMongoDBImage (version string ) string {
579+ repoUrl := os .Getenv (mongodbRepoUrl )
580+ if strings .HasSuffix (repoUrl , "/" ) {
581+ repoUrl = strings .TrimRight (repoUrl , "/" )
582+ }
583+ mongoImageName := os .Getenv (mongodbImageEnv )
584+ return fmt .Sprintf ("%s/%s:%s" , repoUrl , mongoImageName , version )
585+ }
586+
575587func mongodbContainer (version string , volumeMounts []corev1.VolumeMount ) container.Modification {
576588 mongoDbCommand := []string {
577589 "/bin/sh" ,
@@ -590,7 +602,7 @@ exec mongod -f /data/automation-mongod.conf ;
590602
591603 return container .Apply (
592604 container .WithName (mongodbName ),
593- container .WithImage (fmt . Sprintf ( "mongo:%s" , version )),
605+ container .WithImage (getMongoDBImage ( version )),
594606 container .WithResourceRequirements (resourcerequirements .Defaults ()),
595607 container .WithCommand (mongoDbCommand ),
596608 container .WithEnvs (
0 commit comments