diff --git a/go.mod b/go.mod index 3e0f38b3656..276af495221 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/jenkins-x/go-scm v1.5.117 github.com/mitchellh/go-homedir v1.1.0 github.com/pkg/errors v0.9.1 - github.com/tektoncd/plumbing v0.0.0-20200430135134-e53521e1d887 + github.com/tektoncd/plumbing v0.0.0-20201021153918-6b7e894737b5 go.opencensus.io v0.22.4 go.uber.org/zap v1.15.0 golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a // indirect diff --git a/go.sum b/go.sum index a886a09f39c..fa9b61cc41c 100644 --- a/go.sum +++ b/go.sum @@ -622,6 +622,7 @@ github.com/google/go-github/v28 v28.1.1/go.mod h1:bsqJWQX05omyWVmc00nEUql9mhQyv3 github.com/google/go-github/v29 v29.0.3/go.mod h1:CHKiKKPHJ0REzfwc14QMklvtHwCveD0PxlMjLlzAM5E= github.com/google/go-licenses v0.0.0-20191112164736-212ea350c932/go.mod h1:16wa6pRqNDUIhOtwF0GcROVqMeXHZJ7H6eGDFUh5Pfk= github.com/google/go-licenses v0.0.0-20200227160636-0fa8c766a591/go.mod h1:JWeTIGPLQ9gF618ZOdlUitd1gRR/l99WOkHOlmR/UVA= +github.com/google/go-licenses v0.0.0-20200602185517-f29a4c695c3d/go.mod h1:g1VOUGKZYIqe8lDq2mL7plhAWXqrEaGUs7eIjthN1sk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/go-replayers/grpcreplay v0.1.0/go.mod h1:8Ig2Idjpr6gifRd6pNVggX6TC1Zw6Jx74AKp7QNH2QE= github.com/google/go-replayers/httpreplay v0.1.0/go.mod h1:YKZViNhiGgqdBlUbI2MwGpq4pXxNmhJLPHQ7cv2b5no= @@ -1018,8 +1019,11 @@ github.com/openzipkin/zipkin-go v0.2.2 h1:nY8Hti+WKaP0cRsSeQ026wU03QsM762XBeCXBb github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/otiai10/copy v1.0.2 h1:DDNipYy6RkIkjMwy+AWzgKiNTyj2RUI9yEMeETEpVyc= github.com/otiai10/copy v1.0.2/go.mod h1:c7RpqBkwMom4bYTSkLSym4VSJz/XtncWRAj/J4PEIMY= +github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= +github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= +github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo= @@ -1218,6 +1222,8 @@ github.com/tektoncd/plumbing v0.0.0-20191216083742-847dcf196de9/go.mod h1:QZHgU0 github.com/tektoncd/plumbing v0.0.0-20200217163359-cd0db6e567d2/go.mod h1:QZHgU07PRBTRF6N57w4+ApRu8OgfYLFNqCDlfEZaD9Y= github.com/tektoncd/plumbing v0.0.0-20200430135134-e53521e1d887 h1:crv70CBAJ2gZFSbf13aRVwdbjR2GYwTms/ZEok/SnFM= github.com/tektoncd/plumbing v0.0.0-20200430135134-e53521e1d887/go.mod h1:cZPJIeTIoP7UPTxQyTQLs7VE1TiXJSNj0te+If4Q+jI= +github.com/tektoncd/plumbing v0.0.0-20201021153918-6b7e894737b5 h1:Y2Gd3X79zqvCd6AdiWyi/pnSewSkLxKygpvXNFXwscg= +github.com/tektoncd/plumbing v0.0.0-20201021153918-6b7e894737b5/go.mod h1:WTWwsg91xgm+jPOKoyKVK/yRYxnVDlUYeDlypB1lDdQ= github.com/tektoncd/plumbing/pipelinerun-logs v0.0.0-20191206114338-712d544c2c21/go.mod h1:S62EUWtqmejjJgUMOGB1CCCHRp6C706laH06BoALkzU= github.com/tetafro/godot v0.3.7/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0= github.com/tetafro/godot v0.4.2/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0= diff --git a/vendor/github.com/tektoncd/plumbing/DEVELOPMENT.md b/vendor/github.com/tektoncd/plumbing/DEVELOPMENT.md index 5ff251ed523..e01e1849ea8 100644 --- a/vendor/github.com/tektoncd/plumbing/DEVELOPMENT.md +++ b/vendor/github.com/tektoncd/plumbing/DEVELOPMENT.md @@ -1,3 +1,97 @@ # Development guide -_[See CONTRIBUTING.md](CONTRIBUTING.md)._ \ No newline at end of file +## Local Kubernetes Cluster with Tekton + +To setup a local development environment for Tekton based CI +and CD pipelines hosted in this repo, the first step is to run +Tekton in a local cluster. + +There are several options available, `minikube`, `kind` and `k3c` +are good options to run a kubernetes cluster on your laptop. +If you have go 1.14+ and docker installed, you can use the +automated script for `kind`: + +```bash +# Install Kind if not installed yet +GO111MODULE="on" go get sigs.k8s.io/kind@v0.9.0 + +# Delete any pre-existing Tekton cluster +kind delete cluster --name tekton + +# Install the new cluster +./hack/tekton_in_kind.sh +``` + +If the deployment was successful, you should see a message: + +```bash +Tekton Dashboard available at http://localhost:9097” +``` + +## Tekton Based CI + +Setting up a working CI with a local cluster requires using +a service like [smee](https://smee.io) to forward GitHub webhooks +to the service in your local cluster. + +In the following steps we use `smee`. You will need `npm` to install +the client. You will also need `tkn` installed to run the webhook +creation task. + +```bash +# Install the smee client +npm install -g smee-client +``` + +You will use webhooks triggered by your personal fork of the +`tektoncd/plumbing` repo and forward them the cluster running on +your laptop. + +Create a GitHub personal token with `admin:repo_hook` persmissions +at least. This will be used to create the webhook. + +```bash +# Define GitHub variables, including the token and webhook secret +GITHUB_TOKEN= +GITHUB_SECRET=$(ruby -rsecurerandom -e 'puts SecureRandom.hex(20)') +GITHUB_ORG= # The org or user where your fork is hosted +GITHUB_REPO= # The name of the fork, typically "plumbing" +GITHUB_USER= # Your GitHub username + +# Deploy plumbing resources. Run from the root of your local clone +# The sed command injects your fork GitHub org in the CEL filters +kustomize build tekton/ci | \ + sed -E 's/tektoncd(\/p[^i]+|\(|\/'\'')/'$GITHUB_ORG'\1/g' | \ + kubectl create -f - + +# Create the secret used by the GitHub interceptor +kubectl create secret generic ci-webhook -n tektonci --from-literal=secret=$GITHUB_SECRET + +# Expose the event listener via Smee +kubectl port-forward service/el-tekton-ci-webhook -n tektonci 9999:8080 &> el-tekton-ci-webhook-pf.log & +smee --target http://127.0.0.1:9999/ &> smee.log & +SMEE_TARGET=$(tail -1 smee.log | cut -d'/' -f3-) + +# Install a Task to create the webhook, create a secret used by it +kubectl apply -f https://raw.githubusercontent.com/tektoncd/triggers/master/docs/getting-started/create-webhook.yaml +kubectl create secret generic github --from-literal=token=$GITHUB_TOKEN --from-literal=secret=$GITHUB_SECRET + +# Setup the webhook in your fork that points to the smee service +tkn task start create-webhook -p ExternalDomain=$SMEE_TARGET -p GitHubUser=$GITHUB_USER -p GitHubRepo=$GITHUB_REPO -p GitHubOrg=$GITHUB_ORG -p GitHubSecretName=github -p GitHubAccessTokenKey=token -p GitHubSecretStringKey=secret +``` + +Push or sync a PR to your fork, and watch the pipelines running in your +cluster. You can use `redeliver` from the GitHub webhook UI to resend +and event and re-trigger pipelines. + +This guide does not include setting up status updates back to GitHub. +If you need those for development, you'll need to ensure that: + +- Install resources under `tekton/resources` to deploy the + `tekton-events` event listener +- Configure Tekton send cloud events to the `tekton-events` + event listener like on the [dogfooding](https://github.com/tektoncd/plumbing/blob/master/tekton/cd/pipeline/overlays/dogfooding/config-defaults.yaml) cluster. +- Create the [secret](https://github.com/tektoncd/plumbing/blob/534861ab15eb5787cac51512eaae6ca2101a7573/tekton/resources/ci/github-template.yaml#L121-L123) + needed by the GitHub update jobs to update status checks. + +See also _[CONTRIBUTING.md](CONTRIBUTING.md). diff --git a/vendor/github.com/tektoncd/plumbing/Makefile b/vendor/github.com/tektoncd/plumbing/Makefile index 681a6818de5..c5ec4bb9ca9 100644 --- a/vendor/github.com/tektoncd/plumbing/Makefile +++ b/vendor/github.com/tektoncd/plumbing/Makefile @@ -12,18 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -images: test-runner skopeo tkn +CONTAINER_RUNTIME=docker +REPO = +IMAGES = $(sort $(patsubst tekton/images/%/,%,$(dir $(wildcard tekton/images/*/)))) -skopeo: - docker build . -f tekton/images/skopeo/Dockerfile -t gcr.io/tekton-releases/dogfooding/skopeo +images: $(IMAGES) + echo $(IMAGES) -test-runner: - docker build . -f tekton/images/test-runner/Dockerfile -t gcr.io/tekton-releases/dogfooding/test-runner +%: tekton/images/% + $(CONTAINER_RUNTIME) build $< -f $`. - - `RELEASE_BRANCH`: contains the release branch if `--branch` was passed. Otherwise - it's empty and `master` HEAD will be considered the release branch. - - `RELEASE_NOTES`: contains the filename with the release notes if `--release-notes` - was passed. The release notes is a simple markdown file. - - `RELEASE_GCS_BUCKET`: contains the GCS bucket name to store the manifests if - `--release-gcs` was passed, otherwise the default value `knative-nightly/` - will be used. It is empty if `--publish` was not passed. - - `KO_DOCKER_REPO`: contains the GCR to store the images if `--release-gcr` was - passed, otherwise the default value `gcr.io/knative-nightly` will be used. It - is set to `ko.local` if `--publish` was not passed. - - `SKIP_TESTS`: true if `--skip-tests` was passed. This is handled automatically. - - `TAG_RELEASE`: true if `--tag-release` was passed. In this case, the environment - variable `TAG` will contain the release tag in the form `vYYYYMMDD-`. - - `PUBLISH_RELEASE`: true if `--publish` was passed. In this case, the environment - variable `KO_FLAGS` will be updated with the `-L` option. - - `PUBLISH_TO_GITHUB`: true if `--version`, `--branch` and `--publish-release` - were passed. - - All boolean environment variables default to false for safety. - - All environment variables above, except `KO_FLAGS`, are marked read-only once - `main()` is called (see below). +1. kubectl installed -1. Call the `main()` function passing `$@` (without quotes). +1. cluster gke_tekton-nightly_europe-north1-a_robocat defined in the local kubeconfig -### Sample release script +Usage: -```bash -source vendor/github.com/knative/test-infra/scripts/release.sh +`deploy-release.sh -p project -v version [-b bucket] [-e extra-path] [-f file]` -function build_release() { - # config/ contains the manifests - ko resolve ${KO_FLAGS} -f config/ > release.yaml - YAMLS_TO_PUBLISH="release.yaml" -} +Where: -main $@ -``` +- `project` is `pipeline`, `triggers` or `dashboard` + +- `version` is the release number i.e. `v0.13.2` + +- `bucket` is the URL of the bucket where the release fiel is stored, `gs://tekton-releases` by default + +- `extra-path` is the root path within the bucket where release are stored, empty by default + +- `file` is the name of the release file, `release.yaml` by default + +To summarize, the deployment job will look for the release file into `///previous//` diff --git a/vendor/github.com/tektoncd/plumbing/scripts/deploy-release.sh b/vendor/github.com/tektoncd/plumbing/scripts/deploy-release.sh new file mode 100644 index 00000000000..b08f4d40246 --- /dev/null +++ b/vendor/github.com/tektoncd/plumbing/scripts/deploy-release.sh @@ -0,0 +1,114 @@ +#!/bin/bash +set -eu -o pipefail + +declare TEKTON_PROJECT TEKTON_VERSION RELEASE_BUCKET_OPT RELEASE_EXTRA_PATH RELEASE_FILE + +# This script allows to deploy a Tekton release to the dogfooding cluster +# by creating a job in the robocat cluster. The complete flow is: +# cronjob --[json payload]--> robocat event listener --> deploy trigger template --> deploy pipelinerun +# The deploy pipelinerun users a cluster resource on the robocat cluster to deploy to dogfooding + +# Prerequisites: +# - kubectl installed +# - cluster gke_tekton-nightly_europe-north1-a_robocat defined in the local kubeconfig + +# Read command line options +while getopts ":p:v:" opt; do + case ${opt} in + p ) + TEKTON_PROJECT=$OPTARG + ;; + v ) + TEKTON_VERSION=$OPTARG + ;; + b ) + RELEASE_BUCKET_OPT=$OPTARG + ;; + e ) + RELEASE_EXTRA_PATH=$OPTARG + ;; + f ) + RELEASE_FILE=$OPTARG + ;; + \? ) + echo "Invalid option: $OPTARG" 1>&2 + echo 1>&2 + echo "Usage: deploy-release.sh -p project -v version [-b bucket] [-e extra-path] [-f file]" 1>&2 + ;; + : ) + echo "Invalid option: $OPTARG requires an argument" 1>&2 + ;; + esac +done +shift $((OPTIND -1)) + +# Check and defaults input params +if [ -z "$TEKTON_PROJECT" ]; then + echo "Please specify a project with -p project" 1>&2 + exit 1 +fi +if [ -z "$TEKTON_VERSION" ]; then + echo "Please specify a version with -v version" 1>&2 + exit 1 +fi +RELEASE_BUCKET=${RELEASE_BUCKET_OPT:-gs://tekton-releases} +if [ -z "$RELEASE_FILE" ]; then + if [ "$TEKTON_PROJECT" == "dashboard" ]; then + RELEASE_FILE="tekton-dashboard-release-readonly.yaml" + else + RELEASE_FILE="release.yaml" + fi +fi + +# Deploy the release +cat < /workspace/post-body.json + { + "trigger-template": "tekton", + "params": { + "target": { + "namespace": "tekton-pipelines", + "cluster-resource": "dogfooding-tekton-deployer" + }, + "tekton": { + "project": "$TEKTON_PROJECT", + "version": "$TEKTON_VERSION", + "environment": "dogfooding", + "bucket": "$RELEASE_BUCKET", + "file": "$RELEASE_FILE", + "extra-path": "$RELEASE_EXTRA_PATH" + }, + "plumbing": { + "repository": "github.com/tektoncd/plumbing", + "revision": "master" + } + } + } + EOF + curl -d @/workspace/post-body.json http://el-tekton-cd.default.svc.cluster.local:8080 + restartPolicy: Never + terminationGracePeriodSeconds: 30 + volumes: + - emptyDir: {} + name: workspace +EOF \ No newline at end of file diff --git a/vendor/github.com/tektoncd/plumbing/scripts/dummy.go b/vendor/github.com/tektoncd/plumbing/scripts/dummy.go index c87432b2640..9b144b8ec8b 100644 --- a/vendor/github.com/tektoncd/plumbing/scripts/dummy.go +++ b/vendor/github.com/tektoncd/plumbing/scripts/dummy.go @@ -16,11 +16,5 @@ limitations under the License. package scripts -import ( - "fmt" -) - -func main() { - fmt.Println("This is a dummy go file so `go dep` or go modules can be used with tektoncd/plumbing/scripts") - fmt.Println("This file can be safely removed if one day this directory contains real, useful go code") -} +// This is a dummy go file so `go dep` or go modules can be used with tektoncd/plumbing or sub-packages +// This file can be safely removed if one day this directory contains real, useful go code diff --git a/vendor/modules.txt b/vendor/modules.txt index bf085a93261..283e6859ab6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -296,7 +296,7 @@ github.com/shurcooL/graphql/internal/jsonutil github.com/sirupsen/logrus # github.com/spf13/pflag v1.0.5 github.com/spf13/pflag -# github.com/tektoncd/plumbing v0.0.0-20200430135134-e53521e1d887 +# github.com/tektoncd/plumbing v0.0.0-20201021153918-6b7e894737b5 github.com/tektoncd/plumbing github.com/tektoncd/plumbing/scripts # github.com/vdemeester/k8s-pkg-credentialprovider v1.17.4