Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support creating namespaced ECR repositories #386

Merged
merged 2 commits into from
Apr 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions docker/ecr/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"log"
"os"
"strings"

"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/ecr"
Expand All @@ -17,10 +18,10 @@ import (
)

func EnsureRepositoryExistsFunc(registryAddress, ecrLifecyclePolicy string) func(
_, repositoryName string, _ ...string,
destRegistry, repositoryName string, _ ...string,
) error {
return func(
_, repositoryName string, _ ...string,
destRegistry, repositoryName string, _ ...string,
) error {
_, _, region, err := ParseECRRegistry(registryAddress)
if err != nil {
Expand All @@ -31,6 +32,11 @@ func EnsureRepositoryExistsFunc(registryAddress, ecrLifecyclePolicy string) func
log.Fatalf("unable to load SDK config, %v", err)
}

// if destRegistry has a path append it when creating the repository
if _, path, found := strings.Cut(destRegistry, "/"); found && len(path) > 0 {
repositoryName = fmt.Sprintf("%s/%s", path, repositoryName)
dkoshkin marked this conversation as resolved.
Show resolved Hide resolved
}

// Using the Config value, create the S3 client
svc := ecr.NewFromConfig(cfg)
repos, err := svc.DescribeRepositories(
Expand Down