Skip to content

Commit ff94d41

Browse files
authored
Merge pull request #586 from fluxcd/rewrite-dev
2 parents bd3d781 + 9c7661d commit ff94d41

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+12101
-4087
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ manifests: controller-gen ## Generate manifests, e.g. CRD, RBAC, etc.
127127
cd api; $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role paths="./..." output:crd:artifacts:config="../config/crd/bases"
128128

129129
api-docs: gen-crd-api-reference-docs ## Generate API reference documentation
130-
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir=./api/v1beta1 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/source.md
130+
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir=./api/v1beta2 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/source.md
131131

132132
tidy: ## Run go mod tidy
133133
go mod tidy

PROJECT

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
domain: toolkit.fluxcd.io
22
repo: github.com/fluxcd/source-controller
33
resources:
4+
- group: source
5+
kind: GitRepository
6+
version: v1beta2
7+
- group: source
8+
kind: HelmRepository
9+
version: v1beta2
10+
- group: source
11+
kind: HelmChart
12+
version: v1beta2
13+
- group: source
14+
kind: Bucket
15+
version: v1beta2
416
- group: source
517
kind: GitRepository
618
version: v1beta1

api/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ go 1.17
44

55
require (
66
github.com/fluxcd/pkg/apis/acl v0.0.3
7-
github.com/fluxcd/pkg/apis/meta v0.10.2
8-
k8s.io/apimachinery v0.23.1
7+
github.com/fluxcd/pkg/apis/meta v0.12.0
8+
k8s.io/apimachinery v0.23.2
99
sigs.k8s.io/controller-runtime v0.11.0
1010
)
1111

@@ -24,5 +24,5 @@ require (
2424
k8s.io/klog/v2 v2.30.0 // indirect
2525
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704 // indirect
2626
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
27-
sigs.k8s.io/structured-merge-diff/v4 v4.2.0 // indirect
27+
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
2828
)

api/go.sum

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv
123123
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
124124
github.com/fluxcd/pkg/apis/acl v0.0.3 h1:Lw0ZHdpnO4G7Zy9KjrzwwBmDZQuy4qEjaU/RvA6k1lc=
125125
github.com/fluxcd/pkg/apis/acl v0.0.3/go.mod h1:XPts6lRJ9C9fIF9xVWofmQwftvhY25n1ps7W9xw0XLU=
126-
github.com/fluxcd/pkg/apis/meta v0.10.2 h1:pnDBBEvfs4HaKiVAYgz+e/AQ8dLvcgmVfSeBroZ/KKI=
127-
github.com/fluxcd/pkg/apis/meta v0.10.2/go.mod h1:KQ2er9xa6koy7uoPMZjIjNudB5p4tXs+w0GO6fRcy7I=
126+
github.com/fluxcd/pkg/apis/meta v0.12.0 h1:Ssyltj6E9A7y32sZrzjog0m+bIsFM/3lHHfmpxesUAU=
127+
github.com/fluxcd/pkg/apis/meta v0.12.0/go.mod h1:SPrSWMwDK7Ls2/4GadzhjDjPFbKrzzgzuZ0oDO3jzso=
128128
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
129129
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
130130
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
@@ -897,8 +897,8 @@ k8s.io/api v0.23.0 h1:WrL1gb73VSC8obi8cuYETJGXEoFNEh3LU0Pt+Sokgro=
897897
k8s.io/api v0.23.0/go.mod h1:8wmDdLBHBNxtOIytwLstXt5E9PddnZb0GaMcqsvDBpg=
898898
k8s.io/apiextensions-apiserver v0.23.0/go.mod h1:xIFAEEDlAZgpVBl/1VSjGDmLoXAWRG40+GsWhKhAxY4=
899899
k8s.io/apimachinery v0.23.0/go.mod h1:fFCTTBKvKcwTPFzjlcxp91uPFZr+JA0FubU4fLzzFYc=
900-
k8s.io/apimachinery v0.23.1 h1:sfBjlDFwj2onG0Ijx5C+SrAoeUscPrmghm7wHP+uXlo=
901-
k8s.io/apimachinery v0.23.1/go.mod h1:SADt2Kl8/sttJ62RRsi9MIV4o8f5S3coArm0Iu3fBno=
900+
k8s.io/apimachinery v0.23.2 h1:dBmjCOeYBdg2ibcQxMuUq+OopZ9fjfLIR5taP/XKeTs=
901+
k8s.io/apimachinery v0.23.2/go.mod h1:zDqeV0AK62LbCI0CI7KbWCAYdLg+E+8UXJ0rIz5gmS8=
902902
k8s.io/apiserver v0.23.0/go.mod h1:Cec35u/9zAepDPPFyT+UMrgqOCjgJ5qtfVJDxjZYmt4=
903903
k8s.io/client-go v0.23.0/go.mod h1:hrDnpnK1mSr65lHHcUuIZIXDgEbzc7/683c6hyG4jTA=
904904
k8s.io/code-generator v0.23.0/go.mod h1:vQvOhDXhuzqiVfM/YHp+dmg10WDZCchJVObc9MvowsE=
@@ -924,8 +924,9 @@ sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 h1:kDi4JBNAsJWfz1aEXhO8Jg87J
924924
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2/go.mod h1:B+TnT182UBxE84DiCz4CVE26eOSDAeYCpfDnC2kdKMY=
925925
sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
926926
sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
927-
sigs.k8s.io/structured-merge-diff/v4 v4.2.0 h1:kDvPBbnPk+qYmkHmSo8vKGp438IASWofnbbUKDE/bv0=
928927
sigs.k8s.io/structured-merge-diff/v4 v4.2.0/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
928+
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 h1:bKCqE9GvQ5tiVHn5rfn1r+yao3aLQEaLzkkmAkf+A6Y=
929+
sigs.k8s.io/structured-merge-diff/v4 v4.2.1/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
929930
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
930931
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
931932
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=

