@@ -119,7 +119,7 @@ func NewGitSourceCreateCommand() *cobra.Command {
119119 Example : util .Doc (`
120120 <BIN> git-source create runtime_name git-source-name --git-src-repo https://github.com/owner/repo-name/my-workflow
121121 ` ),
122- PreRun : func (cmd * cobra.Command , args []string ) {
122+ PreRunE : func (cmd * cobra.Command , args []string ) error {
123123 ctx := cmd .Context ()
124124
125125 if len (args ) < 1 {
@@ -133,6 +133,11 @@ func NewGitSourceCreateCommand() *cobra.Command {
133133 if gsCloneOpts .Repo == "" {
134134 log .G (ctx ).Fatal ("must enter a valid value to --git-src-repo. Example: https://github.com/owner/repo-name/path/to/workflow" )
135135 }
136+
137+ err := ensureRepo (cmd , args , insCloneOpts )
138+ if err != nil {
139+ return err
140+ }
136141
137142 isValid , err := IsValid (args [1 ])
138143 if err != nil {
@@ -149,6 +154,7 @@ func NewGitSourceCreateCommand() *cobra.Command {
149154
150155 insCloneOpts .Parse ()
151156 gsCloneOpts .Parse ()
157+ return nil
152158 },
153159 RunE : func (cmd * cobra.Command , args []string ) error {
154160 ctx := cmd .Context ()
@@ -396,15 +402,23 @@ func RunGitSourceList(ctx context.Context, runtimeName string) error {
396402
397403 for _ , gs := range gitSources {
398404 name := gs .Metadata .Name
399- repoURL := gs . Self . RepoURL
400- path := gs . Self . Path
405+ repoURL := "N/A"
406+ path := "N/A"
401407 healthStatus := "N/A"
402408 syncStatus := gs .Self .Status .SyncStatus .String ()
403409
404410 if gs .Self .Status .HealthStatus != nil {
405411 healthStatus = gs .Self .Status .HealthStatus .String ()
406412 }
407413
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+
408422 _ , err = fmt .Fprintf (tb , "%s\t %s\t %s\t %s\t %s\n " ,
409423 name ,
410424 repoURL ,
@@ -432,7 +446,7 @@ func NewGitSourceDeleteCommand() *cobra.Command {
432446 Example : util .Doc (`
433447 <BIN> git-source delete runtime_name git-source_name
434448 ` ),
435- PreRun : func (cmd * cobra.Command , args []string ) {
449+ PreRunE : func (cmd * cobra.Command , args []string ) error {
436450 ctx := cmd .Context ()
437451
438452 if len (args ) < 1 {
@@ -443,7 +457,13 @@ func NewGitSourceDeleteCommand() *cobra.Command {
443457 log .G (ctx ).Fatal ("must enter git-source name" )
444458 }
445459
460+ err := ensureRepo (cmd , args , insCloneOpts )
461+ if err != nil {
462+ return err
463+ }
464+
446465 insCloneOpts .Parse ()
466+ return nil
447467 },
448468 RunE : func (cmd * cobra.Command , args []string ) error {
449469 ctx := cmd .Context ()
@@ -491,7 +511,7 @@ func NewGitSourceEditCommand() *cobra.Command {
491511 Example : util .Doc (`
492512 <BIN> git-source edit runtime_name git-source_name --git-src-repo https://github.com/owner/repo-name/my-workflow
493513 ` ),
494- PreRun : func (cmd * cobra.Command , args []string ) {
514+ PreRunE : func (cmd * cobra.Command , args []string ) error {
495515 ctx := cmd .Context ()
496516
497517 if len (args ) < 1 {
@@ -506,8 +526,14 @@ func NewGitSourceEditCommand() *cobra.Command {
506526 log .G (ctx ).Fatal ("must enter a valid value to --git-src-repo. Example: https://github.com/owner/repo-name/path/to/workflow" )
507527 }
508528
529+ err := ensureRepo (cmd , args , insCloneOpts )
530+ if err != nil {
531+ return err
532+ }
533+
509534 insCloneOpts .Parse ()
510535 gsCloneOpts .Parse ()
536+ return nil
511537 },
512538 RunE : func (cmd * cobra.Command , args []string ) error {
513539 ctx := cmd .Context ()
0 commit comments