Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ktong committed Feb 10, 2024
1 parent 23d42a3 commit a26673f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
14 changes: 6 additions & 8 deletions provider/appconfig/appconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (a *AppConfig) Watch(ctx context.Context, onChange func(map[string]any)) er
for {
select {
case <-ticker.C:
out, err := a.load(ctx)
values, err := a.load(ctx)
if err != nil {
a.logger.WarnContext(
ctx, "Error when reloading from AWS AppConfig",
Expand All @@ -120,8 +120,8 @@ func (a *AppConfig) Watch(ctx context.Context, onChange func(map[string]any)) er
continue
}

if out != nil {
onChange(out)
if values != nil {
onChange(values)
}
case <-ctx.Done():
return nil
Expand Down Expand Up @@ -208,16 +208,14 @@ func (c *clientProxy) loadClient(ctx context.Context) (*appconfigdata.Client, er
c.clientOnce.Do(func() {
if reflect.ValueOf(c.config).IsZero() {
if c.config, err = config.LoadDefaultConfig(ctx); err != nil {
err = fmt.Errorf("load default AWS config: %w", err)

Check warning on line 211 in provider/appconfig/appconfig.go

View check run for this annotation

Codecov / codecov/patch

provider/appconfig/appconfig.go#L211

Added line #L211 was not covered by tests

return
}
}

c.client = appconfigdata.NewFromConfig(c.config)
})

if err != nil {
return nil, fmt.Errorf("load client: %w", err)
}

return c.client, nil
return c.client, err
}
2 changes: 1 addition & 1 deletion provider/flag/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func WithDelimiter(delimiter string) Option {
}
}

// WithNameSplitter provides the function used to split environment variable names into nested keys.
// WithNameSplitter provides the function used to split flag names into nested keys.
// If it returns an nil/[]string{}/[]string{""}, the variable will be ignored.
//
// For example, with the default splitter, an flag name like "parent.child.key"
Expand Down
2 changes: 1 addition & 1 deletion provider/pflag/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func WithDelimiter(delimiter string) Option {
}
}

// WithNameSplitter provides the function used to split environment variable names into nested keys.
// WithNameSplitter provides the function used to split flag names into nested keys.
// If it returns an nil/[]string{}/[]string{""}, the variable will be ignored.
//
// For example, with the default splitter, an flag name like "parent.child.key"
Expand Down

0 comments on commit a26673f

Please sign in to comment.