helper

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: Apache-2.0 Imports: 27 Imported by: 3

Documentation

Index

Constants

View Source
const ConsoleLinkMasterNamePrefix = "system-master-link"

ConsoleLinkMasterNamePrefix is the prefix applied to Console link for system master

View Source
const ConsoleLinkText = "APIManager - 3scale"

ConsoleLinkText is the text of the consoleLink shown on the webconsole

Variables

View Source
var DefaultTransport = &Transport{
	Transport: http.DefaultTransport,
}

DefaultTransport is the default logging transport that wraps http.DefaultTransport.

View Source
var (
	ErrNonExistentKey = errors.New("non-existent key")
)

Errors

Functions

func ArrayContains added in v0.7.0

func ArrayContains(a []string, x string) bool

ArrayContains tells whether a contains x.

func ArrayFind added in v0.7.0

func ArrayFind(a []string, x string) int

ArrayFind returns the smallest index i at which x == a[i], or len(a) if there is no such index.

func ArrayStringDifference added in v0.6.0

func ArrayStringDifference(a, b []string) []string

func ArrayStringIntersection added in v0.6.0

func ArrayStringIntersection(a, b []string) []string

func CmpResourceList added in v0.4.0

func CmpResourceList(a, b *v1.ResourceList) bool

CmpResourceList returns true if the resourceList a is equal to b,

func CmpResources added in v0.4.0

func CmpResources(a, b *v1.ResourceRequirements) bool

CmpResources returns true if the resource requirements a is equal to b,

func EnsureObjectMeta added in v0.4.0

func EnsureObjectMeta(existing, desired common.KubernetesObject) bool

EnsureObjectMeta ensure Labels, Annotations

func EnsureString added in v0.4.0

func EnsureString(modified *bool, existing *string, required string)

func EnvVarFromConfigMap added in v0.6.0

func EnvVarFromConfigMap(envVarName string, configMapName, configMapKey string) v1.EnvVar

func EnvVarFromConfigMapOptional added in v0.6.0

func EnvVarFromConfigMapOptional(envVarName string, configMapName, configMapKey string) v1.EnvVar

func EnvVarFromSecret added in v0.6.0

func EnvVarFromSecret(envVarName string, secretName, secretKey string) v1.EnvVar

func EnvVarFromSecretOptional added in v0.6.0

func EnvVarFromSecretOptional(envVarName string, secretName, secretKey string) v1.EnvVar

func EnvVarFromValue added in v0.6.0

func EnvVarFromValue(name string, value string) v1.EnvVar

func FindContainerPortByName added in v0.6.0

func FindContainerPortByName(ports []v1.ContainerPort, name string) (v1.ContainerPort, bool)

func FindEnvVar added in v0.6.0

func FindEnvVar(a []v1.EnvVar, x string) int

FindEnvVar returns the smallest index i at which x == a[i], or -1 if there is no such index.

func GenericConsoleLinkMutator added in v0.7.0

func GenericConsoleLinkMutator(existingObj, desiredObj common.KubernetesObject) (bool, error)

GenericConsoleLinkMutator performs the reconciliation for consolelink objects

func GetEnvVar added in v0.4.0

func GetEnvVar(key, def string) string
func GetMasterConsoleLink(route *routev1.Route) *consolev1.ConsoleLink

GetMasterConsoleLink creates the consolelink obj for a target

func GetMasterConsoleLinkName added in v0.7.0

func GetMasterConsoleLinkName(namespace string) string

GetMasterConsoleLinkName returns the consolelink name

func GetSecret added in v0.5.0

func GetSecret(name string, namespace string, client k8sclient.Client) (*v1.Secret, error)

func GetSecretDataFromStringData added in v0.5.0

func GetSecretDataFromStringData(secretStringData map[string]string) map[string][]byte

func GetSecretDataValue added in v0.5.0

func GetSecretDataValue(secretData map[string][]byte, fieldName string) *string

func GetSecretDataValueOrDefault added in v0.5.0

func GetSecretDataValueOrDefault(secretData map[string][]byte, fieldName string, defaultValue string) string

func GetSecretStringDataFromData added in v0.5.0

func GetSecretStringDataFromData(secretData map[string][]byte) map[string]string

func GetStringPointerValueOrDefault added in v0.5.0

func GetStringPointerValueOrDefault(val *string, def string) string

func IsInvalidSpecError added in v0.6.0

func IsInvalidSpecError(err error) bool

func IsOrphanSpecError added in v0.6.0

func IsOrphanSpecError(err error) bool

func MarshalObjectToYAML added in v0.6.0

func MarshalObjectToYAML(object runtime.Object) ([]byte, error)

func MergeMapStringString added in v0.4.0

func MergeMapStringString(modified *bool, existing *map[string]string, desired map[string]string)

func MergeSecretData added in v0.5.0

func MergeSecretData(from, to map[string][]byte) map[string][]byte

Returns a new map containing the contents of `from` and the contents of `to`. The value for entries with duplicated keys will be that of `from`

func MeteringLabels added in v0.6.0

func MeteringLabels(componentName, componentVersion string, componentType ComponentType) map[string]string

func ParseVersion added in v0.6.0

func ParseVersion(image string) string

