Skip to content

Commit

Permalink
Fix pointer might be nil error
Browse files Browse the repository at this point in the history
Signed-off-by: kerthcet <kerthcet@gmail.com>
  • Loading branch information
kerthcet committed Feb 17, 2025
1 parent 162d591 commit 5a50b00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/controller/modeladapter/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ func buildModelAdapterEndpointSlice(instance *modelv1alpha1.ModelAdapter, pod *c

func buildModelAdapterService(instance *modelv1alpha1.ModelAdapter) *corev1.Service {
labels := map[string]string{
"model.aibrix.ai/name": instance.Spec.BaseModel,
"adapter.model.aibrix.ai/name": instance.Name,
}
if instance.Spec.BaseModel != nil {
labels["model.aibrix.ai/name"] = *instance.Spec.BaseModel
}

ports := []corev1.ServicePort{
{
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/modeladapter/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/ptr"
)

func TestBuildModelAdapterEndpointSlice(t *testing.T) {
Expand Down Expand Up @@ -75,7 +76,7 @@ func TestBuildModelAdapterService(t *testing.T) {
Namespace: "default",
},
Spec: modelv1alpha1.ModelAdapterSpec{
BaseModel: "test-model",
BaseModel: ptr.To[string]("test-model"),
},
}

Expand Down

0 comments on commit 5a50b00

Please sign in to comment.