Back to

Package util

v0.0.0 (f628490)
Latest Go to latest
Published: Jul 8, 2020 | License: Apache-2.0 | Module:


* Copyright 2019-2020, EnMasse authors. * License: Apache License 2.0 (see the file LICENSE or

* Copyright 2019, EnMasse authors. * License: Apache License 2.0 (see the file LICENSE or


Package Files


const ConnectsTo = ""
const EnMasseOpenshift4EnvVar = "ENMASSE_OPENSHIFT4"
const EnMasseOpenshiftEnvVar = "ENMASSE_OPENSHIFT"


var (
	PossibleCharacters = []rune("abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789" + ";:,.-_=")
	MaxLen             = big.NewInt(int64(len(PossibleCharacters)))
var UserGVK = userapiv1.GroupVersion.WithKind("User")

func AddressName

func AddressName(object metav1.Object, prefix string) string

Get an address name from an IoTProject the name is the prefix (e.g. "telemetry") plus the project name. The name is not encoded in any way.

func ContainsString

func ContainsString(strings []string, value string) bool

Searches a **sorted** for a string value.

func CreateSecret

func CreateSecret(ctx context.Context, client client.Client, scheme *runtime.Scheme, namespace string, secretName string, owner metav1.Object, applyfn ApplySecretFn) error

func DefaultJavaRequiresNativeTls

func DefaultJavaRequiresNativeTls() bool

func EncodeAddressSpaceAsMetaName

func EncodeAddressSpaceAsMetaName(addressName string) string

Encode an address name so that it can be put inside the field of an Address object

func EncodeAsMetaName

func EncodeAsMetaName(name string, maxLength int) string

func FalsePtr

func FalsePtr() *bool

func GeneratePassword

func GeneratePassword(length int) (string, error)

generate a password which is X characters (runes) long, and also X bytes long

func GenerateSelfSignedCertSecret

func GenerateSelfSignedCertSecret(host string, alternateIPs []net.IP, alternateDNS []string, secret *corev1.Secret) error

func GetBooleanEnv

func GetBooleanEnv(key string) bool

func GetBooleanEnvOrDefault

func GetBooleanEnvOrDefault(key string, defaultValue bool) bool

func GetDurationEnvOrDefault

func GetDurationEnvOrDefault(key string, defaultValue time.Duration) time.Duration

func GetEnvOrDefault

func GetEnvOrDefault(key string, defaultValue string) string

func GetEnvOrError

func GetEnvOrError(name string) (string, error)

func GetFsGroupOverride

func GetFsGroupOverride(component string) *int64

func GetInfrastructureNamespace

func GetInfrastructureNamespace() (string, error)

Get the name of the infrastructure namespace

func GetPortForService

func GetPortForService(servicePorts []v1.ServicePort, name string) (*int32, error)

func GetTemplateList

func GetTemplateList() []string

func GetUintEnvOrDefault

func GetUintEnvOrDefault(key string, base int, bitSize int, defaultValue uint64) uint64

func HasApi

func HasApi(gvk schema.GroupVersionKind) bool

func IsModuleEnabled

func IsModuleEnabled(module string) bool

check if a controller module is enabled, or not

func IsNewObject

func IsNewObject(object v1.Object) bool

func IsNotReadyYetError

func IsNotReadyYetError(err error) bool

Test if this is a NotReadyYetError error

func IsOpenshift

func IsOpenshift() bool

func IsOpenshift4

func IsOpenshift4() bool

detect if we are running on openshift 4

func IsSameRef

func IsSameRef(ref1, ref2 v1.OwnerReference) bool

func Max

func Max(x, y int64) int64

func MaxDuration

func MaxDuration(x, y time.Duration) time.Duration

func Min

func Min(x, y int64) int64

func MinDuration

func MinDuration(x, y time.Duration) time.Duration

func MustGetInfrastructureNamespace

func MustGetInfrastructureNamespace() string

Get the name of th infrastructure namespace, panics if 'NAMESPACE' is unset

func NewConfigurationError

func NewConfigurationError(format string, a ...interface{}) error

func NewObjectNotReadyYetError

func NewObjectNotReadyYetError(object v1.Object) *objectNotReadyYetError

func NewOwnerRef

func NewOwnerRef(owner v1.Object, gvk schema.GroupVersionKind) *v1.OwnerReference

func OnlyNonRecoverableErrors

func OnlyNonRecoverableErrors(err error) bool

Returns true if all errors covered by this error implement the NonRecoverableError interface.

If the error is a simple error, the only the one error will be checked. If the error is a "multierr" error, then all recorded errors will be checked.

If the error is "nil", then "true" is being returned.

func OpenshiftUri

func OpenshiftUri() (*url.URL, bool, error)

func RandomBrokerName

func RandomBrokerName() string

func ServiceToCommonName

func ServiceToCommonName(serviceNamespace, serviceName string) string

func SetInfrastructureNamespaceForTesting

func SetInfrastructureNamespaceForTesting(value string)

Allows to set the infrastructure namespace when doing tests

func SplitUserName

func SplitUserName(name string) (string, string, error)

func TenantNameForObject

func TenantNameForObject(object metav1.Object) string

func ToX500Name

func ToX500Name(asn1Name []byte) (string, error)

Convert a name from an X509 certificate into a string

We cannot use the Go method pkix.Name.ToString() function as the whole name decoding logic in Go is full of assumptions which are not correct. Go takes the RDNSequence and re-arranges and re-encodes the entries in a way that they no longer correspond to the original sequence. Thus we simply take the raw value, and encode it ourselves as string.

Also see:

func WellKnownOauthMetadata

func WellKnownOauthMetadata() (map[string]interface{}, error)

func WrapAsNonRecoverable

func WrapAsNonRecoverable(err error) error

Wrap any error as non-recoverable. This allows having a proper cause chain, but still be able to flag certain errors as non-recoverable.

type ApplySecretFn

type ApplySecretFn func(secret *corev1.Secret) error

type ConfigurationError

type ConfigurationError struct {
	Reason string

an error in the configuration, non-recoverable

func (*ConfigurationError) Error

func (e *ConfigurationError) Error() string

type EnvironmentProvider

type EnvironmentProvider interface {
	LookupEnv(string) (string, bool)
	Get(string) string

type MockEnvironmentProvider

type MockEnvironmentProvider struct {
	Environment map[string]string

func (MockEnvironmentProvider) Get

func (p MockEnvironmentProvider) Get(name string) string

func (MockEnvironmentProvider) LookupEnv

func (p MockEnvironmentProvider) LookupEnv(name string) (string, bool)

type MultiTool

type MultiTool struct {
	Continue bool
	Changed  bool
	Error    error

func (*MultiTool) Ran

func (m *MultiTool) Ran(err error)

func (*MultiTool) Reset

func (m *MultiTool) Reset()

func (*MultiTool) Return

func (m *MultiTool) Return() (bool, error)

func (*MultiTool) Run

func (m *MultiTool) Run(operation func() error)

func (*MultiTool) RunChange

func (m *MultiTool) RunChange(operation func() (bool, error))

type NonRecoverableError

type NonRecoverableError interface {
	// contains filtered or unexported methods

type OSEnvironmentProvider

type OSEnvironmentProvider struct {

func (OSEnvironmentProvider) Get

func (p OSEnvironmentProvider) Get(name string) string

func (OSEnvironmentProvider) LookupEnv

func (p OSEnvironmentProvider) LookupEnv(name string) (string, bool)

type Parameters

type Parameters struct {
	Params map[string]string

type TemplateHelper

type TemplateHelper struct {
	Parameters   Parameters
	TemplatePath string
	TemplateList []string

func NewTemplateHelper

func NewTemplateHelper(extraParams map[string]string) *TemplateHelper

Creates a new template helper and populates the values for all template properties.

func (*TemplateHelper) CreateResource

func (h *TemplateHelper) CreateResource(template string) (runtime.Object, error)

type WrappedNonRecoverableError

type WrappedNonRecoverableError struct {
	// contains filtered or unexported fields

func (WrappedNonRecoverableError) Cause

func (e WrappedNonRecoverableError) Cause() error

func (*WrappedNonRecoverableError) Error

func (e *WrappedNonRecoverableError) Error() string
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier