ApplicationService#

class phalanx.services.application.ApplicationService(path, config_storage, helm_storage)#

Bases: object

Service for manipulating Phalanx applications.

Parameters:
  • path (Path) – Root path to the Phalanx directory structure.

  • config_storage (ConfigStorage) – Storage object for the Phalanx configuration.

  • helm_storage (HelmStorage) – Interface to Helm actions.

Methods Summary

add_helm_repositories([applications, quiet])

Add all Helm repositories used by any application to Helm's cache.

create(name, starter, description)

Create configuration for a new application.

lint(app_names, env_name)

Lint an application with Helm.

lint_all(*[, only_changes_from_branch])

Lint all applications with Helm.

template(app_name, env_name)

Expand the templates of an application chart.

Methods Documentation

add_helm_repositories(applications=None, *, quiet=False)#

Add all Helm repositories used by any application to Helm’s cache.

To perform other Helm operations, such as downloading third-party charts in order to run helm lint, all third-party Helm chart repositories have to be added to Helm’s cache. This does that for every application in the Phalanx configuration.

Consistent names for the Helm repositories are used so that this command can be run repeatedly.

Parameters:
  • applications (Optional[Iterable[str]], default: None) – If given, only add Helm repositories required by these applications.

  • quiet (bool, default: False) – Whether to suppress Helm’s standard output.

Returns:

Whether any Helm repositories were added. If there were none, the caller should not call helm update, because it fails if there are no repositories.

Return type:

bool

create(name, starter, description)#

Create configuration for a new application.

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

  • starter (HelmStarter) – Name of the Helm starter to use as the template for the application.

  • description (str) – Short description of the application.

Raises:

ApplicationExistsError – Raised if the application being created already exists.

Return type:

None

lint(app_names, env_name)#

Lint an application with Helm.

Registers any required Helm repositories, refreshes them, downloads dependencies, and runs helm lint on the application chart, configured for the given environment.

Parameters:
  • app_names (list[str]) – Names of the applications to lint.

  • env_name (Optional[str]) – Name of the environment. If not given, lint all environments for which this application has a configuration.

Returns:

Whether linting passed.

Return type:

bool

lint_all(*, only_changes_from_branch=None)#

Lint all applications with Helm.

Registers any required Helm repositories, refreshes them, downloads dependencies, and runs helm lint on every combination of application chart and configured environment.

Parameters:

only_changes_from_branch (Optional[str], default: None) – If given, only lint application and environment pairs that may have been affected by Git changes relative to the given branch. In other words, assume all application chart configurations identical to the given branch are uninteresting, and only lint the ones that have changed.

Returns:

Whether linting passed.

Return type:

bool

template(app_name, env_name)#

Expand the templates of an application chart.

Run helm template for an application chart, passing in the appropriate parameters for that environment.

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

  • env_name (str) – Name of the environment. If not given, lint all environments for which this application has a configuration.

Returns:

Output from helm template.

Return type:

str

Raises:

HelmFailedError – Raised if Helm fails.