forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuilder.go
121 lines (101 loc) · 3.45 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package builder
import (
"os"
"github.com/spf13/cobra"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"github.com/openshift/origin/pkg/build/builder/cmd"
cmdversion "github.com/openshift/origin/pkg/cmd/version"
"github.com/openshift/origin/pkg/version"
)
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.`)
gitCloneLong = templates.LongDesc(`
Perform a Git clone
This command executes a Git clone using arguments passed via the environment.
It expects to be run inside of a container.`)
manageDockerfileLong = templates.LongDesc(`
Manipulates a dockerfile for a docker build.
This command updates a dockerfile based on build inputs.
It expects to be run inside of a container.`)
extractImageContentLong = templates.LongDesc(`
Extracts files from existing images.
This command extracts files from existing images to use as input to a build.
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(cmdversion.NewCmdVersion(name, version.Get(), os.Stdout))
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(cmdversion.NewCmdVersion(name, version.Get(), os.Stdout))
return cmd
}
// NewCommandGitClone manages cloning the git source for a build.
// It also manages binary build input content.
func NewCommandGitClone(name string) *cobra.Command {
cmd := &cobra.Command{
Use: name,
Short: "Git clone source code",
Long: gitCloneLong,
Run: func(c *cobra.Command, args []string) {
err := cmd.RunGitClone(c.OutOrStderr())
kcmdutil.CheckErr(err)
},
}
cmd.AddCommand(cmdversion.NewCmdVersion(name, version.Get(), os.Stdout))
return cmd
}
func NewCommandManageDockerfile(name string) *cobra.Command {
cmd := &cobra.Command{
Use: name,
Short: "Manage a dockerfile for a docker build",
Long: manageDockerfileLong,
Run: func(c *cobra.Command, args []string) {
err := cmd.RunManageDockerfile(c.OutOrStderr())
kcmdutil.CheckErr(err)
},
}
cmd.AddCommand(cmdversion.NewCmdVersion(name, version.Get(), os.Stdout))
return cmd
}
func NewCommandExtractImageContent(name string) *cobra.Command {
cmd := &cobra.Command{
Use: name,
Short: "Extract build input content from existing images",
Long: extractImageContentLong,
Run: func(c *cobra.Command, args []string) {
err := cmd.RunExtractImageContent(c.OutOrStderr())
kcmdutil.CheckErr(err)
},
}
cmd.AddCommand(cmdversion.NewCmdVersion(name, version.Get(), os.Stdout))
return cmd
}