Skip to content

Commit 168fdfe

Browse files
authored
refactor: migrate use of deprecated HelmRelease .status.lastReleaseRevision (#4374)
1 parent ea33d9f commit 168fdfe

File tree

3 files changed

+40
-24
lines changed

3 files changed

+40
-24
lines changed

core/server/inventory.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -489,13 +489,6 @@ func secretNameFromHelmRelease(helmRelease *helmv2.HelmRelease) *client.ObjectKe
489489
}
490490
}
491491

492-
if latestRevision := helmRelease.Status.LastReleaseRevision; latestRevision > 0 {
493-
return &client.ObjectKey{
494-
Name: fmt.Sprintf(helmSecretNameFmt, helmRelease.GetReleaseName(), latestRevision),
495-
Namespace: helmRelease.GetStorageNamespace(),
496-
}
497-
}
498-
499492
return nil
500493
}
501494

@@ -504,9 +497,5 @@ func defaultNSFromHelmRelease(helmRelease *helmv2.HelmRelease) string {
504497
return latest.Namespace
505498
}
506499

507-
if latestRevision := helmRelease.Status.LastReleaseRevision; latestRevision > 0 {
508-
return helmRelease.GetReleaseNamespace()
509-
}
510-
511500
return ""
512501
}

core/server/inventory_test.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,11 @@ func TestGetInventoryHelmRelease(t *testing.T) {
230230
},
231231
Spec: helmv2.HelmReleaseSpec{},
232232
Status: helmv2.HelmReleaseStatus{
233-
LastReleaseRevision: 1,
233+
History: helmv2.Snapshots{{
234+
Name: "first-helm-name",
235+
Version: 1,
236+
Namespace: ns.Name,
237+
}},
234238
},
235239
}
236240

@@ -307,8 +311,7 @@ func TestGetInventoryHelmReleaseNoNSResources(t *testing.T) {
307311
TargetNamespace: "test-ns",
308312
},
309313
Status: helmv2.HelmReleaseStatus{
310-
StorageNamespace: ns.Name,
311-
LastReleaseRevision: 0,
314+
StorageNamespace: ns.Name,
312315
History: helmv2.Snapshots{
313316
{
314317
Name: "first-helm-name",
@@ -401,7 +404,11 @@ func TestGetInventoryHelmReleaseWithKubeconfig(t *testing.T) {
401404
},
402405
},
403406
Status: helmv2.HelmReleaseStatus{
404-
LastReleaseRevision: 1,
407+
History: helmv2.Snapshots{{
408+
Name: "first-helm-name",
409+
Version: 1,
410+
Namespace: ns.Name,
411+
}},
405412
},
406413
}
407414

core/server/objects_test.go

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,11 @@ func TestGetObject_HelmReleaseWithInventory(t *testing.T) {
169169
},
170170
Spec: helmv2.HelmReleaseSpec{},
171171
Status: helmv2.HelmReleaseStatus{
172-
LastReleaseRevision: 1,
172+
History: helmv2.Snapshots{{
173+
Name: "first-helm-name",
174+
Version: 1,
175+
Namespace: ns.Name,
176+
}},
173177
},
174178
}
175179
// Create helm storage.
@@ -248,7 +252,11 @@ func TestGetObject_HelmReleaseWithCompressedInventory(t *testing.T) {
248252
},
249253
Spec: helmv2.HelmReleaseSpec{},
250254
Status: helmv2.HelmReleaseStatus{
251-
LastReleaseRevision: 1,
255+
History: helmv2.Snapshots{{
256+
Name: "first-helm-name",
257+
Version: 1,
258+
Namespace: ns.Name,
259+
}},
252260
},
253261
}
254262
// Create helm storage.
@@ -310,7 +318,11 @@ func TestGetObject_HelmReleaseCantGetSecret(t *testing.T) {
310318
},
311319
Spec: helmv2.HelmReleaseSpec{},
312320
Status: helmv2.HelmReleaseStatus{
313-
LastReleaseRevision: 1,
321+
History: helmv2.Snapshots{{
322+
Name: "first-helm-name",
323+
Version: 1,
324+
Namespace: ns.Name,
325+
}},
314326
},
315327
}
316328
secret := &corev1.Secret{
@@ -588,7 +600,11 @@ func TestListObject_HelmReleaseWithInventory(t *testing.T) {
588600
},
589601
Spec: helmv2.HelmReleaseSpec{},
590602
Status: helmv2.HelmReleaseStatus{
591-
LastReleaseRevision: 1,
603+
History: helmv2.Snapshots{{
604+
Name: "first-helm-name",
605+
Version: 1,
606+
Namespace: ns.Name,
607+
}},
592608
},
593609
}
594610
// Create helm storage.
@@ -643,12 +659,12 @@ func TestListObject_HelmReleaseWithInventoryHistory(t *testing.T) {
643659
},
644660
Spec: helmv2.HelmReleaseSpec{},
645661
Status: helmv2.HelmReleaseStatus{
646-
StorageNamespace: ns.Name,
647-
LastReleaseRevision: 0,
662+
StorageNamespace: ns.Name,
648663
History: helmv2.Snapshots{
649664
{
650-
Name: "first-helm-name",
651-
Version: 1,
665+
Name: "first-helm-name",
666+
Version: 1,
667+
Namespace: ns.Name,
652668
},
653669
},
654670
},
@@ -705,7 +721,11 @@ func TestListObject_HelmReleaseCantGetSecret(t *testing.T) {
705721
},
706722
Spec: helmv2.HelmReleaseSpec{},
707723
Status: helmv2.HelmReleaseStatus{
708-
LastReleaseRevision: 1,
724+
History: helmv2.Snapshots{{
725+
Name: "first-helm-name",
726+
Version: 1,
727+
Namespace: ns.Name,
728+
}},
709729
},
710730
}
711731
secret := &corev1.Secret{

0 commit comments

Comments
 (0)