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