This commit is contained in:
@@ -10,6 +10,7 @@ func Build() *cobra.Command {
|
||||
}
|
||||
|
||||
cmd.AddCommand(
|
||||
BuildRustBin(),
|
||||
BuildGolangBin(),
|
||||
BuildDocker(),
|
||||
)
|
||||
|
52
pkg/cli/build_rust_bin.go
Normal file
52
pkg/cli/build_rust_bin.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/bust/pkg/builder"
|
||||
"git.front.kjuulh.io/kjuulh/bust/pkg/pipelines"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func BuildRustBin() *cobra.Command {
|
||||
var (
|
||||
binName string
|
||||
)
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "rustbin",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if err := cmd.ParseFlags(args); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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).
|
||||
WithRustBin(&pipelines.RustBinOpts{
|
||||
DockerImageOpt: &pipelines.DockerImageOpt{
|
||||
ImageName: repoName,
|
||||
},
|
||||
BinName: binName,
|
||||
}).
|
||||
Execute(ctx)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().StringVar(&binName, "bin-name", "", "bin-name is the binary to build, and what will be present in the output folder")
|
||||
|
||||
return cmd
|
||||
}
|
@@ -19,6 +19,9 @@ var docker embed.FS
|
||||
//go:embed templates/default/*
|
||||
var defaultFs embed.FS
|
||||
|
||||
//go:embed templates/rustbin_default/*
|
||||
var rustbinDefault embed.FS
|
||||
|
||||
func NewInitCmd() *cobra.Command {
|
||||
var (
|
||||
template string
|
||||
@@ -48,6 +51,11 @@ func NewInitCmd() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
break
|
||||
case "rustbin_default":
|
||||
if err := initializeTemplate(&rustbinDefault, "rustbin_default", name); err != nil {
|
||||
return err
|
||||
}
|
||||
break
|
||||
default:
|
||||
return errors.New("could not find matching templates, please run [bust template ls] instead")
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var templates = []string{"docker", "gobin_default", "default"}
|
||||
var templates = []string{"docker", "gobin_default", "default", "rustbin_default"}
|
||||
|
||||
func NewLsCmd() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
|
5
pkg/cli/templatecmd/templates/rustbin_default/.drone.yml
Normal file
5
pkg/cli/templatecmd/templates/rustbin_default/.drone.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
kind: template
|
||||
load: bust_rustbin_default_template.yaml
|
||||
name: [[.Name]]
|
||||
data:
|
||||
bin_name: default
|
Reference in New Issue
Block a user