update as library

This commit is contained in:
2022-10-29 18:15:55 +02:00
parent 7577144747
commit 45ca537f6d
3 changed files with 15 additions and 18 deletions

35
pkg/cli/cli.go Normal file
View File

@@ -0,0 +1,35 @@
package cmd
import (
"context"
"log"
"github.com/spf13/cobra"
)
func Build(requirementsf func(*cobra.Command), buildf func(ctx context.Context) error) *cobra.Command {
var (
imageTag string
)
cmd := &cobra.Command{
Use: "build",
RunE: func(cmd *cobra.Command, args []string) error {
if err := cmd.ParseFlags(args); err != nil {
return err
}
if imageTag != "" {
log.Printf("Building image: %s\n", imageTag)
}
return buildf(cmd.Context())
},
}
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)
return cmd
}