func PortFromURL

func PortFromURL(url *url.URL) int

PortFromURL infers port number if it is not explict

func SetURLDefaultPort

func SetURLDefaultPort(rawurl string) string

SetURLDefaultPort adds the default Port if not set

func SortedMapStringStringKeys added in v0.6.0

func SortedMapStringStringKeys(input map[string]string) []string

func SortedMapStringStringValues added in v0.6.0

func SortedMapStringStringValues(input map[string]string) []string

func UIDBasedJobName added in v0.6.0

func UIDBasedJobName(prefix string, uid types.UID) (string, error)

UIDBasedJobName returns a Job name that is compromised of the provided prefix, a hyphen and the provided uid: "<prefix>-<uid>". The returned name is a DNS1123 Label compliant name. Due to UIDs are 36 characters of length this means that the maximum prefix lenght that can be provided is of 26 characters. If the generated name is not DNS1123 compliant an error is returned

func UnwrapRawExtensions added in v0.3.0

func UnwrapRawExtensions(rawExts []runtime.RawExtension) []common.KubernetesObject

NOTE: remove when templates are gone

func WrapRawExtension added in v0.3.0

func WrapRawExtension(object runtime.Object) runtime.RawExtension

NOTE: remove when templates are gone

func WrapRawExtensions added in v0.3.0

func WrapRawExtensions(objects []common.KubernetesObject) []runtime.RawExtension

NOTE: remove when templates are gone

Types

type ComponentType added in v0.6.0

type ComponentType string
const (
	ApplicationType    ComponentType = "application"
	InfrastructureType ComponentType = "infrastructure"
)

type FieldTypeError added in v0.6.0

type FieldTypeError int
const (
	// InvalidError represents that the combination of configuration in the resource spec
	// is not supported. This is not a transient error, but
	// indicates a state that must be fixed before progress can be made.
	// Example: the two mutually exclusive attributes have been set.
	InvalidError FieldTypeError = iota

	// OrphanError represents that the configuration in the resource spec
	// contains reference to some not existing resource.
	// This is (should be) a transient error, but
	// indicates a state that must be fixed before progress can be made.
	// Example: the product Spec references non existing backend resource
	OrphanError
)

type MemoryCache added in v0.6.0

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

MemoryCache implements a simple memory cache No expiration No eviction policies Not threadsafe

func NewMemoryCache added in v0.6.0

func NewMemoryCache() *MemoryCache

func (*MemoryCache) Exists added in v0.6.0

func (c *MemoryCache) Exists(key string) bool

func (*MemoryCache) Get added in v0.6.0

func (c *MemoryCache) Get(key string) (interface{}, error)

func (*MemoryCache) Put added in v0.6.0

func (c *MemoryCache) Put(key string, data interface{})

type SecretCacheElement added in v0.6.0

type SecretCacheElement struct {
	Secret *v1.Secret
	Err    error
}

type SecretSource added in v0.6.0

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

func NewSecretSource added in v0.6.0

func NewSecretSource(client client.Client, namespace string) *SecretSource

func (*SecretSource) CachedSecret added in v0.6.0

func (s *SecretSource) CachedSecret(secretName string) (*v1.Secret, error)

func (*SecretSource) FieldValue added in v0.6.0

func (s *SecretSource) FieldValue(secretName, fieldName string, def string) (string, error)

func (*SecretSource) FieldValueFromRequiredSecret added in v0.6.0

func (s *SecretSource) FieldValueFromRequiredSecret(secretName, fieldName string, def string) (string, error)

func (*SecretSource) RequiredFieldValueFromRequiredSecret added in v0.6.0

func (s *SecretSource) RequiredFieldValueFromRequiredSecret(secretName, fieldName string) (string, error)

type SpecError added in v0.6.0

type SpecError interface {
	error
	FieldType() FieldTypeError
}

SpecError is exposed by errors that can be converted to an api.Status object for finer grained details.

type SpecFieldError added in v0.6.0

type SpecFieldError struct {
	ErrorType      FieldTypeError
	FieldErrorList field.ErrorList
}

func (*SpecFieldError) Error added in v0.6.0

func (s *SpecFieldError) Error() string

Error implements the Error interface.

func (*SpecFieldError) FieldType added in v0.6.0

func (s *SpecFieldError) FieldType() FieldTypeError

FieldType implements the SpecError interface.

type TaskRunner added in v0.6.0

type TaskRunner interface {
	Run() error
	// AddTask register tasks to be executed sequentially
	// Tasks will be executed in order. First in, first to be executed.
	AddTask(string, func(interface{}) error)
}

TaskRunner abstracts task running engine

func NewTaskRunner added in v0.6.0

func NewTaskRunner(ctx interface{}, logger logr.Logger) TaskRunner

NewTaskRunner TaskRunner Constructor

type Transport added in v0.6.0

type Transport struct {
	Transport http.RoundTripper
}

Transport implements http.RoundTripper. When set as Transport of http.Client, it executes HTTP requests with logging. No field is mandatory.

func (*Transport) RoundTrip added in v0.6.0

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip is the core part of this module and implements http.RoundTripper. Executes HTTP request with request/response logging.

Jump to

Keyboard shortcuts

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