Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ func (p *OutParams) UnmarshalJSON(b []byte) (err error) {
p.Description = github.String(getStringOrStringFromFile(p.RawDescription))
}

if p.RawAutoMerge != nil {
p.AutoMerge = github.Bool(getBool(p.RawAutoMerge))
}

var payload map[string]interface{}
json.Unmarshal(p.RawPayload, &payload)

Expand Down Expand Up @@ -140,6 +144,19 @@ func NewOutRequest() OutRequest {
return OutRequest{}
}

func getBool(field json.RawMessage) bool {
var rawValue interface{}
if err := json.Unmarshal(field, &rawValue); err == nil {
switch rawValue := rawValue.(type) {
case bool:
return rawValue
default:
panic("Could not read bool out of Params field")
}
}
return true
}

func getStringOrStringFromFile(field json.RawMessage) string {
var rawValue interface{}
if err := json.Unmarshal(field, &rawValue); err == nil {
Expand Down