Skip to content

Commit 5959e3a

Browse files
authored
fix: GetInstalledDashboard should support nil Chart (#4236)
1 parent 379395c commit 5959e3a

File tree

2 files changed

+36
-42
lines changed

2 files changed

+36
-42
lines changed

pkg/run/install/install_dashboard.go

+3-9
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,9 @@ func GetInstalledDashboard(ctx context.Context, kubeClient client.Client, namesp
157157
dashboardName := ""
158158

159159
for _, helmRelease := range helmReleaseList.Items {
160-
chart := helmRelease.Spec.Chart
161-
162-
if shouldDetectEnterpriseDashboard && chart != nil && chart.Spec.Chart == enterpriseDashboardHelmChartName &&
163-
chart.Spec.SourceRef.Name == enterpriseDashboardHelmRepositoryName {
164-
return DashboardTypeEnterprise, helmRelease.Name, nil
165-
}
166-
167-
if shouldDetectOSSDashboard && chart == nil {
168-
return DashboardTypeOSS, dashboardName, nil
160+
// TODO(Flux 2.4 migration): We might want to also check the new ChartRef sibling field.
161+
if helmRelease.Spec.Chart == nil {
162+
continue
169163
}
170164

171165
chartSpec := helmRelease.Spec.Chart.Spec

pkg/run/install/install_dashboard_test.go

+33-33
Original file line numberDiff line numberDiff line change
@@ -194,51 +194,51 @@ var _ = Describe("InstallDashboard", func() {
194194

195195
var _ = Describe("GetInstalledDashboard", func() {
196196
var (
197-
fakeContext context.Context
198-
// fakeClientWithHelmReleases client.WithWatch
199-
fakeClientWithDeployments client.WithWatch
200-
blankClient client.WithWatch
201-
errorClient ErroringFakeClient
197+
fakeContext context.Context
198+
fakeClientWithHelmReleases client.WithWatch
199+
fakeClientWithDeployments client.WithWatch
200+
blankClient client.WithWatch
201+
errorClient ErroringFakeClient
202202
)
203203

204204
BeforeEach(func() {
205205
fakeContext = context.Background()
206206
scheme, err := kube.CreateScheme()
207207
Expect(err).NotTo(HaveOccurred())
208208

209-
// fakeClientWithHelmReleases = fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(helmReleaseFixtures...).Build()
209+
fakeClientWithHelmReleases = fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(helmReleaseFixtures...).Build()
210210
fakeClientWithDeployments = fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(deploymentFixtures...).Build()
211211
blankClient = fake.NewClientBuilder().WithScheme(scheme).Build()
212212
errorClient = ErroringFakeClient{}
213213
})
214214

215-
// It("returns the oss dashboard type if the dashboard is installed with a helmrelease", func() {
216-
// dashboardType, dashboardName, err := GetInstalledDashboard(fakeContext, fakeClientWithHelmReleases, testNamespace, map[DashboardType]bool{
217-
// DashboardTypeOSS: true,
218-
// })
219-
// Expect(err).ToNot(HaveOccurred())
220-
// Expect(dashboardType).To(Equal(DashboardTypeOSS))
221-
// Expect(dashboardName).To(Equal("dashboard-2"))
222-
// })
223-
//
224-
// It("returns the enterprise dashboard type if the dashboard is installed with a helmrelease", func() {
225-
// dashboardType, dashboardName, err := GetInstalledDashboard(fakeContext, fakeClientWithHelmReleases, testNamespace, map[DashboardType]bool{
226-
// DashboardTypeEnterprise: true,
227-
// })
228-
// Expect(err).ToNot(HaveOccurred())
229-
// Expect(dashboardType).To(Equal(DashboardTypeEnterprise))
230-
// Expect(dashboardName).To(Equal("dashboard-3"))
231-
// })
232-
//
233-
// It("returns the enterprise dashboard type if both dashboards are installed with a helmrelease", func() {
234-
// dashboardType, dashboardName, err := GetInstalledDashboard(fakeContext, fakeClientWithHelmReleases, testNamespace, map[DashboardType]bool{
235-
// DashboardTypeOSS: true,
236-
// DashboardTypeEnterprise: true,
237-
// })
238-
// Expect(err).ToNot(HaveOccurred())
239-
// Expect(dashboardType).To(Equal(DashboardTypeEnterprise))
240-
// Expect(dashboardName).To(Equal("dashboard-3"))
241-
// })
215+
It("returns the oss dashboard type if the dashboard is installed with a helmrelease", func() {
216+
dashboardType, dashboardName, err := GetInstalledDashboard(fakeContext, fakeClientWithHelmReleases, testNamespace, map[DashboardType]bool{
217+
DashboardTypeOSS: true,
218+
})
219+
Expect(err).ToNot(HaveOccurred())
220+
Expect(dashboardType).To(Equal(DashboardTypeOSS))
221+
Expect(dashboardName).To(Equal("dashboard-2"))
222+
})
223+
224+
It("returns the enterprise dashboard type if the dashboard is installed with a helmrelease", func() {
225+
dashboardType, dashboardName, err := GetInstalledDashboard(fakeContext, fakeClientWithHelmReleases, testNamespace, map[DashboardType]bool{
226+
DashboardTypeEnterprise: true,
227+
})
228+
Expect(err).ToNot(HaveOccurred())
229+
Expect(dashboardType).To(Equal(DashboardTypeEnterprise))
230+
Expect(dashboardName).To(Equal("dashboard-3"))
231+
})
232+
233+
It("returns the enterprise dashboard type if both dashboards are installed with a helmrelease", func() {
234+
dashboardType, dashboardName, err := GetInstalledDashboard(fakeContext, fakeClientWithHelmReleases, testNamespace, map[DashboardType]bool{
235+
DashboardTypeOSS: true,
236+
DashboardTypeEnterprise: true,
237+
})
238+
Expect(err).ToNot(HaveOccurred())
239+
Expect(dashboardType).To(Equal(DashboardTypeEnterprise))
240+
Expect(dashboardName).To(Equal("dashboard-3"))
241+
})
242242

243243
It("returns the oss dashboard type if the dashboard is installed with a deployment only", func() {
244244
dashboardType, dashboardName, err := GetInstalledDashboard(fakeContext, fakeClientWithDeployments, testNamespace, map[DashboardType]bool{

0 commit comments

Comments
 (0)