bust/pkg/cli/build_golang_bin.go

46 lines
911 B
Go
Raw Permalink Normal View History

2022-10-30 18:33:59 +01:00
package cli
import (
"errors"
"os"
2022-10-31 20:16:26 +01:00
"git.front.kjuulh.io/kjuulh/bust/pkg/builder"
"git.front.kjuulh.io/kjuulh/bust/pkg/pipelines"
2022-10-30 18:33:59 +01:00
"github.com/spf13/cobra"
)
func BuildGolangBin() *cobra.Command {
cmd := &cobra.Command{
Use: "golangbin",
RunE: func(cmd *cobra.Command, args []string) error {
repoName := os.Getenv("DRONE_REPO_NAME")
if repoName == "" {
return errors.New("could not find DRONE_REPO_NAME")
}
ctx := cmd.Context()
builder, err := builder.New(ctx)
if err != nil {
return err
}
defer builder.CleanUp()
return pipelines.
New(builder).
WithGolangBin(&pipelines.GolangBinOpts{
DockerImageOpt: &pipelines.DockerImageOpt{
2022-10-31 00:21:58 +01:00
ImageName: repoName,
2022-10-30 18:33:59 +01:00
},
2022-10-31 00:26:44 +01:00
BuildPath: "main.go",
BinName: "main",
2022-10-31 02:02:00 +01:00
CGOEnabled: false,
2022-10-31 01:43:19 +01:00
ExecuteOnEntrypoint: false,
2022-10-30 18:33:59 +01:00
}).
Execute(ctx)
},
}
return cmd
}