utils

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// APIContainerName ...
	APIContainerName string = "kappnav-api"
	// UIContainerName ...
	UIContainerName string = "kappnav-ui"
	// ControllerContainerName ...
	ControllerContainerName string = "kappnav-controller"
	// OAuthProxyContainerName ...
	OAuthProxyContainerName string = "oauth-proxy"
	// OAuthProxyContainerConfigKey ...
	OAuthProxyContainerConfigKey string = "oauthProxy"
	// ServiceAccountNameSuffix ...
	ServiceAccountNameSuffix string = "sa"
)
View Source
const (
	// OAuthRedirectAnnotationName ...
	OAuthRedirectAnnotationName string = "serviceaccounts.openshift.io/oauth-redirectreference.primary"
	// OAuthVolumeName ...
	OAuthVolumeName string = "ui-service-tls"
	// OAuthVolumeMountPath ...
	OAuthVolumeMountPath string = "/etc/tls/private"
)

Variables

This section is empty.

Functions

func CallerName added in v0.8.0

func CallerName() string

CallerName get the caller program file name, line number and function name in "fileName:line# funcName"

func CreateControllerDeploymentContainers

func CreateControllerDeploymentContainers(existingContainers []corev1.Container, instance *kappnavv1.Kappnav) []corev1.Container

CreateControllerDeploymentContainers ...

func CreateUIDeploymentContainers

func CreateUIDeploymentContainers(existingContainers []corev1.Container, instance *kappnavv1.Kappnav) []corev1.Container

CreateUIDeploymentContainers ...

func CreateUIVolumes

func CreateUIVolumes(instance *kappnavv1.Kappnav) []corev1.Volume

CreateUIVolumes ...

func CustomizeApplication added in v0.8.0

func CustomizeApplication(app *appv1beta1.Application, instance *kappnavv1.Kappnav, annotations map[string]string)

CustomizeApplication ...

func CustomizeBuiltinConfigMap

func CustomizeBuiltinConfigMap(logger Logger, builtinConfig *corev1.ConfigMap, r *ReconcilerBase, instance *kappnavv1.Kappnav)

CustomizeBuiltinConfigMap ...

func CustomizeClusterRoleBinding

func CustomizeClusterRoleBinding(crb *rbacv1.ClusterRoleBinding,
	sa *corev1.ServiceAccount, instance *kappnavv1.Kappnav)

CustomizeClusterRoleBinding ...

func CustomizeConfigMap

func CustomizeConfigMap(configMap *corev1.ConfigMap, instance *kappnavv1.Kappnav, mapType string)

CustomizeConfigMap ...

func CustomizeDeployment

func CustomizeDeployment(deploy *appsv1.Deployment, instance *kappnavv1.Kappnav)

CustomizeDeployment ...

func CustomizeIngress

func CustomizeIngress(ingress *extensionsv1beta1.Ingress, instance *kappnavv1.Kappnav)

CustomizeIngress ...

func CustomizeKAM added in v0.8.0

func CustomizeKAM(kam *kamv1.KindActionMapping, default_kam *kamv1.KindActionMapping, instance *kappnavv1.Kappnav)

CustomizeKAM ...

func CustomizeKappnavConfigMap

func CustomizeKappnavConfigMap(kappnavConfig *corev1.ConfigMap, kappnavURL string, instance *kappnavv1.Kappnav)

CustomizeKappnavConfigMap ...

func CustomizePodSpec

func CustomizePodSpec(pts *corev1.PodTemplateSpec, parentComponent *metav1.ObjectMeta,
	containers []corev1.Container, volumes []corev1.Volume, instance *kappnavv1.Kappnav)

CustomizePodSpec ...

func CustomizeRoute

func CustomizeRoute(route *routev1.Route, instance *kappnavv1.Kappnav)

CustomizeRoute ...

func CustomizeSecret

func CustomizeSecret(secret *corev1.Secret, instance *kappnavv1.Kappnav)

CustomizeSecret ...

func CustomizeService

func CustomizeService(service *corev1.Service, instance *kappnavv1.Kappnav, annotations map[string]string)

CustomizeService ...

func CustomizeServiceAccount

func CustomizeServiceAccount(logger Logger, sa *corev1.ServiceAccount, uiService *metav1.ObjectMeta, instance *kappnavv1.Kappnav)

CustomizeServiceAccount ...

func CustomizeUIIngressSpec

