diff --git a/release/cli/pkg/images/images.go b/release/cli/pkg/images/images.go index c73cc152a258..4517aada973b 100644 --- a/release/cli/pkg/images/images.go +++ b/release/cli/pkg/images/images.go @@ -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) diff --git a/release/cli/pkg/operations/upload.go b/release/cli/pkg/operations/upload.go index caa48040488c..f50a831ae1f8 100644 --- a/release/cli/pkg/operations/upload.go +++ b/release/cli/pkg/operations/upload.go @@ -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