Skip to content

Commit

Permalink
Replace kubebuilder with knative/build style controllers
Browse files Browse the repository at this point in the history
This PR removes the kubebuilder dependency and framework from knative/build-pipeline,
opting to instead use the hack/update-codegen.sh scripts approach to generating CRD
libraries. The controller and directory structure were also updated to more closely
mirror knative/build.

Resource was temporarily renamed StandardResource as it collided with a method
Register in pkg/apis/pipeline/v1alpha1/register.go.

Currently tests are stubbed out since all of the existing tests were
kubebuilder specific - we'll have to add more!

Updates developer docs to include how to interact with this repo now
that we've switched styles.

Fixes #57
  • Loading branch information
bobcatfish committed Sep 26, 2018
1 parent 15f1373 commit 5182bc5
Show file tree
Hide file tree
Showing 6,162 changed files with 85,388 additions and 1,627,871 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
File renamed without changes.
41 changes: 32 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Test binary, build with `go test -c`
*.test
# Fortran module files
*.mod
*.smod

# Output of the go coverage tool, specifically when used with LiteIDE
# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# Emacs garbage
*~

# VSCode config
.vscode

# bin folder
bin/
# JetBrains IDE config
.idea
3 changes: 3 additions & 0 deletions .ko.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
baseImageOverrides:
github.com/knative/build-pipeline/cmd/creds-init: gcr.io/knative-releases/build-base:latest
github.com/knative/build-pipeline/cmd/git-init: gcr.io/knative-releases/build-base:latest
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ This work is being done by
If you are interested please join our meetings and or slack!

All docs shared with this group are made visible to members of
[knative-dev@](https://groups.google.com/forum/#!forum/knative-dev), please join if you are interested!
[knative-dev@](https://groups.google.com/forum/#!forum/knative-dev), please join if you are interested!
108 changes: 69 additions & 39 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,37 @@
1. Create [a GitHub account](https://github.com/join)
1. Setup [GitHub access via
SSH](https://help.github.com/articles/connecting-to-github-with-ssh/)
1. [Create and checkout a repo fork](#checkout-your-fork)
1. Set up your [shell environment](#environment-setup)
1. Install [requirements](#requirements)
1. [Set up a kubernetes cluster](https://github.com/knative/serving/blob/master/docs/creating-a-kubernetes-cluster.md)
1. [Configure kubectl to use your cluster](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/)
1. [Set up a docker repository you can push to](https://github.com/knative/serving/blob/master/docs/setting-up-a-docker-registry.md)

Then you can [iterate](#iterating) (including [runing the controllers with `ko`](#running-controllers)).

### Checkout your fork

The Go tools require that you clone the repository to the `src/github.com/knative/build-pipeline` directory
in your [`GOPATH`](https://github.com/golang/go/wiki/SettingGOPATH).

To check out this repository:

1. Create your own [fork of this
repo](https://help.github.com/articles/fork-a-repo/)
1. Clone it to your machine:

```shell
mkdir -p ${GOPATH}/src/github.com/knative
cd ${GOPATH}/src/github.com/knative
git clone git@github.com:${YOUR_GITHUB_USERNAME}/build-pipeline.git
cd build-pipeline
git remote add upstream git@github.com:knative/build-pipeline.git
git remote set-url --push upstream no_push
```

_Adding the `upstream` remote sets you up nicely for regularly [syncing your
fork](https://help.github.com/articles/syncing-a-fork/)._

### Requirements

Expand All @@ -17,64 +45,66 @@ You must install these tools:
1. [`git`](https://help.github.com/articles/set-up-git/): For source control
1. [`dep`](https://github.com/golang/dep): For managing external Go
dependencies.
1. [`ko`](https://github.com/google/go-containerregistry/tree/master/cmd/ko): For
development.
1. [`kubectl`](https://kubernetes.io/docs/tasks/tools/install-kubectl/): For interacting with your kube cluster (also required for kubebuidler)
1. [`kustomize`](https://github.com/kubernetes-sigs/kustomize): Required for kubebuilder
1. [`kubebuilder`](https://book.kubebuilder.io/quick_start.html): For generating CRD related
boilerplate (see [docs on iterating with kubebuilder](#installing-and-running)) - Note that
the installation instructions default to `mac`, use the tabs at the top to switch to `linux`

## Iterating
## Environment Setup

### Dependencies
To [run your controllers with `ko`](#running-controllers) you'll need to set these environment
variables (we recommend adding them to your `.bashrc`):

This repo uses [`dep`](https://golang.github.io/dep/docs/daily-dep.html) for dependency management:
1. `GOPATH`: If you don't have one, simply pick a directory and add `export GOPATH=...`
1. `$GOPATH/bin` on `PATH`: This is so that tooling installed via `go get` will work properly.
1. `KO_DOCKER_REPO`: The docker repository to which developer images should be pushed (e.g. `gcr.io/[gcloud-project]`).

* Update the deps with `dep ensure -update`
* `dep ensure` should be a no-op
* Add a dep with `dep ensure -add $MY_DEP`
`.bashrc` example:

### Changing types
```shell
export GOPATH="$HOME/go"
export PATH="${PATH}:${GOPATH}/bin"
export KO_DOCKER_REPO='gcr.io/my-gcloud-project-name'
```

When updating types, you should regenerate any generated code with:
Make sure to configure [authentication](
https://cloud.google.com/container-registry/docs/advanced-authentication#standalone_docker_credential_helper)
for your `KO_DOCKER_REPO` if required. To be able to push images to `gcr.io/<project>`, you need to run this once:

```bash
make generate
```shell
gcloud auth configure-docker
```

Then test this by [installing and running](#installing-and-running).

### Installing and running
## Iterating

The skeleton for this project was generated using [kubebuilder](https://book.kubebuilder.io/quick_start.html),
which created our [Makefile](./Makefile). The `Makefile` will call out to `kubectl`,
so you must [configure your `kubeconfig` to use your cluster](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/).
While iterating on the project, you may need to:

Then a typical development cycle will look like this:
1. [Run controllers](#running-controllers)
1. Update your (external) dependencies with: `./hack/update-deps.sh`.
1. Update your type definitions with: `./hack/update-codegen.sh`.

```bash
# Add/update CRDs in your kubernetes cluster
make install
To make changes to these CRDs, you will probably interact with:

# Run your controller locally, (stop execution with `ctrl-c`)
make run
* The CRD type definitions in [./pkg/apis/pipeline/alpha1](./pkg/apis/pipeline/v1alpha1)
* The controllers in [./pkg/controller](./pkg/controller)
* The clients are in [./pkg/client](./pkg/controller) (these are generated by `./hack/update-codegen.sh`)

# In another terminal, deploy tasks
kubectl apply -f config/samples
```
## Running controllers

You will also want to [run tests](#running-tests).
You can stand up a version of this controller on-cluster (to your `kubectl config current-context`) with:

### Running tests
```shell
# This will register the CRD and deploy the controller to start acting on them.
ko apply -f config/
```

Run the tests with:
As you make changes to the code, you can redeploy your controller with:

```bash
make test
```shell
ko apply -f config/controller.yaml
```

### Where's the code?

To make changes to these CRDs, you will probably interact with:
You can clean up everything with:

* The CRD type definitions in [./pkg/apis/pipeline/v1beta1](./pkg/apis/pipeline/v1beta1)
* The controllers in [./pkg/controller](./pkg/controller)
```shell
ko delete -f config/
```
17 changes: 0 additions & 17 deletions Dockerfile

This file was deleted.

Loading

0 comments on commit 5182bc5

Please sign in to comment.