Skip to content

Latest commit

 

History

History
164 lines (114 loc) · 4.93 KB

DEVELOPMENT.md

File metadata and controls

164 lines (114 loc) · 4.93 KB

Developing

Getting started

  1. Create a GitHub account
  2. Setup GitHub access via SSH
  3. Create and checkout a repo fork
  4. Set up your shell environment
  5. Install requirements
  6. Set up a Kubernetes cluster

Then you can iterate.

Checkout your fork

The Go tools require that you clone the repository to the src/github.com/tektoncd/cli directory in your GOPATH.

To check out this repository:

  1. Create your own fork of this repo
  2. Clone it to your machine:
mkdir -p ${GOPATH}/src/github.com/tektoncd
cd ${GOPATH}/src/github.com/tektoncd
git clone [email protected]:${YOUR_GITHUB_USERNAME}/cli.git
cd cli
git remote add upstream [email protected]:tektoncd/cli.git
git remote set-url --push upstream no_push

Adding the upstream remote sets you up nicely for regularly syncing your fork.

Requirements

You must install these tools:

  1. go: The language Tekton Pipelines CLI is built in
  2. git: For source control
  3. kubectl (optional): For interacting with your kube cluster

Kubernetes cluster

Docker for Desktop using an edge version has been proven to work for both developing and running Pipelines. Your Kubernetes version must be 1.11 or later.

To setup a cluster with GKE:

  1. Install required tools and setup GCP project (You may find it useful to save the ID of the project in an environment variable (e.g. PROJECT_ID).
  2. Create a GKE cluster

Note that the --scopes argument to gcloud container cluster create controls what GCP resources the cluster's default service account has access to; for example to give the default service account full access to your GCR registry, you can add storage-full to your --scopes arg.

Environment Setup

To build the Tekton pipelines cli, you'll need to set GO111MODULE=on environment variable to force go to use go modules.

Iterating

While iterating on the project, you may need to:

  1. Install Tekton pipeline
  2. Building Tekton client
  3. Add and run tests
  4. Generate docs

Building Tekton client

Dependencies:

go mod is used and required for dependencies.

Building In Local Directory:

The following command builds the tkn binary in your current directory:

go build ./cmd/tkn

After it finishes, you can run the following to execute the binary to verify it works:

./tkn

Building and Adding to $PATH:

If you want this tkn binary on your $PATH, a couple options are:

  1. Use go install ./cmd/tkn to install the binary into your $GOBIN. Rerun go install ./cmd/tkn when you want to update the binary.

  2. Add a soft link to the binary into your $PATH. Rerun go build when you want to update the binary.

    go build ./cmd/tkn
    ln -s $PWD/tkn $GOPATH/bin/tkn
  3. After it finishes, you can run the following to execute the binary to verify it works:

    ./tkn

Whether you have added the tkn binary to your current directory or added it to your $PATH, you are now be ready to make changes to tkn.

Notes:

  • For building, Go 1.12 is required
  • If you are building in your $GOPATH folder, you need to specify GO111MODULE for building it
# if you are building in your $GOPATH
GO111MODULE=on go build ./cmd/tkn

You can now try updating code for client and test out the changes by building the tkn binary.

Generate Docs

The docs are autogenerated according to cobra command. Whenever you are updating any command configuration, you should also update the docs in the PR.

  • To generate/update markdown pages

    make docs
  • To generate/update man pages

    make man

Install Pipeline

You can stand up a version of this controller on-cluster (to your kubectl config current-context):