6464 PushOnly bool // Push only mode, skips build process
6565 SourceTarPath string // Path to Docker image tar file to load and push
6666 TarPath string // Path to save Docker image as tar file
67- OCIArchive bool // Use OCI archive format (true=oci-archive, false=docker-archive)
6867 }
6968)
7069
@@ -138,15 +137,14 @@ func (p Plugin) Exec() error {
138137
139138 // If TarPath is specified and Dryrun is enabled, save the image to a tar file
140139 if p .TarPath != "" && p .Dryrun && len (p .Build .Tags ) > 0 {
141- // Create parent directories if they don't exist
142- dir := filepath .Dir (p .TarPath )
143- if err := os .MkdirAll (dir , 0755 ); err != nil {
144- return fmt .Errorf ("error creating directories for tar file: %s" , err )
140+ // Ensure parent directories exist
141+ if err := os .MkdirAll (filepath .Dir (p .TarPath ), 0755 ); err != nil {
142+ return fmt .Errorf ("failed to create parent directories for tar path: %s" , err )
145143 }
146144
147145 imageToSave := fmt .Sprintf ("%s:%s" , p .Build .Repo , p .Build .Tags [0 ])
148146 fmt .Println ("Saving image to tar:" , p .TarPath )
149- cmds = append (cmds , commandSaveTar (imageToSave , p .TarPath , p . OCIArchive ))
147+ cmds = append (cmds , commandSaveTar (imageToSave , p .TarPath ))
150148 }
151149
152150 if p .Cleanup {
@@ -405,7 +403,7 @@ func (p Plugin) pushOnly() error {
405403 }
406404
407405 fmt .Println ("Loading image from tar:" , p .SourceTarPath )
408- loadCmd := commandLoadTar (p .SourceTarPath , p . OCIArchive )
406+ loadCmd := commandLoadTar (p .SourceTarPath )
409407 loadCmd .Stdout = os .Stdout
410408 loadCmd .Stderr = os .Stderr
411409 trace (loadCmd )
@@ -502,18 +500,11 @@ func (p Plugin) pushOnly() error {
502500 return nil
503501}
504502
505- // getArchiveFormat returns the appropriate archive format prefix based on the OCIArchive flag
506- func getArchiveFormat (useOCIArchive bool ) string {
507- if useOCIArchive {
508- return "oci-archive:"
509- }
510- return "docker-archive:"
511- }
503+
512504
513505// commandLoadTar creates a command to load an image from a tar file
514- func commandLoadTar (tarPath string , useOCIArchive bool ) * exec.Cmd {
515- archiveFormat := getArchiveFormat (useOCIArchive )
516- return exec .Command (buildahExe , "--storage-driver" , "vfs" , "pull" , archiveFormat + tarPath )
506+ func commandLoadTar (tarPath string ) * exec.Cmd {
507+ return exec .Command (buildahExe , "--storage-driver" , "vfs" , "pull" , "docker-archive:" + tarPath )
517508}
518509
519510// commandImageExists creates a command to check if an image exists
@@ -522,7 +513,6 @@ func commandImageExists(image string) *exec.Cmd {
522513}
523514
524515// commandSaveTar creates a command to save an image to a tar file
525- func commandSaveTar (image string , tarPath string , useOCIArchive bool ) * exec.Cmd {
526- archiveFormat := getArchiveFormat (useOCIArchive )
527- return exec .Command (buildahExe , "push" , "--storage-driver" , "vfs" , image , archiveFormat + tarPath )
516+ func commandSaveTar (image string , tarPath string ) * exec.Cmd {
517+ return exec .Command (buildahExe , "push" , "--storage-driver" , "vfs" , image , "docker-archive:" + tarPath )
528518}
0 commit comments