@@ -129,8 +129,9 @@ func NewGitSourceCreateCommand() *cobra.Command {
129
129
)
130
130
131
131
cmd := & cobra.Command {
132
- Use : "create runtime_name git-source_name" ,
133
- Short : "add a new git-source to an existing runtime" ,
132
+ Use : "create RUNTIME_NAME GITSOURCE_NAME" ,
133
+ Short : "Adds a new git-source to an existing runtime" ,
134
+ Args : cobra .MaximumNArgs (2 ),
134
135
Example : util .Doc (`
135
136
<BIN> git-source create runtime_name git-source-name --git-src-repo https://github.com/owner/repo-name/my-workflow
136
137
` ),
@@ -228,7 +229,7 @@ func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error
228
229
if err := appDef .CreateApp (ctx , nil , opts .InsCloneOpts , opts .RuntimeName , store .Get ().CFGitSourceType , opts .Include , "" ); err != nil {
229
230
return fmt .Errorf ("failed to create git-source application. Err: %w" , err )
230
231
}
231
-
232
+
232
233
log .G (ctx ).Infof ("Successfully created git-source: '%s'" , opts .GsName )
233
234
234
235
return nil
@@ -264,7 +265,7 @@ func createDemoResources(ctx context.Context, opts *GitSourceCreateOptions, gsRe
264
265
commitMsg := fmt .Sprintf ("Created demo pipelines in %s Directory" , opts .GsCloneOpts .Path ())
265
266
266
267
log .G (ctx ).Info ("Pushing demo pipelines to the new git-source repo" )
267
-
268
+
268
269
if err := apu .PushWithMessage (ctx , gsRepo , commitMsg ); err != nil {
269
270
return fmt .Errorf ("failed to push demo pipelines to git-source repo: %w" , err )
270
271
}
@@ -280,7 +281,7 @@ func createPlaceholderIfNeeded(ctx context.Context, opts *GitSourceCreateOptions
280
281
}
281
282
282
283
if len (fi ) == 0 {
283
- if err = billyUtils .WriteFile (gsFs , "DUMMY" , []byte {}, 0666 ); err != nil {
284
+ if err = billyUtils .WriteFile (gsFs , "DUMMY" , []byte {}, 0666 ); err != nil {
284
285
return fmt .Errorf ("failed to write the git-source placeholder file. Err: %w" , err )
285
286
}
286
287
@@ -434,18 +435,16 @@ func createCronExampleTrigger() (*sensorsv1alpha1.Trigger, error) {
434
435
435
436
func NewGitSourceListCommand () * cobra.Command {
436
437
cmd := & cobra.Command {
437
- Use : "list runtime_name " ,
438
+ Use : "list RUNTIME_NAME " ,
438
439
Short : "List all Codefresh git-sources of a given runtime" ,
440
+ Args : cobra .MaximumNArgs (1 ),
439
441
Example : util .Doc (`<BIN> git-source list my-runtime` ),
440
- PreRun : func (cmd * cobra.Command , args []string ) {
442
+ RunE : func (cmd * cobra.Command , args []string ) error {
441
443
if len (args ) < 1 {
442
- log . G ( cmd . Context ()). Fatal ("must enter runtime name" )
444
+ return fmt . Errorf ("must enter runtime name" )
443
445
}
444
- },
445
- RunE : func (cmd * cobra.Command , args []string ) error {
446
- ctx := cmd .Context ()
447
446
448
- return RunGitSourceList (ctx , args [0 ])
447
+ return RunGitSourceList (cmd . Context () , args [0 ])
449
448
},
450
449
}
451
450
return cmd
@@ -514,21 +513,21 @@ func NewGitSourceDeleteCommand() *cobra.Command {
514
513
)
515
514
516
515
cmd := & cobra.Command {
517
- Use : "delete runtime_name git-source_name " ,
516
+ Use : "delete RUNTIME_NAME GITSOURCE_NAME " ,
518
517
Short : "delete a git-source from a runtime" ,
518
+ Args : cobra .MaximumNArgs (2 ),
519
519
Example : util .Doc (`
520
520
<BIN> git-source delete runtime_name git-source_name
521
521
` ),
522
522
PreRunE : func (cmd * cobra.Command , args []string ) error {
523
- ctx := cmd .Context ()
524
523
store .Get ().Silent = true
525
524
526
525
if len (args ) < 1 {
527
- log . G ( ctx ). Fatal ("must enter runtime name" )
526
+ return fmt . Errorf ("must enter runtime name" )
528
527
}
529
528
530
529
if len (args ) < 2 {
531
- log . G ( ctx ). Fatal ("must enter git-source name" )
530
+ return fmt . Errorf ("must enter git-source name" )
532
531
}
533
532
534
533
err := ensureRepo (cmd , args [0 ], insCloneOpts , true )
@@ -580,25 +579,25 @@ func NewGitSourceEditCommand() *cobra.Command {
580
579
)
581
580
582
581
cmd := & cobra.Command {
583
- Use : "edit runtime_name git-source_name " ,
582
+ Use : "edit RUNTIME_NAME GITSOURCE_NAME " ,
584
583
Short : "edit a git-source of a runtime" ,
584
+ Args : cobra .MaximumNArgs (2 ),
585
585
Example : util .Doc (`
586
- <BIN> git-source edit runtime_name git-source_name --git-src-repo https://github.com/owner/repo-name/my-workflow
586
+ <BIN> git-source edit runtime_name git-source_name --git-src-repo https://github.com/owner/repo-name.git/path/to/dir
587
587
` ),
588
588
PreRunE : func (cmd * cobra.Command , args []string ) error {
589
- ctx := cmd .Context ()
590
589
store .Get ().Silent = true
591
590
592
591
if len (args ) < 1 {
593
- log . G ( ctx ). Fatal ("must enter a runtime name" )
592
+ return fmt . Errorf ("must enter a runtime name" )
594
593
}
595
594
596
595
if len (args ) < 2 {
597
- log . G ( ctx ). Fatal ("must enter a git-source name" )
596
+ return fmt . Errorf ("must enter a git-source name" )
598
597
}
599
598
600
599
if gsCloneOpts .Repo == "" {
601
- log . G ( ctx ). Fatal ( "must enter a valid value to --git-src-repo. Example: https://github.com/owner/repo-name/path/to/workflow " )
600
+ return fmt . Errorf ( "must enter a valid value to --git-src-repo. Example: https://github.com/owner/repo-name.git /path/to/dir " )
602
601
}
603
602
604
603
err := ensureRepo (cmd , args [0 ], insCloneOpts , true )
0 commit comments