Skip to content

[Feature]: RegistryCred multiple private registry credentials support #532

@szaher

Description

@szaher

Problem

At the moment testcontainers supports providing registry credentials via RegistryCred in ContainerRequest but this is problematic when using multiple private docker registries specially with multi-stage docker files.


FROM ACCOUNT1.dkr.ecr.us-east-1.amazonaws.com/myimages/app:v1.0
FROM ACCOUNT2.dkr.ecr.us-west-2.amazonaws.com/mirror/alpine:4.0.0 as curl

RUN apk add --no-cache --update curl

FROM curl as curl_container
ENV GRPC_HEALTH_PROBE_VERSION v0.2.2
RUN curl -fsSL https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 -o /grpc_health_probe \
  && chmod +x /grpc_health_probe


Solution

RegistryCred parameter's type in the container request can be map[string]map[string]string

var registryCreds map[string]map[string]string
registryCreds["ACCOUNT1.dkr.ecr.us-east-1.amazonaws.com"] = map[string]string{"username": "Saad", "password": "123"}

or

import types
func GetRegistryCreds() {
	var registryCreds map[string]types.AuthConfig

	auth1 := types.AuthConfig{
		Username: "Saad",
		Password: "2407",
	}
	registryCreds["ACCOUNT1.dkr.ecr.us-east-1.amazonaws.com"] = auth1
	
	auth2 := types.AuthConfig{
		Username:      "User2",
		Password:      "1808",
	}
	registryCreds["ACCOUNT2.dkr.ecr.us-west-2.amazonaws.com"] = auth2
}


Benefit

It enables support for multiple private registries

Alternatives

user must have all his/her images on private repo

Would you like to help contributing this feature?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew functionality or new behaviors on the existing onehacktoberfestPull Requests accepted for Hacktoberfest.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions