@@ -119,7 +119,7 @@ func NewGitSourceCreateCommand() *cobra.Command {
119
119
Example : util .Doc (`
120
120
<BIN> git-source create runtime_name git-source-name --git-src-repo https://github.com/owner/repo-name/my-workflow
121
121
` ),
122
- PreRun : func (cmd * cobra.Command , args []string ) {
122
+ PreRunE : func (cmd * cobra.Command , args []string ) error {
123
123
ctx := cmd .Context ()
124
124
125
125
if len (args ) < 1 {
@@ -133,6 +133,11 @@ func NewGitSourceCreateCommand() *cobra.Command {
133
133
if gsCloneOpts .Repo == "" {
134
134
log .G (ctx ).Fatal ("must enter a valid value to --git-src-repo. Example: https://github.com/owner/repo-name/path/to/workflow" )
135
135
}
136
+
137
+ err := ensureRepo (cmd , args , insCloneOpts )
138
+ if err != nil {
139
+ return err
140
+ }
136
141
137
142
isValid , err := IsValid (args [1 ])
138
143
if err != nil {
@@ -149,6 +154,7 @@ func NewGitSourceCreateCommand() *cobra.Command {
149
154
150
155
insCloneOpts .Parse ()
151
156
gsCloneOpts .Parse ()
157
+ return nil
152
158
},
153
159
RunE : func (cmd * cobra.Command , args []string ) error {
154
160
ctx := cmd .Context ()
@@ -396,15 +402,23 @@ func RunGitSourceList(ctx context.Context, runtimeName string) error {
396
402
397
403
for _ , gs := range gitSources {
398
404
name := gs .Metadata .Name
399
- repoURL := gs . Self . RepoURL
400
- path := gs . Self . Path
405
+ repoURL := "N/A"
406
+ path := "N/A"
401
407
healthStatus := "N/A"
402
408
syncStatus := gs .Self .Status .SyncStatus .String ()
403
409
404
410
if gs .Self .Status .HealthStatus != nil {
405
411
healthStatus = gs .Self .Status .HealthStatus .String ()
406
412
}
407
413
414
+ if gs .Self .RepoURL != nil {
415
+ repoURL = * gs .Self .RepoURL
416
+ }
417
+
418
+ if gs .Self .Path != nil {
419
+ path = * gs .Self .Path
420
+ }
421
+
408
422
_ , err = fmt .Fprintf (tb , "%s\t %s\t %s\t %s\t %s\n " ,
409
423
name ,
410
424
repoURL ,
@@ -432,7 +446,7 @@ func NewGitSourceDeleteCommand() *cobra.Command {
432
446
Example : util .Doc (`
433
447
<BIN> git-source delete runtime_name git-source_name
434
448
` ),
435
- PreRun : func (cmd * cobra.Command , args []string ) {
449
+ PreRunE : func (cmd * cobra.Command , args []string ) error {
436
450
ctx := cmd .Context ()
437
451
438
452
if len (args ) < 1 {
@@ -443,7 +457,13 @@ func NewGitSourceDeleteCommand() *cobra.Command {
443
457
log .G (ctx ).Fatal ("must enter git-source name" )
444
458
}
445
459
460
+ err := ensureRepo (cmd , args , insCloneOpts )
461
+ if err != nil {
462
+ return err
463
+ }
464
+
446
465
insCloneOpts .Parse ()
466
+ return nil
447
467
},
448
468
RunE : func (cmd * cobra.Command , args []string ) error {
449
469
ctx := cmd .Context ()
@@ -491,7 +511,7 @@ func NewGitSourceEditCommand() *cobra.Command {
491
511
Example : util .Doc (`
492
512
<BIN> git-source edit runtime_name git-source_name --git-src-repo https://github.com/owner/repo-name/my-workflow
493
513
` ),
494
- PreRun : func (cmd * cobra.Command , args []string ) {
514
+ PreRunE : func (cmd * cobra.Command , args []string ) error {
495
515
ctx := cmd .Context ()
496
516
497
517
if len (args ) < 1 {
@@ -506,8 +526,14 @@ func NewGitSourceEditCommand() *cobra.Command {
506
526
log .G (ctx ).Fatal ("must enter a valid value to --git-src-repo. Example: https://github.com/owner/repo-name/path/to/workflow" )
507
527
}
508
528
529
+ err := ensureRepo (cmd , args , insCloneOpts )
530
+ if err != nil {
531
+ return err
532
+ }
533
+
509
534
insCloneOpts .Parse ()
510
535
gsCloneOpts .Parse ()
536
+ return nil
511
537
},
512
538
RunE : func (cmd * cobra.Command , args []string ) error {
513
539
ctx := cmd .Context ()
0 commit comments