webhook

package
v0.0.0-...-fc3a142 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EventNewKubernetesVersionAvailable is the event type that is sent when a new Kubernetes version is available.
	EventNewKubernetesVersionAvailable = "Microsoft.ContainerService.NewKubernetesVersionAvailable"
	// EventClusterSupportEnding is the event type that is sent when support for a Kubernetes version is ending.
	EventClusterSupportEnding = "Microsoft.ContainerService.ClusterSupportEnding"
	// EventClusterSupportEnded is the event type that is sent when support for a Kubernetes version has ended.
	EventClusterSupportEnded = "Microsoft.ContainerService.ClusterSupportEnded"
	// EventNodePoolRollingStarted is the event type that is sent when a node pool rolling upgrade has started.
	EventNodePoolRollingStarted = "Microsoft.ContainerService.NodePoolRollingStarted"
	// EventNodePoolRollingSucceeded is the event type that is sent when a node pool rolling upgrade has succeeded.
	EventNodePoolRollingSucceeded = "Microsoft.ContainerService.NodePoolRollingSucceeded"
	// EventNodePoolRollingFailed is the event type that is sent when a node pool rolling upgrade has failed.
	EventNodePoolRollingFailed = "Microsoft.ContainerService.NodePoolRollingFailed"
)
View Source
const (
	// AzureEventGridOrigin represents the origin string for Azure Event Grid.
	AzureEventGridOrigin = "eventgrid.azure.net"
)

Variables

This section is empty.

Functions

func NewCloudEventHandler

func NewCloudEventHandler(ctx context.Context, pub *Publisher) (http.Handler, error)

NewCloudEventHandler creates a new CloudEvent handler with the given Publisher.

func NewServer

func NewServer(h http.Handler, opts ServerOptions) *http.Server

NewServer creates a new http.Server with the given handler, port and path. The handler is expected to provide the webhook functionality.

func Shutdown

func Shutdown(ctx context.Context, s *http.Server, done chan<- struct{}, timeout time.Duration)

Shutdown gracefully shuts down the server when a SIGINT or SIGTERM is received.

Types

type ContainerServiceClusterRollingEvent

type ContainerServiceClusterRollingEvent struct {
	NodePoolName string `json:"nodePoolName"`
}

ContainerServiceClusterRollingEvent represents the commonality for node pool rolling events.

type ContainerServiceClusterSupportEndedEvent

type ContainerServiceClusterSupportEndedEvent struct {
	ContainerServiceClusterSupportEvent
}

ContainerServiceClusterSupportEndedEvent is the event sent when support for a Kubernetes version has ended.

func (ContainerServiceClusterSupportEndedEvent) String

String returns a string representation of the ContainerServiceClusterSupportEndedEvent.

type ContainerServiceClusterSupportEndingEvent

type ContainerServiceClusterSupportEndingEvent struct {
	ContainerServiceClusterSupportEvent
}

ContainerServiceClusterSupportEndingEvent is the event sent when support for a Kubernetes version is ending.

func (ContainerServiceClusterSupportEndingEvent) String

String returns a string representation of the ContainerServiceClusterSupportEndingEvent.

type ContainerServiceClusterSupportEvent

type ContainerServiceClusterSupportEvent struct {
	KubernetesVersion string `json:"kubernetesVersion"`
}

ContainerServiceClusterSupportEvent represents the commonality for support ending and support ended events.

type ContainerServiceNewKubernetesVersionAvailableEvent

type ContainerServiceNewKubernetesVersionAvailableEvent struct {
	// LatestSupportedKubernetesVersion is the latest supported Kubernetes version.
	LatestSupportedKubernetesVersion string `json:"latestSupportedKubernetesVersion"`
	// LatestStableKubernetesVersion is the latest stable Kubernetes version.
	LatestStableKubernetesVersion string `json:"latestStableKubernetesVersion"`
	// LowestMinorKubernetesVersion is the lowest minor Kubernetes version.
	LowestMinorKubernetesVersion string `json:"lowestMinorKubernetesVersion"`
	// LatestPreviewKubernetesVersion is the latest preview Kubernetes version.
	LatestPreviewKubernetesVersion string `json:"latestPreviewKubernetesVersion"`
}

