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

[release-0.21] Use ECR Public source client for image checks in prod bundle release #9016

Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 14 additions & 4 deletions release/cli/pkg/images/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,24 @@ func ComputeImageDigestFromManifest(ecrPublicClient *ecrpublicsdk.ECRPublic, reg
return fmt.Sprintf("%x", digest), nil
}

func CheckRepositoryImagesAndTagsCountLimit(sourceImageUri, releaseImageUri, sourceContainerRegistry, releaseContainerRegistry string, ecrClient *ecrsdk.ECR, ecrPublicClient *ecrpublicsdk.ECRPublic) error {
func CheckRepositoryImagesAndTagsCountLimit(sourceImageUri, releaseImageUri, sourceContainerRegistry, releaseContainerRegistry string, ecrClient interface{}, ecrPublicClient *ecrpublicsdk.ECRPublic) error {
repository, _ := artifactutils.SplitImageUri(releaseImageUri, releaseContainerRegistry)

fmt.Printf("Checking if image %s can be pushed to repository %s\n", releaseImageUri, repository)

sourceImageDigest, err := ecr.GetImageDigest(sourceImageUri, sourceContainerRegistry, ecrClient)
if err != nil {
return errors.Cause(err)
var sourceImageDigest string
var err error
switch ecrClient.(type) {
case *ecrsdk.ECR:
sourceImageDigest, err = ecr.GetImageDigest(sourceImageUri, sourceContainerRegistry, ecrClient.(*ecrsdk.ECR))
if err != nil {
return errors.Cause(err)
}
case *ecrpublicsdk.ECRPublic:
sourceImageDigest, err = ecrpublic.GetImageDigest(sourceImageUri, sourceContainerRegistry, ecrClient.(*ecrpublicsdk.ECRPublic))
if err != nil {
return errors.Cause(err)
}
}

allImagesCount, err := ecrpublic.GetAllImagesCount(repository, ecrPublicClient)
Expand Down
7 changes: 6 additions & 1 deletion release/cli/pkg/operations/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ func handleImageUpload(_ context.Context, r *releasetypes.ReleaseConfig, package
releaseImageUri := artifact.Image.ReleaseImageURI
sourceEcrAuthConfig := defaultSourceEcrAuthConfig
sourceContainerRegistry := r.SourceContainerRegistry
sourceEcrClient := r.SourceClients.ECR.EcrClient
var sourceEcrClient interface{}
if r.ReleaseEnvironment == "production" && r.BundleRelease {
sourceEcrClient = r.SourceClients.ECR.EcrPublicClient
} else {
sourceEcrClient = r.SourceClients.ECR.EcrClient
}
if packagesutils.NeedsPackagesAccountArtifacts(r) && (strings.Contains(sourceImageUri, "eks-anywhere-packages") || strings.Contains(sourceImageUri, "ecr-token-refresher") || strings.Contains(sourceImageUri, "credential-provider-package")) {
sourceEcrAuthConfig = packagesSourceEcrAuthConfig
sourceContainerRegistry = r.PackagesSourceContainerRegistry
Expand Down
Loading