@@ -226,6 +226,8 @@ func PushImagesFromTempRegistry(airgapRootDir string, imageList []string, option
226
226
defer wc .Close ()
227
227
}
228
228
229
+ totalImages := len (imageInfos )
230
+ var imageCounter int
229
231
for imageID , imageInfo := range imageInfos {
230
232
srcRef , err := tempRegistry .SrcRef (imageID )
231
233
if err != nil {
@@ -280,6 +282,8 @@ func PushImagesFromTempRegistry(airgapRootDir string, imageList []string, option
280
282
ReportWriter : reportWriter ,
281
283
},
282
284
}
285
+ imageCounter ++
286
+ fmt .Printf ("Pushing image %d/%d\n " , imageCounter , totalImages )
283
287
if err := pushImage (pushImageOpts ); err != nil {
284
288
return errors .Wrapf (err , "failed to push image %s" , imageID )
285
289
}
@@ -699,6 +703,8 @@ func PushEmbeddedClusterArtifacts(airgapBundle string, opts imagetypes.PushEmbed
699
703
}
700
704
defer gzipReader .Close ()
701
705
706
+ var artifacts []string
707
+
702
708
tarReader := tar .NewReader (gzipReader )
703
709
pushedArtifacts := make ([]string , 0 )
704
710
for {
@@ -718,52 +724,49 @@ func PushEmbeddedClusterArtifacts(airgapBundle string, opts imagetypes.PushEmbed
718
724
continue
719
725
}
720
726
721
- if err := func () error {
722
- dstFilePath := filepath .Join (tmpDir , header .Name )
723
- if err := os .MkdirAll (filepath .Dir (dstFilePath ), 0755 ); err != nil {
724
- return errors .Wrap (err , "failed to create path" )
725
- }
726
- defer os .RemoveAll (dstFilePath )
727
+ dstFilePath := filepath .Join (tmpDir , header .Name )
728
+ if err := os .MkdirAll (filepath .Dir (dstFilePath ), 0755 ); err != nil {
729
+ return nil , errors .Wrap (err , "failed to create path" )
730
+ }
727
731
728
- dstFile , err := os .Create (dstFilePath )
729
- if err != nil {
730
- return errors .Wrap (err , "failed to create file" )
731
- }
732
- defer dstFile .Close ()
732
+ dstFile , err := os .Create (dstFilePath )
733
+ if err != nil {
734
+ return nil , errors .Wrap (err , "failed to create file" )
735
+ }
733
736
734
- if _ , err := io .Copy (dstFile , tarReader ); err != nil {
735
- return errors .Wrap (err , "failed to copy file data" )
736
- }
737
+ if _ , err := io .Copy (dstFile , tarReader ); err != nil {
738
+ dstFile .Close ()
739
+ return nil , errors .Wrap (err , "failed to copy file data" )
740
+ }
737
741
738
- // push each file as an oci artifact to the registry
739
- name := filepath .Base (dstFilePath )
740
- repository := filepath .Join ("embedded-cluster" , imageutil .SanitizeRepo (name ))
741
- artifactFile := imagetypes.OCIArtifactFile {
742
- Name : name ,
743
- Path : dstFilePath ,
744
- MediaType : EmbeddedClusterMediaType ,
745
- }
742
+ dstFile .Close ()
743
+ artifacts = append (artifacts , dstFilePath )
744
+ }
746
745
747
- pushOCIArtifactOpts := imagetypes. PushOCIArtifactOptions {
748
- Files : []imagetypes. OCIArtifactFile { artifactFile },
749
- ArtifactType : EmbeddedClusterArtifactType ,
750
- Registry : opts . Registry ,
751
- Repository : repository ,
752
- Tag : opts . Tag ,
753
- HTTPClient : opts . HTTPClient ,
754
- }
746
+ for i , dstFilePath := range artifacts {
747
+ name := filepath . Base ( dstFilePath )
748
+ repository := filepath . Join ( "embedded-cluster" , imageutil . SanitizeRepo ( name ))
749
+ artifactFile := imagetypes. OCIArtifactFile {
750
+ Name : name ,
751
+ Path : dstFilePath ,
752
+ MediaType : EmbeddedClusterMediaType ,
753
+ }
755
754
756
- artifact := fmt .Sprintf ("%s:%s" , filepath .Join (opts .Registry .Endpoint , opts .Registry .Namespace , repository ), opts .Tag )
757
- fmt .Printf ("Pushing artifact %s\n " , artifact )
758
- if err := pushOCIArtifact (pushOCIArtifactOpts ); err != nil {
759
- return errors .Wrapf (err , "failed to push oci artifact %s" , name )
760
- }
761
- pushedArtifacts = append (pushedArtifacts , artifact )
755
+ pushOCIArtifactOpts := imagetypes.PushOCIArtifactOptions {
756
+ Files : []imagetypes.OCIArtifactFile {artifactFile },
757
+ ArtifactType : EmbeddedClusterArtifactType ,
758
+ Registry : opts .Registry ,
759
+ Repository : repository ,
760
+ Tag : opts .Tag ,
761
+ HTTPClient : opts .HTTPClient ,
762
+ }
762
763
763
- return nil
764
- }(); err != nil {
765
- return nil , err
764
+ fmt .Printf ("Pushing embedded cluster artifact %d/%d\n " , i + 1 , len (artifacts ))
765
+ artifact := fmt .Sprintf ("%s:%s" , filepath .Join (opts .Registry .Endpoint , opts .Registry .Namespace , repository ), opts .Tag )
766
+ if err := pushOCIArtifact (pushOCIArtifactOpts ); err != nil {
767
+ return nil , errors .Wrapf (err , "failed to push oci artifact %s" , name )
766
768
}
769
+ pushedArtifacts = append (pushedArtifacts , artifact )
767
770
}
768
771
769
772
return pushedArtifacts , nil
0 commit comments