util

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const SkiperatorUser = int64(150)

Variables

View Source
var (
	IstioMetricsPortNumber = intstr.FromInt(15020)
	IstioMetricsPortName   = intstr.FromString("istio-metrics")
	IstioMetricsPath       = "/stats/prometheus"

	IstioRevisionLabel = "istio.io/rev"
)
View Source
var CommonAnnotations = map[string]string{

	"argocd.argoproj.io/sync-options": "Prune=false",
}
View Source
var LeastPrivilegeContainerSecurityContext = corev1.SecurityContext{
	Capabilities: PointTo(corev1.Capabilities{
		Add: []corev1.Capability{},
		Drop: []corev1.Capability{
			"all",
		},
	}),
	Privileged:               PointTo(false),
	RunAsUser:                PointTo(SkiperatorUser),
	RunAsGroup:               PointTo(SkiperatorUser),
	RunAsNonRoot:             PointTo(true),
	ReadOnlyRootFilesystem:   PointTo(true),
	AllowPrivilegeEscalation: PointTo(false),
	SeccompProfile: &corev1.SeccompProfile{
		Type: corev1.SeccompProfileTypeRuntimeDefault,
	},
}

A security context for use in pod containers created by Skiperator follow least privilege best practices for the whole Container Security Context

Functions

func ErrDoPanic

func ErrDoPanic(err error, message string)

func ErrIsMissingOrNil

func ErrIsMissingOrNil(recorder record.EventRecorder, err error, message string, object runtime.Object) bool

func GenerateHashFromName

func GenerateHashFromName(name string) uint64

func GetConfigMap

func GetConfigMap(client client.Client, ctx context.Context, namespacedName types.NamespacedName) (corev1.ConfigMap, error)

func GetHashForStructs added in v1.0.0

func GetHashForStructs(obj []interface{}) string

func GetObjectDiff added in v1.0.0

func GetObjectDiff[T any](a T, b T) (diff.Changelog, error)

func GetPodAppSelector added in v1.0.0

func GetPodAppSelector(applicationName string) map[string]string

func HasUpperCaseLetter added in v1.0.0

func HasUpperCaseLetter(word string) bool

func IsInternal

func IsInternal(hostname string) bool

func PointTo added in v1.0.0

func PointTo[T any](x T) *T

func ResolveImageTags added in v1.0.0

func ResolveImageTags(ctx context.Context, log logr.Logger, config *rest.Config, deployment *appsv1.Deployment) (*appsv1.Deployment, error)

func ResourceNameWithKindPostfix added in v1.0.0

func ResourceNameWithKindPostfix(resourceName string, kind string) string

func SetCommonAnnotations

func SetCommonAnnotations(object client.Object)

Types

type MatchesPredicate

type MatchesPredicate[T client.Object] func(T) bool

func (MatchesPredicate[T]) Create

func (m MatchesPredicate[T]) Create(evt event.CreateEvent) bool

func (MatchesPredicate[T]) Delete

func (m MatchesPredicate[T]) Delete(evt event.DeleteEvent) bool

func (MatchesPredicate[T]) Generic

func (m MatchesPredicate[T]) Generic(evt event.GenericEvent) bool

func (MatchesPredicate[T]) Update

func (m MatchesPredicate[T]) Update(evt event.UpdateEvent) bool

type ReconcilerBase

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

ReconcilerBase is a base struct from which all reconcilers can be derived from. By doing so your reconcilers will also inherit a set of utility functions To inherit from reconciler just build your finalizer this way:

type MyReconciler struct {
  util.ReconcilerBase
  ... other optional fields ...
}

func NewFromManager

func NewFromManager(mgr manager.Manager, recorder record.EventRecorder) ReconcilerBase

NewReconcilerBase is a contruction function to create a new ReconcilerBase.

func NewReconcilerBase

func NewReconcilerBase(client client.Client, extensionsClient *apiextensionsclient.Clientset, scheme *runtime.Scheme, restConfig *rest.Config, recorder record.EventRecorder, apireader client.Reader) ReconcilerBase

func (*ReconcilerBase) DeleteObjectIfExists added in v1.0.0

func (r *ReconcilerBase) DeleteObjectIfExists(ctx context.Context, object client.Object) error

func (*ReconcilerBase) EmitNormalEvent added in v1.0.0

func (r *ReconcilerBase) EmitNormalEvent(object runtime.Object, reason string, message string)

func (*ReconcilerBase) EmitWarningEvent added in v1.0.0

func (r *ReconcilerBase) EmitWarningEvent(object runtime.Object, reason string, message string)

func (*ReconcilerBase) GetApiExtensionsClient added in v1.0.0

func (r *ReconcilerBase) GetApiExtensionsClient() *apiextensionsclient.Clientset

GetApiExtensionsClient returns the underlying API Extensions client

func (*ReconcilerBase) GetClient

func (r *ReconcilerBase) GetClient() client.Client

GetClient returns the underlying client

func (*ReconcilerBase) GetEgressServices added in v1.0.0

func (r *ReconcilerBase) GetEgressServices(ctx context.Context, owner client.Object, accessPolicy *podtypes.AccessPolicy) ([]corev1.Service, error)

func (*ReconcilerBase) GetRecorder

func (r *ReconcilerBase) GetRecorder() record.EventRecorder

GetRecorder returns the underlying recorder

func (*ReconcilerBase) GetRestConfig

func (r *ReconcilerBase) GetRestConfig() *rest.Config

GetRestConfig returns the undelying rest config

func (*ReconcilerBase) GetScheme

func (r *ReconcilerBase) GetScheme() *runtime.Scheme

GetScheme returns the scheme

func (*ReconcilerBase) IsIstioEnabledForNamespace added in v1.0.0

func (r *ReconcilerBase) IsIstioEnabledForNamespace(ctx context.Context, namespaceName string) bool

func (*ReconcilerBase) ShouldReconcile added in v1.0.0

func (r *ReconcilerBase) ShouldReconcile(ctx context.Context, obj client.Object) (bool, error)

Jump to

Keyboard shortcuts

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