Documentation ¶
Overview ¶
Package util contains misc utils
Index ¶
- Variables
- func Add[T any](ctx context.Context, entries ...T)
- func Get[T any](ctx context.Context) []T
- func GetNamespacedName(obj metav1.Object) types.NamespacedName
- func MergeMaps(first map[string]string, second map[string][]byte) (map[string]string, error)
- func NewBootstrapSecrets(name types.NamespacedName) (*corev1.Secret, error)
- func ParseNamespacedName(name string, options ...NamespacedNameOption) (*types.NamespacedName, error)
- func WithBin[T any](ctx context.Context) context.Context
- type Config
- type NamespacedNameOption
- type RestartOnConfigChange
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidNamespacedNameFormat namespaced name format error ErrInvalidNamespacedNameFormat = errors.New("invalid format, expect name or namespace/name") // ErrNamespaceExpected indicates that a namespace must be provided ErrNamespaceExpected = errors.New("missing namespace for resource") // ErrEmptyName indicates the resource must be non-empty ErrEmptyName = errors.New("resource name cannot be blank") )
Functions ¶
func GetNamespacedName ¶
func GetNamespacedName(obj metav1.Object) types.NamespacedName
GetNamespacedName a convenience method to return types.NamespacedName for an object
func NewBootstrapSecrets ¶
func NewBootstrapSecrets(name types.NamespacedName) (*corev1.Secret, error)
NewBootstrapSecrets generate secrets for pomerium bootstrap
func ParseNamespacedName ¶
func ParseNamespacedName(name string, options ...NamespacedNameOption) (*types.NamespacedName, error)
ParseNamespacedName parses "namespace/name" or "name" format
Types ¶
type NamespacedNameOption ¶
type NamespacedNameOption func(name *types.NamespacedName) error
NamespacedNameOption customizes namespaced name parsing
func WithClusterScope ¶
func WithClusterScope() NamespacedNameOption
WithClusterScope ensures the name is not namespaced
func WithDefaultNamespace ¶
func WithDefaultNamespace(namespace string) NamespacedNameOption
WithDefaultNamespace will set namespace to provided default, if missing
func WithMustNamespace ¶
func WithMustNamespace(namespace string) NamespacedNameOption
WithMustNamespace enforces the namespace to match provided one
func WithNamespaceExpected ¶
func WithNamespaceExpected() NamespacedNameOption
WithNamespaceExpected will set namespace to provided default, if missing
type RestartOnConfigChange ¶
type RestartOnConfigChange[T Config[T]] interface { // OnConfigUpdated may be called to provide updated configuration versions OnConfigUpdated(context.Context, T) // Run runs the task, restarting it when equal() returns false, by canceling task's execution context // if the task cannot complete within the given timeout threshold, Run would return an error // ensuring there are no unaccounted tasks left Run(ctx context.Context, equal func(prev, next T) bool, fn func(context.Context, T) error, shutdownTimeout time.Duration, ) error }
RestartOnConfigChange allows to run a task that should be restarted when config changes.
func NewRestartOnChange ¶
func NewRestartOnChange[T Config[T]]() RestartOnConfigChange[T]
NewRestartOnChange create a new instance