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

Add SafePtr wrapper #393

Merged
merged 1 commit into from Nov 17, 2023
Merged

Add SafePtr wrapper #393

merged 1 commit into from Nov 17, 2023

Conversation

kaisoz
Copy link

@kaisoz kaisoz commented Nov 12, 2023

What this PR does / why we need it:

If a nil pointer value is provided when logging, it will be dereferenced leading to a panic message. This PR adds a simple wrapper called SafePtr which helps preventing this by returning a nil interface in case the provided pointer is nil, or the same pointer if it's not nil.

This function is available when compiling with Go >= 1.18 since it uses generics.

Release note:

Add SafePtr wrapper

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 12, 2023
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Nov 12, 2023
@k8s-ci-robot
Copy link

Welcome @kaisoz!

It looks like this is your first PR to kubernetes/klog 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/klog has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 12, 2023
Copy link

@pohly pohly left a comment

Choose a reason for hiding this comment

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

Some small nits, looks good overall.

safeptr.go Outdated Show resolved Hide resolved
safeptr.go Outdated Show resolved Hide resolved
safeptr.go Outdated Show resolved Hide resolved
@kaisoz
Copy link
Author

kaisoz commented Nov 13, 2023

Some small nits, looks good overall.

Thanks for the review @pohly , I've added your suggestions 😊

safeptr.go Show resolved Hide resolved
@kaisoz
Copy link
Author

kaisoz commented Nov 13, 2023

Done @pohly, I've rewritten the function description, let me know what you think 😊

safeptr.go Outdated Show resolved Hide resolved
Copy link

@pohly pohly left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 14, 2023
@harshanarayana
Copy link

/lgtm

@pohly
Copy link

pohly commented Nov 15, 2023

/assign @dims

For approval. Should we update the OWNERS so that I can approve and remove @serathius?

@dims
Copy link
Member

dims commented Nov 15, 2023

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 15, 2023
@dims
Copy link
Member

dims commented Nov 15, 2023

For approval. Should we update the OWNERS so that I can approve and remove @serathius?

Yes please @pohly

@kaisoz
Copy link
Author

kaisoz commented Nov 16, 2023

I'll fix the lint fails. Not sure why the check is failing with 1.19 though, I'll have a closer look

@dgrisonnet
Copy link
Member

/assign @pohly
/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 16, 2023
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 17, 2023
@kaisoz
Copy link
Author

kaisoz commented Nov 17, 2023

I fixed the lint problem but the lgtm got removed and is not running the rest of the tests. @pohly @dims could you please re-lgtm it? Thanks!

Copy link

@pohly pohly left a comment

Choose a reason for hiding this comment

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

/lgtm

We might need to do something about the Go version dependency, but let's see whether this triggers another test run.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 17, 2023
@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dims, harshanarayana, kaisoz, pohly

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@pohly
Copy link

