Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrSpecNotFound is returned when the spec is not found ErrSpecNotFound = errors.New("spec not found") )
Functions ¶
func Load ¶
func Load() error
Load loads the configuration from the viper configuration file if an error is occurred, it will be returned
func Validate ¶
func Validate(config *Configuration) error
Validate the configuration file and her content
Types ¶
type Configuration ¶
type Configuration struct { // APIVerion is the version of the API that will be used APIVersion string `mapstructure:"apiVersion" json:"apiVersion"` // Observability is the configuration for observability Observability Observability `mapstructure:"observability" json:"observability"` // Specs is the configuration for the webhooks specs Specs []*WebhookSpec `mapstructure:"specs" json:"specs"` }
Configuration is the struct contains all the configuration defined in the webhooks yaml file
func (*Configuration) GetSpec ¶
func (c *Configuration) GetSpec(name string) (*WebhookSpec, error)
GetSpec returns the spec for the given name, if no entry is found, ErrSpecNotFound is returned
func (*Configuration) GetSpecByEndpoint ¶
func (c *Configuration) GetSpecByEndpoint(endpoint string) (*WebhookSpec, error)
GetSpecByEndpoint returns the spec for the given endpoint, if no entry is found, ErrSpecNotFound is returned
type FormattingSpec ¶
type FormattingSpec struct { // TemplatePath is the path to the template used to formatting the payload TemplatePath string `mapstructure:"templatePath"` // TemplateString is a plaintext template used to formatting the payload TemplateString string `mapstructure:"templateString"` // ResolvedTemplate is the template after resolving the template variables // It is defined by the configuration loader and cannot be overridden Template string `mapstructure:"-"` }
FormattingSpec is the struct contains the configuration to formatting the payload of the webhook spec. The field TempalteString is prioritized over the field TemplatePath when both are defined.
type Observability ¶
type Observability struct { // MetricsEnabled is the flag to enable or disable the prometheus metrics // endpoint and expose the metrics MetricsEnabled bool `mapstructure:"metricsEnabled" json:"metricsEnabled"` }
Observability is the struct contains the configuration for observability defined in the webhooks yaml file.
type Security ¶
type Security struct { // ID is the ID of the security. It must be unique in the configuration // file. It is defined by the user and is used to identify the security // factory as .Outputs ID string `mapstructure:"id"` // Inputs is the configuration for the inputs of the security. It is // defined by the user and following the specification of the security // factory Inputs []*factory.InputConfig `mapstructure:"inputs"` // Specs is the configuration for the specs of the security. It is // defined by the user and following the specification of the security // factory Specs map[string]interface{} `mapstructure:",remain"` }
Security is the struct contains the configuration for a security defined in the webhooks yaml file.
type StorageSpec ¶
type StorageSpec struct { // Type is the type of the storage. It must be a valid storage type // defined in the storage package. Type string `mapstructure:"type" json:"type"` // Specs is the configuration for the storage. It is defined by the user // following the storage type specification // NOTE: this field is hidden for json to prevent mistake of the user // when he use the custom formatting option and leak credentials Specs map[string]interface{} `mapstructure:"specs" json:"-"` // Format is used to define the payload format sent by the webhook spec // to this storage. If not defined, the format of the webhook spec is // used. // It is defined by the user and can be empty. See HasFormatting() method // to know if the webhook spec has format Formatting *FormattingSpec `mapstructure:"formatting" json:"-"` // Client is the storage client. It is defined by the configuration loader // and cannot be overridden Client storage.Pusher `mapstructure:"-" json:"-"` }
StorageSpec is the struct contains the configuration for a storage defined in the webhooks yaml file.
func (StorageSpec) HasFormatting ¶
func (s StorageSpec) HasFormatting() bool
HasFormatting returns true if the storage spec has a formatting
type WebhookSpec ¶
type WebhookSpec struct { // Name is the name of the webhook spec. It must be unique in the configuration // file. It is used to identify the webhook spec in the configuration file // and is defined by the user Name string `mapstructure:"name" json:"name"` // EntrypointURL is the URL of the entrypoint of the webhook spec. It must // be unique in the configuration file. It is defined by the user // It is used to identify the webhook spec when receiving a request EntrypointURL string `mapstructure:"entrypointUrl" json:"entrypointUrl"` // Security is the configuration for the security of the webhook spec // It is defined by the user and can be empty. See HasSecurity() method // to know if the webhook spec has security Security []map[string]Security `mapstructure:"security" json:"-"` // Format is used to define the payload format sent by the webhook spec // to all storages. Each storage can have its own format. When this // configuration is empty, the default formatting setting is used (body as JSON) // It is defined by the user and can be empty. See HasGlobalFormatting() method // to know if the webhook spec has format Formatting *FormattingSpec `mapstructure:"formatting" json:"-"` // SecurityPipeline is the security pipeline of the webhook spec // It is defined by the configuration loader. This field is not defined // by the user and cannot be overridden SecurityPipeline *factory.Pipeline `mapstructure:"-" json:"-"` // Storage is the configuration for the storage of the webhook spec // It is defined by the user and can be empty. Storage []*StorageSpec `mapstructure:"storage" json:"-"` }
WebhookSpec is the struct contains the configuration for a webhook spec defined in the webhooks yaml file.
func (WebhookSpec) HasGlobalFormatting ¶
func (s WebhookSpec) HasGlobalFormatting() bool
HasGlobalFormatting returns true if the spec has a global formatting
func (WebhookSpec) HasSecurity ¶
func (s WebhookSpec) HasSecurity() bool
HasSecurity returns true if the spec has a security factories