Skip to content

Commit b2da6f0

Browse files
committed
api: Remove deprecated Checksum from Artifact
Signed-off-by: Hidde Beydals <[email protected]>
1 parent 9c80a66 commit b2da6f0

20 files changed

+145
-306
lines changed

api/v1/artifact_types.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ type Artifact struct {
4343
// +optional
4444
Revision string `json:"revision"`
4545

46-
// Checksum is the SHA256 checksum of the Artifact file.
47-
// Deprecated: use Artifact.Digest instead.
48-
// +optional
49-
Checksum string `json:"checksum,omitempty"`
50-
5146
// Digest is the digest of the file in the form of '<algorithm>:<checksum>'.
5247
// +optional
5348
// +kubebuilder:validation:Pattern="^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$"
@@ -76,13 +71,13 @@ func (in *Artifact) HasRevision(revision string) bool {
7671
return TransformLegacyRevision(in.Revision) == TransformLegacyRevision(revision)
7772
}
7873

79-
// HasChecksum returns if the given checksum matches the current Checksum of
80-
// the Artifact.
81-
func (in *Artifact) HasChecksum(checksum string) bool {
74+
// HasDigest returns if the given digest matches the current Digest of the
75+
// Artifact.
76+
func (in *Artifact) HasDigest(digest string) bool {
8277
if in == nil {
8378
return false
8479
}
85-
return in.Checksum == checksum
80+
return in.Digest == digest
8681
}
8782

8883
// ArtifactDir returns the artifact dir path in the form of

config/crd/bases/source.toolkit.fluxcd.io_buckets.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,6 @@ spec:
376376
artifact:
377377
description: Artifact represents the last successful Bucket reconciliation.
378378
properties:
379-
checksum:
380-
description: 'Checksum is the SHA256 checksum of the Artifact
381-
file. Deprecated: use Artifact.Digest instead.'
382-
type: string
383379
digest:
384380
description: Digest is the digest of the file in the form of '<algorithm>:<checksum>'.
385381
pattern: ^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$

config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,6 @@ spec:
198198
description: Artifact represents the last successful GitRepository
199199
reconciliation.
200200
properties:
201-
checksum:
202-
description: 'Checksum is the SHA256 checksum of the Artifact
203-
file. Deprecated: use Artifact.Digest instead.'
204-
type: string
205201
digest:
206202
description: Digest is the digest of the file in the form of '<algorithm>:<checksum>'.
207203
pattern: ^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$
@@ -325,10 +321,6 @@ spec:
325321
items:
326322
description: Artifact represents the output of a Source reconciliation.
327323
properties:
328-
checksum:
329-
description: 'Checksum is the SHA256 checksum of the Artifact
330-
file. Deprecated: use Artifact.Digest instead.'
331-
type: string
332324
digest:
333325
description: Digest is the digest of the file in the form of
334326
'<algorithm>:<checksum>'.
@@ -973,10 +965,6 @@ spec:
973965
description: Artifact represents the last successful GitRepository
974966
reconciliation.
975967
properties:
976-
checksum:
977-
description: 'Checksum is the SHA256 checksum of the Artifact
978-
file. Deprecated: use Artifact.Digest instead.'
979-
type: string
980968
digest:
981969
description: Digest is the digest of the file in the form of '<algorithm>:<checksum>'.
982970
pattern: ^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$
@@ -1100,10 +1088,6 @@ spec:
11001088
items:
11011089
description: Artifact represents the output of a Source reconciliation.
11021090
properties:
1103-
checksum:
1104-
description: 'Checksum is the SHA256 checksum of the Artifact
1105-
file. Deprecated: use Artifact.Digest instead.'
1106-
type: string
11071091
digest:
11081092
description: Digest is the digest of the file in the form of
11091093
'<algorithm>:<checksum>'.

config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,6 @@ spec:
451451
description: Artifact represents the output of the last successful
452452
reconciliation.
453453
properties:
454-
checksum:
455-
description: 'Checksum is the SHA256 checksum of the Artifact
456-
file. Deprecated: use Artifact.Digest instead.'
457-
type: string
458454
digest:
459455
description: Digest is the digest of the file in the form of '<algorithm>:<checksum>'.
460456
pattern: ^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$

config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,6 @@ spec:
368368
description: Artifact represents the last successful HelmRepository
369369
reconciliation.
370370
properties:
371-
checksum:
372-
description: 'Checksum is the SHA256 checksum of the Artifact
373-
file. Deprecated: use Artifact.Digest instead.'
374-
type: string
375371
digest:
376372
description: Digest is the digest of the file in the form of '<algorithm>:<checksum>'.
377373
pattern: ^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$

config/crd/bases/source.toolkit.fluxcd.io_ocirepositories.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,6 @@ spec:
194194
description: Artifact represents the output of the last successful
195195
OCI Repository sync.
196196
properties:
197-
checksum:
198-
description: 'Checksum is the SHA256 checksum of the Artifact
199-
file. Deprecated: use Artifact.Digest instead.'
200-
type: string
201197
digest:
202198
description: Digest is the digest of the file in the form of '<algorithm>:<checksum>'.
203199
pattern: ^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$

controllers/artifact_matchers_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ func (m matchArtifact) Match(actual interface{}) (success bool, err error) {
5151
if ok, err = Equal(m.expected.Revision).Match(actualArtifact.Revision); !ok {
5252
return ok, err
5353
}
54-
if ok, err = Equal(m.expected.Checksum).Match(actualArtifact.Checksum); !ok {
55-
return ok, err
56-
}
5754
if ok, err = Equal(m.expected.Size).Match(actualArtifact.Size); !ok {
5855
return ok, err
5956
}

controllers/bucket_controller.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -329,21 +329,13 @@ func (r *BucketReconciler) notify(ctx context.Context, oldObj, newObj *bucketv1.
329329
if resErr == nil && res == sreconcile.ResultSuccess && newObj.Status.Artifact != nil {
330330
annotations := map[string]string{
331331
fmt.Sprintf("%s/%s", sourcev1.GroupVersion.Group, eventv1.MetaRevisionKey): newObj.Status.Artifact.Revision,
332-
fmt.Sprintf("%s/%s", sourcev1.GroupVersion.Group, eventv1.MetaChecksumKey): newObj.Status.Artifact.Checksum,
333-
}
334-
if newObj.Status.Artifact.Digest != "" {
335-
annotations[sourcev1.GroupVersion.Group+"/"+eventv1.MetaDigestKey] = newObj.Status.Artifact.Digest
336-
}
337-
338-
var oldChecksum string
339-
if oldObj.GetArtifact() != nil {
340-
oldChecksum = oldObj.GetArtifact().Checksum
332+
fmt.Sprintf("%s/%s", sourcev1.GroupVersion.Group, eventv1.MetaDigestKey): newObj.Status.Artifact.Digest,
341333
}
342334

343335
message := fmt.Sprintf("stored artifact with %d fetched files from '%s' bucket", index.Len(), newObj.Spec.BucketName)
344336

345337
// Notify on new artifact and failure recovery.
346-
if oldChecksum != newObj.GetArtifact().Checksum {
338+
if !oldObj.GetArtifact().HasDigest(newObj.GetArtifact().Digest) {
347339
r.AnnotatedEventf(newObj, annotations, corev1.EventTypeNormal,
348340
"NewArtifact", message)
349341
ctrl.LoggerFrom(ctx).Info(message)

controllers/bucket_controller_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func TestBucketReconciler_reconcileStorage(t *testing.T) {
194194
assertArtifact: &sourcev1.Artifact{
195195
Path: "/reconcile-storage/d.txt",
196196
Revision: "d",
197-
Checksum: "18ac3e7343f016890c510e93f935261169d9e3f565436429830faf0934f4f8e4",
197+
Digest: "sha256:18ac3e7343f016890c510e93f935261169d9e3f565436429830faf0934f4f8e4",
198198
URL: testStorage.Hostname + "/reconcile-storage/d.txt",
199199
Size: int64p(int64(len("d"))),
200200
},
@@ -242,7 +242,7 @@ func TestBucketReconciler_reconcileStorage(t *testing.T) {
242242
obj.Status.Artifact = &sourcev1.Artifact{
243243
Path: fmt.Sprintf("/reconcile-storage/hostname.txt"),
244244
Revision: "f",
245-
Checksum: "3b9c358f36f0a31b6ad3e14f309c7cf198ac9246e8316f9ce543d5b19ac02b80",
245+
Digest: "sha256:3b9c358f36f0a31b6ad3e14f309c7cf198ac9246e8316f9ce543d5b19ac02b80",
246246
URL: "http://outdated.com/reconcile-storage/hostname.txt",
247247
}
248248
if err := testStorage.MkdirAll(*obj.Status.Artifact); err != nil {
@@ -261,7 +261,7 @@ func TestBucketReconciler_reconcileStorage(t *testing.T) {
261261
assertArtifact: &sourcev1.Artifact{
262262
Path: "/reconcile-storage/hostname.txt",
263263
Revision: "f",
264-
Checksum: "3b9c358f36f0a31b6ad3e14f309c7cf198ac9246e8316f9ce543d5b19ac02b80",
264+
Digest: "sha256:3b9c358f36f0a31b6ad3e14f309c7cf198ac9246e8316f9ce543d5b19ac02b80",
265265
URL: testStorage.Hostname + "/reconcile-storage/hostname.txt",
266266
Size: int64p(int64(len("file"))),
267267
},
@@ -1293,7 +1293,7 @@ func TestBucketReconciler_notify(t *testing.T) {
12931293
res: sreconcile.ResultSuccess,
12941294
resErr: nil,
12951295
newObjBeforeFunc: func(obj *bucketv1.Bucket) {
1296-
obj.Status.Artifact = &sourcev1.Artifact{Revision: "xxx", Checksum: "yyy"}
1296+
obj.Status.Artifact = &sourcev1.Artifact{Revision: "xxx", Digest: "yyy"}
12971297
},
12981298
wantEvent: "Normal NewArtifact stored artifact with 2 fetched files from",
12991299
},
@@ -1302,12 +1302,12 @@ func TestBucketReconciler_notify(t *testing.T) {
13021302
res: sreconcile.ResultSuccess,
13031303
resErr: nil,
13041304
oldObjBeforeFunc: func(obj *bucketv1.Bucket) {
1305-
obj.Status.Artifact = &sourcev1.Artifact{Revision: "xxx", Checksum: "yyy"}
1305+
obj.Status.Artifact = &sourcev1.Artifact{Revision: "xxx", Digest: "yyy"}
13061306
conditions.MarkTrue(obj, sourcev1.FetchFailedCondition, sourcev1.GitOperationFailedReason, "fail")
13071307
conditions.MarkFalse(obj, meta.ReadyCondition, meta.FailedReason, "foo")
13081308
},
13091309
newObjBeforeFunc: func(obj *bucketv1.Bucket) {
1310-
obj.Status.Artifact = &sourcev1.Artifact{Revision: "xxx", Checksum: "yyy"}
1310+
obj.Status.Artifact = &sourcev1.Artifact{Revision: "xxx", Digest: "yyy"}
13111311
conditions.MarkTrue(obj, meta.ReadyCondition, meta.SucceededReason, "ready")
13121312
},
13131313
wantEvent: "Normal Succeeded stored artifact with 2 fetched files from",
@@ -1317,12 +1317,12 @@ func TestBucketReconciler_notify(t *testing.T) {
13171317
res: sreconcile.ResultSuccess,
13181318
resErr: nil,
13191319
oldObjBeforeFunc: func(obj *bucketv1.Bucket) {
1320-
obj.Status.Artifact = &sourcev1.Artifact{Revision: "xxx", Checksum: "yyy"}
1320+
obj.Status.Artifact = &sourcev1.Artifact{Revision: "xxx", Digest: "yyy"}
13211321
conditions.MarkTrue(obj, sourcev1.FetchFailedCondition, sourcev1.GitOperationFailedReason, "fail")
13221322
conditions.MarkFalse(obj, meta.ReadyCondition, meta.FailedReason, "foo")
13231323
},
13241324
newObjBeforeFunc: func(obj *bucketv1.Bucket) {
1325-
obj.Status.Artifact = &sourcev1.Artifact{Revision: "aaa", Checksum: "bbb"}
1325+
obj.Status.Artifact = &sourcev1.Artifact{Revision: "aaa", Digest: "bbb"}
13261326
conditions.MarkTrue(obj, meta.ReadyCondition, meta.SucceededReason, "ready")
13271327
},
13281328
wantEvent: "Normal NewArtifact stored artifact with 2 fetched files from",
@@ -1332,11 +1332,11 @@ func TestBucketReconciler_notify(t *testing.T) {
13321332
res: sreconcile.ResultSuccess,
13331333
resErr: nil,
13341334
oldObjBeforeFunc: func(obj *bucketv1.Bucket) {
1335-
obj.Status.Artifact = &sourcev1.Artifact{Revision: "xxx", Checksum: "yyy"}
1335+
obj.Status.Artifact = &sourcev1.Artifact{Revision: "xxx", Digest: "yyy"}
13361336
conditions.MarkTrue(obj, meta.ReadyCondition, meta.SucceededReason, "ready")
13371337
},
13381338
newObjBeforeFunc: func(obj *bucketv1.Bucket) {
1339-
obj.Status.Artifact = &sourcev1.Artifact{Revision: "xxx", Checksum: "yyy"}
1339+
obj.Status.Artifact = &sourcev1.Artifact{Revision: "xxx", Digest: "yyy"}
13401340
conditions.MarkTrue(obj, meta.ReadyCondition, meta.SucceededReason, "ready")
13411341
},
13421342
},

controllers/gitrepository_controller.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,7 @@ func (r *GitRepositoryReconciler) notify(ctx context.Context, oldObj, newObj *so
325325
if r.shouldNotify(oldObj, newObj, res, resErr) {
326326
annotations := map[string]string{
327327
fmt.Sprintf("%s/%s", sourcev1.GroupVersion.Group, eventv1.MetaRevisionKey): newObj.Status.Artifact.Revision,
328-
fmt.Sprintf("%s/%s", sourcev1.GroupVersion.Group, eventv1.MetaChecksumKey): newObj.Status.Artifact.Checksum,
329-
}
330-
if newObj.Status.Artifact.Digest != "" {
331-
annotations[sourcev1.GroupVersion.Group+"/"+eventv1.MetaDigestKey] = newObj.Status.Artifact.Digest
332-
}
333-
334-
var oldChecksum string
335-
if oldObj.GetArtifact() != nil {
336-
oldChecksum = oldObj.GetArtifact().Checksum
328+
fmt.Sprintf("%s/%s", sourcev1.GroupVersion.Group, eventv1.MetaDigestKey): newObj.Status.Artifact.Digest,
337329
}
338330

339331
// A partial commit due to no-op clone doesn't contain the commit
@@ -346,7 +338,7 @@ func (r *GitRepositoryReconciler) notify(ctx context.Context, oldObj, newObj *so
346338
}
347339

348340
// Notify on new artifact and failure recovery.
349-
if oldChecksum != newObj.GetArtifact().Checksum {
341+
if !oldObj.GetArtifact().HasDigest(newObj.GetArtifact().Digest) {
350342
r.AnnotatedEventf(newObj, annotations, corev1.EventTypeNormal,
351343
"NewArtifact", message)
352344
ctrl.LoggerFrom(ctx).Info(message)
@@ -1019,7 +1011,7 @@ func gitContentConfigChanged(obj *sourcev1.GitRepository, includes *artifactSet)
10191011
observedInclArtifact := obj.Status.IncludedArtifacts[index]
10201012
currentIncl := artifacts[index]
10211013

1022-
// Check if the include are the same in spec and status.
1014+
// Check if include is the same in spec and status.
10231015
if !gitRepositoryIncludeEqual(incl, observedIncl) {
10241016
return true
10251017
}
@@ -1028,7 +1020,7 @@ func gitContentConfigChanged(obj *sourcev1.GitRepository, includes *artifactSet)
10281020
if !observedInclArtifact.HasRevision(currentIncl.Revision) {
10291021
return true
10301022
}
1031-
if observedInclArtifact.Checksum != currentIncl.Checksum {
1023+
if !observedInclArtifact.HasDigest(currentIncl.Digest) {
10321024
return true
10331025
}
10341026
}

0 commit comments

Comments
 (0)