add omitempty to json fields

This commit is contained in:
Adnan Hajdarevic 2015-11-21 17:06:02 +01:00
parent ed9d557a13
commit 9cef8ed882

View file

@ -195,8 +195,8 @@ func ExtractParameterAsString(s string, params interface{}) (string, bool) {
// Argument type specifies the parameter key name and the source it should // Argument type specifies the parameter key name and the source it should
// be extracted from // be extracted from
type Argument struct { type Argument struct {
Source string `json:"source"` Source string `json:"source,omitempty"`
Name string `json:"name"` Name string `json:"name,omitempty"`
} }
// Get Argument method returns the value for the Argument's key name // Get Argument method returns the value for the Argument's key name
@ -248,15 +248,15 @@ func (ha *Argument) Get(headers, query, payload *map[string]interface{}) (string
// Hook type is a structure containing details for a single hook // Hook type is a structure containing details for a single hook
type Hook struct { type Hook struct {
ID string `json:"id"` ID string `json:"id,omitempty"`
ExecuteCommand string `json:"execute-command"` ExecuteCommand string `json:"execute-command,omitempty"`
CommandWorkingDirectory string `json:"command-working-directory"` CommandWorkingDirectory string `json:"command-working-directory,omitempty"`
ResponseMessage string `json:"response-message"` ResponseMessage string `json:"response-message,omitempty"`
CaptureCommandOutput bool `json:"include-command-output-in-response"` CaptureCommandOutput bool `json:"include-command-output-in-response,omitempty"`
PassEnvironmentToCommand []Argument `json:"pass-environment-to-command"` PassEnvironmentToCommand []Argument `json:"pass-environment-to-command,omitempty"`
PassArgumentsToCommand []Argument `json:"pass-arguments-to-command"` PassArgumentsToCommand []Argument `json:"pass-arguments-to-command,omitempty"`
JSONStringParameters []Argument `json:"parse-parameters-as-json"` JSONStringParameters []Argument `json:"parse-parameters-as-json,omitempty"`
TriggerRule *Rules `json:"trigger-rule"` TriggerRule *Rules `json:"trigger-rule,omitempty"`
} }
// ParseJSONParameters decodes specified arguments to JSON objects and replaces the // ParseJSONParameters decodes specified arguments to JSON objects and replaces the
@ -386,10 +386,10 @@ func (h *Hooks) MatchAll(id string) []*Hook {
// Rules is a structure that contains one of the valid rule types // Rules is a structure that contains one of the valid rule types
type Rules struct { type Rules struct {
And *AndRule `json:"and"` And *AndRule `json:"and,omitempty"`
Or *OrRule `json:"or"` Or *OrRule `json:"or,omitempty"`
Not *NotRule `json:"not"` Not *NotRule `json:"not,omitempty"`
Match *MatchRule `json:"match"` Match *MatchRule `json:"match,omitempty"`
} }
// Evaluate finds the first rule property that is not nil and returns the value // Evaluate finds the first rule property that is not nil and returns the value
@ -464,11 +464,11 @@ func (r NotRule) Evaluate(headers, query, payload *map[string]interface{}, body
// MatchRule will evaluate to true based on the type // MatchRule will evaluate to true based on the type
type MatchRule struct { type MatchRule struct {
Type string `json:"type"` Type string `json:"type,omitempty"`
Regex string `json:"regex"` Regex string `json:"regex,omitempty"`
Secret string `json:"secret"` Secret string `json:"secret,omitempty"`
Value string `json:"value"` Value string `json:"value,omitempty"`
Parameter Argument `json:"parameter"` Parameter Argument `json:"parameter,omitempty"`
} }
// Constants for the MatchRule type // Constants for the MatchRule type