-
Notifications
You must be signed in to change notification settings - Fork 567
/
env.go
41 lines (36 loc) · 1.12 KB
/
env.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
package server
import (
"context"
"path"
etcd "go.etcd.io/etcd/client/v3"
"k8s.io/client-go/kubernetes"
"github.com/pachyderm/pachyderm/v2/src/internal/serviceenv"
"github.com/pachyderm/pachyderm/v2/src/internal/task"
)
// Env is the dependencies needed to run the pachW Controller
type Env struct {
EtcdPrefix string
EtcdClient *etcd.Client
TaskService task.Service
KubeClient kubernetes.Interface
Namespace string
MaxReplicas int
MinReplicas int
BackgroundContext context.Context
}
func EnvFromServiceEnv(env serviceenv.ServiceEnv) (*Env, error) {
etcdPrefix := path.Join(env.Config().EtcdPrefix, env.Config().PFSEtcdPrefix)
if env.AuthServer() == nil {
panic("auth server cannot be nil")
}
return &Env{
EtcdPrefix: etcdPrefix,
EtcdClient: env.GetEtcdClient(),
TaskService: env.GetTaskService(etcdPrefix),
KubeClient: env.GetKubeClient(),
Namespace: env.Config().Namespace,
MinReplicas: env.Config().PachwMinReplicas,
MaxReplicas: env.Config().PachwMaxReplicas,
BackgroundContext: env.Context(),
}, nil
}