Skip to content

Commit

Permalink
feat: add headers http trigger (#642)
Browse files Browse the repository at this point in the history
  • Loading branch information
VaibhavPage authored May 6, 2020
1 parent 00594f8 commit 1db7e26
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 6 deletions.
14 changes: 12 additions & 2 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,16 @@
"description": "BasicAuth configuration for the http request.",
"$ref": "#/definitions/io.argoproj.sensor.v1alpha1.BasicAuth"
},
"headers": {
"description": "Headers for the HTTP request.",
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
},
"method": {
"description": "Method refers to the type of the HTTP request. Refer https://golang.org/src/net/http/method.go for more info. Default value is POST.",
"type": "string"
Expand All @@ -1504,15 +1514,15 @@
"items": {
"$ref": "#/definitions/io.argoproj.sensor.v1alpha1.TriggerParameter"
},
"x-kubernetes-list-type": "triggerParameters"
"x-kubernetes-list-type": "atomic"
},
"payload": {
"description": "Payload is the list of key-value extracted from an event payload to construct the HTTP request payload.",
"type": "array",
"items": {
"$ref": "#/definitions/io.argoproj.sensor.v1alpha1.TriggerParameter"
},
"x-kubernetes-list-type": "payloadParameters"
"x-kubernetes-list-type": "atomic"
},
"timeout": {
"description": "Timeout refers to the HTTP request timeout in seconds. Default value is 60 seconds.",
Expand Down
12 changes: 12 additions & 0 deletions api/sensor.html
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,18 @@ <h3 id="argoproj.io/v1alpha1.HTTPTrigger">HTTPTrigger
<p>BasicAuth configuration for the http request.</p>
</td>
</tr>
<tr>
<td>
<code>headers</code></br>
<em>
map[string][]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Headers for the HTTP request.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="argoproj.io/v1alpha1.JSONType">JSONType
Expand Down
22 changes: 22 additions & 0 deletions api/sensor.md
Original file line number Diff line number Diff line change
Expand Up @@ -2779,6 +2779,28 @@ BasicAuth configuration for the http request.

</tr>

<tr>

<td>

<code>headers</code></br> <em> map\[string\]\[\]string </em>

</td>

<td>

<em>(Optional)</em>

<p>

Headers for the HTTP request.

</p>

</td>

</tr>

</tbody>

</table>
Expand Down
26 changes: 24 additions & 2 deletions pkg/apis/sensor/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions pkg/apis/sensor/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ type HTTPTrigger struct {
// URL refers to the URL to send HTTP request to.
URL string `json:"url" protobuf:"bytes,1,name=url"`
// Payload is the list of key-value extracted from an event payload to construct the HTTP request payload.
// +listType=payloadParameters
// +listType=atomic
Payload []TriggerParameter `json:"payload" protobuf:"bytes,2,rep,name=payload"`
// TLS configuration for the HTTP client.
// +optional
Expand All @@ -400,7 +400,7 @@ type HTTPTrigger struct {
Method string `json:"method,omitempty" protobuf:"bytes,4,opt,name=method"`
// Parameters is the list of key-value extracted from event's payload that are applied to
// the HTTP trigger resource.
// +listType=triggerParameters
// +listType=atomic
Parameters []TriggerParameter `json:"parameters,omitempty" protobuf:"bytes,5,rep,name=parameters"`
// Timeout refers to the HTTP request timeout in seconds.
// Default value is 60 seconds.
Expand All @@ -409,6 +409,10 @@ type HTTPTrigger struct {
// BasicAuth configuration for the http request.
// +optional
BasicAuth *BasicAuth `json:"basicAuth,omitempty" protobuf:"bytes,7,opt,name=basicAuth"`
// Headers for the HTTP request.
// +mapType=granular
// +optional
Headers map[string][]string `json:"headers,omitempty" protobuf:"bytes,8,opt,name=headers"`
}

// TLSConfig refers to TLS configuration for the HTTP client
Expand Down
15 changes: 15 additions & 0 deletions pkg/apis/sensor/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions sensors/triggers/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ func (t *HTTPTrigger) Execute(resource interface{}) (interface{}, error) {
return nil, errors.Wrapf(err, "failed to construct request for %s", trigger.URL)
}

if trigger.Headers != nil {
request.Header = trigger.Headers
}

basicAuth := trigger.BasicAuth

if basicAuth != nil {
Expand Down

0 comments on commit 1db7e26

Please sign in to comment.