Return error if both jobID and runID are specified

This commit is contained in:
Cameron Booth 2022-03-14 10:01:19 -07:00
parent 3645975da7
commit 24ec53365b
2 changed files with 5 additions and 11 deletions

View file

@ -50,11 +50,7 @@ func NewCmdRerun(f *cmdutil.Factory, runF func(*RerunOptions) error) *cobra.Comm
}
if opts.RunID != "" && opts.JobID != "" {
opts.RunID = ""
if opts.IO.CanPrompt() {
cs := opts.IO.ColorScheme()
fmt.Fprintf(opts.IO.ErrOut, "%s both run and job IDs specified; ignoring run ID\n", cs.WarningIcon())
}
return cmdutil.FlagErrorf("specify only one of <run-id> or <job-id>")
}
if runF != nil {

View file

@ -76,12 +76,10 @@ func TestNewCmdRerun(t *testing.T) {
},
},
{
name: "with args job and runID ignores runID",
tty: true,
cli: "1234 --job 5678",
wants: RerunOptions{
JobID: "5678",
},
name: "with args jobID and runID fails",
tty: true,
cli: "1234 --job 5678",
wantsErr: true,
},
{
name: "with arg job with no ID fails",