Skip to content

Commit

Permalink
get plugin service from cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
airycanon committed Dec 1, 2023
1 parent 90be1ef commit f200a14
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions testing/framework/cluster/service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cluster

import (
"context"
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

func Service(ctx context.Context, clt client.Client, name string) (*corev1.Service, error) {
services := &corev1.ServiceList{}

if err := clt.List(ctx, services, client.MatchingLabels{"plugin": name}); err != nil {
return nil, err
}

if len(services.Items) > 0 {
return &services.Items[0], nil
}
return nil, nil
}

0 comments on commit f200a14

Please sign in to comment.