api/v1beta1/bucket_types.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,13 @@ func BucketProgressing(bucket Bucket) Bucket {
126126
bucket.Status.ObservedGeneration = bucket.Generation
127127
bucket.Status.URL = ""
128128
bucket.Status.Conditions = []metav1.Condition{}
129-
meta.SetResourceCondition(&bucket, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
129+
newCondition := metav1.Condition{
130+
Type: meta.ReadyCondition,
131+
Status: metav1.ConditionUnknown,
132+
Reason: meta.ProgressingReason,
133+
Message: "reconciliation in progress",
134+
}
135+
apimeta.SetStatusCondition(bucket.GetStatusConditions(), newCondition)
130136
return bucket
131137
}
132138

@@ -136,14 +142,26 @@ func BucketProgressing(bucket Bucket) Bucket {
136142
func BucketReady(bucket Bucket, artifact Artifact, url, reason, message string) Bucket {
137143
bucket.Status.Artifact = &artifact
138144
bucket.Status.URL = url
139-
meta.SetResourceCondition(&bucket, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
145+
newCondition := metav1.Condition{
146+
Type: meta.ReadyCondition,
147+
Status: metav1.ConditionTrue,
148+
Reason: reason,
149+
Message: message,
150+
}
151+
apimeta.SetStatusCondition(bucket.GetStatusConditions(), newCondition)
140152
return bucket
141153
}
142154

143155
// BucketNotReady sets the meta.ReadyCondition on the Bucket to 'False', with
144156
// the given reason and message. It returns the modified Bucket.
145157
func BucketNotReady(bucket Bucket, reason, message string) Bucket {
146-
meta.SetResourceCondition(&bucket, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
158+
newCondition := metav1.Condition{
159+
Type: meta.ReadyCondition,
160+
Status: metav1.ConditionFalse,
161+
Reason: reason,
162+
Message: message,
163+
}
164+
apimeta.SetStatusCondition(bucket.GetStatusConditions(), newCondition)
147165
return bucket
148166
}
149167

api/v1beta1/gitrepository_types.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,13 @@ func GitRepositoryProgressing(repository GitRepository) GitRepository {
196196
repository.Status.ObservedGeneration = repository.Generation
197197
repository.Status.URL = ""
198198
repository.Status.Conditions = []metav1.Condition{}
199-
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
199+
newCondition := metav1.Condition{
200+
Type: meta.ReadyCondition,
201+
Status: metav1.ConditionUnknown,
202+
Reason: meta.ProgressingReason,
203+
Message: "reconciliation in progress",
204+
}
205+
apimeta.SetStatusCondition(repository.GetStatusConditions(), newCondition)
200206
return repository
201207
}
202208

@@ -207,15 +213,27 @@ func GitRepositoryReady(repository GitRepository, artifact Artifact, includedArt
207213
repository.Status.Artifact = &artifact
208214
repository.Status.IncludedArtifacts = includedArtifacts
209215
repository.Status.URL = url
210-
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
216+
newCondition := metav1.Condition{
217+
Type: meta.ReadyCondition,
218+
Status: metav1.ConditionTrue,
219+
Reason: reason,
220+
Message: message,
221+
}
222+
apimeta.SetStatusCondition(repository.GetStatusConditions(), newCondition)
211223
return repository
212224
}
213225

214226
// GitRepositoryNotReady sets the meta.ReadyCondition on the given GitRepository
215227
// to 'False', with the given reason and message. It returns the modified
216228
// GitRepository.
217229
func GitRepositoryNotReady(repository GitRepository, reason, message string) GitRepository {
218-
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
230+
newCondition := metav1.Condition{
231+
Type: meta.ReadyCondition,
232+
Status: metav1.ConditionFalse,
233+
Reason: reason,
234+
Message: message,
235+
}
236+
apimeta.SetStatusCondition(repository.GetStatusConditions(), newCondition)
219237
return repository
220238
}
221239

api/v1beta1/helmchart_types.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,13 @@ func HelmChartProgressing(chart HelmChart) HelmChart {
152152
chart.Status.ObservedGeneration = chart.Generation
153153
chart.Status.URL = ""
154154
chart.Status.Conditions = []metav1.Condition{}
155-
meta.SetResourceCondition(&chart, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
155+
newCondition := metav1.Condition{
156+
Type: meta.ReadyCondition,
157+
Status: metav1.ConditionUnknown,
158+
Reason: meta.ProgressingReason,
159+
Message: "reconciliation in progress",
160+
}
161+
apimeta.SetStatusCondition(chart.GetStatusConditions(), newCondition)
156162
return chart
157163
}
158164

@@ -162,15 +168,27 @@ func HelmChartProgressing(chart HelmChart) HelmChart {
162168
func HelmChartReady(chart HelmChart, artifact Artifact, url, reason, message string) HelmChart {
163169
chart.Status.Artifact = &artifact
164170
chart.Status.URL = url
165-
meta.SetResourceCondition(&chart, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
171+
newCondition := metav1.Condition{
172+
Type: meta.ReadyCondition,
173+
Status: metav1.ConditionTrue,
174+
Reason: reason,
175+
Message: message,
176+
}
177+
apimeta.SetStatusCondition(chart.GetStatusConditions(), newCondition)
166178
return chart
167179
}
168180

169181
// HelmChartNotReady sets the meta.ReadyCondition on the given HelmChart to
170182
// 'False', with the given reason and message. It returns the modified
171183
// HelmChart.
172184
func HelmChartNotReady(chart HelmChart, reason, message string) HelmChart {
173-
meta.SetResourceCondition(&chart, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
185+
newCondition := metav1.Condition{
186+
Type: meta.ReadyCondition,
187+
Status: metav1.ConditionFalse,
188+
Reason: reason,
189+
Message: message,
190+
}
191+
apimeta.SetStatusCondition(chart.GetStatusConditions(), newCondition)
174192
return chart
175193
}
176194

api/v1beta1/helmrepository_types.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,13 @@ func HelmRepositoryProgressing(repository HelmRepository) HelmRepository {
113113
repository.Status.ObservedGeneration = repository.Generation
114114
repository.Status.URL = ""
115115
repository.Status.Conditions = []metav1.Condition{}
116-
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
116+
newCondition := metav1.Condition{
117+
Type: meta.ReadyCondition,
118+
Status: metav1.ConditionUnknown,
119+
Reason: meta.ProgressingReason,
120+
Message: "reconciliation in progress",
121+
}
122+
apimeta.SetStatusCondition(repository.GetStatusConditions(), newCondition)
117123
return repository
118124
}
119125

@@ -123,15 +129,27 @@ func HelmRepositoryProgressing(repository HelmRepository) HelmRepository {
123129
func HelmRepositoryReady(repository HelmRepository, artifact Artifact, url, reason, message string) HelmRepository {
124130
repository.Status.Artifact = &artifact
125131
repository.Status.URL = url
126-
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
132+
newCondition := metav1.Condition{
133+
Type: meta.ReadyCondition,
134+
Status: metav1.ConditionTrue,
135+
Reason: reason,
136+
Message: message,
137+
}
138+
apimeta.SetStatusCondition(repository.GetStatusConditions(), newCondition)
127139
return repository
128140
}
129141

130142
// HelmRepositoryNotReady sets the meta.ReadyCondition on the given
131143
// HelmRepository to 'False', with the given reason and message. It returns the
132144
// modified HelmRepository.
133145
func HelmRepositoryNotReady(repository HelmRepository, reason, message string) HelmRepository {
134-
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
146+
newCondition := metav1.Condition{
147+
Type: meta.ReadyCondition,
148+
Status: metav1.ConditionFalse,
149+
Reason: reason,
150+
Message: message,
151+
}
152+
apimeta.SetStatusCondition(repository.GetStatusConditions(), newCondition)
135153
return repository
136154
}
137155

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/artifact_types.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
Copyright 2022 The Flux authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta2
18+
19+
import (
20+
"path"
21+
"strings"
22+
23+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24+
)
25+
26+
// Artifact represents the output of a Source synchronisation.
27+
type Artifact struct {
28+
// Path is the relative file path of this Artifact.
29+
// It can be used to locate the Artifact file in the root of the Artifact
30+
// storage on the local file system of the controller managing the Source.
31+
// +required
32+
Path string `json:"path"`
33+
34+
// URL is the HTTP address of this artifact.
35+
// It is used by the consumers of the artifacts to fetch and use the
36+
// artifacts. It is expected to be resolvable from within the cluster.
37+
// +required
38+
URL string `json:"url"`
39+
40+
// Revision is a human readable identifier traceable in the origin source
41+
// system. It can be a Git commit SHA, Git tag, a Helm index timestamp, a Helm
42+
// chart version, etc.
43+
// +optional
44+
Revision string `json:"revision"`
45+
46+
// Checksum is the SHA256 checksum of the artifact.
47+
// +optional
48+
Checksum string `json:"checksum"`
49+
50+
// LastUpdateTime is the timestamp corresponding to the last update of this
51+
// artifact.
52+
// +required
53+
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
54+
}
55+
56+
// HasRevision returns true if the given revision matches the current Revision
57+
// of the Artifact.
58+
func (in *Artifact) HasRevision(revision string) bool {
59+
if in == nil {
60+
return false
61+
}
62+
return in.Revision == revision
63+
}
64+
65+
// ArtifactDir returns the artifact dir path in the form of
66+
// <source-kind>/<source-namespace>/<source-name>.
67+
func ArtifactDir(kind, namespace, name string) string {
68+
kind = strings.ToLower(kind)
69+
return path.Join(kind, namespace, name)
70+
}
71+
72+
// ArtifactPath returns the artifact path in the form of
73+
// <source-kind>/<source-namespace>/<source-name>/<artifact-filename>.
74+
func ArtifactPath(kind, namespace, name, filename string) string {
75+
return path.Join(ArtifactDir(kind, namespace, name), filename)
76+
}

0 commit comments

Comments
 (0)