Repository navigation
pkg/kernelversion: fix linting and sync with upstream - #13701
Conversation
There was a problem hiding this comment.
Pull request overview
Updates pkg/kernelversion to align with upstream seccomp profile sources and modern Go idioms while cleaning up minor linting issues.
Changes:
- Switch kernel release string conversion to
unix.ByteSliceToStringfor NUL-terminatedutsnamefields. - Simplify kernel version caching logic using
sync.OnceValuesand ensureunamefailures propagate as errors. - Update upstream reference links and adjust tests to use
errors.Newwhere formatting isn’t needed.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/kernelversion/kernel_linux.go | Uses unix.ByteSliceToString and sync.OnceValues to simplify and harden kernel version detection/caching; updates upstream link. |
| pkg/kernelversion/kernel_linux_test.go | Removes unnecessary fmt usage, keeps error expectations stable via message comparisons; updates upstream link. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5056924 to
4eae619
Compare
| /* | ||
| File copied and customized based on | ||
| https://github.com/moby/moby/tree/v20.10.14/profiles/seccomp/kernel_linux.go | ||
| https://github.com/moby/profiles/blob/seccomp/v0.2.3/seccomp/kernel_linux.go |
There was a problem hiding this comment.
If we're in here anyway, it'd be good to include the copyright information of that file as well. Both are Apache 2.0 and compatible, but right now we're just crediting "The containerd Authors." but we should also credit "The Moby Authors." (and yes, a lot of those are the same people 😂).
| https://github.com/moby/profiles/blob/seccomp/v0.2.3/seccomp/kernel_linux.go | |
| https://github.com/moby/profiles/blob/seccomp/v0.2.3/seccomp/kernel_linux.go | |
| Copyright The Moby Authors. | |
| SPDX-License-Identifier: Apache-2.0 |
There was a problem hiding this comment.
Heh; yes, while working on this PR, I actually noticed that the "correct" header is SPDX-FileCopyrightText nowadays; moby/profiles#34
And when forking (like in this repository) it could even be SPDX-SnippetCopyrightText:; https://spdx.github.io/spdx-spec/v2.3/file-tags/#h3-snippet-tags-format
(and yes, a lot of those are the same people 😂).
Yup! Lot of code in the container ecosystem moved around multiple times. I think it's the right thing to do (at least best effort to give credits due where credits due), but it can add a lot of noise / boilerplating.
To reduce noise, I've actually contemplated to switch to SPDX headers in containerd as well (I can open a ticket / draft PR for that)
4eae619 to
b179c1f
Compare
| // SPDX-FileCopyrightText: Copyright The Moby Authors | ||
| // SPDX-License-Identifier: Apache-2.0 |
There was a problem hiding this comment.
Hm.. right yeah, if that otherwise means it "discards" the top-level apache header, we probably need to repeat.
One more reason to consider using SPDX for containerd itself as well
b179c1f to
0b302ea
Compare
similar to [moby@8a5c131] [moby@8a5c131]: moby/moby@8a5c131 Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
The package was moved to a separate module; update the links to make it easier to discover the current version of upstream. Signed-off-by: Sebastiaan van Stijn <[email protected]>
0b302ea to
296f917
Compare

pkg/kernelversion: use unix.ByteSliceToString for utsname fields
similar to moby@8a5c131
pkg/kernelversion: fix minor linting issues
pkg/kernelversion: simplify code with sync.OnceValues
pkg/kernelversion: update links to upstream source
The package was moved to a separate module; update the links to
make it easier to discover the current version of upstream.