ArgoCDStorage

class phalanx.storage.argocd.ArgoCDStorage

Bases: object

Interface to Argo CD operations.

Calls the argocd command-line client. Used primarily by the installer.

Methods Summary

create_environment(environment, ...)

Manually create an Argo CD application.

login(username, password)

Authenticate to Argo CD.

set_project(application, project)

Set the Argo CD project of an application.

sync(application, *[, timeout])

Sync a specific Argo CD application.

sync_all(app_of_apps_name, *[, timeout])

Sync all Argo CD applications under an app of apps.

Methods Documentation

create_environment(environment, app_of_apps_name, *, git_url, git_branch)

Manually create an Argo CD application.

Used only by the installer for installing the app of apps to bootstrap the environment.

Parameters:
  • environment (str) – Name of the environment.

  • app_of_apps_name (str) – Name of the app of apps Argo CD application.

  • git_url (str) – URL to the Phalanx Git repository.

  • git_branch (str) – Name of the branch in that repository from which to pull the Argo CD configuration.

Raises:

CommandFailedError – Raised if Argo CD fails.

Return type:

None

login(username, password)

Authenticate to Argo CD.

Authenticates using username and password authentication with port forwarding. This normally must be done before any other Argo CD operations.

Parameters:
  • username (str) – Username for authentication. (Usually this will be admin.)

  • password (SecretStr) – Password for that user.

Raises:

CommandFailedError – Raised if Argo CD fails.

Return type:

None

set_project(application, project)

Set the Argo CD project of an application.

Parameters:
  • application (str) – Application to change.

  • project (Project) – Project to move it into.

Raises:

CommandFailedError – Raised if Argo CD fails.

Return type:

None

sync(application, *, timeout=datetime.timedelta(seconds=120))

Sync a specific Argo CD application.

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

  • timeout (timedelta, default: datetime.timedelta(seconds=120)) – How long to wait for the sync to complete.

Raises:
  • CommandFailedError – Raised if Argo CD fails.

  • CommandTimedOutError – Raised if the command timed out. The timeout is also passed to Argo CD as an option, so normally the command should fail and raise CommandFailedError instead. This exception means the Argo CD timeout didn’t work for some reason.

Return type:

None

sync_all(app_of_apps_name, *, timeout=datetime.timedelta(seconds=30))

Sync all Argo CD applications under an app of apps.

Parameters:
  • app_of_apps_name (str) – Name of the parent app of apps.

  • timeout (timedelta, default: datetime.timedelta(seconds=30)) – How long to wait for the sync to complete.

Raises:
  • CommandFailedError – Raised if Argo CD fails.

  • CommandTimedOutError – Raised if the command timed out. The timeout is also passed to Argo CD as an option, so normally the command should fail and raise CommandFailedError instead. This exception means the Argo CD timeout didn’t work for some reason.

Return type:

None