Skip to content

Commit

Permalink
Avoid hardcoding jiraTimesheetCode
Browse files Browse the repository at this point in the history
  • Loading branch information
tdaron committed Feb 28, 2021
1 parent 8c591ad commit 309eba1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jira/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type WorklogsField struct {

}
type RequestFields struct {
TimesheetCode string `json:"customfield_10101"` //CUSTOM FIELD WITH ODOO TIMESHEET CODE
TimesheetCode string `json:"odoo_timesheet_code"` //CUSTOM FIELD WITH ODOO TIMESHEET CODE
Worklog WorklogsField `json:"worklog"`
}

Expand Down
11 changes: 10 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ var odooCredsOk = false


func Handler(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
jiraRequest, err := jira.NewWorklogRequest(request.Body)


var timesheetCodeField = os.Getenv("JIRA_TIMESHEET_FIELD")
if timesheetCodeField == "" {
timesheetCodeField = "customfield_10101" //Default value
}

var body = strings.ReplaceAll(request.Body, timesheetCodeField, "odoo_timesheet_code")

jiraRequest, err := jira.NewWorklogRequest(body)
if err != nil {
return ErrorResponse(jira.Request{}, err), nil
}
Expand Down

0 comments on commit 309eba1

Please sign in to comment.