Developer Overview of Pegleg¶
Pegleg’s core mission is to, alongside Deckhand, facilitate document authoring strategies within Airship, by:
aggregating documents across multiple revisioned repositories, each of which contains multiple documents defining sites’ software and hardware stacks
providing early linting of documents prior to their collection and eventual deployment
including utility functions enabling operators and developers alike to list available sites, render individual manifests via Deckhand, bootstrap repositories with Pegleg-compliant directory layouts, to name a few
Pegleg, as a CLI, has a rather simplistic architecture. It is meaningful to visualize Pegleg alongside Deckhand:
cli module implements the user-facing CLI. For more information
about this module, reference the CLI documentation.
Because Airship is a container-centric platform, the developer workflow heavily utilizes containers for testing and publishing. It also requires Pegleg to produce multiple artifacts that are related, but separate: the Python package, the Docker image and the Helm chart. The code is published via the Docker image artifact.
Pegleg strives to conform to the Airship coding conventions.
The Pegleg code base lives under
pegleg. Pegleg supports py36 interpreter.
Pegleg Dockerfiles for supported distributions are located in
/images/pegleg along with any artifacts built specifically to enable the
container image. Make targets are used for generating and testing the
make images- Build the Pegleg Docker image.
Pegleg, as a containerized CLI, uses Docker via
execute CLI commands. Commands can also be executed using the
Rather than, after each local code change, rebuilding the Pegleg image and
IMAGE environment variable so
the latest code changes, it is possible to use a virtual environment for
much faster development.
This can achieved by issuing the following commands (from the root Pegleg directory):
# Quick way of building a virtualenv and installing all required # dependencies into it. tox -e py36 --notest source .tox/py36/bin/activate pip install -e . # Now is it possible to run the Pegleg CLI to test local changes: pegleg <command> <options> # Or run unit tests: pytest -k <regex>
Note that after setting up the virtual environment, one only needs to source it in order to re-run unit tests or Pegleg CLI commands, to test local changes.