Development

Develop with Go-Lang in Linux

  1. Get Go-lang 1.15.3 from official site
  2. Add go command to your PATH: export PATH=$PATH:/usr/local/go/bin
  3. Define GOPATH: export GOPATH=$(go env GOPATH)
  4. Add Go workspace to your PATH: export PATH=$PATH:$(go env GOPATH)/bin
  5. Define the base path: mkdir -p $GOPATH/src/github.com/
  6. Clone the project:
    • cd $GOPATH/src/github.com/
    • git clone <project>
    • cd <project>
  7. Define GO111MODULE: export GO111MODULE=on to be able to compile locally.

Compilation

To compile, type: go build -o ingress-ats main/main.go

Unit Tests

The project includes unit tests for the controller written in Golang and the ATS plugin written in Lua.

To run the Golang unit tests: go test ./watcher/ && go test ./redis/

The Lua unit tests use busted for testing. busted can be installed using luarocks:luarocks install busted. More information on how to install busted is available here.

:warning: Note that the project uses Lua 5.1 version

To run the Lua unit tests:

  • cd pluginats
  • busted connect_redis_test.lua

Text-Editor

The repository comes with basic support for both vscode and vim.

If you're using vscode:

  • .vscode/settings.json contains some basic settings for whitespaces and tabs
  • .vscode/extensions.json contains a few recommended extensions for this project.
  • It is highly recommended to install the Go extension since it contains the code lint this project used during development.

If you're using vim, a vimrc file with basic whitespace and tab configurations is also provided