flowbber.plugins.sources.env
¶This source collects environment variables.
Danger
This source can leak sensitive data. Please adjust include
and
exclude
patterns accordingly.
By default include
and exclude
patterns are empty, so no data will
be collected. See Usage below for examples.
Data collected:
{
"pythonhashseed": 720667772
}
Dependencies:
pip3 install flowbber[env]
Usage:
Variables will be collected if the name of the variable match any item in the
include
list but DOES NOT match any item in the exclude
list.
Variables names will be stored in lowercase if the lowercase
option is set
to true
(the default).
Optionally, a type can be specified for each environment variable, so that it is parsed, interpreted and collected with the expected datatype.
[[sources]]
type = "env"
id = "..."
[sources.config]
include = ["PYTHONHASHSEED"]
exclude = []
lowercase = true
[sources.config.types]
PYTHONHASHSEED = "integer"
{
"sources": [
{
"type": "env",
"id": "...",
"config": {
"include": [
"PYTHONHASHSEED"
],
"exclude": [],
"lowercase": true,
"types": {
"PYTHONHASHSEED": "integer"
}
}
}
]
}
Filtering examples:
Collect all environment variables
{
"include": ["*"],
"exclude": []
}
Collect all except a few
{
"include": ["*"],
"exclude": ["*KEY*", "*SECRET*"]
}
Collect only the ones specified
{
"include": ["PYTHONHASHSEED"],
"exclude": []
}
Using with Jenkins CI
This source is very helpful to collect information from Jenkins CI:
[[sources]]
type = "env"
id = "jenkins"
[sources.config]
include = [
"BUILD_NUMBER",
"JOB_NAME",
"GIT_COMMIT",
"GIT_URL",
"GIT_BRANCH",
"BUILD_TIMESTAMP"
]
lowercase = false
[sources.config.types]
BUILD_NUMBER = "integer"
BUILD_TIMESTAMP = "iso8601"
Note
To parse the BUILD_TIMESTAMP
variable as ISO 8601 the format needs to be
set to ISO 8601. For more information visit:
https://wiki.jenkins.io/display/JENKINS/Build+Timestamp+Plugin
{
"sources": [
{
"type": "env",
"id": "jenkins",
"config": {
"include": [
"BUILD_NUMBER",
"JOB_NAME",
"GIT_COMMIT",
"GIT_URL",
"GIT_BRANCH",
"BUILD_TIMESTAMP"
],
"lowercase": false,
"types": {
"BUILD_NUMBER": "integer"
}
}
}
]
}
List of patterns of environment variables to include.
Matching is performed using Python’s fnmatch.
Default: []
Optional: True
Schema:
{
'type': 'list',
'schema': {
'type': 'string',
'empty': False,
},
}
Secret: False
List of patterns of environment variables to exclude.
Matching is performed using Python’s fnmatch.
Default: []
Optional: True
Schema:
{
'type': 'list',
'schema': {
'type': 'string',
'empty': False,
},
}
Secret: False
Store variables names in lowercase.
Default: True
Optional: True
Schema:
{
'type': 'boolean',
}
Secret: False
Specify the data type of the environment variables.
At the time of this writing, the types allowed are:
int()
function.float()
function.str()
function.flowbber.utils.types.autocast()
.flowbber.utils.types.booleanize()
.flowbber.utils.iso8601.iso8601_to_datetime()
.Default: None
Optional: True
Schema:
{
'type': 'dict',
'keysrules': {
'type': 'string',
'empty': False,
},
'valuesrules': {
'type': 'string',
'empty': False,
'allowed': list(TYPE_PARSERS),
},
}
Secret: False