/
types.go
40 lines (33 loc) · 1.03 KB
/
types.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
package handle
import (
"log"
"github.com/ez-deploy/apiserver/handle/internal/authority"
"github.com/ez-deploy/apiserver/handle/internal/configurable"
"github.com/ez-deploy/apiserver/handle/internal/identity"
"github.com/ez-deploy/apiserver/handle/internal/project"
)
const configFilename = "apiserver.conf.yaml"
type handlerImpl struct {
*configurable.ConfigurableImpl
*authority.AuthorityOpsImpl
*identity.AuthableImpl
*identity.IdentityOpsImpl
*project.ProjectOpsImpl
}
func New() *handlerImpl {
cfg, err := getConfigFromFile(configFilename)
if err != nil {
log.Fatal(err)
}
clientset, err := createGRPCClientsFromConfig(cfg)
if err != nil {
log.Fatal(err)
}
return &handlerImpl{
ConfigurableImpl: &configurable.ConfigurableImpl{},
AuthableImpl: identity.NewAuthableImpl(clientset.identityClient),
IdentityOpsImpl: identity.NewIdentityOpsImpl(clientset.identityClient),
AuthorityOpsImpl: &authority.AuthorityOpsImpl{},
ProjectOpsImpl: project.New(clientset.authorityClient, clientset.projectClient),
}
}