-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.go
39 lines (32 loc) · 867 Bytes
/
client.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 client
import (
"context"
v1 "github.com/alexfalkowski/konfig/api/konfig/v1"
v1c "github.com/alexfalkowski/konfig/client/v1/config"
)
// Client for konfig.
type Client struct {
client v1.ServiceClient
config *v1c.Config
}
// NewClient for konfig.
func NewClient(client v1.ServiceClient, config *v1c.Config) *Client {
return &Client{client: client, config: config}
}
// Config from client.
func (c *Client) Config(ctx context.Context) ([]byte, error) {
req := &v1.GetConfigRequest{
Application: c.config.Application,
Version: c.config.Version,
Environment: c.config.Environment,
Continent: c.config.Continent,
Country: c.config.Country,
Command: c.config.Command,
Kind: c.config.Kind,
}
resp, err := c.client.GetConfig(ctx, req)
if err != nil {
return nil, err
}
return resp.GetConfig().GetData(), nil
}