<commit_before># Kubeless developer guide

This will cover the steps need to be done in order to build your local development environment for Kubeless.

## Setting things up

As Kubeless project is mainly developed in the Go Programming Language, the first thing you should do is guarantee that Go is installed and all environment variables are properly set.

In this example we will use Ubuntu Linux 16.04.2 LTS as the target host on where the project will be built.

### Installing Go

* Visit [https://golang.org/dl/](https://golang.org/dl/)
* Download the most recent Go version (here we used 1.9) and unpack the file
* Check the installation process on [https://golang.org/doc/install](https://golang.org/doc/install)
* Set the Go environment variables

```bash
export GOROOT=/GoDir/go
export GOPATH=/GoDir/go/bin
export PATH=$GOPATH:$PATH
```

### Create a working directory for the project

```bash
export KUBELESS_WORKING_DIR=$GOROOT/src/github.com/kubeless/
mkdir -p $KUBELESS_WORKING_DIR
```

### Fork the repository

1. Visit the repo: [https://github.com/kubeless/kubeless](https://github.com/kubeless/kubeless)
1. Click `Fork` button (top right) to establish a cloud-based fork.

### Clone from your fork

```bash
cd $KUBELESS_WORKING_DIR
git clone https://github.com/<YOUR FORK>
cd $KUBELESS_WORKING_DIR/kubeless
git remote add upstream https://github.com/kubeless/kubeless.git

# Never push to upstream master
git remote set-url --push upstream no_push
# Checking your remote set correctly
git remote -v
```

### Bootstrapping your local dev environment

To get all the needed tools to build and test, run:

```bash
cd $KUBELESS_WORKING_DIR/kubeless
make bootstrap
```

Or if you want to use a containerized environment you can use [minikube](https://github.com/kubernetes/minikube).
If you already have minikube use the following script to set it up:

```bash
cd $KUBELESS_WORKING_DIR/kubeless
./script/start-test-environment.sh
```

This will start a new minikube virtual machine and will open a bash shell in which you can build any local binary or execute the tests. Note that the Kubeless code will be mounted from outside so you can still edit your files with your favourite text editor.

### Building local binaries

To make the binaries for your platform, run:

```bash
cd $KUBELESS_WORKING_DIR/kubeless
make binary
make function-controller
```

This will instruct "make" to run the scripts to build the kubeless client and the kubeless controller image.

You can build kubeless for multiple platforms with:

```bash
make binary-cross
```

The binaries accordingly located at `bundles/kubeless_$OS_$arch` folder.

### Building Trigger Controllers

Each Kubeless trigger controller is being developed on its own repository. You can find more information about those controllers in their repositories:

 - [HTTP Trigger](https://github.com/kubeless/http-trigger)
 - [CronJob Trigger](https://github.com/kubeless/cronjob-trigger)
 - [Kafka Trigger](https://github.com/kubeless/kafka-trigger)
 - [NATS Trigger](https://github.com/kubeless/nats-trigger)

### Building k8s manifests file

To regenerate the most updated k8s manifests file, run:

> Note that you will need the [`kubecfg`](https://github.com/ksonnet/kubecfg/releases/) in your `PATH` in order to generate the Kubeless manifests.

```bash
cd $KUBELESS_WORKING_DIR
export KUBECFG_JPATH=$PWD/ksonnet-lib
git clone --depth=1 https://github.com/ksonnet/ksonnet-lib.git
cd $KUBELESS_WORKING_DIR/kubeless
make all-yaml
```

If everything is ok, you'll have generated manifests file under the `$KUBELESS_WORKING_DIR` root directory:

```
kubeless-openshift.yaml
kubeless-non-rbac.yaml
kubeless.yaml
```<commit_msg>add AWS Kinesis Trigger (#1181)<commit_after># Kubeless developer guide

This will cover the steps need to be done in order to build your local development environment for Kubeless.

## Setting things up

As Kubeless project is mainly developed in the Go Programming Language, the first thing you should do is guarantee that Go is installed and all environment variables are properly set.

In this example we will use Ubuntu Linux 16.04.2 LTS as the target host on where the project will be built.

### Installing Go

* Visit [https://golang.org/dl/](https://golang.org/dl/)
* Download the most recent Go version (here we used 1.9) and unpack the file
* Check the installation process on [https://golang.org/doc/install](https://golang.org/doc/install)
* Set the Go environment variables

```bash
export GOROOT=/GoDir/go
export GOPATH=/GoDir/go/bin
export PATH=$GOPATH:$PATH
```

### Create a working directory for the project

```bash
export KUBELESS_WORKING_DIR=$GOROOT/src/github.com/kubeless/
mkdir -p $KUBELESS_WORKING_DIR
```

### Fork the repository

1. Visit the repo: [https://github.com/kubeless/kubeless](https://github.com/kubeless/kubeless)
1. Click `Fork` button (top right) to establish a cloud-based fork.

### Clone from your fork

```bash
cd $KUBELESS_WORKING_DIR
git clone https://github.com/<YOUR FORK>
cd $KUBELESS_WORKING_DIR/kubeless
git remote add upstream https://github.com/kubeless/kubeless.git

# Never push to upstream master
git remote set-url --push upstream no_push
# Checking your remote set correctly
git remote -v
```

### Bootstrapping your local dev environment

To get all the needed tools to build and test, run:

```bash
cd $KUBELESS_WORKING_DIR/kubeless
make bootstrap
```

Or if you want to use a containerized environment you can use [minikube](https://github.com/kubernetes/minikube).
If you already have minikube use the following script to set it up:

```bash
cd $KUBELESS_WORKING_DIR/kubeless
./script/start-test-environment.sh
```

This will start a new minikube virtual machine and will open a bash shell in which you can build any local binary or execute the tests. Note that the Kubeless code will be mounted from outside so you can still edit your files with your favourite text editor.

### Building local binaries

To make the binaries for your platform, run:

```bash
cd $KUBELESS_WORKING_DIR/kubeless
make binary
make function-controller
```

This will instruct "make" to run the scripts to build the kubeless client and the kubeless controller image.

You can build kubeless for multiple platforms with:

```bash
make binary-cross
```

The binaries accordingly located at `bundles/kubeless_$OS_$arch` folder.

### Building Trigger Controllers

Each Kubeless trigger controller is being developed on its own repository. You can find more information about those controllers in their repositories:

 - [HTTP Trigger](https://github.com/kubeless/http-trigger)
 - [CronJob Trigger](https://github.com/kubeless/cronjob-trigger)
 - [Kafka Trigger](https://github.com/kubeless/kafka-trigger)
 - [NATS Trigger](https://github.com/kubeless/nats-trigger)
 - [AWS Kinesis Trigger](https://github.com/kubeless/kinesis-trigger)

### Building k8s manifests file

To regenerate the most updated k8s manifests file, run:

> Note that you will need the [`kubecfg`](https://github.com/ksonnet/kubecfg/releases/) in your `PATH` in order to generate the Kubeless manifests.

```bash
cd $KUBELESS_WORKING_DIR
export KUBECFG_JPATH=$PWD/ksonnet-lib
git clone --depth=1 https://github.com/ksonnet/ksonnet-lib.git
cd $KUBELESS_WORKING_DIR/kubeless
make all-yaml
```

If everything is ok, you'll have generated manifests file under the `$KUBELESS_WORKING_DIR` root directory:

```
kubeless-openshift.yaml
kubeless-non-rbac.yaml
kubeless.yaml
```
{'fraction_non_alphanumeric': 0.09311361200428725, 'fraction_numerical': 0.0037513397642015005, 'mean_word_length': 4.746728252501924, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 31, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6492587', 'n_tokens_mistral': 2433, 'n_tokens_neox': 2252, 'n_words': 863}