Temple Package¶
temple.setup¶
Creates and initializes a project from a template
-
temple.setup.
setup
(template, version=None)[source]¶ Sets up a new project from a template
Note that the
temple.constants.TEMPLE_ENV_VAR
is set to ‘setup’ during the duration of this function.Parameters:
temple.update¶
Updates a temple project with the latest template
-
temple.update.
up_to_date
(version=None)[source]¶ Checks if a temple project is up to date with the repo
Note that the
temple.constants.TEMPLE_ENV_VAR
is set to ‘update’ for the duration of this function.Parameters: version (str, optional) – Update against this git SHA or branch of the template
Returns: True if up to date with
version
(or latest version), False otherwiseReturn type: boolean
Raises: NotInGitRepoError
– When running outside of a git repoInvalidTempleProjectError
– When not inside a valid temple repository
-
temple.update.
update
(old_template=None, old_version=None, new_template=None, new_version=None, enter_parameters=False)[source]¶ Updates the temple project to the latest template
Proceeeds in the following steps:
- Ensure we are inside the project repository
- Obtain the latest version of the package template
- If the package is up to date with the latest template, return
- If not, create an empty template branch with a new copy of the old template
- Create an update branch from HEAD and merge in the new template copy
- Create a new copy of the new template and merge into the empty template branch
- Merge the updated empty template branch into the update branch
- Ensure temple.yaml reflects what is in the template branch
- Remove the empty template branch
Note that the
temple.constants.TEMPLE_ENV_VAR
is set to ‘update’ for the duration of this function.Two branches will be created during the update process, one named
_temple_update
and one named_temple_update_temp
. At the end of the process,_temple_update_temp
will be removed automatically. The work will be left in_temple_update
in an uncommitted state for review. The update will fail early if either of these branches exist before the process starts.Parameters: - old_template (str, default=None) – The old template from which to update. Defaults to the template in temple.yaml
- old_version (str, default=None) – The old version of the template. Defaults to the version in temple.yaml
- new_template (str, default=None) – The new template for updating. Defaults to the template in temple.yaml
- new_version (str, default=None) – The new version of the new template to update. Defaults to the latest version of the new template
- enter_parameters (bool, default=False) – Force entering template parameters for the project
Raises: NotInGitRepoError
– When not inside of a git repositoryInvalidTempleProjectError
– When not inside a valid temple repositoryInDirtyRepoError
– When an update is triggered while the repo is in a dirty stateExistingBranchError
– When an update is triggered and there is an existing update branch
Returns: True if update was performed or False if template was already up to date
Return type: boolean
temple.ls¶
Lists all temple templates and projects spun up with those templates
-
temple.ls.
ls
(github_user, template=None)[source]¶ Lists all temple templates and packages associated with those templates
If
template
is None, returns the available templates for the configured Github org.If
template
is a Github path to a template, returns all projects spun up with that template.ls
uses the github search API to find results.Note that the
temple.constants.TEMPLE_ENV_VAR
is set to ‘ls’ for the duration of this function.Parameters: - github_user (str) – The github user or org being searched.
- template (str, optional) – The template git repo path. If provided, lists all projects that have been created with the provided template. Note that the template path is the SSH path (e.g. git@github.com:CloverHealth/temple.git)
Returns: A dictionary of repository information keyed on the SSH Github url
Return type: Raises: InvalidGithubUserError
– Whengithub_user
is invalid
temple.constants¶
Constants for temple
-
temple.constants.
GITHUB_API_TOKEN_ENV_VAR
= 'GITHUB_API_TOKEN'¶ The Github API token environment variable
-
temple.constants.
TEMPLE_CONFIG_FILE
= 'temple.yaml'¶ The temple config file in each repo
-
temple.constants.
TEMPLE_DOCS_URL
= 'https://github.com/CloverHealth/temple'¶ Temple docs URL
-
temple.constants.
TEMPLE_ENV_VAR
= '_TEMPLE'¶ The environment variable set when running any temple command. It is set to the name of the command
-
temple.constants.
UPDATE_BRANCH_NAME
= '_temple_update'¶ The temporary branches used for updates
temple.exceptions¶
Temple exceptions
-
exception
temple.exceptions.
ExistingBranchError
[source]¶ Thrown when a specifically named branch exists or doesn’t exist as expected.
-
exception
temple.exceptions.
InvalidCurrentBranchError
[source]¶ Thrown when a command cannot run because of the current git branch
-
exception
temple.exceptions.
InvalidEnvironmentError
[source]¶ Thrown when required environment variables are not set
-
exception
temple.exceptions.
InvalidGithubUserError
[source]¶ An invalid github user was passed to ls.
-
exception
temple.exceptions.
InvalidTemplatePathError
[source]¶ Thrown when a template path is not a Github SSH path