Skip to content

Commit

Permalink
fix config aggregator cache (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreZiviani authored Mar 14, 2022
1 parent 5e6ae1c commit 4fb335e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ func Print(pager bool, slices []string) error {
func Config(ctx context.Context, p *ConfigCommand, subservice string) ([]string, error) {
span, ctx := opentracing.StartSpanFromContext(ctx, "config")

cacheKey := fmt.Sprintf("%s-aggregators", p.Profile)

creds, err := sso.GetCredentials(ctx, p.Profile, false)
if err != nil {
return nil, err
Expand All @@ -59,7 +61,7 @@ func Config(ctx context.Context, p *ConfigCommand, subservice string) ([]string,

// Check if we have a cached result of available aggregators
c, _ := cache.New("config")
j, err := c.Fetch(p.Profile)
j, err := c.Fetch(cacheKey)

aggregators := []configtypes.ConfigurationAggregator{}
if err == nil {
Expand All @@ -83,7 +85,7 @@ func Config(ctx context.Context, p *ConfigCommand, subservice string) ([]string,
}

tmpj, _ := json.Marshal(aggregators)
c.Save(p.Profile, string(tmpj), time.Duration(10)*time.Minute)
c.Save(cacheKey, string(tmpj), time.Duration(10)*time.Minute)

spanGetAggregators.Finish()
}
Expand Down

0 comments on commit 4fb335e

Please sign in to comment.