Skip to content

Commit 4304bbe

Browse files
authored
Merge pull request #31 from fluxcd/spec-sync
docs: Sync specification with API
2 parents d77ae99 + 61d49ca commit 4304bbe

File tree

7 files changed

+49
-47
lines changed

7 files changed

+49
-47
lines changed

api/v1alpha1/source.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ type Source interface {
1111
// GetInterval returns the interval at which the source is updated.
1212
GetInterval() metav1.Duration
1313
}
14+
15+
const (
16+
// SyncAtAnnotation is the timestamp corresponding to an on-demand source sync.
17+
SyncAtAnnotation string = "source.fluxcd.io/syncAt"
18+
)

controllers/predicate.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import (
2424
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
2525
"sigs.k8s.io/controller-runtime/pkg/event"
2626
"sigs.k8s.io/controller-runtime/pkg/predicate"
27+
28+
sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1"
2729
)
2830

2931
type SourceChangePredicate struct {
@@ -43,8 +45,8 @@ func (SourceChangePredicate) Update(e event.UpdateEvent) bool {
4345
}
4446

4547
// handle force sync
46-
if val, ok := e.MetaNew.GetAnnotations()[ForceSyncAnnotation]; ok {
47-
if valOld, okOld := e.MetaOld.GetAnnotations()[ForceSyncAnnotation]; okOld {
48+
if val, ok := e.MetaNew.GetAnnotations()[sourcev1.SyncAtAnnotation]; ok {
49+
if valOld, okOld := e.MetaOld.GetAnnotations()[sourcev1.SyncAtAnnotation]; okOld {
4850
if val != valOld {
4951
return true
5052
}
@@ -56,10 +58,6 @@ func (SourceChangePredicate) Update(e event.UpdateEvent) bool {
5658
return false
5759
}
5860

59-
const (
60-
ForceSyncAnnotation string = "source.fluxcd.io/syncAt"
61-
)
62-
6361
type GarbageCollectPredicate struct {
6462
predicate.Funcs
6563
Scheme *runtime.Scheme

docs/spec/v1alpha1/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# source.fluxcd.io/v1alpha1
22

3-
The is the v1alpha1 API specification for defining the desired state sources of Kubernetes clusters.
3+
This is the v1alpha1 API specification for defining the desired state sources of Kubernetes clusters.
44

55
## Specification
66

@@ -12,4 +12,8 @@ The is the v1alpha1 API specification for defining the desired state sources of
1212

1313
## Implementation
1414

15-
* source-controller [v0.0.1-alpha.1](https://github.com/fluxcd/source-controller/releases)
15+
* [source-controller](https://github.com/fluxcd/source-controller/)
16+
17+
## Consumers
18+
19+
* [kustomize-controller](https://github.com/fluxcd/kustomize-controller/)

docs/spec/v1alpha1/common.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ The controller can be told to check for updates right away by setting an annotat
3737

3838
```go
3939
const (
40-
// ForceSyncAnnotation is the timestamp corresponding to an on-demand source sync.
41-
ForceSyncAnnotation string = "source.fluxcd.io/syncAt"
40+
// SyncAtAnnotation is the timestamp corresponding to an on-demand source sync.
41+
SyncAtAnnotation string = "source.fluxcd.io/syncAt"
4242
)
4343
```
4444

45-
Force sync example:
45+
Trigger source sync example:
4646

4747
```bash
4848
kubectl annotate --overwrite gitrepository/podinfo source.fluxcd.io/syncAt="$(date +%s)"
@@ -143,4 +143,4 @@ const (
143143

144144
## Examples
145145

146-
See the [Git repository](gitrepositories.md) and [Helm chart](helmrepositories.md) APIs.
146+
See the [Git repository](gitrepositories.md) and [Helm chart](helmcharts.md) APIs.

docs/spec/v1alpha1/gitrepositories.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,17 +297,17 @@ Successful sync:
297297
status:
298298
artifact:
299299
lastUpdateTime: "2020-04-07T06:59:23Z"
300-
path: /data/gitrepository/podinfo-default/363a6a8fe6a7f13e05d34c163b0ef02a777da20a.tar.gz
300+
path: /data/gitrepository/default/podinfo/363a6a8fe6a7f13e05d34c163b0ef02a777da20a.tar.gz
301301
revision: master/363a6a8fe6a7f13e05d34c163b0ef02a777da20a
302-
url: http://<host>/gitrepository/podinfo-default/363a6a8fe6a7f13e05d34c163b0ef02a777da20a.tar.gz
302+
url: http://<host>/gitrepository/default/podinfo/363a6a8fe6a7f13e05d34c163b0ef02a777da20a.tar.gz
303303
conditions:
304304
- lastTransitionTime: "2020-04-07T06:59:23Z"
305-
message: 'Fetched artifacts are available at
306-
/data/gitrepository/podinfo-default/363a6a8fe6a7f13e05d34c163b0ef02a777da20a.tar.gz'
305+
message: 'Git repoistory artifacts are available at:
306+
/data/gitrepository/default/podinfo/363a6a8fe6a7f13e05d34c163b0ef02a777da20a.tar.gz'
307307
reason: GitOperationSucceed
308308
status: "True"
309309
type: Ready
310-
url: http://<host>/gitrepository/podinfo-default/latest.tar.gz
310+
url: http://<host>/gitrepository/default/podinfo/latest.tar.gz
311311
```
312312

313313
Failed authentication:
@@ -335,7 +335,7 @@ status:
335335
type: Ready
336336
```
337337

338-
Wait for condition:
338+
Wait for ready condition:
339339

340340
```bash
341341
kubectl wait gitrepository/podinfo --for=condition=ready --timeout=1m

docs/spec/v1alpha1/helmcharts.md

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const (
6666

6767
## Spec examples
6868

69-
Pinned version:
69+
Pull a specific chart version every five minutes:
7070

7171
```yaml
7272
apiVersion: source.fluxcd.io/v1alpha1
@@ -82,9 +82,10 @@ spec:
8282
version: 10.5.7
8383
helmRepositoryRef:
8484
name: stable
85+
interval: 5m
8586
```
8687
87-
Semver range:
88+
Pull the latest chart version that matches the sermver range every ten minutes:
8889
8990
```yaml
9091
apiVersion: source.fluxcd.io/v1alpha1
@@ -97,22 +98,7 @@ spec:
9798
version: ^10.0.0
9899
helmRepositoryRef:
99100
name: stable
100-
```
101-
102-
Interval:
103-
104-
```yaml
105-
apiVersion: source.fluxcd.io/v1alpha1
106-
kind: HelmChart
107-
metadata:
108-
name: redis
109-
namespace: default
110-
spec:
111-
name: redis
112-
version: ^10.0.0
113-
helmRepositoryRef:
114-
name: stable
115-
interval: 30m
101+
interval: 10m
116102
```
117103
118104
## Status examples
@@ -121,10 +107,10 @@ Successful chart pull:
121107
122108
```yaml
123109
status:
124-
url: http://<host>/helmcharts/redis-default/redis-10.5.7.tgz
110+
url: http://<host>/helmchart/default/redis/redis-10.5.7.tgz
125111
conditions:
126112
- lastTransitionTime: "2020-04-10T09:34:45Z"
127-
message: Fetched artifact are available at /data/helmcharts/redis-default/redis-10.5.7.tgz
113+
message: Helm chart is available at /data/helmchart/default/redis/redis-10.5.7.tgz
128114
reason: ChartPullSucceeded
129115
status: "True"
130116
type: Ready
@@ -136,8 +122,14 @@ Failed chart pull:
136122
status:
137123
conditions:
138124
- lastTransitionTime: "2020-04-10T09:34:45Z"
139-
message: ''
125+
message: 'invalid chart URL format'
140126
reason: ChartPullFailed
141127
status: "False"
142128
type: Ready
143129
```
130+
131+
Wait for ready condition:
132+
133+
```bash
134+
kubectl wait helmchart/redis --for=condition=ready --timeout=1m
135+
```

docs/spec/v1alpha1/helmrepositories.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,20 @@ const (
6464

6565
## Spec examples
6666

67-
Public Helm repository:
67+
Pull the index of a public Helm repository every ten minutes:
6868

6969
```yaml
7070
apiVersion: source.fluxcd.io/v1alpha1
7171
kind: HelmRepository
7272
metadata:
7373
name: stable
7474
namespace: default
75-
annotations:
76-
# force sync trigger
77-
source.fluxcd.io/syncAt: "2020-04-06T15:39:52+03:00"
7875
spec:
7976
url: https://kubernetes-charts.storage.googleapis.com/
80-
interval: 1m
77+
interval: 10m
8178
```
8279
83-
Private Helm repository:
80+
Pull the index of a private Helm repository every minute:
8481
8582
```yaml
8683
apiVersion: source.fluxcd.io/v1alpha1
@@ -114,10 +111,10 @@ Successful indexation:
114111
115112
```yaml
116113
status:
117-
url: http://<host>/helmrepository/podinfo-default/index.yaml
114+
url: http://<host>/helmrepository/default/stable/index.yaml
118115
conditions:
119116
- lastTransitionTime: "2020-04-10T09:34:45Z"
120-
message: Fetched artifact are available at /data/helmrepositories/podinfo-default/index-21c195d78e699e4b656e2885887d019627838993.yaml
117+
message: Helm repository index is available at /data/helmrepository/default/stable/index-21c195d78e699e4b656e2885887d019627838993.yaml
121118
reason: IndexationSucceeded
122119
status: "True"
123120
type: Ready
@@ -146,3 +143,9 @@ status:
146143
status: "False"
147144
type: Ready
148145
```
146+
147+
Wait for ready condition:
148+
149+
```bash
150+
kubectl wait helmrepository/stable --for=condition=ready --timeout=1m
151+
```

0 commit comments

Comments
 (0)