api

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

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
}

Config holds settings required to create new api

func ParseConfig

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

ParseConfig retrieves Config from given ConfigMap and Secret

func (Config) GetGlobalDestinations

func (cfg Config) GetGlobalDestinations(labels 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 *v1.ConfigMap, secret *v1.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