-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathendpoints.go
31 lines (26 loc) · 919 Bytes
/
endpoints.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Package kubernetes provides access to the Kubernetes API
package kubernetes
import (
"fmt"
"k8s.io/client-go/pkg/api/v1"
)
// EndpointsController provides access to the kubernetes endpoints functions
type EndpointsController struct {
client Client
}
// NewEndpointsController stores our real or mocked kubernetes client object
func NewEndpointsController(client Client) *EndpointsController {
return &EndpointsController{
client: client,
}
}
// GetEndpoints is a wrapper function around the kubernetes client. If there is any manipulation or filtering
// of the kubernetes types or data, it should be done here.
func (e EndpointsController) GetEndpoints(service string, namespace string) (*v1.Endpoints, error) {
endpoints, err := e.client.GetEndpoints(service, namespace)
if err != nil {
err = fmt.Errorf("Could not get endpoints: %s", err)
return &v1.Endpoints{}, err
}
return endpoints, nil
}