github.com/cloudposse/helm@v2.2.3+incompatible/docs/developers.md (about)

     1  # Developers Guide
     2  
     3  This guide explains how to set up your environment for developing on
     4  Helm and Tiller.
     5  
     6  ## Prerequisites
     7  
     8  - Go 1.6.0 or later
     9  - Glide 0.12.0 or later
    10  - kubectl 1.2 or later
    11  - A Kubernetes cluster (optional)
    12  - The gRPC toolchain
    13  
    14  ## Building Helm/Tiller
    15  
    16  We use Make to build our programs. The simplest way to get started is:
    17  
    18  ```console
    19  $ make bootstrap build
    20  ```
    21  
    22  This will build both Helm and Tiller. `make bootstrap` will attempt to
    23  install certain tools if they are missing.
    24  
    25  To run all of the tests (without running the tests for `vendor/`), run
    26  `make test`.
    27  
    28  To run Helm and Tiller locally, you can run `bin/helm` or `bin/tiller`.
    29  
    30  - Helm and Tiller are known to run on macOS and most Linuxes, including
    31    Alpine.
    32  - Tiller must have access to a Kubernetes cluster. It learns about the
    33    cluster by examining the Kube config files that `kubectl` uses.
    34  
    35  ### Man pages
    36  
    37  Man pages and Markdown documentation are already pre-built in `docs/`. You may
    38  regenerate documentation using `make docs`.
    39  
    40  To expose the Helm man pages to your `man` client, you can put the files in your
    41  `$MANPATH`:
    42  
    43  ```
    44  $ export MANPATH=$GOPATH/src/k8s.io/helm/docs/man:$MANPATH
    45  $ man helm
    46  ```
    47  
    48  ## gRPC and Protobuf
    49  
    50  Helm and Tiller communicate using gRPC. To get started with gRPC, you will need to...
    51  
    52  - Install `protoc` for compiling protobuf files. Releases are
    53    [here](https://github.com/google/protobuf/releases)
    54  - Run Helm's `make bootstrap` to generate the `protoc-gen-go` plugin and
    55    place it in `bin/`.
    56  
    57  Note that you need to be on protobuf 3.x (`protoc --version`). The
    58  version of `protoc-gen-go` is tied to the version of gRPC used in
    59  Kubernetes. So the plugin is maintained locally.
    60  
    61  While the gRPC and ProtoBuf specs remain silent on indentation, we
    62  require that the indentation style matches the Go format specification.
    63  Namely, protocol buffers should use tab-based indentation and rpc
    64  declarations should follow the style of Go function declarations.
    65  
    66  ### The Helm API (HAPI)
    67  
    68  We use gRPC as an API layer. See `pkg/proto/hapi` for the generated Go code,
    69  and `_proto` for the protocol buffer definitions.
    70  
    71  To regenerate the Go files from the protobuf source, `make protoc`.
    72  
    73  ## Docker Images
    74  
    75  To build Docker images, use `make docker-build`.
    76  
    77  Pre-build images are already available in the official Kubernetes Helm
    78  GCR registry.
    79  
    80  ## Running a Local Cluster
    81  
    82  For development, we highly recommend using the
    83  [Kubernetes Minikube](https://github.com/kubernetes/minikube)
    84  developer-oriented distribution. Once this is installed, you can use
    85  `helm init` to install into the cluster.
    86  
    87  For developing on Tiller, it is sometimes more expedient to run Tiller locally
    88  instead of packaging it into an image and running it in-cluster. You can do
    89  this by telling the Helm client to us a local instance.
    90  
    91  ```console
    92  $ make build
    93  $ bin/tiller
    94  ```
    95  
    96  And to configure the Helm client, use the `--host` flag or export the `HELM_HOST`
    97  environment variable:
    98  
    99  ```console
   100  $ export HELM_HOST=localhost:44134
   101  $ helm install foo
   102  ```
   103  
   104  (Note that you do not need to use `helm init` when you are running Tiller directly)
   105  
   106  Tiller should run on any >= 1.3 Kubernetes cluster.
   107  
   108  ## Contribution Guidelines
   109  
   110  We welcome contributions. This project has set up some guidelines in
   111  order to ensure that (a) code quality remains high, (b) the project
   112  remains consistent, and (c) contributions follow the open source legal
   113  requirements. Our intent is not to burden contributors, but to build
   114  elegant and high-quality open source code so that our users will benefit.
   115  
   116  Make sure you have read and understood the main CONTRIBUTING guide:
   117  
   118  https://github.com/kubernetes/helm/blob/master/CONTRIBUTING.md
   119  
   120  ### Structure of the Code
   121  
   122  The code for the Helm project is organized as follows:
   123  
   124  - The individual programs are located in `cmd/`. Code inside of `cmd/`
   125    is not designed for library re-use.
   126  - Shared libraries are stored in `pkg/`.
   127  - The raw ProtoBuf files are stored in `_proto/hapi` (where `hapi` stands for 
   128    the Helm Application Programming Interface).
   129  - The Go files generated from the `proto` definitions are stored in `pkg/proto`.
   130  - The `scripts/` directory contains a number of utility scripts. Most of these
   131    are used by the CI/CD pipeline.
   132  - The `rootfs/` folder is used for Docker-specific files.
   133  - The `docs/` folder is used for documentation and examples.
   134  
   135  Go dependencies are managed with
   136  [Glide](https://github.com/Masterminds/glide) and stored in the
   137  `vendor/` directory.
   138  
   139  ### Git Conventions
   140  
   141  We use Git for our version control system. The `master` branch is the
   142  home of the current development candidate. Releases are tagged.
   143  
   144  We accept changes to the code via GitHub Pull Requests (PRs). One
   145  workflow for doing this is as follows:
   146  
   147  1. Go to your `$GOPATH/k8s.io` directory and `git clone` the
   148     `github.com/kubernetes/helm` repository.
   149  2. Fork that repository into your GitHub account
   150  3. Add your repository as a remote for `$GOPATH/k8s.io/helm`
   151  4. Create a new working branch (`git checkout -b feat/my-feature`) and
   152     do your work on that branch.
   153  5. When you are ready for us to review, push your branch to GitHub, and
   154     then open a new pull request with us.
   155  
   156  For Git commit messages, we follow the [Semantic Commit Messages](http://karma-runner.github.io/0.13/dev/git-commit-msg.html):
   157  
   158  ```
   159  fix(helm): add --foo flag to 'helm install'
   160  
   161  When 'helm install --foo bar' is run, this will print "foo" in the
   162  output regardless of the outcome of the installation.
   163  
   164  Closes #1234
   165  ```
   166  
   167  Common commit types:
   168  
   169  - fix: Fix a bug or error
   170  - feat: Add a new feature
   171  - docs: Change documentation
   172  - test: Improve testing
   173  
   174  Common scopes:
   175  
   176  - helm: The Helm CLI
   177  - tiller: The Tiller server
   178  - proto: Protobuf definitions
   179  - pkg/lint: The lint package. Follow a similar convention for any
   180    package
   181  - `*`: two or more scopes
   182  
   183  Read more:
   184  - The [Deis Guidelines](https://github.com/deis/workflow/blob/master/src/contributing/submitting-a-pull-request.md)
   185    were the inspiration for this section.
   186  - Karma Runner [defines](http://karma-runner.github.io/0.13/dev/git-commit-msg.html) the semantic commit message idea.
   187  
   188  ### Go Conventions
   189  
   190  We follow the Go coding style standards very closely. Typically, running
   191  `go fmt` will make your code beautiful for you.
   192  
   193  We also typically follow the conventions recommended by `go lint` and
   194  `gometalinter`. Run `make test-style` to test the style conformance.
   195  
   196  Read more:
   197  
   198  - Effective Go [introduces formatting](https://golang.org/doc/effective_go.html#formatting).
   199  - The Go Wiki has a great article on [formatting](https://github.com/golang/go/wiki/CodeReviewComments).
   200  
   201  ### Protobuf Conventions
   202  
   203  Because this project is largely Go code, we format our Protobuf files as
   204  closely to Go as possible. There are currently no real formatting rules
   205  or guidelines for Protobuf, but as they emerge, we may opt to follow
   206  those instead.
   207  
   208  Standards:
   209  - Tabs for indentation, not spaces.
   210  - Spacing rules follow Go conventions (curly braces at line end, spaces
   211    around operators).
   212  
   213  Conventions:
   214  - Files should specify their package with `option go_package = "...";`
   215  - Comments should translate into good Go code comments (since `protoc`
   216    copies comments into the destination source code file).
   217  - RPC functions are defined in the same file as their request/response
   218    messages.
   219  - Deprecated RPCs, messages, and fields are marked deprecated in the comments (`// UpdateFoo
   220    DEPRECATED updates a foo.`).