ContainerServiceNewKubernetesVersionAvailableEvent is the event that is sent by Azure Kubernetes Service when a new Kubernetes version is available in the CloudEvent's data field.

func (ContainerServiceNewKubernetesVersionAvailableEvent) String

String returns a string representation of the ContainerServiceNewKubernetesVersionAvailableEvent.

type ContainerServiceNodePoolRollingFailedEvent

type ContainerServiceNodePoolRollingFailedEvent struct {
	ContainerServiceClusterRollingEvent
}

ContainerServiceNodePoolRollingFailedEvent is the event sent when a node pool rolling upgrade has failed.

func (ContainerServiceNodePoolRollingFailedEvent) String

String returns a string representation of the ContainerServiceNodePoolRollingFailedEvent.

type ContainerServiceNodePoolRollingStartedEvent

type ContainerServiceNodePoolRollingStartedEvent struct {
	ContainerServiceClusterRollingEvent
}

ContainerServiceNodePoolRollingStartedEvent is the event sent when a node pool rolling upgrade has started.

func (ContainerServiceNodePoolRollingStartedEvent) String

String returns a string representation of the ContainerServiceNodePoolRollingStartedEvent.

type ContainerServiceNodePoolRollingSucceededEvent

type ContainerServiceNodePoolRollingSucceededEvent struct {
	ContainerServiceClusterRollingEvent
}

ContainerServiceNodePoolRollingSucceededEvent is the event sent when a node pool rolling upgrade has succeeded.

func (ContainerServiceNodePoolRollingSucceededEvent) String

String returns a string representation of the ContainerServiceNodePoolRollingSucceededEvent.

type Message

type Message struct {
	Source    string
	PlainText string
	HTML      string
}

Message represents a message.

type MessageBuilder

type MessageBuilder[T ContainerServiceEvent] struct {
	// contains filtered or unexported fields
}

MessageBuilder builds messages for a specific Azure Event Grid event type.

func NewMessageBuilder

func NewMessageBuilder[T ContainerServiceEvent](filename string) MessageBuilder[T]

NewMessageBuilder creates a new MessageBuilder with the given template filename.

func (MessageBuilder[T]) Build

func (m MessageBuilder[T]) Build(e T, src string) (Message, error)

Build creates a new Message from the given event type and event source.

type Options

type Options func(options *options) error

Options represents a functional option for the Publisher.

func WithEmail

func WithEmail(from, to, subject string) Options

WithEmail configures the Publisher to use a specific email recipient. This is required when using SendGrid or SMTP.

func WithLogging

func WithLogging() Options

WithLogging configures the Publisher to output messages as structured logs.

func WithPublisherFunc

func WithPublisherFunc(fn PublisherFunc) Options

WithPublisherFunc configures the Publisher to use a custom PublisherFunc.

func WithSMTP

func WithSMTP(host string, port int, username string, password string) Options

WithSMTP configures the Publisher to send messages via SMTP.

func WithSendgrid

func WithSendgrid(apiKey string) Options

WithSendgrid configures the Publisher to send messages via SendGrid.

type Publisher

type Publisher struct {
	// contains filtered or unexported fields
}

Publisher is a message publisher.

func NewPublisher

func NewPublisher(opts ...Options) (*Publisher, error)

NewPublisher creates a new Publisher with the given options.

func (*Publisher) Publish

func (p *Publisher) Publish(m Message) error

Publish sends a message to all registered publishers.

type PublisherFunc

type PublisherFunc func(m Message) error

PublisherFunc is a function that publishes a message.

type ServerOptions

type ServerOptions struct {
	Path    string
	Port    int
	Secret1 string
	Secret2 string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL