update golangci
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing

This commit is contained in:
2023-06-04 18:51:00 +03:00
parent e1dfdc28ff
commit 9f7cf38e93
21 changed files with 144 additions and 113 deletions

View File

@@ -44,16 +44,16 @@ func (p *Provider) Name() string {
}
func (p *Provider) Read(ctx context.Context, key config.Key) (config.Variable, error) {
k := p.key(ctx, key)
name := p.key(ctx, key)
resp, err := p.client.Get(ctx, k, client.WithPrefix())
resp, err := p.client.Get(ctx, name, client.WithPrefix())
if err != nil {
return config.Variable{}, fmt.Errorf("%w: key:%s, prov:%s", err, k, p.Name())
return config.Variable{}, fmt.Errorf("%w: key:%s, prov:%s", err, name, p.Name())
}
val, err := p.resolve(k, resp.Kvs)
val, err := p.resolve(name, resp.Kvs)
if err != nil {
return config.Variable{}, fmt.Errorf("%w: key:%s, prov:%s", err, k, p.Name())
return config.Variable{}, fmt.Errorf("%w: key:%s, prov:%s", err, name, p.Name())
}
return val, nil
@@ -89,13 +89,7 @@ func (p *Provider) getEventKvs(events []*client.Event) ([]*pb.KeyValue, []*pb.Ke
func (p *Provider) resolve(key string, kvs []*pb.KeyValue) (config.Variable, error) {
for _, kv := range kvs {
switch {
case kv == nil:
return config.Variable{
Name: key,
Provider: p.Name(),
}, nil
case string(kv.Key) == key:
if kv != nil && string(kv.Key) == key {
return config.Variable{
Value: value.JBytes(kv.Value),
Name: key,
@@ -104,8 +98,5 @@ func (p *Provider) resolve(key string, kvs []*pb.KeyValue) (config.Variable, err
}
}
return config.Variable{
Name: key,
Provider: p.Name(),
}, config.ErrVariableNotFound
return config.Variable{}, fmt.Errorf("%w: name %s", config.ErrVariableNotFound, key)
}