Skip to content

Commit

Permalink
fix npe
Browse files Browse the repository at this point in the history
  • Loading branch information
sophon-zt committed Dec 13, 2024
1 parent 31b322e commit 7846fb1
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions pkg/controller/configuration/resource_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"fmt"

corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand Down Expand Up @@ -81,15 +80,11 @@ func (r *ResourceFetcher[T]) ComponentAndComponentDef() *T {
}
return r.Wrap(func() error {
r.ComponentObj = &appsv1.Component{}
err := r.Client.Get(r.Context, componentKey, r.ComponentObj, inDataContext())
if apierrors.IsNotFound(err) {
return nil
} else if err != nil {
if err := r.Client.Get(r.Context, componentKey, r.ComponentObj, inDataContext()); err != nil {
return err
}

if len(r.ComponentObj.Spec.CompDef) == 0 {
return nil
return fmt.Errorf("componentDefinition not found in component: %s", r.ComponentObj.Name)
}

compDefKey := types.NamespacedName{
Expand Down

0 comments on commit 7846fb1

Please sign in to comment.