This repo contains:
- Tools common to working with all PCO repos. This consists of Bash functions for cloning and navigating PCO git repos, and for managing the state of Python venvs used within those repos.
- Installation scripts to quickly get a new user set up with the tooling.
With a fresh user that belongs to the wheel group (can sudo without a password), run the following to install
everything.
curl --silent --show-error --location https://raw.githubusercontent.com/openshift-eng/pco-devtools/main/bootstrap.sh | bash- Install Homebrew (instructions from the Homebrew website):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"- Install a modern Bash and set it as your default shell (enter your password when prompted). Using Bash as your default shell is important, as various helper scripts we use assume that the system shell is modern Bash.
brew install bash
# This 1-liner appends the path to the new bash to `/private/etc/shells`.
new_bash="$(brew --prefix)/bin/bash" ; ! grep -E "${new_bash}" /private/etc/shells >/dev/null && (echo "${new_bash}" | sudo tee -a /private/etc/shells)
# Set your default shell to the new bash:
chsh -s "$(brew --prefix)/bin/bash"
# Use the new Bash by either re-starting your terminal or running:
exec "$(brew --prefix)/bin/bash"- Begin the install process:
curl --silent --show-error --location https://raw.githubusercontent.com/openshift-eng/pco-devtools/main/bootstrap.sh | bashA Project is either a directory containing a pyproject.toml file or requirements.txt file. Each Project has
its own independent venv.
Some venv and intra-repo navigation commands target a Project, and these are referred to by the Project's name. A Project's name depends on its location within the repo:
- A Project defined by a
requirements.txtfile at the top of the repo has an empty name. The navigation commands implicitly auto-target this Project. - A repo with multiple projects (e.g.
openshift-eng/infra-toolbox) refers to a project by the name of the directory containing the Project. e.g. The Project within/apps/aws-toolkitis referred to asaws-toolkit, and the Project within/libs/dpp-github-configis referred to asdpp-github-config.
Activating a venv for a Project marks it as the "Active Project". Each repo stores its own Active Project independent of other repos.
Changing directories into a repo will automatically re-activate the Active Project's venv (if it exists).
Clones a PCO-owned repo and configures it:
- Clones
github.com/<your_github_username>/REPO_NAMEintoPCO_REPO_DIR/TARGETDIR_NAME. (TARGETDIR_NAMEdefaults toREPO_NAME). If--upstream-onlyis specified, it clones fromgithub.com/openshift-eng/REPO_NAMEand does not perform further configuration. - Adds the git remote
upstream:github.com/openshift-eng/REPO_NAME - Installs the repo's pre-commit hook, if it has one.
This script is located at the top of this repo.
It uses the gh underneath the hood, so you must have previously authorized gh with gh auth login.
Change directory to $PCO_REPO_DIR/REPO_NAME and auto-activate the venv (if there is one).
List all repos under $PCO_REPO_DIR, and what git branch they're checked out to.
These commands are expected to be called from within a repo.
Change directory to the top of the repo.
Change directory to the current venvs's directory of installed site-packages. This is useful for inspecting the
source code of installed pip dependencies.
Change directory to PROJECT. The current venv is not modified.
Use [TAB] to autocomplete PROJECT. e.g. cdd aws-to[TAB] --> cdd aws-toolkit.
For repos with only a single Project (in the top directory), the Project name is implicit.
Activates a venv for the nearest Project.
- Find the nearest Project, found by searching upwards from the current directory, and mark it as the Active Project.
- Activate the Project's venv (creating it if necessary).
Deactivate the current venv (if there is one), and clear the "Active Project".
Same as venv off except the venv's directory will be deleted.
Change directory to PROJECT's directory and activate the venv. (Same as cdd [PROJECT] ; venv on)
Similar to cdd [PROJECT], autocomplete on PROJECT is supported.
In a infra-toolbox repo, this is a shortcut to change directory into Atlas's main source code.
Shortcut for cdd atlas ; cd atlas
In a infra-toolbox repo, this is a shortcut to change directory into /apps/support-toolkit where most support
tasks are performed.
Shortcut for venv go support-toolkit