Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 47b8fa7

Browse files
committedFeb 6, 2018
oc new-build --push-secret option
1 parent 8ca3f60 commit 47b8fa7

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed
 

‎pkg/oc/cli/cmd/newbuild.go

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ func NewCmdNewBuild(name, baseName string, f *clientcmd.Factory, in io.Reader, o
114114
cmd.Flags().StringSliceVar(&config.DockerImages, "docker-image", config.DockerImages, "Name of a Docker image to use as a builder.")
115115
cmd.Flags().StringSliceVar(&config.Secrets, "build-secret", config.Secrets, "Secret and destination to use as an input for the build.")
116116
cmd.Flags().StringVar(&config.SourceSecret, "source-secret", "", "The name of an existing secret that should be used for cloning a private git repository.")
117+
cmd.Flags().StringVar(&config.PushSecret, "push-secret", "", "The name of an existing secret that should be used for pushing to a Docker repository if --to-docker and --to are set.")
117118
cmd.Flags().StringVar(&config.Name, "name", "", "Set name to use for generated build artifacts.")
118119
cmd.Flags().StringVar(&config.To, "to", "", "Push built images to this image stream tag (or Docker image repository if --to-docker is set).")
119120
cmd.Flags().BoolVar(&config.OutputDocker, "to-docker", false, "If true, have the build output push to a Docker repository.")

‎pkg/oc/generate/cmd/newapp.go

+10
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ type AppConfig struct {
106106

107107
AllowSecretUse bool
108108
SourceSecret string
109+
PushSecret string
109110
AllowNonNumericExposedPorts bool
110111
SecretAccessor app.SecretAccessor
111112

@@ -906,6 +907,15 @@ func (c *AppConfig) Run() (*AppResult, error) {
906907
}
907908
}
908909
}
910+
if len(c.PushSecret) > 0 {
911+
for _, obj := range objects {
912+
if bc, ok := obj.(*buildapi.BuildConfig); ok {
913+
glog.V(4).Infof("Setting push secret for build config to: %v", c.SourceSecret)
914+
bc.Spec.Output.PushSecret = &kapi.LocalObjectReference{Name: c.PushSecret}
915+
break
916+
}
917+
}
918+
}
909919

910920
return &AppResult{
911921
List: &kapi.List{Items: objects},

‎test/cmd/newapp.sh

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ os::cmd::expect_success_and_text 'oc new-build https://github.com/openshift/cake
6868
os::cmd::expect_success_and_text 'oc new-app -f examples/quickstarts/cakephp-mysql.json --source-secret=mysecret -o yaml' 'name: mysecret'
6969
os::cmd::expect_success 'oc new-app https://github.com/openshift/cakephp-ex --source-secret=mysecret'
7070
os::cmd::expect_success 'oc delete all --selector="label=cakephp-ex"'
71+
# setting push secret via the --push-secret flag
72+
os::cmd::expect_success_and_text 'oc new-build https://github.com/openshift/cakephp-ex --push-secret=mynewsecret -o yaml' 'name: mynewsecret'
7173

7274

7375
# check label creation

0 commit comments

Comments
 (0)
Please sign in to comment.