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 incorrect validation for ServiceResolver #456

Merged
merged 2 commits into from
Mar 15, 2021
Merged

Conversation

lkysow
Copy link
Member

@lkysow lkysow commented Mar 15, 2021

Changes proposed in this PR:

  • ServiceResolver validation: if hashPolicy.field is set fieldValue must also be set
  • ServiceResolver validation: hashPolicy.field can be empty if hashPolicy.sourceIP is true

How I've tested this PR:

  • unit tests

How I expect reviewers to test this PR:

  • review tests & changes

Checklist:

  • Tests added
  • CHANGELOG entry added (HashiCorp engineers only, community PRs should not add a changelog entry)

@lkysow lkysow force-pushed the service-resolver-bugfix branch from e6f6ee7 to f0626bf Compare March 15, 2021 19:27
asJSON, _ := json.Marshal(in)
errs = append(errs, field.Invalid(path, string(asJSON),
"cannot set both field and sourceIP"))
} else if in.FieldValue == "" {
Copy link
Member Author

Choose a reason for hiding this comment

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

using else if here because if they're setting:

field: cookie
sourceIP: true

then thought only one error (can't set both field and sourceIP) is clearer than two: (can't set both field and sourceIP, if field is set fieldValue must also be set)

@lkysow lkysow requested review from a team, ndhanushkodi and thisisnotashwin and removed request for a team March 15, 2021 19:29
Copy link
Contributor

@thisisnotashwin thisisnotashwin left a comment

Choose a reason for hiding this comment

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

Nicely done!!

Copy link
Contributor

@ndhanushkodi ndhanushkodi left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@lkysow lkysow merged commit c70361e into master Mar 15, 2021
@lkysow lkysow deleted the service-resolver-bugfix branch March 15, 2021 22:52
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.

3 participants