From ad43749d4473420a1f01aaf14d4ce63228ca6f22 Mon Sep 17 00:00:00 2001 From: Rokibul Hasan Date: Sat, 26 Oct 2024 08:49:29 +0600 Subject: [PATCH] Fix panic issue Signed-off-by: Rokibul Hasan --- pkg/cmd/get/hubinfo/exec.go | 5 +++-- pkg/helpers/check/check.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/get/hubinfo/exec.go b/pkg/cmd/get/hubinfo/exec.go index eab93388..a35f5b41 100644 --- a/pkg/cmd/get/hubinfo/exec.go +++ b/pkg/cmd/get/hubinfo/exec.go @@ -118,7 +118,8 @@ func (o *Options) printComponents() error { } o.printer.Write(printer.LEVEL_0, "Components:\n") - if check.IsFeatureEnabled(cmgr.Spec.AddOnManagerConfiguration.FeatureGates, string(feature.AddonManagement)) { + + if cmgr.Spec.AddOnManagerConfiguration != nil && check.IsFeatureEnabled(cmgr.Spec.AddOnManagerConfiguration.FeatureGates, string(feature.AddonManagement)) { if err := o.printAddOnManager(cmgr); err != nil { return err } @@ -150,7 +151,7 @@ func (o *Options) printRegistration(cmgr *v1.ClusterManager) error { func (o *Options) printWork(cmgr *v1.ClusterManager) error { o.printer.Write(printer.LEVEL_1, "Work:\n") - if check.IsFeatureEnabled(cmgr.Spec.WorkConfiguration.FeatureGates, string(feature.ManifestWorkReplicaSet)) { + if cmgr.Spec.WorkConfiguration != nil && check.IsFeatureEnabled(cmgr.Spec.WorkConfiguration.FeatureGates, string(feature.ManifestWorkReplicaSet)) { err := printer.PrintComponentsDeploy(o.printer, o.kubeClient, cmgr.Status.RelatedResources, componentNameWorkController) if err != nil { return err diff --git a/pkg/helpers/check/check.go b/pkg/helpers/check/check.go index ae2935d2..d241999a 100644 --- a/pkg/helpers/check/check.go +++ b/pkg/helpers/check/check.go @@ -81,7 +81,7 @@ func findResource(list *metav1.APIResourceList, resourceName string) bool { func IsFeatureEnabled(featureGates []operatorv1.FeatureGate, feature string) bool { for _, fg := range featureGates { - if fg.Feature == feature { + if fg.Feature == feature && fg.Mode == operatorv1.FeatureGateModeTypeEnable { return true } }