bootstrap

package
v0.0.0-...-ab80bd7 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: GPL-3.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// ConfigMapName is the name of the cluster-wide config ConfigMap.
	ConfigMapName = "cluster"
	// ConfigMapKey is the key that holds the cluster config in the ConfigMap.
	ConfigMapKey = "cluster.yaml"
)
View Source
const (
	// DeploymentName is the name of the cluster-wide dispatcher Deployment.
	DeploymentName = "dispatcher"
	// ContainerName is the name of the dispatcher container.
	ContainerName = "dispatcher"
)
View Source
const (
	// EnvNATSURL holds the NATS URL in the dispatcher environment.
	EnvNATSURL = "NATS_URL"
	// EnvNATSSecret holds the NATS Secret name in the dispatcher environment.
	EnvNATSSecret = "NATS_SECRET"
	// EnvNATSAuth holds the NATS authentication method in the dispatcher environment.
	EnvNATSAuth = "NATS_AUTH"
	// EnvNATSTLS holds the NATS TLS setting in the dispatcher environment.
	EnvNATSTLS = "NATS_TLS"
	// EnvNATSStream holds the NATS stream name in the dispatcher environment.
	EnvNATSStream = "NATS_STREAM"
	// EnvNATSMaxPayload holds the NATS payload limit in the dispatcher environment.
	EnvNATSMaxPayload = "NATS_MAX_PAYLOAD"
	// EnvDispatchAttempts holds the dispatch attempt limit in the dispatcher environment.
	EnvDispatchAttempts = "DISPATCH_ATTEMPTS"
	// EnvDispatchTimeout holds the dispatch timeout in the dispatcher environment.
	EnvDispatchTimeout = "DISPATCH_TIMEOUT"
	// EnvWorkflowTTL holds the workflow retention in the dispatcher environment.
	EnvWorkflowTTL = "WORKFLOW_TTL"
)
View Source
const (
	// ServiceAccountName is the name of the dispatcher ServiceAccount.
	ServiceAccountName = "dispatcher"
	// ClusterRoleName is the name of the dispatcher ClusterRole.
	ClusterRoleName = "dispatcher"
	// RoleBindingName is the name of the dispatcher RoleBinding.
	RoleBindingName = "dispatcher"
)

Variables

This section is empty.

Functions

func ApplyClusterRole

func ApplyClusterRole(ctx context.Context, clusterRoles typedrbacv1.ClusterRoleInterface, desired *rbacv1.ClusterRole) error

ApplyClusterRole creates or replaces a ClusterRole.

func ApplyConfigMap

func ApplyConfigMap(ctx context.Context, configMaps typedcorev1.ConfigMapInterface, desired *corev1.ConfigMap) error

ApplyConfigMap creates or replaces a ConfigMap.

func ApplyDeployment

func ApplyDeployment(ctx context.Context, deployments typedappsv1.DeploymentInterface, desired *appsv1.Deployment) error

ApplyDeployment creates or replaces a Deployment.

func ApplyDispatcherDeployment

func ApplyDispatcherDeployment(ctx context.Context, deployments typedappsv1.DeploymentInterface, desired *appsv1.Deployment) error

ApplyDispatcherDeployment is an alias for ApplyDeployment.

func ApplyRoleBinding

func ApplyRoleBinding(ctx context.Context, roleBindings typedrbacv1.RoleBindingInterface, desired *rbacv1.RoleBinding) error

ApplyRoleBinding creates or replaces a RoleBinding.

func ApplyServiceAccount

func ApplyServiceAccount(ctx context.Context, serviceAccounts typedcorev1.ServiceAccountInterface, desired *corev1.ServiceAccount) error

ApplyServiceAccount creates or replaces a ServiceAccount.

func PayloadLimit

func PayloadLimit(client NATSClient, requested *resource.Quantity) *resource.Quantity

PayloadLimit returns the lower of the requested payload and the server maximum.

func RenderClusterRole

func RenderClusterRole() *rbacv1.ClusterRole

RenderClusterRole builds the dispatcher ClusterRole.

func RenderConfigMap

func RenderConfigMap(namespace string, connection Connection, stream string, limits Limits) (*corev1.ConfigMap, error)

RenderConfigMap builds the cluster ConfigMap from the connection and limits.

func RenderDeployment

func RenderDeployment(namespace string, connection Connection, stream string, limits Limits, image ...string) (*appsv1.Deployment, error)

RenderDeployment builds the dispatcher Deployment from the connection, limits, and image.

func RenderDispatcherDeployment

func RenderDispatcherDeployment(namespace string, connection Connection, stream string, limits Limits, image ...string) (*appsv1.Deployment, error)

RenderDispatcherDeployment is an alias for RenderDeployment.

func RenderRoleBinding

func RenderRoleBinding(namespace string) *rbacv1.RoleBinding

RenderRoleBinding builds the RoleBinding that grants the ClusterRole to the dispatcher ServiceAccount.

func RenderServiceAccount

func RenderServiceAccount(namespace string) *corev1.ServiceAccount

RenderServiceAccount builds the dispatcher ServiceAccount.

func ValidateNATS

func ValidateNATS(client NATSClient, stream string, dispatchTimeout time.Duration) error

ValidateNATS rejects a server, stream, or stream limits that Octoba cannot use.

Types

type AuthMethod

type AuthMethod string

AuthMethod is the NATS authentication method recorded in the cluster config.

const (
	AuthBasic      AuthMethod = "basic"
	AuthToken      AuthMethod = "token"
	AuthCredential AuthMethod = "credential"
	AuthNKey       AuthMethod = "nkey"
)

type Connection

type Connection struct {
	URL    string
	Secret string
	Auth   AuthMethod
	TLS    bool
}

Connection holds the NATS settings derived from the referenced Secret.

func ConnectionFromSecret

func ConnectionFromSecret(secret *corev1.Secret, url string) (Connection, error)

ConnectionFromSecret derives the NATS connection from a Secret.

func Load

func Load(ctx context.Context, secrets SecretGetter, url, name string) (Connection, *corev1.Secret, error)

Load reads the named Secret and derives the NATS connection from it.

func LoadConnection

func LoadConnection(ctx context.Context, secrets SecretGetter, url, name string) (Connection, error)

LoadConnection reads the named Secret and derives the NATS connection from it.

type Limits

type Limits struct {
	NATSPayload      *resource.Quantity
	DispatchAttempts int
	DispatchTimeout  time.Duration
	WorkflowTTL      time.Duration
}

Limits are the cluster-wide dispatch limits recorded in the cluster config.

type NATSClient

type NATSClient interface {
	ServerVersion() string
	StreamInfo(name string) (*nats.StreamInfo, error)
	UpdateStream(config *nats.StreamConfig, options ...nats.JSOpt) (*nats.StreamInfo, error)
	Close()
}

NATSClient is the subset of a NATS connection that Octoba needs.

func Connect

func Connect(connection Connection, secret *corev1.Secret) (NATSClient, error)

Connect opens a NATS connection from a derived connection and its Secret.

type SecretGetter

type SecretGetter interface {
	Get(ctx context.Context, name string, opts metav1.GetOptions) (*corev1.Secret, error)
}

SecretGetter reads a Kubernetes Secret.

Jump to

Keyboard shortcuts

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