@@ -172,6 +172,7 @@ func TagAndPushImagesFromBundle(airgapBundle string, options imagetypes.PushImag
172
172
Registry : options .Registry ,
173
173
Tag : imageutil .SanitizeTag (fmt .Sprintf ("%s-%s-%s" , airgap .Spec .ChannelID , airgap .Spec .UpdateCursor , airgap .Spec .VersionLabel )),
174
174
HTTPClient : orasretry .DefaultClient ,
175
+ LogForUI : options .LogForUI ,
175
176
}
176
177
pushedArtifacts , err := PushEmbeddedClusterArtifacts (airgapBundle , pushEmbeddedArtifactsOpts )
177
178
if err != nil {
@@ -226,6 +227,8 @@ func PushImagesFromTempRegistry(airgapRootDir string, imageList []string, option
226
227
defer wc .Close ()
227
228
}
228
229
230
+ totalImages := len (imageInfos )
231
+ var imageCounter int
229
232
for imageID , imageInfo := range imageInfos {
230
233
srcRef , err := tempRegistry .SrcRef (imageID )
231
234
if err != nil {
@@ -280,6 +283,10 @@ func PushImagesFromTempRegistry(airgapRootDir string, imageList []string, option
280
283
ReportWriter : reportWriter ,
281
284
},
282
285
}
286
+ imageCounter ++
287
+ if pushImageOpts .LogForUI {
288
+ fmt .Printf ("Pushing image %d/%d\n " , imageCounter , totalImages )
289
+ }
283
290
if err := pushImage (pushImageOpts ); err != nil {
284
291
return errors .Wrapf (err , "failed to push image %s" , imageID )
285
292
}
@@ -699,6 +706,8 @@ func PushEmbeddedClusterArtifacts(airgapBundle string, opts imagetypes.PushEmbed
699
706
}
700
707
defer gzipReader .Close ()
701
708
709
+ var artifacts []string
710
+
702
711
tarReader := tar .NewReader (gzipReader )
703
712
pushedArtifacts := make ([]string , 0 )
704
713
for {
@@ -718,52 +727,52 @@ func PushEmbeddedClusterArtifacts(airgapBundle string, opts imagetypes.PushEmbed
718
727
continue
719
728
}
720
729
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 )
730
+ dstFilePath := filepath .Join (tmpDir , header .Name )
731
+ if err := os .MkdirAll (filepath .Dir (dstFilePath ), 0755 ); err != nil {
732
+ return nil , errors .Wrap (err , "failed to create path" )
733
+ }
727
734
728
- dstFile , err := os .Create (dstFilePath )
729
- if err != nil {
730
- return errors .Wrap (err , "failed to create file" )
731
- }
732
- defer dstFile .Close ()
735
+ dstFile , err := os .Create (dstFilePath )
736
+ if err != nil {
737
+ return nil , errors .Wrap (err , "failed to create file" )
738
+ }
733
739
734
- if _ , err := io .Copy (dstFile , tarReader ); err != nil {
735
- return errors .Wrap (err , "failed to copy file data" )
736
- }
740
+ if _ , err := io .Copy (dstFile , tarReader ); err != nil {
741
+ dstFile .Close ()
742
+ return nil , errors .Wrap (err , "failed to copy file data" )
743
+ }
737
744
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
- }
745
+ dstFile .Close ()
746
+ artifacts = append (artifacts , dstFilePath )
747
+ }
746
748
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
- }
749
+ for i , dstFilePath := range artifacts {
750
+ name := filepath . Base ( dstFilePath )
751
+ repository := filepath . Join ( "embedded-cluster" , imageutil . SanitizeRepo ( name ))
752
+ artifactFile := imagetypes. OCIArtifactFile {
753
+ Name : name ,
754
+ Path : dstFilePath ,
755
+ MediaType : EmbeddedClusterMediaType ,
756
+ }
755
757
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 )
758
+ pushOCIArtifactOpts := imagetypes.PushOCIArtifactOptions {
759
+ Files : []imagetypes.OCIArtifactFile {artifactFile },
760
+ ArtifactType : EmbeddedClusterArtifactType ,
761
+ Registry : opts .Registry ,
762
+ Repository : repository ,
763
+ Tag : opts .Tag ,
764
+ HTTPClient : opts .HTTPClient ,
765
+ }
762
766
763
- return nil
764
- }(); err != nil {
765
- return nil , err
767
+ if opts .LogForUI {
768
+ fmt .Printf ("Pushing artifact %d/%d\n " , i + 1 , len (artifacts ))
769
+ }
770
+
771
+ artifact := fmt .Sprintf ("%s:%s" , filepath .Join (opts .Registry .Endpoint , opts .Registry .Namespace , repository ), opts .Tag )
772
+ if err := pushOCIArtifact (pushOCIArtifactOpts ); err != nil {
773
+ return nil , errors .Wrapf (err , "failed to push oci artifact %s" , name )
766
774
}
775
+ pushedArtifacts = append (pushedArtifacts , artifact )
767
776
}
768
777
769
778
return pushedArtifacts , nil
0 commit comments