Skip to content

Commit

Permalink
Allow specifying repo,branch info for buildconfig over CLI.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtnpro committed Nov 3, 2016
1 parent 5763ca8 commit 4ee7d2a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
2 changes: 2 additions & 0 deletions cli/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ func Convert(c *cli.Context) {
CreateDS: c.BoolT("daemonset"),
CreateRC: c.BoolT("replicationcontroller"),
CreateBuildConfig: c.BoolT("buildconfig"),
Repo: c.String("repo"),
Branch: c.String("branch"),
CreateDeploymentConfig: c.BoolT("deploymentconfig"),
}

Expand Down
12 changes: 12 additions & 0 deletions cli/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ func ConvertOpenShiftCommand() cli.Command {
Name: "buildconfig,bc",
Usage: "Generate a BuildConfig for Openshift",
},
cli.StringFlag{
Name: "repo",
Value: "",
Usage: "Specify source repository for buildconfig (default remote origin)",
EnvVar: "REPO",
},
cli.StringFlag{
Name: "branch",
Value: "master",
Usage: "Specify repository branch to use for buildconfig (default master)",
EnvVar: "BRANCH",
},
},
}
command.Flags = append(command.Flags, commonConvertFlags()...)
Expand Down
2 changes: 2 additions & 0 deletions pkg/kobject/kobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ type ConvertOptions struct {
CreateDS bool
CreateDeploymentConfig bool
CreateBuildConfig bool
Repo string
Branch string
CreateChart bool
GenerateYaml bool
Replicas int
Expand Down
13 changes: 9 additions & 4 deletions pkg/transformer/openshift/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,12 @@ func (o *OpenShift) initImageStream(name string, service kobject.ServiceConfig)
}

// initBuildConfig initialize Openshifts BuildConfig Object
func initBuildConfig(name string, service kobject.ServiceConfig, inputFile string) *buildapi.BuildConfig {
func initBuildConfig(name string, service kobject.ServiceConfig, inputFile string, repo string, branch string) *buildapi.BuildConfig {
uri := repo
if uri != "" {
uri = getGitRemote("origin")
}

bc := &buildapi.BuildConfig{
TypeMeta: unversioned.TypeMeta{
Kind: "BuildConfig",
Expand All @@ -152,8 +157,8 @@ func initBuildConfig(name string, service kobject.ServiceConfig, inputFile strin
buildapi.CommonSpec{
Source: buildapi.BuildSource{
Git: &buildapi.GitBuildSource{
Ref: "master",
URI: getGitRemote("origin"),
Ref: branch,
URI: uri,
},
ContextDir: getAbsBuildContext(service.Build, inputFile),
},
Expand Down Expand Up @@ -242,7 +247,7 @@ func (o *OpenShift) Transform(komposeObject kobject.KomposeObject, opt kobject.C
}

if opt.CreateBuildConfig && service.Build != "" {
objects = append(objects, initBuildConfig(name, service, opt.InputFile)) // Openshift BuildConfigs
objects = append(objects, initBuildConfig(name, service, opt.InputFile, opt.Repo, opt.Branch)) // Openshift BuildConfigs
}

// If ports not provided in configuration we will not make service
Expand Down

0 comments on commit 4ee7d2a

Please sign in to comment.