From 60e13e60201ea664372c14701336cd6b3d5398de Mon Sep 17 00:00:00 2001 From: Max Jonas Werner Date: Fri, 31 Mar 2023 17:07:14 +0200 Subject: [PATCH] update GitOps Toolkit guides Signed-off-by: Max Jonas Werner --- content/en/flux/gitops-toolkit/packages.md | 11 +++++----- .../en/flux/gitops-toolkit/source-watcher.md | 21 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/content/en/flux/gitops-toolkit/packages.md b/content/en/flux/gitops-toolkit/packages.md index bd35bfe3e..631c0b963 100644 --- a/content/en/flux/gitops-toolkit/packages.md +++ b/content/en/flux/gitops-toolkit/packages.md @@ -32,16 +32,15 @@ go get github.com/fluxcd/source-controller/api Import package ```go -import sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" +import sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2" ``` -and/or (depending on the API types you will be consuming) +and for `GitRepository` objects: ```go import sourcev1 "github.com/fluxcd/source-controller/api/v1" ``` - API Types | Name | Version | @@ -102,10 +101,10 @@ go get github.com/fluxcd/notification-controller/api Import package ```go -import notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2" +import notificationv1b2 "github.com/fluxcd/notification-controller/api/v1beta2" ``` -and/or (depending on the API types you will be consuming) +and for `Receiver` objects: ```go import notificationv1 "github.com/fluxcd/notification-controller/api/v1" @@ -169,7 +168,7 @@ import ( helmv2 "github.com/fluxcd/helm-controller/api/v2beta1" apimeta "github.com/fluxcd/pkg/apis/meta" - sourcev1 "github.com/fluxcd/source-controller/api/v1beta1" + sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" ) func main() { diff --git a/content/en/flux/gitops-toolkit/source-watcher.md b/content/en/flux/gitops-toolkit/source-watcher.md index 2d4ae7208..edad7e3ac 100644 --- a/content/en/flux/gitops-toolkit/source-watcher.md +++ b/content/en/flux/gitops-toolkit/source-watcher.md @@ -15,10 +15,10 @@ events and reacts to revision changes by downloading the artifact produced by On your dev machine install the following tools: -* go >= 1.19 +* go >= 1.20 * kubebuilder >= 3.0 -* kind >= 0.8 -* kubectl >= 1.21 +* kind >= 0.17 +* kubectl >= 1.25 ## Install Flux @@ -93,14 +93,13 @@ Create a Git source: flux create source git test \ --url=https://github.com/fluxcd/flux2 \ --ignore-paths='/*,!/manifests' \ ---tag=v0.34.0 +--tag=v0.41.2 ``` The source-watcher will log the revision: ```sh -New revision detected {"gitrepository": "flux-system/test", "revision": "v0.34.0@sha1:90f0d81532f6ea76c30974267956c7eaee5c1dea"} -Processing manifests... +{"level":"info","ts":"2023-03-31T16:43:42.703+0200","msg":"New revision detected","controller":"gitrepository","controllerGroup":"source.toolkit.fluxcd.io","controllerKind":"GitRepository","GitRepository":{"name":"test","namespace":"flux-system"},"namespace":"flux-system","name":"test","reconcileID":"ef0fe80e-3952-4835-ae9d-01760c4eadde","revision":"v0.41.2@sha1:81606709114f6d16a432f9f4bfc774942f054327"} ``` Change the Git tag: @@ -109,13 +108,13 @@ Change the Git tag: flux create source git test \ --url=https://github.com/fluxcd/flux2 \ --ignore-paths='/*,!/manifests' \ ---tag=v0.35.0 +--tag=v2.0.0-rc.1 ``` And source-watcher will log the new revision: ```sh -New revision detected {"gitrepository": "flux-system/test", "revision": "v0.35.0@sha1:1bf63a94c22d1b9b7ccf92f66a1a34a74bd72fca"} +{"level":"info","ts":"2023-03-31T16:51:33.499+0200","msg":"New revision detected","controller":"gitrepository","controllerGroup":"source.toolkit.fluxcd.io","controllerKind":"GitRepository","GitRepository":{"name":"test","namespace":"flux-system"},"namespace":"flux-system","name":"test","reconcileID":"cc0f83bb-b7a0-4c19-a254-af9962ae39cd","revision":"v2.0.0-rc.1@sha1:658925c2c0e6c408597d907a8ebee06a9a6d7f30"} ``` The source-controller reports the revision under `GitRepository.Status.Artifact.Revision` in the format: `@sha1:`. @@ -172,7 +171,7 @@ func (r *GitRepositoryWatcher) Reconcile(ctx context.Context, req ctrl.Request) defer os.RemoveAll(tmpDir) // download and extract artifact - if err := r.artifactFetcher.Fetch(artifact.URL, artifact.Checksum, tmpDir); err != nil { + if err := r.artifactFetcher.Fetch(artifact.URL, artifact.Digest, tmpDir); err != nil { log.Error(err, "unable to fetch artifact") return ctrl.Result{}, err } @@ -236,8 +235,8 @@ and Kubernetes [controller-runtime](https://pkg.go.dev/sigs.k8s.io/controller-ru ```go require ( - github.com/fluxcd/pkg/runtime v0.20.0 - sigs.k8s.io/controller-runtime v0.13.0 + github.com/fluxcd/pkg/runtime v0.35.0 + sigs.k8s.io/controller-runtime v0.14.6 ) ```