envitro¶
docker¶
Docker specific environment variable reading.
A set of functions to read environment variables for docker links.
-
envitro.docker.host(alias_name, default=None, allow_none=False)¶ Get the host from the docker link alias or return the default.
Parameters: - alias_name – The docker link alias
- default – The default value if the link isn’t available
- allow_none – If the return value can be None (i.e. optional)
Examples
Assuming a Docker link was created with
docker --link postgres:dband the resulting environment variable isDB_PORT=tcp://172.17.0.82:5432.>>> envitro.docker.host('DB') 172.17.0.82
-
envitro.docker.isset(alias_name)¶ Return a boolean if the docker link is set or not and is a valid looking docker link value.
Parameters: alias_name – The link alias name
-
envitro.docker.port(alias_name, default=None, allow_none=False)¶ Get the port from the docker link alias or return the default.
Parameters: - alias_name – The docker link alias
- default – The default value if the link isn’t available
- allow_none – If the return value can be None (i.e. optional)
Examples
Assuming a Docker link was created with
docker --link postgres:dband the resulting environment variable isDB_PORT=tcp://172.17.0.82:5432.>>> envitro.docker.port('DB') 5432
-
envitro.docker.protocol(alias_name, default=None, allow_none=False)¶ Get the protocol from the docker link alias or return the default.
Parameters: - alias_name – The docker link alias
- default – The default value if the link isn’t available
- allow_none – If the return value can be None (i.e. optional)
Examples
Assuming a Docker link was created with
docker --link postgres:dband the resulting environment variable isDB_PORT=tcp://172.17.0.82:5432.>>> envitro.docker.protocol('DB') tcp
-
envitro.docker.read(alias_name, allow_none=False)¶ Get the raw docker link value.
Get the raw environment variable for the docker link
Parameters: - alias_name – The environment variable name
- default – The default value if the link isn’t available
- allow_none – If the return value can be None (i.e. optional)
decorators¶
Decorators that modify execution based on environment variables.
A module with decorators that can enable/disable the execution of a function based on the existance or value of an environment variable. Mostly intended as a syntactically nice way of enabling/disabling automated tests based on environment variables.
-
envitro.decorators.bool(name, execute_bool=True, default=None)¶ Only execute the function if the boolean variable is set.
Parameters: - name – The name of the environment variable
- execute_bool – The boolean value to execute the function on
- default – The default value if the environment variable is not set (respects execute_bool)
Returns: The function return value or None if the function was skipped.
-
envitro.decorators.isset(name)¶ Only execute the function if the variable is set.
Parameters: name – The name of the environment variable Returns: The function return value or None if the function was skipped.
-
envitro.decorators.write(name, value)¶ Temporarily change or set the environment variable during the execution of a function.
Parameters: - name – The name of the environment variable
- value – A value to set for the environment variable
Returns: The function return value.