Options
All
  • Public
  • Public/Protected
  • All
Menu

Configs is an in-memory document store for Kubernetes objects populated from/to configuration files.

It enables performing rich query and mutation operations.

Hierarchy

  • Configs

Index

Constructors

constructor

  • Creates a Config.

    Parameters

    • input: KubernetesObject[] = []

      Input Kubernetes objects. If supplied multiple objects with the same kubernetesKey discards all but the last one. Does not preserve insertion order of the given objects.

    • Optional functionConfig: KubernetesObject

      Kubernetes object used to parameterize the function's behavior.

    • Optional results: Result[]

      For testing only: List of Results returned by the function.

    Returns Configs

Properties

logToStdErr

logToStdErr: undefined | boolean

Determines whether addResults should also log to stderr.

Methods

addResults

  • addResults(...results: Result[]): void
  • Adds given result(s) representing structured findings by the function.

    Parameters

    Returns void

deepCopy

delete

  • Deletes all objects with the same kubernetesKey as any of the given objects.

    Does not throw if given duplicates or keys which are not present in the Configs.

    Parameters

    Returns void

deleteAll

  • deleteAll(): void

get

  • Returns an array of objects matching the given Kind type predicate.

    Casts to an array of Kind. May throw if isKind is incorrect.

    The ordering of objects is deterministic.

    Returned objects are pass-by-reference; mutating them results in changes being persisted.

    Type parameters

    Parameters

    Returns Kind[]

getAll

  • Returns an array of all the objects in this Configs.

    The ordering of objects is deterministic.

    Returned objects are pass-by-reference; mutating them results in changes being persisted.

    Returns KubernetesObject[]

getFunctionConfig

getFunctionConfigMap

  • getFunctionConfigMap(): undefined | Map<string, string>
  • Returns the map of data values if functionConfig is of kind ConfigMap.

    Throws a FunctionConfigError if functionConfig is undefined OR if the kind is not a v1/ConfigMap.

    Returns undefined | Map<string, string>

getFunctionConfigValue

  • getFunctionConfigValue(key: string): undefined | string
  • Returns the value for the given key if functionConfig is of kind ConfigMap.

    Throws a FunctionConfigError if functionConfig kind is not a ConfigMap.

    Returns undefined if functionConfig is undefined OR if the ConfigMap has no such key in the 'data' section.

    key

    key The key in the 'data' field in the ConfigMap object given as the functionConfig.

    Parameters

    • key: string

    Returns undefined | string

getFunctionConfigValueOrThrow

  • getFunctionConfigValueOrThrow(key: string): string

getResults

groupBy

  • Partitions the objects using the provided key function

    The ordering of objects with the same key is deterministic.

    Example: Partition configs by Namespace:

    const configsByNamespace = configs.groupBy((o) => o.metadata.namespace)
    

    Parameters

    Returns [string, KubernetesObject[]][]

hasUnexpectedFunctionParameter

  • hasUnexpectedFunctionParameter(expectedDataKeys: string[]): undefined | string[]
  • Detects if an unknown value has been provided to the config map

    Parameters

    • expectedDataKeys: string[]

      The set of keys expected in the Configs data

    Returns undefined | string[]

    Returns undefined if the config map is undefined. Otherwise returns a string[] containing the invalid keys. The string[] will be empty if all of the config maps keys are members of the expecteKeys.

insert

  • Inserts objects into the Configs.

    If another object already in Configs has the same kubernetesKey, replaces that one with the given object.

    If inserting multiple objects with the same kubernetesKey, discards all but the last one.

    Does not preserve insertion order of the given objects.

    Parameters

    Returns void

toResourceList

Generated using TypeDoc