Skip to content

Commit

Permalink
feat: add image push
Browse files Browse the repository at this point in the history
  • Loading branch information
BacchusJackson committed Jun 10, 2024
1 parent e6fd2be commit 5afd98e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmd/workflow-engine/cli/v1/run-task.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
)

var (
flagCLIInterface = new(string)
flagAntivirusPull = new(bool)
flagExperimental = new(bool)
flagPodmanInterface = new(bool)
Expand Down Expand Up @@ -185,6 +184,20 @@ var runSecretsCodeScanTask = &cobra.Command{
},
}

var runImagePushTask = &cobra.Command{
Use: "image-push",
Short: "push an image to an image registry",
PreRunE: configPreRunE,
RunE: func(cmd *cobra.Command, args []string) error {
if *flagPodmanInterface {
task := tasks.NewGenericImagePushTask("podman", config.ImageTag)
return task.Run(cmd.Context(), cmd.ErrOrStderr())
}
task := tasks.NewGenericImagePushTask("docker", config.ImageTag)
return task.Run(cmd.Context(), cmd.ErrOrStderr())
},
}

var runSASTCodeScanTask = &cobra.Command{
Use: "sast-code-scan",
Short: "run static analysis security testing (SAST) on the code base",
Expand Down
25 changes: 25 additions & 0 deletions pkg/tasks/image-push.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package tasks

import (
"context"
"fmt"
"io"
"os/exec"
)

type GenericImagePushTask struct {
TagName string
cmdName string
}

func NewGenericImagePushTask(cliInterface string, tagName string) *GenericImagePushTask {
return &GenericImagePushTask{
TagName: tagName,
cmdName: cliInterface,
}
}

func (t *GenericImagePushTask) Run(ctx context.Context, stderr io.Writer) error {
pushCmd := exec.Command(t.cmdName, "push")
return StreamStderr(pushCmd, stderr, fmt.Sprintf("%s push", t.cmdName))
}

0 comments on commit 5afd98e

Please sign in to comment.