Skip to content

Commit

Permalink
add tar output
Browse files Browse the repository at this point in the history
  • Loading branch information
dskiff committed Apr 27, 2024
1 parent 28f2f8d commit 83de0a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/build/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/daemon"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/google/go-containerregistry/pkg/v1/tarball"
)

func publish(ctx BuildContext, image v1.Image, target BuildSpecTarget) error {
Expand All @@ -31,6 +32,12 @@ func publish(ctx BuildContext, image v1.Image, target BuildSpecTarget) error {
if err != nil {
return fmt.Errorf("failed to write image to daemon: %w", err)
}
case LOCAL_FILE:
log.Println("Publishing to local file...")
err := tarball.WriteToFile("out.tar", ref, image)
if err != nil {
return fmt.Errorf("failed to write image to file: %w", err)
}
default:
return fmt.Errorf("unknown target type: %d", target.Type)
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/build/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type TargetType int
const (
REMOTE TargetType = iota
LOCAL_DAEMON
LOCAL_FILE
)

type Platform struct {
Expand Down Expand Up @@ -132,6 +133,8 @@ func ParseTargetType(str string) (TargetType, error) {
return REMOTE, nil
case "LOCAL_DAEMON":
return LOCAL_DAEMON, nil
case "LOCAL_FILE":
return LOCAL_FILE, nil
case "":
return REMOTE, nil
default:
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type BuildCmd struct {
Entrypoint string `short:"e" help:"Entrypoint for the embedded artifacts" env:"TKO_ENTRYPOINT" default:"/tko-app/app"`

TargetRepo string `short:"t" help:"Target repository" env:"TKO_TARGET_REPO" required:"true"`
TargetType string `short:"T" help:"Target type" env:"TKO_TARGET_TYPE" default:"REMOTE" enum:"REMOTE,LOCAL_DAEMON"`
TargetType string `short:"T" help:"Target type" env:"TKO_TARGET_TYPE" default:"REMOTE" enum:"REMOTE,LOCAL_DAEMON,LOCAL_FILE"`

Author string `short:"a" help:"Author of the build" env:"TKO_AUTHOR" default:"github.com/dskiff/tko"`

Expand Down

0 comments on commit 83de0a9

Please sign in to comment.