api

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: Apache-2.0 Imports: 18 Imported by: 12 modules, 30 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

This section is empty.

Variables

This section is empty.

Functions

func NewAPI

func NewAPI(cfg Config, getVars GetVars) (*api, error)

NewAPI creates new api instance using provided config

func NewFactory

func NewFactory(settings Settings, defaultNamespace string, secretsInformer cache.SharedIndexInformer, cmInformer cache.SharedIndexInformer) *apiFactory

NewFactory creates a new API factory if namespace is not empty, it will override the default namespace set in settings

Types

type API

type API interface {
	Send(obj map[string]interface{}, templates []string, dest services.Destination) error
	RunTrigger(triggerName string, vars map[string]interface{}) ([]triggers.ConditionResult, error)
	AddNotificationService(name string, service services.NotificationService)
	GetNotificationServices() map[string]services.NotificationService
	GetConfig() Config
}

API provides high level interface to send notifications and manage notification services

type Config

type Config struct {
	Services  map[string]ServiceFactory
	Triggers  map[string][]triggers.Condition
	Templates map[string]services.Notification
	// Subscriptions holds list of default application subscriptions
	Subscriptions subscriptions.DefaultSubscriptions
	// DefaultTriggers holds list of triggers that is used by default if subscriber don't specify trigger
	DefaultTriggers []string
	// ServiceDefaultTriggers holds list of default triggers per service
	ServiceDefaultTriggers map[string][]string
	Namespace              string
	IsSelfServiceConfig    bool
}

Config holds settings required to create new api

func ParseConfig

func ParseConfig(configMap *corev1.ConfigMap, secret *corev1.Secret) (*Config, error)

ParseConfig retrieves Config from given ConfigMap and Secret

func (Config) GetGlobalDestinations

func (cfg Config) GetGlobalDestinations(resourceLabels map[string]string) services.Destinations

Returns list of destinations for the specified trigger

type Factory

type Factory interface {
	GetAPI() (API, error)
	GetAPIsFromNamespace(namespace string) (map[string]API, error)
}

Factory creates an API instance

type GetVars

type GetVars func(obj map[string]interface{}, dest services.Destination) map[string]interface{}

type ServiceFactory

type ServiceFactory func() (services.NotificationService, error)

type Settings

type Settings struct {
	// ConfigMapName holds Kubernetes ConfigName name that contains notifications settings
	ConfigMapName string
	// SecretName holds Kubernetes Secret name that contains sensitive information
	SecretName string
	// InitGetVars returns a function that produces notifications context variables
	InitGetVars func(cfg *Config, configMap *corev1.ConfigMap, secret *corev1.Secret) (GetVars, error)
	// DefaultNamespace default namespace for ConfigMap and Secret.
	// For self-service notification, we get notification configurations from rollout resource namespace
	// and also the default namespace
	DefaultNamespace string
}

Settings holds a set of settings required for API creation

Jump to

Keyboard shortcuts

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