Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "configuration"

Index

Type aliases

ExpressCustomizer

ExpressCustomizer: function

Customize the express server configuration: For example to add custom routes

Example:

const newRouteCustomizer = (express: exp.Express, ...handlers: exp.RequestHandler[]) => { express.get("/new-route", ...handlers, (req, res) => { res.json({ key: "value" }); }); }

Type declaration

    • (express: exp.Express, ...handlers: exp.RequestHandler[]): void
    • Parameters

      • express: exp.Express
      • Rest ...handlers: exp.RequestHandler[]

      Returns void

Variables

Const EnvironmentVariablePrefix

EnvironmentVariablePrefix: "ATOMIST_" = "ATOMIST_"

Const PlaceholderExpression

PlaceholderExpression: RegExp = /\$\{([.a-zA-Z_-]+)([.:0-9a-zA-Z-_ \" ]+)*\}/g

Functions

cfgLog

  • cfgLog(source: string): void
  • Log the loading of a configuration

    Parameters

    • source: string

      name of configuration source

    Returns void

configurationValue

  • configurationValue<T>(path: string, defaultValue?: T): T
  • Exposes the configuration for lookup of configuration values. This is useful for components to obtain values eg. from configuration.custom like user provided secrets etc.

    Type parameters

    • T

    Parameters

    • path: string

      the property path evaluated against the configuration instance

    • Optional defaultValue: T

    Returns T

defaultConfiguration

  • Generate defaults for various configuration option values. These will only be used if values are not provided by any source. Values not provided here will be undefined.

    Returns Configuration

    default configuration

getUserConfig

invokePostProcessors

loadAtomistConfig

  • Load configuration from the ATOMIST_CONFIG environment variable, if it the variable is defined, and merge it into the passed in configuration. The value of the ATOMIST_CONFIG environment variable should be serialized JSON of AutomationServerOptions. The values from the environment variable will override values in the passed in configuration. If the environment variable is not defined, the passed in configuration is returned unchanged.

    Returns AutomationServerOptions

    automation server options

loadAtomistConfigPath

  • Load configuration from the file defined by the ATOMIST_CONFIG_PATH environment variable, if it the variable is defined and the file exists, and return it. The contents of the ATOMIST_CONFIG_PATH file should be serialized JSON of AutomationServerOptions. If the environment variable is not defined or the file path specified by its value cannot be read as JSON, an empty object is returned.

    Returns AutomationServerOptions

    automation server options

loadAutomationConfig

  • Load the automation configuration from the configuration object exported from cfgPath and return it. If no configuration path is provided, the package will be searched for a file named atomist.config.js. If no atomist.config.js is found, an empty object is returned. If more than one is found, an exception is thrown.

    Parameters

    • Optional cfgPath: string

      location of automation configuration

    Returns Configuration

    automation configuration

loadConfiguration

  • Load and populate the automation configuration. The configuration is loaded from several locations with the following precedence from highest to lowest.

    1. Recognized environment variables (see below)
    2. The value of the ATOMIST_CONFIG environment variable, parsed as JSON and cast to AutomationServerOptions
    3. The contents of the ATOMIST_CONFIG_PATH file as AutomationServerOptions
    4. The automation's atomist.config.js exported configuration as Configuration
    5. The contents of the user's client.config.json as UserConfig resolving user and per-module configuration into Configuration
    6. ProductionDefaultConfiguration if ATOMIST_ENV or NODE_ENV is set to "production" or TestingDefaultConfiguration if ATOMIST_ENV or NODE_ENV is set to "staging" or "testing", with ATOMIST_ENV taking precedence over NODE_ENV.
    7. LocalDefaultConfiguration

    If any of the sources are missing, they are ignored. Any truthy configuration values specified by sources of higher precedence cause any values provided by sources of lower precedence to be ignored. Arrays are replaced, not merged. Typically the only required values in the configuration for a successful registration are the apiKey or token and non-empty workspaceIds.

    Placeholder of the form ${ENV_VARIABLE} in string configuration values will get resolved against the environment. The resolution happens at the very end when all configs have been merged.

    The configuration exported from the atomist.config.js is modified to contain the final configuration values and returned from this function.

    Parameters

    • Optional cfgPath: string

      path to file exporting the configuration object, if not provided the package is searched for one

    Returns Promise<Configuration>

    merged configuration object

loadDefaultConfiguration

  • Return the default configuration based on NODE_ENV or ATOMIST_ENV. ATOMIST_ENV takes precedence if it is set.

    Returns Configuration

loadUserConfiguration

  • Try to read user config, overriding its values with a per-module configuration that matches this automation.

    Parameters

    • Optional name: string

      automation client package name to load as module config if it exists

    • Optional version: string

      automation client package version to load as module config if version satifies module config version range

    Returns AutomationServerOptions

    module-specific config with user config supplying defaults

mergeConfigs

resolveConfigurationValue

  • resolveConfigurationValue(environmentVariables: string[], configKeyPaths: string[], defaultValue?: string): string
  • Resolve a value from a environment variables or configuration keys. The environment variables are checked in order and take precedence over the configuration key, which are also checked in order. If no truthy values are found, undefined is returned.

    Parameters

    • environmentVariables: string[]

      environment variables to check

    • configKeyPaths: string[]

      configuration keys, as JSON paths, to check

    • Optional defaultValue: string

      value to use if no environment variables or config keys have values

    Returns string

    first truthy value found, or defaultValue

resolveEnvironmentVariables

  • Resolve ATOMIST_ environment variables and add them to config. Variables of like ATOMIST_custom_foo_bar will be converted to a json path of custom.foo.bar.

    Parameters

    Returns void

resolveModuleConfig

  • Merge a user's global and proper per-module configuration, if it exists. Values from the per-module configuration take precedence over the user-wide values. Per-module configuration is gotten from the first per-module configuration that matches name and, optionally, the version is within the per-module configuration's version range. A module configuration without a version range matches the named module with any version. If no version is provided, any version range is satisfied, meaning the first per-module configuration with a matching name is used. If no name is provide, only the user configuration is loaded. The first per-module match is used. This means if you have multiple configurations for the same named module and you want to include a default configuration for that module, put a configuration without a version range after all the configurations with version ranges. Note that only values from the first per-module match are used.

    Parameters

    • userConfig: UserConfig

      the user's configuration, which may include per-module configuration

    • Optional name: string

      automation client package name to load as module config if it exists

    • Optional version: string

      automation client package version to load as module config if version satifies module config version range

    Returns AutomationServerOptions

    the merged module and user configuration

resolvePlaceholder

  • resolvePlaceholder(value: string): string

resolvePlaceholders

  • Resolve placeholders against the process.env. Placeholders should be of form ${ENV_VAR}. Placeholders support default values in case they aren't defined: ${ENV_VAR:default value}

    Parameters

    Returns void

resolvePlaceholdersRecursively

  • resolvePlaceholdersRecursively(obj: any): void

resolvePort

  • Resolve the HTTP port from the environment and configuration. The PORT environment variable takes precedence over the config value.

    Parameters

    Returns number

resolveTeamIds

  • Examine environment, config, and cfg for Atomist team IDs. The ATOMIST_TEAMS environment variable takes precedence over the ATOMIST_TEAM environment variable, which takes precedence over the configuration "teamdIds", which takes precedence over cfg.teamIds, which may be undefined, null, or an empty array.

    deprecated

    resolveTeamIds is deprecated and will be removed in a future release

    Parameters

    Returns string[]

resolveToken

  • Resolve the token from the environment and configuration. The ATOMIST_TOKEN environment variable takes precedence over the GITHUB_TOKEN environment variable, which takes precedence over the config value, which takes precedence over the passed in value.

    deprecated

    resolveToken is deprecated and will be removed in a future release

    Parameters

    Returns string

resolveWorkspaceIds

  • Examine environment, config, and cfg for Atomist workspace IDs. The ATOMIST_WORKSPACES environment variable takes precedence over the configuration "workspaceIds", which takes precedence over cfg.workspaceId, which may be undefined, null, or an empty array. If the ATOMIST_WORKSPACES environment variable is not set, workspaceIds is not set in config, and workspaceIds is falsey in cfg and teamIds is resolvable from the configuration, workspaceIds is set to teamIds.

    Parameters

    • cfg: Configuration

      current configuration, whose workspaceIds and teamIds properties may be modified by this function

    Returns string[]

    the resolved workspace IDs

userConfigDir

  • userConfigDir(): string

userConfigPath

  • userConfigPath(): string

validateConfiguration

  • Make sure final configuration has the minimum configuration it needs. It will throw an error if required properties are missing.

    Parameters

    Returns void

writeUserConfig

Object literals

Const LocalDefaultConfiguration

LocalDefaultConfiguration: object

Default configuration when running in neither testing or production.

commands

commands: null = null

environment

environment: string = "local"

events

events: null = null

groups

groups: undefined[] = []

ingesters

ingesters: undefined[] = []

listeners

listeners: undefined[] = []

policy

policy: "ephemeral" = "ephemeral"

postProcessors

postProcessors: undefined[] = []

teamIds

teamIds: undefined[] = []

workspaceIds

workspaceIds: undefined[] = []

applicationEvents

applicationEvents: object

enabled

enabled: false = false

cluster

cluster: object

enabled

enabled: false = false

endpoints

endpoints: object

api

api: string = "https://automation.atomist.com/registration"

graphql

graphql: string = "https://automation.atomist.com/graphql/team"

http

http: object

customizers

customizers: undefined[] = []

enabled

enabled: true = true

host

host: string = "localhost"

port

port: number = 2866

auth

auth: object

basic

basic: object

enabled

enabled: false = false

bearer

bearer: object

enabled

enabled: false = false

client

client: object

factory

factory: AxiosHttpClientFactory = DefaultHttpClientFactory

logging

logging: object

level

level: "debug" = "debug"

banner

banner: object

contributors

contributors: undefined[] = []

enabled

enabled: true = true

file

file: object

enabled

enabled: true = true

level

level: string = "debug"

statsd

statsd: object

enabled

enabled: false = false

ws

ws: object

compress

compress: false = false

enabled

enabled: true = true

timeout

timeout: number = 10000

termination

termination: object

gracePeriod

gracePeriod: number = 10000

graceful

graceful: false = false

Const ProductionDefaultConfiguration

ProductionDefaultConfiguration: object

Configuration defaults for production environments.

environment

environment: string = "production"

policy

policy: "durable" = "durable"

applicationEvents

applicationEvents: object

enabled

enabled: true = true

cluster

cluster: object

enabled

enabled: true = true

http

http: object

auth

auth: object

basic

basic: object

enabled

enabled: true = true

bearer

bearer: object

enabled

enabled: true = true

logging

logging: object

level

level: "info" = "info"

file

file: object

enabled

enabled: false = false

statsd

statsd: object

enabled

enabled: true = true

ws

ws: object

compress

compress: true = true

termination

termination: object

graceful

graceful: true = true

Const TestingDefaultConfiguration

TestingDefaultConfiguration: object

Configuration defaults for pre-production environments.

environment

environment: string = "testing"

policy

policy: "durable" = "durable"

applicationEvents

applicationEvents: object

enabled

enabled: true = true

cluster

cluster: object

enabled

enabled: true = true

http

http: object

auth

auth: object

basic

basic: object

enabled

enabled: true = true

bearer

bearer: object

enabled

enabled: true = true

logging

logging: object

level

level: "info" = "info"

file

file: object

enabled

enabled: false = false

statsd

statsd: object

enabled

enabled: true = true

ws

ws: object

compress

compress: true = true

termination

termination: object

graceful

graceful: true = true

Generated using TypeDoc