Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
105 lines (72 sloc) 3.21 KB

Contributing to Kubeformation

Thanks for your interest in Kuberformation. Follow the steps below to contribute.

Install dependencies

  • Go 1.10 (not required if using Docker)
  • Docker (optional)
  • Dep for managing vendor-ed packages
  • GNU Make for build/test rules

Fork the repo

Fork the repo and clone it into your $GOPATH:

$ mkdir -p $GOPATH/src/github.com/hasura
$ cd $GOPATH/src/github.com/hasura
$ git clone git@github.com:<username>/kubeformation.git
$ cd kubeformation

Add upstream as a remote to pull new changes:

$ git remote add upstream https://github.com/hasura/kubeformation.git

Code

Kuberformation has two interfaces, a command line tool and a web api. All the common code, including the conversion on spec to templates are organised in pkg/ while the cli and api code is in cmd/. More details about code organisation and packages can be found in Godoc.

Spec

The spec that denotes the Kubernetes cluster is versioned. Any backwards compatible changes can be made to the same version spec itself, but a breaking change should result in a new version.

Each version is defined and handled by an implementation of VersionedSpecHandler interface. v1 spec can be found in pkg/spec/v1 as ClusterSpec.

The logic of converting the spec into the structure that provider takes is also implemented in this package. For any breaking change to the spec, a new version has to be created.

Provider

Each managed Kubernetes service provider has it's own package, which contains the templates and the context to render the template. The context is called ProviderSpec.

Each provider should implement the interface called Provider, which has a method MarshalFiles() (map[string][]byte, error). It returns a map of filenames and content, the rendered template.

CLI

kubeformation cli implements a command that takes the cluster spec, renders the template for a provider and writes the files into a directory.

API

The API accepts JSON by POST and responds with either a map of files and contents in JSON or a ZIP file that downloads.

Tests

Write unit tests as much as you can.

Build & Test

  • go run cmd/api/kubeformation.go - test out api
  • go run cmd/cli/kubeformation.go - test out cli

All build and test rules are written in Makefile.

Without docker:

  • make build-api-local builds api server using local go installation
  • make build-cli builds the cli tool
  • make test runs the unit tests

Using docker:

  • make build-api
  • make build-cli-in-docker
  • make test-in-docker

Submit PR

If everything looks well, submit a PR ☺

You can’t perform that action at this time.