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

use FS struct for proc and sys mount points in submodules #149

Merged
merged 6 commits into from
May 3, 2019

Conversation

pgier
Copy link
Collaborator

@pgier pgier commented Apr 11, 2019

Based on discussion in #148, instead of removing the FS type completely, this PR moves the FS type to a shared internal package and exposes a more consistent API for each of the subpackages.

@pgier pgier mentioned this pull request Apr 11, 2019
bcache/get.go Outdated Show resolved Hide resolved
@pgier
Copy link
Collaborator Author

pgier commented Apr 12, 2019

One drawback of this approach is that the affected subpackages now have a dependency on the main procfs and/or sysfs packages. It might be better to add the FS type to the internal/util package and have the sub-modules use that instead of the FS from procfs and sysfs.

@pgier pgier force-pushed the use-fs-type-in-subpackages branch from 889877b to 5f92a6a Compare April 16, 2019 16:54
pgier added 4 commits April 16, 2019 11:59
Signed-off-by: Paul Gier <pgier@redhat.com>
Signed-off-by: Paul Gier <pgier@redhat.com>
Signed-off-by: Paul Gier <pgier@redhat.com>
Moves the FS type definition to the internal/util package.
This allows the sub-packages bcache, blockdevice, nfs, and xfs
to work without bringing in procfs and sysfs as dependencies.

Signed-off-by: Paul Gier <pgier@redhat.com>
@pgier pgier force-pushed the use-fs-type-in-subpackages branch from 5f92a6a to d92cb22 Compare April 16, 2019 17:01
@pgier
Copy link
Collaborator Author

pgier commented Apr 16, 2019

@mdlayher @discordianfish PTAL. I've updated this PR to move the FS/string type to the internal/util package. This allows the sub-packages bcache, blockdevice, nfs, and xfs to work without a dependency on the main procfs and sysfs packages, which was the original purpose of #136. And I made changes to the procfs and sysfs packages to be consistent with the subpackages.

@discordianfish
Copy link
Member

Great, I like that!
One suggestion though (and I'm open for different opinions on this): I would create a fs/ module and move the functions there instead of util/. Util packages are seen as anti-pattern and while I wouldn't avoid them at all cost, it seems reasonable to use a fs module for these functions.

Avoids the anti-pattern of using a 'util' package.

Signed-off-by: Paul Gier <pgier@redhat.com>
bcache/get.go Outdated Show resolved Hide resolved
Signed-off-by: Paul Gier <pgier@redhat.com>
Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

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

LGTM, I like it.

@SuperQ
Copy link
Member

SuperQ commented Apr 30, 2019

@mdlayher Any other issues?

Copy link
Contributor

@mdlayher mdlayher left a comment

Choose a reason for hiding this comment

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

lgtm thanks!

@pgier
Copy link
Collaborator Author

pgier commented May 1, 2019

@discordianfish everything look good to you?

@discordianfish discordianfish merged commit 740c077 into prometheus:master May 3, 2019
@discordianfish
Copy link
Member

Great, thanks! :)

andrewkroh pushed a commit to elastic/go-sysinfo that referenced this pull request May 6, 2019
Update the Linux provider to use procfs.NewFS, and stop using the procfs.FS.Path method which was removed in prometheus/procfs#149.

The changed code works with both the old and new procfs APIs.
remijouannet pushed a commit to remijouannet/procfs that referenced this pull request Oct 20, 2022
…#149)

* use FS struct for proc and sys mount points in submodules

Signed-off-by: Paul Gier <pgier@redhat.com>

* xfs: fix staticcheck issue

Signed-off-by: Paul Gier <pgier@redhat.com>

* better naming for filesystem handles in submodules

Signed-off-by: Paul Gier <pgier@redhat.com>

* refactor FS to reduce inter-package dependencies

Moves the FS type definition to the internal/util package.
This allows the sub-packages bcache, blockdevice, nfs, and xfs
to work without bringing in procfs and sysfs as dependencies.

Signed-off-by: Paul Gier <pgier@redhat.com>

* move fs.go to a new internal.fs package

Avoids the anti-pattern of using a 'util' package.

Signed-off-by: Paul Gier <pgier@redhat.com>

* move default proc and sys mount point constants to internal/fs

Signed-off-by: Paul Gier <pgier@redhat.com>
bobrik pushed a commit to bobrik/procfs that referenced this pull request Jan 14, 2023
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.

4 participants