2019-04-04 14:08:50 +00:00
# How to Contribute to BotKube
We'd love your help!
2019-12-23 17:50:49 +00:00
BotKube is [MIT Licensed ](LICENSE ) and accepts contributions via GitHub pull requests. This document outlines some of the conventions on development workflow, commit message formatting, contact points and other resources to make it easier to get your contributions accepted.
2019-04-04 14:08:50 +00:00
2019-12-23 17:50:49 +00:00
We gratefully welcome improvements to [documentation ](https://www.botkube.io/ "Go to documentation site" ) as well as to code.
2019-04-04 14:08:50 +00:00
## Contributing to documentation
2019-12-23 17:50:49 +00:00
You can contribute to documentation by following [these instructions ](https://github.com/infracloudio/botkube-docs#contributing "Contributing to BotKube Docs" )
2019-04-04 14:08:50 +00:00
## Compile BotKube from source code
2019-12-23 17:50:49 +00:00
2020-10-05 07:09:23 +00:00
Before you proceed, make sure you have installed BotKube Slack/Mattermost/Teams app and copied the required token as per the steps documented [here ](https://www.botkube.io/installation/ )
2019-12-23 17:50:49 +00:00
2019-04-04 14:08:50 +00:00
### Prerequisite
2019-12-23 17:50:49 +00:00
* Make sure you have `go 1.11+` installed with go module activated. (You can set env var with `export GO111MODULE=on` to activate)
* You will also need `make` and [`docker` ](https://docs.docker.com/install/ ) installed on your
2019-04-04 14:08:50 +00:00
machine.
* Clone the source code
```sh
2019-12-23 17:50:49 +00:00
$ git clone https://github.com/infracloudio/botkube.git
2019-04-04 14:08:50 +00:00
```
Now you can build and run BotKube by one of the following ways
2019-12-23 17:50:49 +00:00
2019-04-04 14:08:50 +00:00
### Build the container image
2019-12-23 17:50:49 +00:00
2019-09-30 08:26:19 +00:00
1. This will build BotKube and create a new container image tagged as `infracloudio/botkube:latest`
2019-04-04 14:08:50 +00:00
```sh
$ make build
2019-07-09 08:11:34 +00:00
$ make container-image
Publish multi-arch images with goreleaser (#509)
##### ISSUE TYPE
- Feature Pull Request
##### SUMMARY
- Switch to goreleaser for building and publishing release
- Set BotKube version with build args
- Use docker manifest to build multi-arch image
- Update CI pipeline to build and push image using goreleaser
Fixes #504
```
$ docker manifest inspect ghcr.io/prasadg193/botkube:latest
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"manifests": [
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 1370,
"digest": "sha256:64d94709256eb85452afa06aa15574724266fa6b82b70654ff6b03c467d5a5e4",
"platform": {
"architecture": "amd64",
"os": "linux"
}
},
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 1160,
"digest": "sha256:525d79e629637fd1ae3530223fa380aea26ed299a1fd9ae2787721f4cc33dad5",
"platform": {
"architecture": "amd64",
"os": "linux"
}
},
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 1160,
"digest": "sha256:ef72bc09078929c8aed1161f86c2c86523f6fac664094a034c737ffd582f3ea7",
"platform": {
"architecture": "arm64",
"os": "linux"
}
},
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 1160,
"digest": "sha256:990cd2c6b522a3a69ba73ee83ed0ae306102369f02d09891de8fbfd024d37e87",
"platform": {
"architecture": "arm",
"os": "linux",
"variant": "v7"
}
}
]
}
```
2021-08-19 05:26:22 +00:00
$ docker tag infracloudio/botkube:latest-amd64 < your_account > /botkube:latest
2019-04-04 14:08:50 +00:00
$ docker push < your_account > /botkube:latest
```
Where `<your_account>` is Docker hub account to which you can push the image
2019-12-23 17:50:49 +00:00
2. Deploy newly created image in your cluster.
a. Using helm (v3)
2019-04-04 14:08:50 +00:00
```sh
2019-12-23 17:50:49 +00:00
$ helm repo add infracloudio https://infracloudio.github.io/charts
$ helm repo update
$ kubectl create namespace botkube
$ helm install --version v9.99.9-dev botkube --namespace botkube \
2020-09-28 05:05:01 +00:00
--set communications.slack.enabled=true \
--set communications.slack.channel=< SLACK_CHANNEL_NAME > \
--set communications.slack.token=< SLACK_API_TOKEN_FOR_THE_BOT > \
--set settings.clustername=< CLUSTER_NAME > \
--set settings.kubectl.enabled=< ALLOW_KUBECTL > \
2019-12-23 17:50:49 +00:00
--set image.repository=< your_account > /botkube \
--set image.tag=latest \
infracloudio/botkube
2019-04-04 14:08:50 +00:00
```
2019-12-23 17:50:49 +00:00
Check [values.yaml ](https://github.com/infracloudio/botkube/blob/develop/helm/botkube/values.yaml ) for default options
> Note:
>
> If you are using helm version < 3.0.0, use following command
>
> helm install --version v9.99.9-dev --name botkube --namespace botkube --set \<options\> infracloudio/botkube
b. Using kubectl
1. Edit deploy-all-in-one.yaml and update the configuration.
2020-09-28 05:05:01 +00:00
Set SLACK_ENABLED, SLACK_CHANNEL, SLACK_API_TOKEN, clustername, kubectl.enabled and update the resource events configuration you want to receive notifications for in the configmap.
2019-12-23 17:50:49 +00:00
2. Create botkube namespace and deploy resources
```sh
$ kubectl create ns botkube & & kubectl create -f deploy-all-in-one.yaml -n botkube
```
2019-04-04 14:08:50 +00:00
### Build and run BotKube locally
2019-12-23 17:50:49 +00:00
For faster development, you can also build and run BotKube outside K8s cluster.
1. Build BotKube binary if you don't want to build the container image, you can build the binary like this,
2019-04-04 14:08:50 +00:00
```sh
# Fetch the dependencies
2019-12-23 17:50:49 +00:00
$ go mod download
2019-04-04 14:08:50 +00:00
# Build the binary
$ go build ./cmd/botkube/
```
2019-12-23 17:50:49 +00:00
2. Edit `./resource_config.yaml` and `./comm_config.yaml` to configure resource and set communication credentials.
2019-04-04 14:08:50 +00:00
3. Export the path to directory of `config.yaml`
```sh
# From project root directory
$ export CONFIG_PATH=$(pwd)
```
2019-12-23 17:50:49 +00:00
4. Make sure that correct context is set and you are able to access your Kubernetes cluster
2019-04-04 14:08:50 +00:00
```console
$ kubectl config current-context
minikube
$ kubectl cluster-info
Kubernetes master is running at https://192.168.39.233:8443
CoreDNS is running at https://192.168.39.233:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
...
```
5. Run BotKube binary
```sh
$ ./botkube
```
## Making A Change
2019-12-23 17:50:49 +00:00
* Before making any significant changes, please [open an issue ](https://github.com/infracloudio/botkube/issues ). Discussing your proposed changes ahead of time will make the contribution process smooth for everyone.
2019-04-04 14:08:50 +00:00
2020-10-05 07:09:23 +00:00
* Once we've discussed your changes and you've got your code ready, make sure that the build steps mentioned above pass. Open your pull request against [`develop` ](http://github.com/infracloudio/botkube/tree/develop ) branch.
2019-04-04 14:08:50 +00:00
* To avoid build failures in CI, run
```sh
# From project root directory
$ ./hack/verify-*.sh
```
This will check if the code is properly formatted, linted & vendor directory is present.
2019-12-23 17:50:49 +00:00
* Run e2e tests
```sh
$ ./hack/runtests.sh
```
* Make sure your pull request has [good commit messages ](https://chris.beams.io/posts/git-commit/ ):
2019-04-04 14:08:50 +00:00
* Separate subject from body with a blank line
* Limit the subject line to 50 characters
* Capitalize the subject line
* Do not end the subject line with a period
* Use the imperative mood in the subject line
* Wrap the body at 72 characters
* Use the body to explain _what_ and _why_ instead of _how_
2019-12-23 17:50:49 +00:00
* Try to squash unimportant commits and rebase your changes on to develop branch, this will make sure we have clean log of changes.