func CustomizeUIIngressSpec(ingressSpec *extensionsv1beta1.IngressSpec,
	uiService *corev1.Service, instance *kappnavv1.Kappnav)

CustomizeUIIngressSpec ...

func CustomizeUIRouteSpec

func CustomizeUIRouteSpec(routeSpec *routev1.RouteSpec,
	routeName *metav1.ObjectMeta, instance *kappnavv1.Kappnav)

CustomizeUIRouteSpec ...

func CustomizeUIServiceSpec

func CustomizeUIServiceSpec(serviceSpec *corev1.ServiceSpec, instance *kappnavv1.Kappnav)

CustomizeUIServiceSpec ...

func ErrorWithStack added in v0.8.0

func ErrorWithStack(msg string) string

ErrorWithStack print stack trace for error message

func FormatTimestamp added in v0.8.0

func FormatTimestamp(t time.Time) float64

FormatTimeStamp format with unix seconds in float

func GetCondition

func GetCondition(conditionType kappnavv1.StatusConditionType, status *kappnavv1.KappnavStatus) *kappnavv1.StatusCondition

GetCondition ...

func GetLabels

func GetLabels(instance *kappnavv1.Kappnav,
	existingLabels map[string]string, component *metav1.ObjectMeta, mapType string) map[string]string

GetLabels ...

func IsMinikubeEnv

func IsMinikubeEnv(kubeEnv string) bool

IsMinikubeEnv ...

func IsOCP

func IsOCP(kubeEnv string) bool

IsOCP ...

func IsOpenShift

func IsOpenShift(kubeEnv string) bool

IsOpenShift ...

func RepositoryContains added in v0.10.0

func RepositoryContains(r kappnavv1.Repository, substr string) bool

RepositoryContains ... For use in ConfigMap templates.

func RepositoryHasPrefix added in v0.10.0

func RepositoryHasPrefix(r kappnavv1.Repository, prefix string) bool

RepositoryHasPrefix ... For use in ConfigMap templates.

func RepositoryHasSuffix added in v0.10.0

func RepositoryHasSuffix(r kappnavv1.Repository, suffix string) bool

RepositoryHasSuffix ... For use in ConfigMap templates.

func SetCondition

func SetCondition(condition kappnavv1.StatusCondition, status *kappnavv1.KappnavStatus)

SetCondition ...

func SetKAMDefaults added in v0.8.0

func SetKAMDefaults(instance_kam *kamv1.KindActionMapping) error

SetKAMDefaults sets default kam values on the CR instance

func SetKappnavDefaults

func SetKappnavDefaults(instance *kappnavv1.Kappnav) error

SetKappnavDefaults sets default values on the CR instance

func TagContains added in v0.10.0

func TagContains(t kappnavv1.Tag, substr string) bool

TagContains ... For use in ConfigMap templates.

func TagHasPrefix added in v0.10.0

func TagHasPrefix(t kappnavv1.Tag, prefix string) bool

TagHasPrefix ... For use in ConfigMap templates.

func TagHasSuffix added in v0.10.0

func TagHasSuffix(t kappnavv1.Tag, suffix string) bool

TagHasSuffix ... For use in ConfigMap templates.

Types

type KappnavExtension

type KappnavExtension interface {
	ReconcileAdditionalResources(logger Logger, request reconcile.Request, r *ReconcilerBase, instance *kappnavv1.Kappnav) (reconcile.Result, error)
}

KappnavExtension extends the reconciler to manage additional resources.

func NewKappnavExtension

func NewKappnavExtension() KappnavExtension

NewKappnavExtension ...

type LogLevel added in v0.8.0

type LogLevel int

LogLevel values of LogLevel. LogLevel is what user requests

const (
	// LogLevelNone request no trace
	LogLevelNone LogLevel = 0
	// LogLevelWarning request warning trace
	LogLevelWarning LogLevel = 1
	// LogLevelError request error trace
	LogLevelError LogLevel = 2
	// LogLevelInfo request info trace
	LogLevelInfo LogLevel = 3
	// LogLevelDebug request debug trace
	LogLevelDebug LogLevel = 4
	// LogLevelEntry request entry trace
	LogLevelEntry LogLevel = 5
	// LogLevelAll request all traces
	LogLevelAll LogLevel = 6
)

type LogType added in v0.8.0

type LogType int

LogType values of LogType. LogType is how code categorizes log message

