-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
http_types.go
62 lines (53 loc) · 2.25 KB
/
http_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package v1alpha1
import (
"net/http"
v1 "k8s.io/api/core/v1"
)
type HTTPHeaderSource struct {
SecretKeyRef *v1.SecretKeySelector `json:"secretKeyRef,omitempty" protobuf:"bytes,1,opt,name=secretKeyRef"`
}
type HTTPHeaders []HTTPHeader
// HTTPBodySource contains the source of the HTTP body.
type HTTPBodySource struct {
Bytes []byte `json:"bytes,omitempty" protobuf:"bytes,1,opt,name=bytes"`
}
func (h HTTPHeaders) ToHeader() http.Header {
outHeader := make(http.Header)
for _, header := range h {
// When this is used, header valueFrom should already be resolved
if header.ValueFrom != nil {
continue
}
outHeader[header.Name] = []string{header.Value}
}
return outHeader
}
type HTTPHeader struct {
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
Value string `json:"value,omitempty" protobuf:"bytes,2,opt,name=value"`
ValueFrom *HTTPHeaderSource `json:"valueFrom,omitempty" protobuf:"bytes,3,opt,name=valueFrom"`
}
type HTTP struct {
// Method is HTTP methods for HTTP Request
Method string `json:"method,omitempty" protobuf:"bytes,1,opt,name=method"`
// URL of the HTTP Request
URL string `json:"url" protobuf:"bytes,2,opt,name=url"`
// Headers are an optional list of headers to send with HTTP requests
Headers HTTPHeaders `json:"headers,omitempty" protobuf:"bytes,3,rep,name=headers"`
// TimeoutSeconds is request timeout for HTTP Request. Default is 30 seconds
TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty" protobuf:"bytes,4,opt,name=timeoutSeconds"`
// SuccessCondition is an expression if evaluated to true is considered successful
SuccessCondition string `json:"successCondition,omitempty" protobuf:"bytes,6,opt,name=successCondition"`
// Body is content of the HTTP Request
Body string `json:"body,omitempty" protobuf:"bytes,5,opt,name=body"`
// BodyFrom is content of the HTTP Request as Bytes
BodyFrom *HTTPBodySource `json:"bodyFrom,omitempty" protobuf:"bytes,8,opt,name=bodyFrom"`
// InsecureSkipVerify is a bool when if set to true will skip TLS verification for the HTTP client
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty" protobuf:"bytes,7,opt,name=insecureSkipVerify"`
}
func (h *HTTP) GetBodyBytes() []byte {
if h.BodyFrom != nil {
return h.BodyFrom.Bytes
}
return nil
}