Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "configuration"

Index

Type aliases

ConfigurationPostProcessor

ConfigurationPostProcessor<T>: (configuration: Configuration) => Promise<Configuration & T>

Post process the configuration after is has been merged from the various locations, but before starting the automation client.

Type parameters

  • T = AnyOptions

Type declaration

ExpressCustomizer

ExpressCustomizer: (express: exp.Express, ...handlers: exp.RequestHandler[]) => void

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 DEFAULT_REDACTION_PATTERNS

DEFAULT_REDACTION_PATTERNS: { regexp: RegExp; replacement: string }[] = [{regexp: /\b[A-F0-9]{64}\b/g,replacement: "[ATOMIST_API_KEY]",},{regexp: /[1-9][0-9]+-[0-9a-zA-Z]{40}/g,replacement: "[TWITTER_ACCESS_TOKEN]",},{regexp: /EAACEdEose0cBA[0-9A-Za-z]+/g,replacement: "[FACEBOOK_ACCESS_TOKEN]",},{regexp: /AIza[0-9A-Za-z\-_]{35}/g,replacement: "[GOOGLE_API_KEY]",},{regexp: /[0-9]+-[0-9A-Za-z_]{32}\.apps\.googleusercontent\.com/g,replacement: "[GOOGLE_OAUTH_ID]",},{regexp: /sk_live_[0-9a-z]{32}/g,replacement: "[PICATIC_API_KEY|",},{regexp: /sk_live_[0-9a-zA-Z]{24}/g,replacement: "[STRIPE_REGULAR_API_KEY]",},{regexp: /rk_live_[0-9a-zA-Z]{24}/g,replacement: "[STRIPE_RESTRICTED_API_KEY]",},{regexp: /sq0atp-[0-9A-Za-z\-_]{22}/g,replacement: "[SQUARE_OAUTH_TOKEN]",},{regexp: /sq0csp-[0-9A-Za-z\-_]{43}/g,replacement: "[SQUARE_OAUTH_SECRET]",},{regexp: /access_token\$production\$[0-9a-z]{16}\$[0-9a-f]{32}/g,replacement: "[BRAINTREE_ACCESS_TOKEN]",},{regexp: /amzn\.mws\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/g,replacement: "[AMAZON_AUTH_TOKEN]",},{regexp: /SK[0-9a-fA-F]{32}/g,replacement: "[TWILLIO_API_KEY]",},{regexp: /key-[0-9a-zA-Z]{32}/g,replacement: "[MAILGUN_KEY]",},{regexp: /[0-9a-f]{32}-us[0-9]{1,2}/g,replacement: "[MAILCHIMP_API_KEY]",},{regexp: /\bAK[0-9A-Z]{18}\b/g,replacement: "[AMAZON_ACCESS_KEY]",},{regexp: /\b(https?:\/\/)(?:v1\.)?[a-f0-9]{40}((?::x-oauth-basic)?@)/g,replacement: "$1[GITHUB_TOKEN]$2",},{// https://perishablepress.com/stop-using-unsafe-characters-in-urls/// https://www.ietf.org/rfc/rfc3986.txtregexp: /\b((?:ht|f|sm)tps?:\/\/[^:/?#\[\]@""<>{}|\\^``\s]+:)[^:/?#\[\]@""<>{}|\\^``\s]+@/g,replacement: "$1[URL_PASSWORD]@",},]

Default set of regular expressions used to remove sensitive information from messages and logs. The entries are applied in order, so more specific regular expressions should be placed earlier in the list to avoid a shorter replacement preventing a longer replacement from being applied.

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

    • Default value path: string = ""

      the property path evaluated against the configuration instance

    • Optional defaultValue: T

    Returns T

deepMergeConfigs

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

  • loadAutomationConfig(configPath?: string): Promise<Configuration | undefined>
  • 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 configPath: string

    Returns Promise<Configuration | undefined>

    automation configuration or undefined

loadConfiguration

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

    1. ATOMIST_ environment variables, see resolveEnvironmentVariables
    2. Configuration returned from the post-processors.
    3. Recognized environment variables, see resolveWorkspaceIds, resolvePort
    4. The value of the ATOMIST_CONFIG environment variable, parsed as JSON and cast to AutomationServerOptions
    5. The contents of the ATOMIST_CONFIG_PATH file as AutomationServerOptions
    6. The contents of the user's client.config.json as UserConfig resolving user and per-module configuration into Configuration
    7. The automation atomist.config.js or all index.js files' configurations exported as configuration from those files
    8. 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.
    9. 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 and non-empty workspaceIds.

    Placeholder of the form ${ENV_VARIABLE} in string configuration values will get resolved against the environment. The resolution happens after all of the above configuration sources have been merged.

    After all sources are merged and the resulting configuration processed for placeholders and environment variables, the configuration is validated using validateConfiguration.

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

    Parameters

    • Optional base: string | Promise<Configuration>

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

    Returns Promise<Configuration>

    merged configuration object

loadDefaultConfiguration

loadIndexConfig

  • Load the automation configuration from the configuration objects exported and merged by all index.js files in the automation client.

    Returns Promise<Configuration>

    automation 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

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): Promise<string>

resolvePlaceholders

  • resolvePlaceholders(cfg: Configuration, replacer?: (value: string) => Promise<string>, visited?: any[]): Promise<void>
  • 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

    • cfg: Configuration
    • Default value replacer: (value: string) => Promise<string> = resolvePlaceholder
        • (value: string): Promise<string>
        • Parameters

          • value: string

          Returns Promise<string>

    • Default value visited: any[] = [cfg.sdm, cfg.local, cfg.events, cfg.commands, cfg.listeners]

    Returns Promise<void>

resolvePlaceholdersRecursively

  • resolvePlaceholdersRecursively(obj: any, visited: any[], replacer: (value: string) => Promise<string>): Promise<void>
  • Parameters

    • obj: any
    • visited: any[]
    • replacer: (value: string) => Promise<string>
        • (value: string): Promise<string>
        • Parameters

          • value: string

          Returns Promise<string>

    Returns Promise<void>

resolvePort

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

    Parameters

    Returns number

resolveWorkspaceIds

  • Examine environment, config, and cfg for Atomist workspace IDs. The ATOMIST_WORKSPACES environment variable takes precedence over the config "workspaceIds", which takes precedence over cfg.workspaceId, which may be undefined, null, or an empty array.

    Parameters

    • cfg: Configuration

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

    Returns string[]

    the resolved workspace IDs

userConfigDir

  • userConfigDir(): string

userConfigPath

  • userConfigPath(): string

userConfigPaths

  • userConfigPaths(): string[]
  • Return user automation client configuration paths including such referenced by configuration profiles.

    Returns 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: undefined = undefined

environment

environment: string = "local"

events

events: undefined = undefined

groups

groups: undefined[] = []

ingesters

ingesters: undefined[] = []

listeners

listeners: undefined[] = []

policy

policy: "ephemeral" = "ephemeral"

postProcessors

postProcessors: undefined[] = []

workspaceIds

workspaceIds: undefined[] = []

ws

ws: any = {enabled: true,termination: {graceful: false,gracePeriod: defaultGracePeriod,},compress: false,timeout: 30000,} as any

cluster

cluster: object

enabled

enabled: false = false

endpoints

endpoints: object

api

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

auth

auth: string = "https://api.atomist.com/v2/auth"

graphql

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

http

http: object

customizers

customizers: undefined[] = []

enabled

enabled: true = true

host

host: string = "0.0.0.0"

auth

auth: object

basic

basic: object

enabled

enabled: false = false

bearer

bearer: object

enabled

enabled: false = false

logging

logging: object

callsite

callsite: false = false

color

color: true = true

level

level: "info" = "info"

banner

banner: object

contributors

contributors: undefined[] = []

enabled

enabled: true = true

file

file: object

enabled

enabled: true = true

level

level: "debug" = "debug"

redact

redact: object

log

log: true = true

messages

messages: true = true

patterns

patterns: { regexp: RegExp; replacement: string }[] = DEFAULT_REDACTION_PATTERNS

statsd

statsd: object

enabled

enabled: false = false

Const ProductionDefaultConfiguration

ProductionDefaultConfiguration: object

Configuration defaults for production environments.

environment

environment: string = "production"

policy

policy: "durable" = "durable"

cluster

cluster: object

enabled

enabled: true = true

http

http: object

port

port: number = 2866

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"

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