@@ -141,7 +141,7 @@ func ensureRepo(cmd *cobra.Command, runtimeName string, cloneOpts *git.CloneOpti
141
141
}
142
142
143
143
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 " )
145
145
}
146
146
147
147
return nil
@@ -166,7 +166,7 @@ func getRepoFromUserInput(cmd *cobra.Command) error {
166
166
return cmd .Flags ().Set ("repo" , repoInput )
167
167
}
168
168
169
- func ensureRuntimeName (ctx context.Context , args []string ) (string , error ) {
169
+ func ensureRuntimeName (ctx context.Context , args []string , allowManaged bool ) (string , error ) {
170
170
var (
171
171
runtimeName string
172
172
err error
@@ -177,7 +177,7 @@ func ensureRuntimeName(ctx context.Context, args []string) (string, error) {
177
177
}
178
178
179
179
if ! store .Get ().Silent {
180
- runtimeName , err = getRuntimeNameFromUserSelect (ctx )
180
+ runtimeName , err = getRuntimeNameFromUserSelect (ctx , allowManaged )
181
181
if err != nil {
182
182
return "" , err
183
183
}
@@ -190,7 +190,7 @@ func ensureRuntimeName(ctx context.Context, args []string) (string, error) {
190
190
return runtimeName , nil
191
191
}
192
192
193
- func getRuntimeNameFromUserSelect (ctx context.Context ) (string , error ) {
193
+ func getRuntimeNameFromUserSelect (ctx context.Context , allowManaged bool ) (string , error ) {
194
194
runtimes , err := cfConfig .NewClient ().V2 ().Runtime ().List (ctx )
195
195
if err != nil {
196
196
return "" , err
@@ -200,10 +200,18 @@ func getRuntimeNameFromUserSelect(ctx context.Context) (string, error) {
200
200
return "" , fmt .Errorf ("no runtimes were found" )
201
201
}
202
202
203
- runtimeNames := make ( []string , len ( runtimes ))
203
+ var runtimeNames []string
204
204
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 )
207
215
}
208
216
209
217
templates := & promptui.SelectTemplates {
@@ -219,7 +227,8 @@ func getRuntimeNameFromUserSelect(ctx context.Context) (string, error) {
219
227
}
220
228
221
229
_ , result , err := prompt .Run ()
222
- return result , err
230
+ resultSplit := strings .Split (result , " " )
231
+ return resultSplit [0 ], err
223
232
}
224
233
225
234
func getRuntimeNameFromUserInput () (string , error ) {
@@ -301,6 +310,11 @@ func ensureGitToken(cmd *cobra.Command, cloneOpts *git.CloneOptions, verify bool
301
310
return fmt .Errorf (errMessage )
302
311
}
303
312
}
313
+
314
+ if cloneOpts .Auth .Password == "" {
315
+ return fmt .Errorf ("must provide a git token using --git-token" )
316
+ }
317
+
304
318
return nil
305
319
}
306
320
@@ -635,11 +649,11 @@ func setIscRepo(ctx context.Context, suggestedSharedConfigRepo string) (string,
635
649
return setIscRepoResponse , nil
636
650
}
637
651
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 )
640
654
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 )
642
656
}
643
657
644
- return * user . ActiveAccount . SharedConfigRepo , nil
658
+ return rt . Managed , nil
645
659
}
0 commit comments