Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Latest commit

 

History

History
116 lines (74 loc) · 2.53 KB

Development.md

File metadata and controls

116 lines (74 loc) · 2.53 KB

gsctl Development Documentation

Please read this if you intend to develop on gsctl.

Required Tools, Prerequisites

  • Go environment (brew install go). Check the GOVERSION variable in the Makefile for the required version.
  • GNU Make
  • git
  • Docker

Cloning to the right location

Make sure you have the $GOPATH environment variable set.

$ echo $GOPATH
/Users/johndoe/go

Go to right location, then check out:

$ mkdir -p $GOPATH/src/github.com/giantswarm
$ cd $GOPATH/src/github.com/giantswarm
$ git clone https://github.com/giantswarm/gsctl.git
$ cd gsctl

So the repo content will end up in $GOPATH/src/github.com/giantswarm/gsctl.

Dependencies

Dependencies are managed using the Go modules tooling.

This means the GO111MODULE environment variable has to be set to auto or yes.

Executing gsctl during development

One option is to execute the program via go run, like in this example:

# ensure packr binary is up-to-date
$ packr

$ go run main.go info

Or you can first build a binary and then execute it.

$ go build && ./gsctl info

To build a binary for your platform like the release build would do, do this:

$ make clean
$ make
$ make install

Running tests

The Makefile provides a few shortcuts.

To execute all Go unit tests:

make gotest

To quickly run a number of commands:

make test

Embedded HTML files (packr)

For the sso command, gsctl needs to run a local webserver and show nicely formated html to the user. These html files are found in this folder.

The files get compiled into a binary file in the oidc package by running the packr command.

To learn more about packr, visit: https://github.com/gobuffalo/packr

Coding Style

Before pushing any changes, please:

  • Let gofmt format your code
  • Do a golint . check and act on recommendations before pushing.

Conventions

See Command Blueprint for a scaffold of a command file.

Typed Errors

We use specific error objects and dedicated matcher functions to assert them. Example:

var NotLoggedInError = errgo.New("user not logged in")

// IsNotLoggedInError asserts NotLoggedInError.
func IsNotLoggedInError(err error) bool {
	return errgo.Cause(err) == NotLoggedInError
}

Publishing a Release

See RELEASE.md