Skip to main content
https://github.com/foremast/foremast-utils/actions/workflows/githubactions-tox.yml/badge.svg https://github.com/foremast/foremast-utils/actions/workflows/codeql-analysis.yml/badge.svg Join the chat at https://gitter.im/foremast/foremast https://badge.fury.io/py/foremast-utils.svg

foremast-utils

foremast-utils is a utility library that generates a service name convention based on a repo url. The library is mainly used to ensure that an application is able to easily know the path to a service it may need.

from foremastutils import Parser, Generator

url = 'https://github.com/foremast/test.git'
project, repo = Parser(url).parse_url()

# a way to customize based on your conventions
my_formats = {
    'jenkins_job_name': '{project}-{repo}-master',
    'app': 'app-{project}{repo}',
    'custom': '{project}*.*{repo}',
}

info = Generator(project, repo, 'dev', formats=my_formats)

info.jenkins()
# {'name': 'foremast-test-master'}

info.app_name()
# app-foremasttest

info.custom
# foremast*.*test

Classes

Parser

This class is needed to parse and gather details about a git repository. A url is split up and the result is a project, repo.

Generator

This class provides details about an application’s details when using different technologies. Its a simple and concise way to know how a specific app is referenced in jenkins, gitlab, s3, iam, dns and among other services tools.

Formats

This class provides a mechanism to alter the way Generator generates certain application references. It is mainly referenced within Generator to provide that functionality.

In setting up the format the following variables are exposed:

VARIABLE

DESCRIPTION

domain

Domain

env

Environment

project

Git project/group name (lowercase)

raw_project

Git project/group name

raw_repo

Git repo name

repo

Git repo name (lowercase)

These are the services you can customize the formats along with their default format:

SERVICE

DEFAULT

DESCRIPTION

apigateway_domain

api.{env}.{domain}

API gateway base domain

app

{repo}{project}

Application Name

dns_elb

{repo}.{project}.{env}.{domain}

FQDN of DNS ELB

dns_instance

{repo}{project}-xx.{env}.{domain}

FQDN of instances

domain

example.com

Domain

elb_app

{repo}{project}

ELB Name

git_repo

{raw_project}/{raw_repo}

Apps git repo

git_repo_configs

{raw_project}/{raw_repo}-config

Config git repo

git_repo_qe

{raw_project}/{raw_repo}-qa

QA’s git repo

iam_base

{project}_{repo}

IAM profile base

iam_group

{project}

IAM group name

iam_lambda_role

{project}_{repo}_lambda_role

Lambda IAM role name

iam_policy

{project}_{repo}_policy

IAM policy name

iam_profile

{project}_{repo}_profile

IAM profile name

iam_role

{project}_{repo}_role

IAM role name

iam_user

{project}_{repo}

IAM username

jenkins_job_name

{project}_{repo}

Jenkins job name

s3_app_bucket

{project}-{repo}

Application specific S3 bucket name

s3_app_region_bucket

{project}-{repo}-{region}

Application specific S3 bucket name with region

s3_archaius_name

archaius-{env}/{project}/{repo}{project}/

S3 full path for archaius

s3_bucket

archaius-{env}

S3 archaius bucket name

s3_bucket_path

{project}/{repo}{project}

S3 path for app (within s3_bucket)

security_group_app

{repo}{project}

Security Group name

shared_s3_app_bucket

common-{project}

S3 bucket name for shared buckets

shared_s3_app_region_bucket

common-{project}-{region}

S3 bucket name for shared buckets with region

Contributions

We encourage contributions, feedback and any bug fixes.

Running Tests

Running tests are very quick and easy when using tox. We validate against python 2.7 and 3.4+

To run the tests simply execute

# only needed once
$ pip install -r requirements-dev.txt

$ tox

Metadata

Release files for foremast-utils 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for foremast-utils 2.0.0
File Size Uploaded
foremast-utils-2.0.0.tar.gz 34.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for foremast-utils 2.0.0
File Interpreter ABI Platform
foremast_utils-2.0.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 46.3 kB

Release files / foremast-utils-2.0.0.tar.gz

Download URL foremast-utils-2.0.0.tar.gz
Size 34.7 kB
Tags Source
SHA-256 checksum
How to use checksums
45026787471078a0571954be3d485ebb6fa4b7fcaaadb2ebb5f9956e26785a40
BLAKE2b-256 checksum
How to use checksums
d319958a42cf1c52036bfab31b5f76f299e46b6e1c06978a0605e1774333b6ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / foremast_utils-2.0.0-py2.py3-none-any.whl

Download URL foremast_utils-2.0.0-py2.py3-none-any.whl
Size 11.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
3af23772ba259ae912a009f2c445dba64f14d7808f7249c1ba22841a07fe5778
BLAKE2b-256 checksum
How to use checksums
f41bd5d4ebee78221d901ba1e7ca7ea80e00653d3e72089c9ababe337138d29a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page