This guide explains how to set up your environment for developing on airshipctl.
Installing Go 1.13¶
Instructions to install Golang are here.
make test verification step requires the GNU Compiler Collection (gcc) to be installed.
To install the GNU Compiler Collection (gcc):
sudo apt-get install gcc
If your organization requires development behind a proxy server, you will need to define the following environment variables with your organization’s information:
HTTP_PROXY=http://username:password@host:port HTTPS_PROXY=http://username:password@host:port NO_PROXY="localhost,127.0.0.1" USE_PROXY=true
When running the gate scripts in
tools/gate locally, if you have not set proxy
information in user’s environment or profile then you will need to add your
proxy information to
Apart from adding proxy information to playbook, we have to add proxy information
to site definations documents. For ephemeral iso to pull docker images behind
proxy, user-data section for ephemeral iso has to be updated in the below file
Add the following contents to the file in runcmd section
- export http_proxy=http://username:password@host:port - export https_proxy=$http_proxy - export HTTP_PROXY=$http_proxy - export HTTPS_PROXY=$http_proxy
Add the following contents to the file in write_files section
- path: /etc/systemd/system/docker.service.d/http-proxy.conf permissions: '0644' owner: root:root content: | [Service] Environment="HTTP_PROXY=http://username:password@host:port" Environment="HTTPS_PROXY=http://username:password@host:port" Environment="NO_PROXY=127.0.0.1,localhost,10.23.25.0/24"
Clone airshipctl code¶
Run the following command to download the latest airshipctl code:
git clone https://opendev.org/airship/airshipctl.git
NOTE: The airshipctl application is a Go module. This means that there is no need to clone the repository into the $GOPATH directory in order to build it. You should be able to build it from any directory as long as $GOPATH is defined correctly.
Installing Docker & Other Tools¶
Prior to building the airshipctl binary, ensure you have Docker, Ansible & other tools installed in your environment.
There is a script in the airshipctl directory named
00_setup.sh which can be
run to download all the required binaries and packages. This script code can be
Standalone instructions to install Docker are here. This is not necessary
if you run
Run the following command to build the airshipctl binary:
This will compile airshipctl and place the resulting binary into the bin directory.
To test the build, including linting and coverage reports, run:
To run all tests in a containerized environment, run:
To build an
airshipctl Docker image, run:
Pre-built images are already available at quay.io. Moreover, in the
airshipctl/tools/gate/, different scripts are present which will
run and download all the required images. The script 10_build_gate.sh
will download all the required images.
We welcome contributions. This project has set up some guidelines in order to ensure that
code quality remains high
the project remains consistent, and
contributions follow the open source legal requirements.
Our intent is not to burden contributors, but to build elegant and high-quality open source code so that our users will benefit. Make sure you have read and understood the main airshipctl Contributing Guide.
Structure of the Code¶
The code for the airshipctl project is organized as follows:
The client-facing code is located in
cmd/. Code inside of
cmd/is not designed for library reuse.
Shared libraries are stored in
Both commands and shared libraries may require test data fixtures. These should be placed in a
testdata/subdirectory within the command or library.
testutil/directory contains functions that are helpful for unit tests.
zuul.d/directory contains Zuul YAML definitions for CI/CD jobs to run.
playbooks/directory contains playbooks that the Zuul CI/CD jobs will run.
tools/directory contains scripts used by the Makefile and CI/CD pipeline.
tools/gatedirectory consists of different scripts. These scripts will setup the environment as per requirements and install all the required packages and binaries. This will also download all the required docker images.
docs/folder is used for documentation and examples.
Go dependencies are managed by
go modand stored in
We use Git for our version control system. The
master branch is the home of
the current development candidate. Releases are tagged.
We accept changes to the code via Gerrit pull requests. One workflow for doing
this is as follows:
airshipctlrepository. For this run the command:
git clone https://opendev.org/airship/airshipctl.git
Use OpenDev documentation to setup Gerrit with the repo.
When set, use this guide to learn the OpenDev development workflow, in a sandbox environment. You can then apply the learnings to start developing airshipctl.
We follow the Go coding style standards very closely. Typically, running
goimports -w -local opendev.org/airship/airshipctl ./ will make your code
beautiful for you.
We also typically follow the conventions of
In order to ensure that all package unit tests follow the same standard and
use the same frameworks, airshipctl has a document outlining
specific test guidelines maintained separately.
Moreover, there are few scripts in directory
tools/gate which run different
tests. The script 20_run_gate_runner.sh will generate airshipctl config
file, deploy ephemeral cluster with infra and cluster API, deploy target cluster
and verify all control pods.