diff --git a/app/gitspace/orchestrator/container/devcontainer_container_utils.go b/app/gitspace/orchestrator/container/devcontainer_container_utils.go index ea3c49899..d6a3cc799 100644 --- a/app/gitspace/orchestrator/container/devcontainer_container_utils.go +++ b/app/gitspace/orchestrator/container/devcontainer_container_utils.go @@ -306,7 +306,7 @@ func PullImage( dockerClient *client.Client, runArgsMap map[types.RunArg]*types.RunArgValue, gitspaceLogger gitspaceTypes.GitspaceLogger, - dockerRegistryAuth gitspaceTypes.DockerRegistryAuth, + imageAuthMap map[string]gitspaceTypes.DockerRegistryAuth, ) error { imagePullRunArg := getImagePullPolicy(runArgsMap) gitspaceLogger.Info("Image pull policy is: " + imagePullRunArg) @@ -331,7 +331,7 @@ func PullImage( gitspaceLogger.Info("Pulling image: " + imageName) - pullOpts, err := buildImagePullOptions(getPlatform(runArgsMap), dockerRegistryAuth) + pullOpts, err := buildImagePullOptions(imageName, getPlatform(runArgsMap), imageAuthMap) if err != nil { return logStreamWrapError(gitspaceLogger, "Error building image pull options", err) } @@ -400,15 +400,16 @@ func isImagePresentLocally(ctx context.Context, imageName string, dockerClient * } func buildImagePullOptions( + imageName, platform string, - dockerRegistryAuth gitspaceTypes.DockerRegistryAuth, + imageAuthMap map[string]gitspaceTypes.DockerRegistryAuth, ) (image.PullOptions, error) { pullOpts := image.PullOptions{Platform: platform} - if dockerRegistryAuth.RegistryURL != "" { + if imageAuth, ok := imageAuthMap[imageName]; ok { authConfig := registry.AuthConfig{ - Username: dockerRegistryAuth.Username.Value(), - Password: dockerRegistryAuth.Password.Value(), - ServerAddress: dockerRegistryAuth.RegistryURL, + Username: imageAuth.Username.Value(), + Password: imageAuth.Password.Value(), + ServerAddress: imageAuth.RegistryURL, } auth, err := encodeAuthToBase64(authConfig) if err != nil { diff --git a/app/gitspace/orchestrator/container/embedded_docker_container_orchestrator.go b/app/gitspace/orchestrator/container/embedded_docker_container_orchestrator.go index fc0e68674..d4cf056f3 100644 --- a/app/gitspace/orchestrator/container/embedded_docker_container_orchestrator.go +++ b/app/gitspace/orchestrator/container/embedded_docker_container_orchestrator.go @@ -116,7 +116,7 @@ func (e *EmbeddedDockerOrchestrator) CreateAndStartGitspace( defer e.closeDockerClient(dockerClient) // todo : update the code when private repository integration is supported in gitness - dockerRegistryAuth := gitspaceTypes.DockerRegistryAuth{} + imagAuthMap := make(map[string]gitspaceTypes.DockerRegistryAuth) // Step 3: Check the current state of the container state, err := e.checkContainerState(ctx, dockerClient, containerName) @@ -149,7 +149,7 @@ func (e *EmbeddedDockerOrchestrator) CreateAndStartGitspace( infra, defaultBaseImage, ideService, - dockerRegistryAuth); err != nil { + imagAuthMap); err != nil { return nil, err } case ContainerStatePaused, ContainerStateCreated, ContainerStateUnknown, ContainerStateDead: @@ -375,7 +375,7 @@ func (e *EmbeddedDockerOrchestrator) runGitspaceSetupSteps( resolvedRepoDetails scm.ResolvedDetails, defaultBaseImage string, gitspaceLogger gitspaceTypes.GitspaceLogger, - dockerRegistryAuth gitspaceTypes.DockerRegistryAuth, + imageAuthMap map[string]gitspaceTypes.DockerRegistryAuth, ) error { homeDir := GetUserHomeDir(gitspaceConfig.GitspaceUser.Identifier) containerName := GetGitspaceContainerName(gitspaceConfig) @@ -393,7 +393,7 @@ func (e *EmbeddedDockerOrchestrator) runGitspaceSetupSteps( } // Pull the required image - if err := PullImage(ctx, imageName, dockerClient, runArgsMap, gitspaceLogger, dockerRegistryAuth); err != nil { + if err := PullImage(ctx, imageName, dockerClient, runArgsMap, gitspaceLogger, imageAuthMap); err != nil { return err } portMappings := infrastructure.GitspacePortMappings @@ -683,7 +683,7 @@ func (e *EmbeddedDockerOrchestrator) createAndStartNewGitspace( infrastructure types.Infrastructure, defaultBaseImage string, ideService ide.IDE, - dockerRegistryAuth gitspaceTypes.DockerRegistryAuth, + imageAuthMap map[string]gitspaceTypes.DockerRegistryAuth, ) error { logStreamInstance, err := e.statefulLogger.CreateLogStream(ctx, gitspaceConfig.ID) if err != nil { @@ -700,7 +700,7 @@ func (e *EmbeddedDockerOrchestrator) createAndStartNewGitspace( resolvedRepoDetails, defaultBaseImage, logStreamInstance, - dockerRegistryAuth, + imageAuthMap, ) if startErr != nil { return fmt.Errorf("failed to start gitspace %s: %w", gitspaceConfig.Identifier, startErr)