forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
builder.go
58 lines (47 loc) · 1.55 KB
/
builder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package builder
import (
"os"
"github.com/spf13/cobra"
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"github.com/openshift/origin/pkg/build/builder/cmd"
ocmd "github.com/openshift/origin/pkg/cmd/cli/cmd"
"github.com/openshift/origin/pkg/cmd/templates"
)
var (
s2iBuilderLong = templates.LongDesc(`
Perform a Source-to-Image build
This command executes a Source-to-Image build using arguments passed via the environment.
It expects to be run inside of a container.`)
dockerBuilderLong = templates.LongDesc(`
Perform a Docker build
This command executes a Docker build using arguments passed via the environment.
It expects to be run inside of a container.`)
)
// NewCommandS2IBuilder provides a CLI handler for S2I build type
func NewCommandS2IBuilder(name string) *cobra.Command {
cmd := &cobra.Command{
Use: name,
Short: "Run a Source-to-Image build",
Long: s2iBuilderLong,
Run: func(c *cobra.Command, args []string) {
err := cmd.RunS2IBuild(c.OutOrStderr())
kcmdutil.CheckErr(err)
},
}
cmd.AddCommand(ocmd.NewCmdVersion(name, nil, os.Stdout, ocmd.VersionOptions{}))
return cmd
}
// NewCommandDockerBuilder provides a CLI handler for Docker build type
func NewCommandDockerBuilder(name string) *cobra.Command {
cmd := &cobra.Command{
Use: name,
Short: "Run a Docker build",
Long: dockerBuilderLong,
Run: func(c *cobra.Command, args []string) {
err := cmd.RunDockerBuild(c.OutOrStderr())
kcmdutil.CheckErr(err)
},
}
cmd.AddCommand(ocmd.NewCmdVersion(name, nil, os.Stdout, ocmd.VersionOptions{}))
return cmd
}