Skip to content

Commit

Permalink
update GitOps Toolkit guides
Browse files Browse the repository at this point in the history
Signed-off-by: Max Jonas Werner <mail@makk.es>
  • Loading branch information
Max Jonas Werner committed Apr 5, 2023
1 parent 6337000 commit 60e13e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
11 changes: 5 additions & 6 deletions content/en/flux/gitops-toolkit/packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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() {
Expand Down
21 changes: 10 additions & 11 deletions content/en/flux/gitops-toolkit/source-watcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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: `<branch|tag>@sha1:<commit>`.
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
)
```

Expand Down

0 comments on commit 60e13e6

Please sign in to comment.