Skip to content

Commit 2224ab2

Browse files
authored
fix: Make board selection optional (#502)
1 parent 86a354b commit 2224ab2

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

internal/config/generator.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ func (c *JiraCLIConfigGenerator) configureServerMeta(server, login string) error
329329
return nil
330330
}
331331

332+
//nolint:gocyclo
332333
func (c *JiraCLIConfigGenerator) configureProjectAndBoardDetails() error {
333334
project := c.usrCfg.Project
334335
board := c.usrCfg.Board
@@ -405,10 +406,16 @@ func (c *JiraCLIConfigGenerator) configureProjectAndBoardDetails() error {
405406
c.value.board = c.boardsMap[strings.ToLower(board)]
406407

407408
if c.value.board == nil && !strings.EqualFold(board, optionNone) {
409+
var suggest string
410+
if len(defaultBoardSuggestions) > 2 {
411+
suggest = strings.Join(defaultBoardSuggestions[2:], ", ")
412+
} else {
413+
suggest = strings.Join(defaultBoardSuggestions, ", ")
414+
}
408415
return fmt.Errorf(
409416
"board not found\n Boards available for the project '%s' are '%s'",
410417
c.value.project.Key,
411-
strings.Join(defaultBoardSuggestions[2:], ", "),
418+
suggest,
412419
)
413420
}
414421
return nil
@@ -638,7 +645,13 @@ func (c *JiraCLIConfigGenerator) getBoardSuggestions(project string) error {
638645

639646
resp, err := c.jiraClient.Boards(project, "")
640647
if err != nil {
641-
return err
648+
if c.value.installation == jira.InstallationTypeCloud {
649+
return err
650+
}
651+
// We don't care about the error in the local instance since board API may not exist if agile-addon is not installed.
652+
// The only option available for board selection, in this case, is "None" if not passed directly from the flag.
653+
c.boardSuggestions = append(c.boardSuggestions, optionNone)
654+
return nil
642655
}
643656
c.boardSuggestions = append(c.boardSuggestions, optionSearch, lineBreak)
644657
for _, board := range resp.Boards {

pkg/jira/client.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,12 @@ func (c *Client) request(ctx context.Context, method, endpoint string, body []by
257257

258258
func dump(req *http.Request, res *http.Response) {
259259
reqDump, _ := httputil.DumpRequest(req, true)
260-
respDump, _ := httputil.DumpResponse(res, false)
261-
262260
prettyPrintDump("Request Details", reqDump)
263-
prettyPrintDump("Response Details", respDump)
261+
262+
if res != nil {
263+
respDump, _ := httputil.DumpResponse(res, false)
264+
prettyPrintDump("Response Details", respDump)
265+
}
264266
}
265267

266268
func prettyPrintDump(heading string, data []byte) {

0 commit comments

Comments
 (0)