19.6. Developer Environment

This page is intended for people who are building Digital Rebar Provision from sources or contributing to the code base. We maintain inline documentation and test environment and contributors are expected to participate in maintenance of those efforts.

Note

Prerequisites: go version 1.16 or better. These documents expect ability to both install and update Golang.

19.6.1. Developer Quick Start

You will need to get the provision source tree.

go get -u gitlab.com/rackn/provision
export GOPATH=${GOPATH:-$HOME/go}
cd "$GOPATH/src/gitlab.com/rackn/provision"

If more details on how to run the result are needed, consult the Production Install section. The install.sh script can be used to install from the source directory after a build.

19.6.2. Building The API

After the code and assets have been obtained once, the process can be repeated from the project root with the following command:

tools/build.sh

Another reason to use the tools/build.sh script is that it will inject version information into the built binaries to make it easier to track what version is deployed. Developer builds and production builds will be identifiable through the version command on both the server and the cli.

Note

If you have performed a previous build and generated assets are updated, you may need to delete embedded directory and checkout git checkout –embedded then rebuild to ensure that the server can start. This problem manifests with the error: No such embedded asset chain.c32: Asset chain.c32 not found

19.6.3. Running the Tests

Digital Rebar Provision uses the Golang test libraries and the development team works hard to maintain test coverage.

The tools/test.sh in the provision root directory is the main way to test the entire code base.

To test individual modules from their subdirectories run: go test

19.6.4. How to get Swagger-Ui

DigiatlRebar Provision uses Swagger to generate interactive help for the API. This is in the tree by default. If an update is needed, do the following:

  • git clone https://github.com/swagger-api/swagger-ui

  • cp -r swagger-ui/dist/* embedded/assets/swagger-ui

  • change in embedded/assets/swagger-ui/index.html:

    @@ -38,7 +38,7 @@
           if (url && url.length > 1) {
             url = decodeURIComponent(url[1]);
           } else {
    -        url = "http://petstore.swagger.io/v2/swagger.json";
    +        url = "https://127.0.0.1:8092/swagger.json";
           }
    
           hljs.configure({
    
  • Rebuild the world (tools/build.sh)

19.6.5. Packaging the Code

Once the code is built, the code can be package for storage in Github or for use by the install.sh script.

Running the tools/package.sh script will generate a dr-provision.zip and dr-provision.sha256 file. These files can be used with the Production Install process.