ConfigStorage#

class phalanx.storage.config.ConfigStorage(path)#

Bases: object

Analyze Phalanx configuration and convert it to models.

Parameters:

path (Path) – Path to the root of the Phalanx configuration.

Methods Summary

add_application_setting(application, setting)

Add the setting for a new application to the environments chart.

get_all_dependency_repositories()

List the URLs of all referenced third-party Helm repositories.

get_application_chart_path(application)

Determine the path to an application Helm chart.

get_application_environments(application)

List all environments for which an application is configured.

get_dependency_repositories(application)

Return URLs for dependency Helm repositories for this application.

get_environment_chart_path()

Determine the path to the top-level environment chart.

get_modified_applications(branch)

Get all modified application and environment pairs.

get_starter_path(starter)

Determine the path to a Helm starter template.

list_application_environments()

List all available applications and their environments.

list_applications()

List all available applications.

list_environments()

List all of the available environments.

load_environment(environment_name)

Load the configuration of a Phalanx environment from disk.

load_environment_config(environment_name)

Load the top-level configuration for a Phalanx environment.

load_phalanx_config()

Load the full Phalanx configuration.

write_application_template(name, template)

Write the Argo CD application template for a new application.

Methods Documentation

add_application_setting(application, setting)#

Add the setting for a new application to the environments chart.

Adds a block for a new application to values.yaml in the environments directory in the correct alphabetical location.

Parameters:
  • application (str) – Name of the new application.

  • setting (str) – Setting block for the new application. Indentation will be added.

Return type:

None

get_all_dependency_repositories()#

List the URLs of all referenced third-party Helm repositories.

Returns:

URLs of third-party Helm repositories referenced by some application chart.

Return type:

set of str

get_application_chart_path(application)#

Determine the path to an application Helm chart.

The application and path may not exist, since this function is also used to generate the path to newly-created applications.

Parameters:

application (str) – Name of the application.

Returns:

Path to that application’s chart.

Return type:

pathlib.Path

get_application_environments(application)#

List all environments for which an application is configured.

This is based entirely on the presence of values-environment.yaml configuration files in the application directory, not on which environments enable the application. This is intentional since this is used to constrain which environments are linted, and we want to lint applications in environments that aren’t currently enabled to ensure they’ve not bitrotted.

Parameters:

application (str) – Name of the application.

Returns:

List of environment names for which that application is configured.

Return type:

list of str

get_dependency_repositories(application)#

Return URLs for dependency Helm repositories for this application.

Parameters:

application (str) – Name of the application.

Returns:

URLs of Helm repositories used by dependencies of this application’s chart.

Return type:

set of str

get_environment_chart_path()#

Determine the path to the top-level environment chart.

Returns:

Path to the top-level environment chart.

Return type:

pathlib.Path

get_modified_applications(branch)#

Get all modified application and environment pairs.

Parameters:

branch (str) – Git branch against which to compare to see what modifications have been made.

Returns:

Dictionary of all modified applications to the list of environments configured for that application that may have been affected.

Return type:

dict of list of str

get_starter_path(starter)#

Determine the path to a Helm starter template.

Parameters:

starter (HelmStarter) – Name of the Helm starter template.

Returns:

Path to that Helm starter template.

Return type:

pathlib.Path

list_application_environments()#

List all available applications and their environments.

Returns:

Dictionary of all applications to lists of environments for which that application has a configuration.

Return type:

dict of list of str

list_applications()#

List all available applications.

Returns:

Names of all applications.

Return type:

list of str

list_environments()#

List all of the available environments.

Returns:

Names of all available environments.

Return type:

list of str

load_environment(environment_name)#

Load the configuration of a Phalanx environment from disk.

Parameters:

environment_name (str) – Name of the environment.

Returns:

Environment configuration.

Return type:

Environment

Raises:

UnknownEnvironmentError – Raised if the named environment has no configuration.

load_environment_config(environment_name)#

Load the top-level configuration for a Phalanx environment.

Unlike load_environment, this only loads the top-level environment configuration and its list of enabled applications. It does not load the configuration for all of the applications themselves.

Parameters:

environment_name (str) – Name of the environent.

Returns:

Loaded environment.

Return type:

Environment

Raises:
load_phalanx_config()#

Load the full Phalanx configuration.

Used primarily for generating docuemntation.

Returns:

Phalanx configuration for all environments.

Return type:

PhalanxConfig

Raises:
write_application_template(name, template)#

Write the Argo CD application template for a new application.

Parameters:
  • name (str) – Name of the application.

  • template (str) – Contents of the Argo CD application and namespace Helm template for the new application.

Raises:

ApplicationExistsError – Raised if the application being created already exists.

Return type:

None