transition: map field name to id

this commit allows a user to use the more friendly field.Name when
transitioning to states which require custom field inputs.

Signed-off-by: ldelossa <ldelossa@redhat.com>
This commit is contained in:
ldelossa
2020-08-26 13:56:59 -04:00
committed by Louis DeLosSantos
parent 6a27e28c61
commit 3c1c4d95e1
+20
View File
@@ -165,6 +165,26 @@ func CmdTransition(o *oreo.Client, globals *jiracli.GlobalOptions, opts *Transit
return err
}
}
// if issueUpdate contains fields lets see if we can map them
// to their ids
if len(issueUpdate.Fields) > 0 {
fields, err := jira.GetFields(o, globals.Endpoint.Value)
if err != nil {
return err
}
for k, v := range issueUpdate.Fields {
for _, f := range fields {
if f.Name == k {
// re-map to field.id
issueUpdate.Fields[f.ID] = v
delete(issueUpdate.Fields, k)
break
}
}
}
}
return jira.TransitionIssue(o, globals.Endpoint.Value, opts.Issue, &issueUpdate)
})
if err != nil {