mainhelper

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2020 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Overview

Package mainhelper provides helper functions for common boilerplate code in writing a main function such as setting up kube informers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcessEnvConfigOrDie

func ProcessEnvConfigOrDie(env interface{})

ProcessEnvConfigOrDie retrieves environment variables.

func RunProfilingServer

func RunProfilingServer(ctx context.Context, logger *zap.SugaredLogger, h *profiling.Handler)

RunProfilingServer starts a profiling server.

Types

type InitOption

type InitOption func(*initArgs)
var WithKubeFakes InitOption = func(args *initArgs) {
	args.injection = injection.Fake

	args.kubeConfig = &rest.Config{}
	args.skipK8sVersionCheck = true
}

WithKubeFakes uses knative injections fakes for any k8s related setup. This is used in tests.

func WithContext

func WithContext(ctx context.Context) InitOption

WithContext specifies the context to use.

func WithEnv

func WithEnv(env interface{}) InitOption

WithEnv specifies a pointer to an envConfig struct.

func WithMetricNamespace added in v0.16.0

func WithMetricNamespace(metricNamespace string) InitOption

WithMetricNamespace specifies the metric namespace to use.

type InitRes

type InitRes struct {
	Logger     *zap.SugaredLogger
	KubeClient kubernetes.Interface
	CMPWatcher configmap.Watcher
	Cleanup    func()
}

InitRes holds a collection of objects after init for convenient access by other custom logic in the main function.

func Init

func Init(component string, opts ...InitOption) (context.Context, *InitRes)

Similar to sharedmain.Main, Init runs common logic in starting a main function, it returns a result object that contains useful artifacts for later use. Unlike sharedmain.Main, Init is meant to be run as a helper function in any main functions, while sharedmain.Main runs controllers with predefined method signatures.

Jump to

Keyboard shortcuts

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