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

fix: add validation to prevent duplicated local ports #50

Merged
merged 2 commits into from
Feb 15, 2024
Merged

Conversation

dnlopes
Copy link
Contributor

@dnlopes dnlopes commented Feb 15, 2024

This PR addresses an issue when a duplicated port on the Remote configuration was provided.

main.go Outdated

if err := validateRemotes(args[1:]); err != nil {
log.Fatal(err)
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

why the else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

func validateRemotes(remotes []string) error {
uniqueRemotes := []string{}

for _, newRemote := range remotes {
Copy link
Contributor

Choose a reason for hiding this comment

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

can't we create a list/slice with ports and use the "unique" package and check the size ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For future proof scenarios, in case we want to extend the validations, having it behind a method is easier.

@dnlopes dnlopes marked this pull request as ready for review February 15, 2024 15:29
@dnlopes dnlopes changed the title fix: add validation to prevent duplicated remote ports fix: add validation to prevent duplicated local ports Feb 15, 2024
@dnlopes dnlopes merged commit e2a4152 into main Feb 15, 2024
6 checks passed
@dnlopes dnlopes deleted the fix/RDGRS-53 branch February 15, 2024 15:40
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