@@ -651,17 +651,18 @@ func (e *ClusterE2ETest) CleanupDownloadedArtifactsAndImages(opts ...CommandOpt)
651651 e .Run ("rm" , "-rf" , defaultDownloadArtifactsOutputLocation , defaultDownloadImagesOutputLocation )
652652}
653653
654+ func getBundleManifestLocation () string {
655+ if _ , err := os .Stat (defaultDownloadArtifactsOutputLocation ); err == nil {
656+ return bundleReleasePathFromArtifacts
657+ }
658+ return defaultBundleReleaseManifestFile
659+ }
660+
654661// DownloadImages runs the EKS-A `download images` command with appropriate args.
655662func (e * ClusterE2ETest ) DownloadImages (opts ... CommandOpt ) {
656663 downloadImagesArgs := []string {"download" , "images" , "-o" , defaultDownloadImagesOutputLocation }
657664 if getBundlesOverride () == "true" {
658- var bundleManifestLocation string
659- if _ , err := os .Stat (defaultDownloadArtifactsOutputLocation ); err == nil {
660- bundleManifestLocation = bundleReleasePathFromArtifacts
661- } else {
662- bundleManifestLocation = defaultBundleReleaseManifestFile
663- }
664- downloadImagesArgs = append (downloadImagesArgs , "--bundles-override" , bundleManifestLocation )
665+ downloadImagesArgs = append (downloadImagesArgs , "--bundles-override" , getBundleManifestLocation ())
665666 }
666667 e .RunEKSA (downloadImagesArgs , opts ... )
667668 if _ , err := os .Stat (defaultDownloadImagesOutputLocation ); err != nil {
@@ -676,18 +677,38 @@ func (e *ClusterE2ETest) ImportImages(opts ...CommandOpt) {
676677 clusterConfig := e .ClusterConfig .Cluster
677678 registyMirrorEndpoint , registryMirrorPort := clusterConfig .Spec .RegistryMirrorConfiguration .Endpoint , clusterConfig .Spec .RegistryMirrorConfiguration .Port
678679 registryMirrorHost := net .JoinHostPort (registyMirrorEndpoint , registryMirrorPort )
679- var bundleManifestLocation string
680- if _ , err := os .Stat (defaultDownloadArtifactsOutputLocation ); err == nil {
681- bundleManifestLocation = bundleReleasePathFromArtifacts
682- } else {
683- bundleManifestLocation = defaultBundleReleaseManifestFile
684- }
680+ bundleManifestLocation := getBundleManifestLocation ()
685681 importImagesArgs := []string {"import images" , "--input" , defaultDownloadImagesOutputLocation , "--bundles" , bundleManifestLocation , "--registry" , registryMirrorHost , "--insecure" }
686682 e .RunEKSA (importImagesArgs , opts ... )
687683}
688684
685+ // GetPackageControllerRepo returns the bundle's package controller chart image.
686+ func (e * ClusterE2ETest ) GetPackageControlleChartRepo () (string , error ) {
687+ bundleManifestLocation := getBundleManifestLocation ()
688+
689+ // Read the bundle file
690+ bundleData , err := os .ReadFile (bundleManifestLocation )
691+ if err != nil {
692+ return "" , fmt .Errorf ("failed to read bundle file %s: %w" , bundleManifestLocation , err )
693+ }
694+
695+ // Parse the bundle
696+ var bundles releasev1.Bundles
697+ if err := yaml .Unmarshal (bundleData , & bundles ); err != nil {
698+ return "" , fmt .Errorf ("failed to parse bundle file: %w" , err )
699+ }
700+
701+ // Get the package controller chart image from the first version bundle
702+ if len (bundles .Spec .VersionsBundles ) == 0 {
703+ return "" , fmt .Errorf ("no version bundles found in bundle file" )
704+ }
705+
706+ return bundles .Spec .VersionsBundles [0 ].PackageController .HelmChart .Image (), nil
707+
708+ }
709+
689710// CopyPackages runs the EKS-A `copy packages` command to copy curated packages to the registry mirror.
690- func (e * ClusterE2ETest ) CopyPackages (packageMirrorAlias string , packageChartRegistry string , packageRegistry string , opts ... CommandOpt ) {
711+ func (e * ClusterE2ETest ) CopyPackages (packageMirrorAlias string , packageRegistry string , opts ... CommandOpt ) {
691712 clusterConfig := e .ClusterConfig .Cluster
692713 registyMirrorEndpoint , registryMirrorPort := clusterConfig .Spec .RegistryMirrorConfiguration .Endpoint , clusterConfig .Spec .RegistryMirrorConfiguration .Port
693714 registryMirrorHost := net .JoinHostPort (registyMirrorEndpoint , registryMirrorPort )
@@ -700,12 +721,12 @@ func (e *ClusterE2ETest) CopyPackages(packageMirrorAlias string, packageChartReg
700721 "copy" , "packages" ,
701722 registryMirrorHost + "/" + packageMirrorAlias ,
702723 "--kube-version" , kubeVersion ,
703- "--src-chart-registry" , packageChartRegistry ,
724+ "--src-chart-registry" , packageRegistry ,
704725 "--src-image-registry" , packageRegistry ,
705726 "--dst-insecure" ,
706727 }
707728
708- e .T .Logf ("Copying curated packages to registry mirror: %s" , registryMirrorHost )
729+ e .T .Logf ("Copying curated packages to registry mirror: %s/%s " , registryMirrorHost , packageMirrorAlias )
709730 e .RunEKSA (copyPackagesArgs , opts ... )
710731}
711732
@@ -1327,22 +1348,6 @@ func (e *ClusterE2ETest) WithCluster(f func(e *ClusterE2ETest)) {
13271348 f (e )
13281349}
13291350
1330- // WithClusterRegistryMirror helps with bringing up and tearing down E2E test clusters when using registry mirror.
1331- func (e * ClusterE2ETest ) WithClusterRegistryMirror (packageMirrorAlias string , packageChartRegistry string , packageRegistry string , f func (e * ClusterE2ETest )) {
1332- e .GenerateClusterConfig ()
1333- e .DownloadArtifacts ()
1334- e .ExtractDownloadedArtifacts ()
1335- e .DownloadImages ()
1336- e .ImportImages ()
1337- e .CopyPackages (packageMirrorAlias , packageChartRegistry , packageRegistry )
1338- e .CreateCluster (WithBundlesOverride (bundleReleasePathFromArtifacts ))
1339- defer func () {
1340- e .GenerateSupportBundleIfTestFailed ()
1341- e .DeleteCluster (WithBundlesOverride (bundleReleasePathFromArtifacts ))
1342- }()
1343- f (e )
1344- }
1345-
13461351// Like WithCluster but does not delete the cluster. Useful for debugging.
13471352func (e * ClusterE2ETest ) WithPersistentCluster (f func (e * ClusterE2ETest )) {
13481353 configPath := e .KubeconfigFilePath ()
0 commit comments