-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
39 lines (30 loc) · 1003 Bytes
/
config.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
package grpc
import (
"context"
"github.com/alexfalkowski/go-service/meta"
v1 "github.com/alexfalkowski/konfig/api/konfig/v1"
"github.com/alexfalkowski/konfig/server/config"
)
// GetConfig for gRPC.
func (s *Server) GetConfig(ctx context.Context, req *v1.GetConfigRequest) (*v1.GetConfigResponse, error) {
resp := &v1.GetConfigResponse{}
cfg, err := config.NewConfig(req.GetApplication(), req.GetVersion(),
req.GetEnvironment(), req.GetContinent(), req.GetCountry(),
req.GetCommand(), req.GetKind())
if err != nil {
return resp, s.error(err)
}
resp.Config = &v1.Config{
Application: cfg.Application(), Version: cfg.Version(),
Environment: cfg.Environment(), Continent: cfg.Continent(), Country: cfg.Country(),
Command: cfg.Command(), Kind: cfg.Kind(),
}
data, err := s.service.GetConfig(ctx, cfg)
if err != nil {
resp.Meta = meta.CamelStrings(ctx, "")
return resp, s.error(err)
}
resp.Config.Data = data
resp.Meta = meta.CamelStrings(ctx, "")
return resp, nil
}