-
Notifications
You must be signed in to change notification settings - Fork 4
/
client_providers.go
46 lines (35 loc) · 1.27 KB
/
client_providers.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Code generated by skv2. DO NOT EDIT.
package v1
import (
batch_v1 "github.com/solo-io/external-apis/pkg/api/k8s/batch/v1"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
)
/*
The intention of these providers are to be used for Mocking.
They expose the Clients as interfaces, as well as factories to provide mocked versions
of the clients when they require building within a component.
See package `github.com/solo-io/skv2/pkg/multicluster/register` for example
*/
// Provider for JobClient from Clientset
func JobClientFromClientsetProvider(clients batch_v1.Clientset) batch_v1.JobClient {
return clients.Jobs()
}
// Provider for Job Client from Client
func JobClientProvider(client client.Client) batch_v1.JobClient {
return batch_v1.NewJobClient(client)
}
type JobClientFactory func(client client.Client) batch_v1.JobClient
func JobClientFactoryProvider() JobClientFactory {
return JobClientProvider
}
type JobClientFromConfigFactory func(cfg *rest.Config) (batch_v1.JobClient, error)
func JobClientFromConfigFactoryProvider() JobClientFromConfigFactory {
return func(cfg *rest.Config) (batch_v1.JobClient, error) {
clients, err := batch_v1.NewClientsetFromConfig(cfg)
if err != nil {
return nil, err
}
return clients.Jobs(), nil
}
}