Skip to content

Commit

Permalink
Use correct registries to integrate with new packages workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
abhay-krishna committed Jul 26, 2024
1 parent e24df70 commit 61b3006
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
16 changes: 8 additions & 8 deletions pkg/curatedpackages/packagecontrollerclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,24 +243,24 @@ func (pc *PackageControllerClient) Enable(ctx context.Context) error {
func (pc *PackageControllerClient) GetCuratedPackagesRegistries(ctx context.Context) (sourceRegistry, defaultRegistry, defaultImageRegistry string) {
sourceRegistry = publicProdECR
defaultImageRegistry = packageProdDomain
accountName := prodAccount
if strings.Contains(pc.chart.Image(), devAccount) {
accountName = devAccount
registry := prodRegistry
if strings.Contains(pc.chart.Image(), devRegistry) {
registry = devRegistry

Check warning on line 248 in pkg/curatedpackages/packagecontrollerclient.go

View check run for this annotation

Codecov / codecov/patch

pkg/curatedpackages/packagecontrollerclient.go#L248

Added line #L248 was not covered by tests
defaultImageRegistry = packageDevDomain
sourceRegistry = publicDevECR
}
if strings.Contains(pc.chart.Image(), stagingAccount) {
accountName = stagingAccount
if strings.Contains(pc.chart.Image(), stagingRegistry) {
registry = stagingRegistry
defaultImageRegistry = packageProdDomain
sourceRegistry = publicStagingECR
}
defaultRegistry = sourceRegistry

if pc.registryMirror != nil {
// account is added as part of registry name in package controller helm chart
// registry name is added as part of sourceRegistry field in package controller helm chart
// https://github.com/aws/eks-anywhere-packages/blob/main/charts/eks-anywhere-packages/values.yaml#L15-L18
sourceRegistry = fmt.Sprintf("%s/%s", pc.registryMirror.CoreEKSAMirror(), accountName)
defaultRegistry = fmt.Sprintf("%s/%s", pc.registryMirror.CoreEKSAMirror(), accountName)
sourceRegistry = fmt.Sprintf("%s/%s", pc.registryMirror.CoreEKSAMirror(), registry)
defaultRegistry = fmt.Sprintf("%s/%s", pc.registryMirror.CoreEKSAMirror(), registry)
if gatedOCINamespace := pc.registryMirror.CuratedPackagesMirror(); gatedOCINamespace != "" {
defaultImageRegistry = gatedOCINamespace
}
Expand Down
20 changes: 13 additions & 7 deletions pkg/curatedpackages/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import (
// Temporary: Curated packages dev and prod accounts are currently hard coded
// This is because there is no mechanism to extract these values as of now.
const (
prodAccount = "eks-anywhere"
devAccount = "l0g8r8j6"
stagingAccount = "w9m0f3l5"
publicProdECR = "public.ecr.aws/" + prodAccount
publicDevECR = "public.ecr.aws/" + devAccount
publicStagingECR = "public.ecr.aws/" + stagingAccount
prodRegistry = "eks-anywhere"
devRegistry = "x3k6m8v0"
stagingRegistry = "w9m0f3l5"
publicProdECR = "public.ecr.aws/" + prodRegistry
publicDevECR = "public.ecr.aws/" + devRegistry
publicStagingECR = "public.ecr.aws/" + stagingRegistry
packageProdDomain = "783794618700.dkr.ecr.us-west-2.amazonaws.com"
packageDevDomain = "857151390494.dkr.ecr.us-west-2.amazonaws.com"
packageDevDomain = "067575901363.dkr.ecr.us-west-2.amazonaws.com"
)

type PackageReader struct {
Expand Down Expand Up @@ -149,12 +149,18 @@ func getChartRegistry(uri string) string {
if strings.Contains(uri, publicProdECR) {
return publicProdECR
}
if strings.Contains(uri, publicStagingECR) {
return publicStagingECR

Check warning on line 153 in pkg/curatedpackages/reader.go

View check run for this annotation

Codecov / codecov/patch

pkg/curatedpackages/reader.go#L153

Added line #L153 was not covered by tests
}
return publicDevECR
}

func getImageRegistry(uri, awsRegion string) string {
if strings.Contains(uri, publicProdECR) {
return strings.ReplaceAll(packageProdDomain, eksaDefaultRegion, awsRegion)
}
if strings.Contains(uri, publicStagingECR) {
return strings.ReplaceAll(packageProdDomain, eksaDefaultRegion, awsRegion)

Check warning on line 163 in pkg/curatedpackages/reader.go

View check run for this annotation

Codecov / codecov/patch

pkg/curatedpackages/reader.go#L163

Added line #L163 was not covered by tests
}
return strings.ReplaceAll(packageDevDomain, eksaDefaultRegion, awsRegion)
}
6 changes: 3 additions & 3 deletions pkg/curatedpackages/regional_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
const (
devRegionalECR string = "067575901363.dkr.ecr.us-west-2.amazonaws.com"
devRegionalPublicECR string = "public.ecr.aws/x3k6m8v0"
stagingRegionalECR string = "067575901363.dkr.ecr.us-west-2.amazonaws.com"
stagingRegionalECR string = "724423470321.dkr.ecr.us-west-2.amazonaws.com"
)

var prodRegionalECRMap = map[string]string{
Expand Down Expand Up @@ -101,10 +101,10 @@ func TestRegistryWithAuthToken(authToken, registry string, do Do) error {

// GetRegionalRegistry get the regional registry corresponding to defaultRegistry in a specific region.
func GetRegionalRegistry(defaultRegistry, region string) string {
if strings.Contains(defaultRegistry, devAccount) {
if strings.Contains(defaultRegistry, devRegistry) {
return devRegionalECR
}
if strings.Contains(defaultRegistry, stagingAccount) {
if strings.Contains(defaultRegistry, stagingRegistry) {
return stagingRegionalECR
}
return prodRegionalECRMap[region]
Expand Down

0 comments on commit 61b3006

Please sign in to comment.