Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## To Be Released

* fix(addons): parse `maintenance-window-hour` as an int
* feat(session): remove region cache on logout

## 1.44.1

Expand Down
9 changes: 9 additions & 0 deletions config/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,12 @@ func GetRegion(ctx context.Context, c Config, name string, opts GetRegionOpts) (
}
return scalingo.Region{}, UnknownRegionError{regionName: name}
}

func DeleteRegionsCache(ctx context.Context, c Config) error {
err := os.Remove(c.RegionsCachePath)
if err != nil && !os.IsNotExist(err) {
return errors.Wrapf(ctx, err, "remove region cache %s", c.RegionsCachePath)
}

return nil
}
10 changes: 10 additions & 0 deletions session/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,15 @@ func DestroyToken(ctx context.Context) error {
if err != nil {
return errors.Wrap(ctx, err, "remove local authentication credentials")
}

// We want to delete the regions cache so that the cache is created again during the next login.
// This is important for people with two different Scalingo accounts, one with and one without access to the osc-secnum-fr1 region.
// If we don't, there is a risk that when the client login with the osc-secnum-fr1 account, the regions cache does not contain the osc-secnum-fr1 region and client cannot contact this region.
// Ref. https://github.com/Scalingo/cli/issues/1057
err = config.DeleteRegionsCache(ctx, config.C)
if err != nil {
return errors.Wrap(ctx, err, "remove local regions cache")
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mega-nitpick: missing break line before the return.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this kind of nitpicks 😄


return nil
}