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

DRY up ignore related conditionals #103

Merged
merged 2 commits into from
Feb 26, 2024
Merged

DRY up ignore related conditionals #103

merged 2 commits into from
Feb 26, 2024

Conversation

rodaine
Copy link
Member

@rodaine rodaine commented Feb 26, 2024

No description provided.

@rodaine rodaine requested a review from pkwarren February 26, 2024 18:09
// only need the zero value for checking ignore_empty constraint
val.IgnoreEmpty = forItems && bldr.shouldIgnoreEmpty(constraints)
if val.IgnoreEmpty {
val.Zero = bldr.zeroValue(fdesc, forItems)
return nil
Copy link
Member

Choose a reason for hiding this comment

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

Can remove this return and fall back to one immediately after.

Copy link
Member Author

Choose a reason for hiding this comment

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

weird that a linter didn't catch that...

fieldConstraints.GetIgnore() == validate.Ignore_IGNORE_IF_UNPOPULATED ||
fieldConstraints.GetIgnore() == validate.Ignore_IGNORE_IF_DEFAULT_VALUE,
IgnoreDefault: fieldDescriptor.HasPresence() && fieldConstraints.GetIgnore() == validate.Ignore_IGNORE_IF_DEFAULT_VALUE,
bldr.shouldIgnoreEmpty(fieldConstraints),
Copy link
Member

Choose a reason for hiding this comment

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

nit: Could put these back on one line if you want now that they're much shorter.

Copy link
Member Author

Choose a reason for hiding this comment

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

kinda like it on multiple lines personally 😅

@rodaine rodaine merged commit e2171c5 into main Feb 26, 2024
7 checks passed
@rodaine rodaine deleted the rodaine/ignore-dry-up branch February 26, 2024 18:17
charithe referenced this pull request in cerbos/cerbos-sdk-go Apr 8, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/bufbuild/protovalidate-go](https://togithub.com/bufbuild/protovalidate-go)
| `v0.6.0` -> `v0.6.1` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fbufbuild%2fprotovalidate-go/v0.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fbufbuild%2fprotovalidate-go/v0.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fbufbuild%2fprotovalidate-go/v0.6.0/v0.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fbufbuild%2fprotovalidate-go/v0.6.0/v0.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [google.golang.org/grpc](https://togithub.com/grpc/grpc-go) |
`v1.62.1` -> `v1.63.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/google.golang.org%2fgrpc/v1.63.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/google.golang.org%2fgrpc/v1.63.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/google.golang.org%2fgrpc/v1.62.1/v1.63.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/google.golang.org%2fgrpc/v1.62.1/v1.63.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>bufbuild/protovalidate-go
(github.com/bufbuild/protovalidate-go)</summary>

###
[`v0.6.1`](https://togithub.com/bufbuild/protovalidate-go/releases/tag/v0.6.1)

[Compare
Source](https://togithub.com/bufbuild/protovalidate-go/compare/v0.6.0...v0.6.1)

#### What's Changed

- Update license years and fix makefile by
[@&#8203;pkwarren](https://togithub.com/pkwarren) in
[https://github.com/bufbuild/protovalidate-go/pull/102](https://togithub.com/bufbuild/protovalidate-go/pull/102)
- DRY up ignore related conditionals by
[@&#8203;rodaine](https://togithub.com/rodaine) in
[https://github.com/bufbuild/protovalidate-go/pull/103](https://togithub.com/bufbuild/protovalidate-go/pull/103)
- Bump the go group with 1 update by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/bufbuild/protovalidate-go/pull/106](https://togithub.com/bufbuild/protovalidate-go/pull/106)
- Bump the go group with 3 updates by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/bufbuild/protovalidate-go/pull/109](https://togithub.com/bufbuild/protovalidate-go/pull/109)
- Bump Go min version to 1.20 by
[@&#8203;jhump](https://togithub.com/jhump) in
[https://github.com/bufbuild/protovalidate-go/pull/110](https://togithub.com/bufbuild/protovalidate-go/pull/110)
- Update README.md by [@&#8203;rodaine](https://togithub.com/rodaine) in
[https://github.com/bufbuild/protovalidate-go/pull/111](https://togithub.com/bufbuild/protovalidate-go/pull/111)
- Add tuuid conformance tests by
[@&#8203;rodaine](https://togithub.com/rodaine) in
[https://github.com/bufbuild/protovalidate-go/pull/114](https://togithub.com/bufbuild/protovalidate-go/pull/114)
- Add generate check CI step by
[@&#8203;rodaine](https://togithub.com/rodaine) in
[https://github.com/bufbuild/protovalidate-go/pull/115](https://togithub.com/bufbuild/protovalidate-go/pull/115)

#### New Contributors

- [@&#8203;jhump](https://togithub.com/jhump) made their first
contribution in
[https://github.com/bufbuild/protovalidate-go/pull/110](https://togithub.com/bufbuild/protovalidate-go/pull/110)

**Full Changelog**:
bufbuild/protovalidate-go@v0.6.0...v0.6.1

</details>

<details>
<summary>grpc/grpc-go (google.golang.org/grpc)</summary>

### [`v1.63.0`](https://togithub.com/grpc/grpc-go/releases/tag/v1.63.0):
Release 1.63.0

[Compare
Source](https://togithub.com/grpc/grpc-go/compare/v1.62.2...v1.63.0)

### Behavior Changes

- grpc: Return canonical target string from `resolver.Address.String()`
(experimental)
([#&#8203;6923](https://togithub.com/grpc/grpc-go/issues/6923))
- client & server: when using write buffer pooling, use input value for
buffer size instead of size\*2
([#&#8203;6983](https://togithub.com/grpc/grpc-go/issues/6983))
- Special Thanks:
[@&#8203;raghav-stripe](https://togithub.com/raghav-stripe)

### New Features

- grpc: add `ClientConn.CanonicalTarget()` to return the canonical
target string.
([#&#8203;7006](https://togithub.com/grpc/grpc-go/issues/7006))
- xds: implement LRS named metrics support ([gRFC
A64](https://togithub.com/grpc/proposal/blob/master/A64-lrs-custom-metrics.md))
([#&#8203;7027](https://togithub.com/grpc/grpc-go/issues/7027))
- Special Thanks:
[@&#8203;danielzhaotongliu](https://togithub.com/danielzhaotongliu)
- grpc: introduce `grpc.NewClient` to allow users to create new clients
in idle mode and with "dns" as the default resolver
([#&#8203;7010](https://togithub.com/grpc/grpc-go/issues/7010))
- Special Thanks:
[@&#8203;bruuuuuuuce](https://togithub.com/bruuuuuuuce)

### API Changes

- grpc: stabilize experimental method `ClientConn.Target()`
([#&#8203;7006](https://togithub.com/grpc/grpc-go/issues/7006))

### Bug Fixes

- xds: fix an issue that would cause the client to send an empty list of
resources for LDS/CDS upon reconnecting with the management server
([#&#8203;7026](https://togithub.com/grpc/grpc-go/issues/7026))
- server: Fix some errors returned by a server when using a
`grpc.Server` as an `http.Handler` with the Go stdlib HTTP server
([#&#8203;6989](https://togithub.com/grpc/grpc-go/issues/6989))
- resolver/dns: add `SetResolvingTimeout` to allow configuring the DNS
resolver's global timeout
([#&#8203;6917](https://togithub.com/grpc/grpc-go/issues/6917))
- Special Thanks: [@&#8203;and1truong](https://togithub.com/and1truong)
- Set the security level of Windows named pipes to NoSecurity
([#&#8203;6956](https://togithub.com/grpc/grpc-go/issues/6956))
    -   Special Thanks: [@&#8203;irsl](https://togithub.com/irsl)

### [`v1.62.2`](https://togithub.com/grpc/grpc-go/releases/tag/v1.62.2):
Release 1.62.2

[Compare
Source](https://togithub.com/grpc/grpc-go/compare/v1.62.1...v1.62.2)

### Dependencies

- Update http2 library to address vulnerability
[CVE-2023-45288](https://www.kb.cert.org/vuls/id/421644)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/cerbos/cerbos-sdk-go).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

---------

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Charith Ellawala <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Charith Ellawala <[email protected]>
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