github.com/argoproj/argo-events@v1.9.1/pkg/apis/eventsource/v1alpha1/webhook_context.go (about)

     1  package v1alpha1
     2  
     3  import (
     4  	corev1 "k8s.io/api/core/v1"
     5  )
     6  
     7  const DefaultMaxWebhookPayloadSize int64 = 1048576 // 1MB
     8  
     9  // WebhookContext holds a general purpose REST API context
    10  type WebhookContext struct {
    11  	// REST API endpoint
    12  	Endpoint string `json:"endpoint" protobuf:"bytes,1,opt,name=endpoint"`
    13  	// Method is HTTP request method that indicates the desired action to be performed for a given resource.
    14  	// See RFC7231 Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content
    15  	Method string `json:"method" protobuf:"bytes,2,opt,name=method"`
    16  	// Port on which HTTP server is listening for incoming events.
    17  	Port string `json:"port" protobuf:"bytes,3,opt,name=port"`
    18  	// URL is the url of the server.
    19  	URL string `json:"url" protobuf:"bytes,4,opt,name=url"`
    20  	// ServerCertPath refers the file that contains the cert.
    21  	ServerCertSecret *corev1.SecretKeySelector `json:"serverCertSecret,omitempty" protobuf:"bytes,5,opt,name=serverCertSecret"`
    22  	// ServerKeyPath refers the file that contains private key
    23  	ServerKeySecret *corev1.SecretKeySelector `json:"serverKeySecret,omitempty" protobuf:"bytes,6,opt,name=serverKeySecret"`
    24  	// Metadata holds the user defined metadata which will passed along the event payload.
    25  	// +optional
    26  	Metadata map[string]string `json:"metadata,omitempty" protobuf:"bytes,7,rep,name=metadata"`
    27  	// AuthSecret holds a secret selector that contains a bearer token for authentication
    28  	// +optional
    29  	AuthSecret *corev1.SecretKeySelector `json:"authSecret,omitempty" protobuf:"bytes,8,opt,name=authSecret"`
    30  	// MaxPayloadSize is the maximum webhook payload size that the server will accept.
    31  	// Requests exceeding that limit will be rejected with "request too large" response.
    32  	// Default value: 1048576 (1MB).
    33  	// +optional
    34  	MaxPayloadSize *int64 `json:"maxPayloadSize,omitempty" protobuf:"bytes,9,opt,name=maxPayloadSize"`
    35  }
    36  
    37  func (wc *WebhookContext) GetMaxPayloadSize() int64 {
    38  	maxPayloadSize := DefaultMaxWebhookPayloadSize
    39  	if wc != nil && wc.MaxPayloadSize != nil {
    40  		maxPayloadSize = *wc.MaxPayloadSize
    41  	}
    42  
    43  	return maxPayloadSize
    44  }