const (
	// LogTypeEntry entry trace type
	LogTypeEntry LogType = 0
	// LogTypeExit exit trace type
	LogTypeExit LogType = 1
	// LogTypeInfo info trace type
	LogTypeInfo LogType = 2
	// LogTypeWarning warning trace type
	LogTypeWarning LogType = 3
	// LogTypeError error trace type
	LogTypeError LogType = 4
	// LogTypeDebug debug trace type
	LogTypeDebug LogType = 5
)

type Logger added in v0.8.0

type Logger interface {
	SetLogLevel(logLevel LogLevel)
	Log(callerName string, logType LogType, logData string, loggerName string)
	IsEnabled(logType LogType) bool
}

Logger interfaces

func NewLogger added in v0.8.0

func NewLogger(enableJSON bool) Logger

NewLogger create new Logger

type Message added in v0.8.0

type Message struct {
	Level     string  `json:"level"`
	Timestamp float64 `json:"ts"`
	Logger    string  `json:"logger"`
	Caller    string  `json:"caller"`
	Msg       string  `json:"msg"`
}

Message JSON structure

type OCPClusterInfo

type OCPClusterInfo struct {
	ConsoleBaseAddress string `yaml:"consoleBaseAddress,omitempty"`
}

OCPClusterInfo ...

type OCPConsoleConfig

type OCPConsoleConfig struct {
	ClusterInfo OCPClusterInfo `yaml:"clusterInfo,omitempty"`
}

OCPConsoleConfig ...

type OKDClusterInfo

type OKDClusterInfo struct {
	ConsolePublicURL      string `yaml:"consolePublicURL,omitempty"`
	AdminConsolePublicURL string `yaml:"adminConsolePublicURL,omitempty"`
}

OKDClusterInfo ...

type OKDConsoleConfig

type OKDConsoleConfig struct {
	ClusterInfo OKDClusterInfo `yaml:"clusterInfo,omitempty"`
}

OKDConsoleConfig ...

type ReconcilerBase

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

ReconcilerBase base reconciler with some common behaviour

func NewReconcilerBase

func NewReconcilerBase(client client.Client, scheme *runtime.Scheme, restConfig *rest.Config, recorder record.EventRecorder) ReconcilerBase

NewReconcilerBase creates a new ReconcilerBase

func (*ReconcilerBase) CreateOrUpdate

func (r *ReconcilerBase) CreateOrUpdate(logger Logger, obj metav1.Object, owner metav1.Object, reconcile func() error) error

CreateOrUpdate ...

func (*ReconcilerBase) DeleteResource

func (r *ReconcilerBase) DeleteResource(obj runtime.Object) error

DeleteResource deletes kubernetes resource

func (*ReconcilerBase) DeleteResources

func (r *ReconcilerBase) DeleteResources(resources []runtime.Object) error

DeleteResources ...

func (*ReconcilerBase) GetClient

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

GetClient returns client

func (*ReconcilerBase) GetDiscoveryClient

func (r *ReconcilerBase) GetDiscoveryClient() (discovery.DiscoveryInterface, error)

GetDiscoveryClient ...

func (*ReconcilerBase) GetOperatorConfigMap

func (r *ReconcilerBase) GetOperatorConfigMap(logger Logger, name string, ns string) (*corev1.ConfigMap, error)

GetOperatorConfigMap ...

func (*ReconcilerBase) GetRecorder

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

GetRecorder returns the underlying recorder

func (*ReconcilerBase) GetScheme

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

GetScheme retuns scheme

func (*ReconcilerBase) IsGroupVersionSupported

func (r *ReconcilerBase) IsGroupVersionSupported(groupVersion string) (bool, error)

IsGroupVersionSupported ...

func (*ReconcilerBase) ManageError

func (r *ReconcilerBase) ManageError(logger Logger, issue error, conditionType kappnavv1.StatusConditionType, cr *kappnavv1.Kappnav) (reconcile.Result, error)

ManageError ...

func (*ReconcilerBase) ManageSuccess

func (r *ReconcilerBase) ManageSuccess(logger Logger, conditionType kappnavv1.StatusConditionType, cr *kappnavv1.Kappnav) (reconcile.Result, error)

ManageSuccess ...

func (*ReconcilerBase) SetDiscoveryClient

func (r *ReconcilerBase) SetDiscoveryClient(discovery discovery.DiscoveryInterface)

SetDiscoveryClient ...

Jump to

Keyboard shortcuts

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