Developer Guide

Building SuperGloo from source

Prerequisites:

Install them all with the following:

mkdir -p ${GOPATH}/src/github.com/solo-io

# Dep
go get -u github.com/golang/dep/cmd/dep

# protoc
unameOut="$(uname -s)"
case "${unameOut}" in
    Linux*)     ARCHIVE=protoc-3.6.1-linux-x86_64.zip;;
    Darwin*)    ARCHIVE=protoc-3.6.1-osx-x86_64.zip;;

curl -OL https://github.com/google/protobuf/releases/download/v3.6.1/${ARCHIVE} && \
    unzip ${ARCHIVE} -d protoc3 && \
    sudo mv protoc3/bin/* /usr/local/bin/ && \
    sudo mv protoc3/include/* /usr/local/include/

# Solo-Kit protoc plugin
mkdir -p ${GOPATH}/src/github.com/solo-io/ && \
    cd ${GOPATH}/src/github.com/solo-io/ && \
    git clone https://github.com/solo-io/solo-kit && \
    cd solo-kit && \
        dep ensure -v && \
    make install-plugin

# make sure $GOPATH/bin is part of your path
export PATH=${PATH}:${GOPATH}/bin/

mkdir -p ${GOPATH}/src/github.com/solo-io/ && \
    cd ${GOPATH}/src/github.com/solo-io/ && \
    git clone https://github.com/solo-io/supergloo && \
    cd supergloo && make init # set up pre-commit githook to enforce Go formatting and imports

Build

cd ${GOPATH}/src/github.com/solo-io/supergloo && \
make supergloo

This will create a supergloo binary for you in the top level directory.

Testing

Prerequisites:

Cluster setup:

# start cluster
minikube start --memory=8192 --cpus=4 --kubernetes-version=v1.10.0
# deploy helm/tiller
helm init

Run tests:

ginkgo -r [Directory]

Updating API

The API is auto-generated from the protos in the api directory. After making changes, run make generated-code -B to re-generate.

Adding Features

Extending SuperGloo can be done by adding additional Syncers to an Event Loop. SuperGloo is built with code generated by Solo-Kit which provides a skeleton for writing event-based systems.

Take a look at pkg/setup/setup.go to see how syncers are registered to the main event loop in SuperGloo.

In order to add a syncer, it needs to implement the interface

type TranslatorSyncer interface {
    Sync(context.Context, *TranslatorSnapshot) error
}

The Sync function is responsible for performing some action in response to a change in either user configuration, or some piece of discovered information. The whole input state for the Sync function is contained in the TranslatorSnapshot, defined in pkg/api/v1/translator_snapshot.sk.go

To extend the functionality of SuperGloo, simply initialize your Syncer and add it to the array of syncers in setup.go