Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A bit of code refactoring #805

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

EloyTolosaDev
Copy link

It started because I wanted to investigate on issue #785 , and I ended up refactoring the codebase a bit while working on it. In the end, I did nothing about the issue because I couldn't figure out what was happening, and I did not get any response from the person who created the issue, so I could not investigate further. After all, it looks like a user problem, as I was unable to reproduce the problem.

What changed?

Functionality did not change, the main changes were:

  1. Removing an unused function "IsOutdatedConfig" as it was only checking if the length of the variable ProfileRegistryURLs and that could be done separately without any function.
  2. Removed an unused error variable "RegistrySyncError" as it did not provide any extra functionality in the case of the error ocurred, also it was not being used.
  3. Removed the awsmerge.Merger struct, and replacing the merger struct functions as package functions, as there were no differences and having an extra awsmerge.Merger struct which did nothing at all looked strange to me.

Why?

How did you test it?

I tested the dassume and dgranted binaries and worked as espected.

Potential risks

Is patch release candidate?

Link to relevant docs PRs

Copy link
Contributor

@chrnorm chrnorm left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution @EloyTolosaDev! One requested change here


registries, err := registry.GetProfileRegistries(interactive)
if err != nil {
clio.Debugf("unable to load granted config file with err %s", err.Error())
return
}

if len(registries) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

registry.IsOutdatedConfig() checks a different field in the Granted config to the one in registry.GetProfileRegistries().

IsOutdatedConfig checks if the length of ProfileRegistryURLS is > 0, whereas GetProfileRegistries uses the ProfileRegistry field.

The change you have made here will cause valid profile registry configuration to return the error. Could you please restore the previous behaviour?

In this instance, I'd propose just restoring the registry.IsOutdatedConfig function and restoring the call to the function. The code there was working in production, so there is no need to change it IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants