Skip to content

Conversation

lmb
Copy link
Collaborator

@lmb lmb commented Aug 7, 2024

internal: move Pin and Unpin to sys

Pin and Unpin implement library-specific behaviour for BPF object pinning.
Move it to package sys since that abstracts away BPF things.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>

internal: move linux specific code to separate package

Move some linux specific code out of package internal into package linux. As
a rule of thumb, code probably belongs in this package if it calls into
package unix.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>

internal/kconfig: move Find to package linux

Move Find to package linux, since it depends on deriving a file name from
the current linux kernel version.

This means that package kconfig only implements parsing of the kconfig
format.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>

examples: add linux build tag to uretprobe, ringbuf, socket_dist

The two examples call into package unix which is not available on non-Unix
platforms. Add build tags so that

    GOOS=windows go build ./...

works without errors.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>

program: use unix.SIGUSR1 in tests

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>

link: use internal/unix in netkit tests

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>

CI: cross build for Windows instead of Darwin

CI cross compiles the package and its tests for Darwin to make sure that
it's possible to edit the source code on other Unix like platforms.

Up the game a little and cross build for Windows instead of Darwin: this
flushes out accidental uses of x/sys/unix instead of internal/unix.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>

lmb added 7 commits August 6, 2024 17:24
Pin and Unpin implement library-specific behaviour for BPF object
pinning. Move it to package sys since that abstracts away BPF things.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Move some linux specific code out of package internal into
package linux. As a rule of thumb, code probably belongs in
this package if it calls into package unix.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Move Find to package linux, since it depends on deriving a
file name from the current linux kernel version.

This means that package kconfig only implements parsing of
the kconfig format.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
The two examples call into package unix which is not available
on non-Unix platforms. Add build tags so that

    GOOS=windows go build ./...

works without errors.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
CI cross compiles the package and its tests for Darwin to make sure
that it's possible to edit the source code on other Unix like platforms.

Up the game a little and cross build for Windows instead of Darwin:
this flushes out accidental uses of x/sys/unix instead of internal/unix.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
@lmb lmb marked this pull request as ready for review August 7, 2024 07:41
@lmb lmb requested review from dylandreimerink, mmat11, rgo3 and a team as code owners August 7, 2024 07:41
Copy link
Member

@dylandreimerink dylandreimerink left a comment

Choose a reason for hiding this comment

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

🚀

"github.com/go-quicktest/qt"
"github.com/jsimonetti/rtnetlink/v2"
"github.com/jsimonetti/rtnetlink/v2/driver"
"golang.org/x/sys/unix"

"github.com/cilium/ebpf"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a linter that checks if imports are formatted correctly? Happy to open an issue!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this could work: https://golangci-lint.run/usage/linters/#goimports with local set to the package url.

Copy link
Contributor

Choose a reason for hiding this comment

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

Skipped the issue and just opened #1541

@lmb lmb merged commit f8b9a8c into cilium:main Aug 7, 2024
17 checks passed
@lmb lmb deleted the internal-tidy branch August 7, 2024 13:05
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