Skip to content

Commit

Permalink
Handle null pointer (#2)
Browse files Browse the repository at this point in the history
Signed-off-by: Rokibul Hasan <[email protected]>
  • Loading branch information
RokibulHasan7 authored Oct 8, 2024
1 parent 26005dc commit 1231b99
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
5 changes: 3 additions & 2 deletions pkg/feature_installer/helmrelease_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
cu "kmodules.xyz/client-go/client"
uiapi "kmodules.xyz/resource-metadata/apis/ui/v1alpha1"
"kmodules.xyz/resource-metadata/hub"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand All @@ -50,8 +51,8 @@ func createHR(featureName, featureSetName, ns string, profile *profilev1alpha1.M
Version: profile.Spec.Features[featureName].Chart.Version,
SourceRef: fluxhelm.CrossNamespaceObjectReference{
Kind: profile.Spec.Features[featureName].Chart.SourceRef.Kind,
Name: profile.Spec.Features[featureName].Chart.SourceRef.Name,
Namespace: profile.Spec.Features[featureName].Chart.SourceRef.Namespace,
Name: hub.BootstrapHelmRepositoryName(),
Namespace: hub.BootstrapHelmRepositoryNamespace(),
},
},
},
Expand Down
24 changes: 13 additions & 11 deletions pkg/feature_installer/opscenter_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,21 @@ func InitializeServer(fakeServer *FakeServer, profile *profilev1alpha1.ManagedCl
return nil, err
}

if clusterMetadata.CAPI.Provider != "" {
if err := unstructured.SetNestedField(overrides, clusterMetadata.CAPI.Provider, "clusterMetadata", "capi", "provider"); err != nil {
return nil, err
if clusterMetadata.CAPI != nil {
if clusterMetadata.CAPI.Provider != "" {
if err := unstructured.SetNestedField(overrides, clusterMetadata.CAPI.Provider, "clusterMetadata", "capi", "provider"); err != nil {
return nil, err
}
}
}
if clusterMetadata.CAPI.Namespace != "" {
if err := unstructured.SetNestedField(overrides, clusterMetadata.CAPI.Namespace, "clusterMetadata", "capi", "namespace"); err != nil {
return nil, err
if clusterMetadata.CAPI.Namespace != "" {
if err := unstructured.SetNestedField(overrides, clusterMetadata.CAPI.Namespace, "clusterMetadata", "capi", "namespace"); err != nil {
return nil, err
}
}
}
if clusterMetadata.CAPI.ClusterName != "" {
if err := unstructured.SetNestedField(overrides, clusterMetadata.CAPI.Namespace, "clusterMetadata", "capi", "clusterName"); err != nil {
return nil, err
if clusterMetadata.CAPI.ClusterName != "" {
if err := unstructured.SetNestedField(overrides, clusterMetadata.CAPI.Namespace, "clusterMetadata", "capi", "clusterName"); err != nil {
return nil, err
}
}
}
if len(clusterMetadata.ClusterManagers) > 0 {
Expand Down

0 comments on commit 1231b99

Please sign in to comment.