@@ -141,7 +141,7 @@ func ensureRepo(cmd *cobra.Command, runtimeName string, cloneOpts *git.CloneOpti
141141 }
142142
143143 if cloneOpts .Repo == "" {
144- return fmt .Errorf ("must enter a valid installation repository URL" )
144+ return fmt .Errorf ("must enter a valid installation repository URL, using --repo " )
145145 }
146146
147147 return nil
@@ -166,7 +166,7 @@ func getRepoFromUserInput(cmd *cobra.Command) error {
166166 return cmd .Flags ().Set ("repo" , repoInput )
167167}
168168
169- func ensureRuntimeName (ctx context.Context , args []string ) (string , error ) {
169+ func ensureRuntimeName (ctx context.Context , args []string , allowManaged bool ) (string , error ) {
170170 var (
171171 runtimeName string
172172 err error
@@ -177,7 +177,7 @@ func ensureRuntimeName(ctx context.Context, args []string) (string, error) {
177177 }
178178
179179 if ! store .Get ().Silent {
180- runtimeName , err = getRuntimeNameFromUserSelect (ctx )
180+ runtimeName , err = getRuntimeNameFromUserSelect (ctx , allowManaged )
181181 if err != nil {
182182 return "" , err
183183 }
@@ -190,7 +190,7 @@ func ensureRuntimeName(ctx context.Context, args []string) (string, error) {
190190 return runtimeName , nil
191191}
192192
193- func getRuntimeNameFromUserSelect (ctx context.Context ) (string , error ) {
193+ func getRuntimeNameFromUserSelect (ctx context.Context , allowManaged bool ) (string , error ) {
194194 runtimes , err := cfConfig .NewClient ().V2 ().Runtime ().List (ctx )
195195 if err != nil {
196196 return "" , err
@@ -200,10 +200,18 @@ func getRuntimeNameFromUserSelect(ctx context.Context) (string, error) {
200200 return "" , fmt .Errorf ("no runtimes were found" )
201201 }
202202
203- runtimeNames := make ( []string , len ( runtimes ))
203+ var runtimeNames []string
204204
205- for index , rt := range runtimes {
206- runtimeNames [index ] = rt .Metadata .Name
205+ for _ , rt := range runtimes {
206+ rtDisplay := rt .Metadata .Name
207+ if rt .Managed {
208+ if ! allowManaged {
209+ // preventing hosted runtimes to prompt
210+ continue
211+ }
212+ rtDisplay = fmt .Sprintf ("%s (hosted)" , rtDisplay )
213+ }
214+ runtimeNames = append (runtimeNames , rtDisplay )
207215 }
208216
209217 templates := & promptui.SelectTemplates {
@@ -219,7 +227,8 @@ func getRuntimeNameFromUserSelect(ctx context.Context) (string, error) {
219227 }
220228
221229 _ , result , err := prompt .Run ()
222- return result , err
230+ resultSplit := strings .Split (result , " " )
231+ return resultSplit [0 ], err
223232}
224233
225234func getRuntimeNameFromUserInput () (string , error ) {
@@ -301,6 +310,11 @@ func ensureGitToken(cmd *cobra.Command, cloneOpts *git.CloneOptions, verify bool
301310 return fmt .Errorf (errMessage )
302311 }
303312 }
313+
314+ if cloneOpts .Auth .Password == "" {
315+ return fmt .Errorf ("must provide a git token using --git-token" )
316+ }
317+
304318 return nil
305319}
306320
@@ -635,11 +649,11 @@ func setIscRepo(ctx context.Context, suggestedSharedConfigRepo string) (string,
635649 return setIscRepoResponse , nil
636650}
637651
638- func getIscRepo (ctx context.Context ) (string , error ) {
639- user , err := cfConfig .NewClient ().V2 ().UsersV2 ().GetCurrent (ctx )
652+ func isRuntimeManaged (ctx context.Context , runtimeName string ) (bool , error ) {
653+ rt , err := cfConfig .NewClient ().V2 ().Runtime ().Get (ctx , runtimeName )
640654 if err != nil {
641- return "" , fmt .Errorf ("failed to get shared config repo. Error : %w" , err )
655+ return false , fmt .Errorf ("failed to get runtime from platform. error : %w" , err )
642656 }
643657
644- return * user . ActiveAccount . SharedConfigRepo , nil
658+ return rt . Managed , nil
645659}
0 commit comments