Skip to content

Commit 291f18b

Browse files
committed
Updated docker.go
1 parent cb9793f commit 291f18b

File tree

2 files changed

+10
-26
lines changed

2 files changed

+10
-26
lines changed

cmd/drone-docker/main.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,6 @@ func main() {
237237
Usage: "Path to save Docker image as tar file",
238238
EnvVar: "PLUGIN_TAR_PATH,PLUGIN_DESTINATION_TAR_PATH",
239239
},
240-
cli.BoolTFlag{
241-
Name: "oci-archive",
242-
Usage: "Use OCI archive format (true=oci-archive, false=docker-archive)",
243-
EnvVar: "PLUGIN_OCI_ARCHIVE",
244-
},
245240
}
246241

247242
if err := app.Run(os.Args); err != nil {
@@ -256,7 +251,6 @@ func run(c *cli.Context) error {
256251
PushOnly: c.Bool("push-only"),
257252
SourceTarPath: c.String("source-tar-path"),
258253
TarPath: c.String("tar-path"),
259-
OCIArchive: c.BoolT("oci-archive"),
260254
Login: docker.Login{
261255
Registry: c.String("docker.registry"),
262256
Username: c.String("docker.username"),

docker.go

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ type (
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

Comments
 (0)