prereceivecli.lib package

Submodules

prereceivecli.lib.utils module

Main code for utils.

class prereceivecli.lib.utils.HashChecker[source]

Bases: object

Implements a git rebuilding context manager for a pre-receive hook.

verify(project, entries)[source]

Verifies the protected files or directories specified in the entries.

Parameters:
  • project (Project) – The project object to verify.
  • entries (dict) – The entries of protected files or directories.
Returns:

A list of errors of the verification failures if any.

Return type:

errors (list)

class prereceivecli.lib.utils.Project(slug: str, group: str, git_path: str, git_command: str, username: str, commit: str, base: str)[source]

Bases: object

Models a project exposing attributes for slug, group and git_path.

class prereceivecli.lib.utils.SecurityEntry(hashes: list, name: str, type: str)[source]

Bases: object

Models a security entry exposing attributes for slug, type and git_path.

prereceivecli.lib.utils.execute_command_with_returned_output(command)[source]

Execute the command with returned output.

prereceivecli.lib.utils.get_project(base, commit)[source]

Constructs a project object from a gitlab project path.

Returns:An object exposing the required attributes of the environment and the project
Return type:(project)
prereceivecli.lib.utils.get_table_for_project_group(project_group, credentials)[source]

Retrieves a dynamodb table following a specific naming convention.

Parameters:
  • project_group (str) – The type of the project to look up the table for. Convention states that the table should be named {type, eg:infrastructure}_git_hook.
  • credentials (AwsCredentials) – An object holding the credentials passed from the authentication process.
Returns:

if found else None

Return type:

(dynamodb Table)

prereceivecli.lib.utils.parse_hook_input()[source]

Parses the git hook input disregarding the tags reference.

prereceivecli.lib.utils.send_slack_message(webhook, message)[source]

Send a message to a webhook in slack.

Parameters:
  • webhook (str) – The webhook to submit the message to
  • message (str) – The message to submit to slack
Returns:

True on success False otherwise

Return type:

(bool)

Module contents

lib package.

Import all parts from lib here.