Skip to content

Commit

Permalink
CLOUDP-295015: [Local Atlas Experience] Add support for private Docke…
Browse files Browse the repository at this point in the history
…r registries (#3575)
  • Loading branch information
jeroenvervaeke authored Jan 24, 2025
1 parent 57bb6d5 commit 2224a16
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
18 changes: 17 additions & 1 deletion internal/cli/deployments/options/deployment_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"fmt"
"io"
"os"
"regexp"
"sort"
"strings"
Expand Down Expand Up @@ -130,8 +131,23 @@ func (opts *DeploymentOpts) LocalMongodHostname() string {

var LocalDevImage = "docker.io/mongodb/mongodb-atlas-local"

func getLocalDevImage() string {
// First check environment variable
if envImage := os.Getenv("ATLAS_LOCAL_DEPLOYMENT_IMAGE"); envImage != "" {
return envImage
}

// Then check profile settings
if profileImage := config.Default().GetLocalDeploymentImage(); profileImage != "" {
return profileImage
}

// Fall back to default image
return LocalDevImage
}

func (opts *DeploymentOpts) MongodDockerImageName() string {
return LocalDevImage + ":" + opts.MdbVersion
return getLocalDevImage() + ":" + opts.MdbVersion
}

func (opts *DeploymentOpts) Spin(funcs ...func() error) error {
Expand Down
14 changes: 14 additions & 0 deletions internal/config/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const (
DockerContainerHostName = "container"
GitHubActionsHostName = "all_github_actions"
AtlasActionHostName = "atlascli_github_action"
LocalDeploymentImage = "local_deployment_image" // LocalDeploymentImage is the config key for the MongoDB Local Dev Docker image
)

var (
Expand Down Expand Up @@ -136,6 +137,7 @@ func GlobalProperties() []string {
skipUpdateCheck,
TelemetryEnabledProperty,
mongoShellPath,
LocalDeploymentImage,
}
}

Expand Down Expand Up @@ -743,3 +745,15 @@ func Path(f string) (string, error) {
p.WriteString(f)
return p.String(), nil
}

// GetLocalDeploymentImage returns the configured MongoDB Docker image URL.
func GetLocalDeploymentImage() string { return Default().GetLocalDeploymentImage() }
func (p *Profile) GetLocalDeploymentImage() string {
return p.GetString(LocalDeploymentImage)
}

// SetLocalDeploymentImage sets the MongoDB Docker image URL.
func SetLocalDeploymentImage(v string) { Default().SetLocalDeploymentImage(v) }
func (*Profile) SetLocalDeploymentImage(v string) {
SetGlobal(LocalDeploymentImage, v)
}

0 comments on commit 2224a16

Please sign in to comment.