pohly commented Nov 17, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Nov 17, 2023
@k8s-ci-robot k8s-ci-robot merged commit 2086216 into kubernetes:main Nov 17, 2023
2 checks passed
@kaisoz kaisoz deleted the add-safeptr branch December 20, 2023 10:56
codeboten pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Mar 12, 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 |
|---|---|---|---|---|---|
| [k8s.io/klog/v2](https://togithub.com/kubernetes/klog) | `v2.110.1` ->
`v2.120.1` |
[![age](https://developer.mend.io/api/mc/badges/age/go/k8s.io%2fklog%2fv2/v2.120.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/k8s.io%2fklog%2fv2/v2.120.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/k8s.io%2fklog%2fv2/v2.110.1/v2.120.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/k8s.io%2fklog%2fv2/v2.110.1/v2.120.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>kubernetes/klog (k8s.io/klog/v2)</summary>

###
[`v2.120.1`](https://togithub.com/kubernetes/klog/releases/tag/v2.120.1):
Prepare klog release for Kubernetes v1.30 (Take 2)

[Compare
Source](https://togithub.com/kubernetes/klog/compare/v2.120.0...v2.120.1)

#### What's Changed

- textlogger: allow caller to override stack unwinding by
[@&#8203;pohly](https://togithub.com/pohly) in
[kubernetes/klog#397

**Full Changelog**:
kubernetes/klog@v2.120.0...v2.120.1

###
[`v2.120.0`](https://togithub.com/kubernetes/klog/releases/tag/v2.120.0):
Prepare klog release for Kubernetes v1.30 (Take 1)

[Compare
Source](https://togithub.com/kubernetes/klog/compare/v2.110.1...v2.120.0)

#### What's Changed

- OWNERS: remove serathius, add mengjiao-liu, promote pohly by
[@&#8203;pohly](https://togithub.com/pohly) in
[kubernetes/klog#394
- docs: clarify relationship between different features by
[@&#8203;pohly](https://togithub.com/pohly) in
[kubernetes/klog#395
- Add SafePtr wrapper by [@&#8203;kaisoz](https://togithub.com/kaisoz)
in
[kubernetes/klog#393
- logr v1.4.1 + SetSlogLogger by
[@&#8203;pohly](https://togithub.com/pohly) in
[kubernetes/klog#396

#### New Contributors

- [@&#8203;kaisoz](https://togithub.com/kaisoz) made their first
contribution in
[kubernetes/klog#393

**Full Changelog**:
kubernetes/klog@v2.110.1...v2.120.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "on tuesday" (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.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- 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/open-telemetry/opentelemetry-collector-contrib).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMzguMSIsInVwZGF0ZWRJblZlciI6IjM3LjIzOC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: opentelemetrybot <107717825+opentelemetrybot@users.noreply.github.com>
DougManton pushed a commit to DougManton/opentelemetry-collector-contrib that referenced this pull request Mar 13, 2024
…1721)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [k8s.io/klog/v2](https://togithub.com/kubernetes/klog) | `v2.110.1` ->
`v2.120.1` |
[![age](https://developer.mend.io/api/mc/badges/age/go/k8s.io%2fklog%2fv2/v2.120.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/k8s.io%2fklog%2fv2/v2.120.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/k8s.io%2fklog%2fv2/v2.110.1/v2.120.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/k8s.io%2fklog%2fv2/v2.110.1/v2.120.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>kubernetes/klog (k8s.io/klog/v2)</summary>

###
[`v2.120.1`](https://togithub.com/kubernetes/klog/releases/tag/v2.120.1):
Prepare klog release for Kubernetes v1.30 (Take 2)

[Compare
Source](https://togithub.com/kubernetes/klog/compare/v2.120.0...v2.120.1)

#### What's Changed

- textlogger: allow caller to override stack unwinding by
[@&open-telemetry#8203;pohly](https://togithub.com/pohly) in
[kubernetes/klog#397

**Full Changelog**:
kubernetes/klog@v2.120.0...v2.120.1

###
[`v2.120.0`](https://togithub.com/kubernetes/klog/releases/tag/v2.120.0):
Prepare klog release for Kubernetes v1.30 (Take 1)

[Compare
Source](https://togithub.com/kubernetes/klog/compare/v2.110.1...v2.120.0)

#### What's Changed

- OWNERS: remove serathius, add mengjiao-liu, promote pohly by
[@&open-telemetry#8203;pohly](https://togithub.com/pohly) in
[kubernetes/klog#394
- docs: clarify relationship between different features by
[@&open-telemetry#8203;pohly](https://togithub.com/pohly) in
[kubernetes/klog#395
- Add SafePtr wrapper by [@&open-telemetry#8203;kaisoz](https://togithub.com/kaisoz)
in
[kubernetes/klog#393
- logr v1.4.1 + SetSlogLogger by
[@&open-telemetry#8203;pohly](https://togithub.com/pohly) in
[kubernetes/klog#396

#### New Contributors

- [@&open-telemetry#8203;kaisoz](https://togithub.com/kaisoz) made their first
contribution in
[kubernetes/klog#393

**Full Changelog**:
kubernetes/klog@v2.110.1...v2.120.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "on tuesday" (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.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- 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/open-telemetry/opentelemetry-collector-contrib).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMzguMSIsInVwZGF0ZWRJblZlciI6IjM3LjIzOC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: opentelemetrybot <107717825+opentelemetrybot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants