add build steps

This commit is contained in:
2022-10-29 22:23:06 +02:00
parent 626e7bec93
commit f5d28094c8
6 changed files with 71 additions and 18 deletions

View File

@@ -1,14 +1,14 @@
package cli
import (
"context"
"log"
"git.front.kjuulh.io/kjuulh/dagger-go/internal"
"git.front.kjuulh.io/kjuulh/dagger-go/pkg/tasks"
"github.com/spf13/cobra"
)
func Build(requirementsf func(*cobra.Command), buildf func(ctx context.Context) error) *cobra.Command {
func Build() *cobra.Command {
var (
imageTag string
)
@@ -20,21 +20,22 @@ func Build(requirementsf func(*cobra.Command), buildf func(ctx context.Context)
return err
}
if imageTag != "" {
log.Printf("Building image: %s\n", imageTag)
}
ctx := cmd.Context()
if buildf != nil {
return buildf(cmd.Context())
}
log.Printf("Building image: %s\n", imageTag)
return tasks.Build(imageTag)
client, err := internal.New(ctx)
if err != nil {
return err
}
defer client.CleanUp()
return tasks.Build(client, imageTag)
},
}
cmd.PersistentFlags().StringVar(&imageTag, "image-tag", "", "the url for which to tag the docker image, defaults to private url, with repo as image name")
requirementsf(cmd)
cmd.MarkPersistentFlagRequired("image-tag")
return cmd
}