update as library

This commit is contained in:
Kasper Juul Hermansen 2022-10-29 18:15:55 +02:00
parent 7577144747
commit 45ca537f6d
Signed by: kjuulh
GPG Key ID: 0F95C140730F2F23
3 changed files with 15 additions and 18 deletions

16
main.go
View File

@ -1,16 +0,0 @@
package daggergo
import (
"git.front.kjuulh.io/kjuulh/dagger-go/cmd"
"github.com/spf13/cobra"
)
func CreateCmd() *cobra.Command {
cobracmd := &cobra.Command{
Use: "dagger-go",
}
cobracmd.AddCommand(cmd.Build())
return cobracmd
}

View File

@ -1,12 +1,13 @@
package cmd
import (
"context"
"log"
"github.com/spf13/cobra"
)
func Build() *cobra.Command {
func Build(requirementsf func(*cobra.Command), buildf func(ctx context.Context) error) *cobra.Command {
var (
imageTag string
)
@ -22,11 +23,13 @@ func Build() *cobra.Command {
log.Printf("Building image: %s\n", imageTag)
}
return nil
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
}

10
pkg/tasks/build.go Normal file
View File

@ -0,0 +1,10 @@
package tasks
import "log"
func Build(imageTag string) error {
log.Printf("building image: %s", imageTag)
return nil
}