|
|
@ -6,10 +6,11 @@ |
|
|
|
package structs |
|
|
|
package structs |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
|
|
|
|
"errors" |
|
|
|
"errors" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jsoniter "github.com/json-iterator/go" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
var ( |
|
|
@ -138,12 +139,14 @@ func (p *CreatePayload) SetSecret(secret string) { |
|
|
|
|
|
|
|
|
|
|
|
// JSONPayload return payload information
|
|
|
|
// JSONPayload return payload information
|
|
|
|
func (p *CreatePayload) JSONPayload() ([]byte, error) { |
|
|
|
func (p *CreatePayload) JSONPayload() ([]byte, error) { |
|
|
|
|
|
|
|
json := jsoniter.ConfigCompatibleWithStandardLibrary |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ParseCreateHook parses create event hook content.
|
|
|
|
// ParseCreateHook parses create event hook content.
|
|
|
|
func ParseCreateHook(raw []byte) (*CreatePayload, error) { |
|
|
|
func ParseCreateHook(raw []byte) (*CreatePayload, error) { |
|
|
|
hook := new(CreatePayload) |
|
|
|
hook := new(CreatePayload) |
|
|
|
|
|
|
|
json := jsoniter.ConfigCompatibleWithStandardLibrary |
|
|
|
if err := json.Unmarshal(raw, hook); err != nil { |
|
|
|
if err := json.Unmarshal(raw, hook); err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
@ -193,6 +196,7 @@ func (p *DeletePayload) SetSecret(secret string) { |
|
|
|
|
|
|
|
|
|
|
|
// JSONPayload implements Payload
|
|
|
|
// JSONPayload implements Payload
|
|
|
|
func (p *DeletePayload) JSONPayload() ([]byte, error) { |
|
|
|
func (p *DeletePayload) JSONPayload() ([]byte, error) { |
|
|
|
|
|
|
|
json := jsoniter.ConfigCompatibleWithStandardLibrary |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -218,6 +222,7 @@ func (p *ForkPayload) SetSecret(secret string) { |
|
|
|
|
|
|
|
|
|
|
|
// JSONPayload implements Payload
|
|
|
|
// JSONPayload implements Payload
|
|
|
|
func (p *ForkPayload) JSONPayload() ([]byte, error) { |
|
|
|
func (p *ForkPayload) JSONPayload() ([]byte, error) { |
|
|
|
|
|
|
|
json := jsoniter.ConfigCompatibleWithStandardLibrary |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -250,6 +255,7 @@ func (p *IssueCommentPayload) SetSecret(secret string) { |
|
|
|
|
|
|
|
|
|
|
|
// JSONPayload implements Payload
|
|
|
|
// JSONPayload implements Payload
|
|
|
|
func (p *IssueCommentPayload) JSONPayload() ([]byte, error) { |
|
|
|
func (p *IssueCommentPayload) JSONPayload() ([]byte, error) { |
|
|
|
|
|
|
|
json := jsoniter.ConfigCompatibleWithStandardLibrary |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -286,6 +292,7 @@ func (p *ReleasePayload) SetSecret(secret string) { |
|
|
|
|
|
|
|
|
|
|
|
// JSONPayload implements Payload
|
|
|
|
// JSONPayload implements Payload
|
|
|
|
func (p *ReleasePayload) JSONPayload() ([]byte, error) { |
|
|
|
func (p *ReleasePayload) JSONPayload() ([]byte, error) { |
|
|
|
|
|
|
|
json := jsoniter.ConfigCompatibleWithStandardLibrary |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -317,12 +324,14 @@ func (p *PushPayload) SetSecret(secret string) { |
|
|
|
|
|
|
|
|
|
|
|
// JSONPayload FIXME
|
|
|
|
// JSONPayload FIXME
|
|
|
|
func (p *PushPayload) JSONPayload() ([]byte, error) { |
|
|
|
func (p *PushPayload) JSONPayload() ([]byte, error) { |
|
|
|
|
|
|
|
json := jsoniter.ConfigCompatibleWithStandardLibrary |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ParsePushHook parses push event hook content.
|
|
|
|
// ParsePushHook parses push event hook content.
|
|
|
|
func ParsePushHook(raw []byte) (*PushPayload, error) { |
|
|
|
func ParsePushHook(raw []byte) (*PushPayload, error) { |
|
|
|
hook := new(PushPayload) |
|
|
|
hook := new(PushPayload) |
|
|
|
|
|
|
|
json := jsoniter.ConfigCompatibleWithStandardLibrary |
|
|
|
if err := json.Unmarshal(raw, hook); err != nil { |
|
|
|
if err := json.Unmarshal(raw, hook); err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
@ -396,6 +405,7 @@ func (p *IssuePayload) SetSecret(secret string) { |
|
|
|
|
|
|
|
|
|
|
|
// JSONPayload encodes the IssuePayload to JSON, with an indentation of two spaces.
|
|
|
|
// JSONPayload encodes the IssuePayload to JSON, with an indentation of two spaces.
|
|
|
|
func (p *IssuePayload) JSONPayload() ([]byte, error) { |
|
|
|
func (p *IssuePayload) JSONPayload() ([]byte, error) { |
|
|
|
|
|
|
|
json := jsoniter.ConfigCompatibleWithStandardLibrary |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -437,6 +447,7 @@ func (p *PullRequestPayload) SetSecret(secret string) { |
|
|
|
|
|
|
|
|
|
|
|
// JSONPayload FIXME
|
|
|
|
// JSONPayload FIXME
|
|
|
|
func (p *PullRequestPayload) JSONPayload() ([]byte, error) { |
|
|
|
func (p *PullRequestPayload) JSONPayload() ([]byte, error) { |
|
|
|
|
|
|
|
json := jsoniter.ConfigCompatibleWithStandardLibrary |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -479,5 +490,6 @@ func (p *RepositoryPayload) SetSecret(secret string) { |
|
|
|
|
|
|
|
|
|
|
|
// JSONPayload JSON representation of the payload
|
|
|
|
// JSONPayload JSON representation of the payload
|
|
|
|
func (p *RepositoryPayload) JSONPayload() ([]byte, error) { |
|
|
|
func (p *RepositoryPayload) JSONPayload() ([]byte, error) { |
|
|
|
|
|
|
|
json := jsoniter.ConfigCompatibleWithStandardLibrary |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
return json.MarshalIndent(p, "", " ") |
|
|
|
} |
|
|
|
} |
|
|
|