@@ -21,7 +21,10 @@ type NewProjectOptions struct {
2121 DisplayName string
2222 Description string
2323
24- Name string
24+ Name string
25+ Server string
26+
27+ SkipConfigWrite bool
2528
2629 Client client.Interface
2730
@@ -73,6 +76,7 @@ func NewCmdRequestProject(baseName, name, ocLoginName, ocProjectName string, f *
7376
7477 cmd .Flags ().StringVar (& options .DisplayName , "display-name" , "" , "Project display name" )
7578 cmd .Flags ().StringVar (& options .Description , "description" , "" , "Project description" )
79+ cmd .Flags ().BoolVar (& options .SkipConfigWrite , "skip-config-write" , false , "If true, the project will not be set as a cluster entry in kubeconfig after being created" )
7680
7781 return cmd
7882}
@@ -86,10 +90,18 @@ func (o *NewProjectOptions) complete(cmd *cobra.Command, f *clientcmd.Factory) e
8690
8791 o .ProjectName = args [0 ]
8892
89- o .ProjectOptions = & ProjectOptions {}
90- o .ProjectOptions .PathOptions = cliconfig .NewPathOptions (cmd )
91- if err := o .ProjectOptions .Complete (f , []string {"" }, o .Out ); err != nil {
92- return err
93+ if ! o .SkipConfigWrite {
94+ o .ProjectOptions = & ProjectOptions {}
95+ o .ProjectOptions .PathOptions = cliconfig .NewPathOptions (cmd )
96+ if err := o .ProjectOptions .Complete (f , []string {"" }, o .Out ); err != nil {
97+ return err
98+ }
99+ } else {
100+ clientConfig , err := f .OpenShiftClientConfig .ClientConfig ()
101+ if err != nil {
102+ return err
103+ }
104+ o .Server = clientConfig .Host
93105 }
94106
95107 return nil
@@ -121,15 +133,22 @@ func (o *NewProjectOptions) Run() error {
121133 if err := o .ProjectOptions .RunProject (); err != nil {
122134 return err
123135 }
124- }
125136
126- fmt .Fprintf (o .Out , `
137+ fmt .Fprintf (o .Out , `
127138You can add applications to this project with the 'new-app' command. For example, try:
128139
129140 %[1]s new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git
130141
131142to build a new example application in Ruby.
132143` , o .Name )
144+ } else {
145+ fmt .Fprintf (o .Out , `Project %[2]q created on server %[3]q.
146+
147+ To switch to this project and start adding applications, use:
148+
149+ %[1]s project %[2]s
150+ ` , o .Name , o .ProjectName , o .Server )
151+ }
133152
134153 return nil
135154}
0 commit comments