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

pgk/capabilities: modernize, switch to github.com/moby/sys/capability #2167

Merged
merged 5 commits into from
Sep 26, 2024

Commits on Sep 25, 2024

  1. pkg/capabilities: rm RHEL < 6.7 compat hack

    Kernel 2.6.32-573.el6, released 2015-07-22 as part of RHEL 6.7,
    supports cap_last_cap file, so there is no need for a workaround.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Sep 25, 2024
    Configuration menu
    Copy the full SHA
    dde7672 View commit details
    Browse the repository at this point in the history
  2. pkg/capabilities: use sync.OnceValues

    sync.OnceValues is available since Go 1.21 and allows to have less
    global variables when using sync.Once.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Sep 25, 2024
    Configuration menu
    Copy the full SHA
    a05c697 View commit details
    Browse the repository at this point in the history
  3. pkg/capabilities: use slices.Sort

    slices.Sort was introduced in Go 1.21. As the code already imports
    slices, using slices.Sort allows to have one less package imported.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Sep 25, 2024
    Configuration menu
    Copy the full SHA
    491900e View commit details
    Browse the repository at this point in the history
  4. pkg/capabilities: remove init

    Replace init and the two global variables with two functions, capList
    and capStrList, wrapped in sync.OnceValues.
    
    This way, there is no runtime overhead of merely including this package,
    as these functions are executed as needed, not during program
    initialization.
    
    While at it:
     - rename getCapName to capName for brewity;
     - use slices.DeleteFunc in capList to filter the slice in place instead
       of making a copy (less garbage to collect);
     - improve AllCapabilities documentation.
    
    Note that currently neither function returns an error; this is a
    preparation for the next patch.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Sep 25, 2024
    Configuration menu
    Copy the full SHA
    36e5f50 View commit details
    Browse the repository at this point in the history
  5. [test] Switch to github.com/moby/sys/capability

    This is a fork of the (no longer maintained)
    github.com/syndtr/gocapability package.
    
    For changes since the fork took place, see
    https://github.com/moby/sys/blob/main/capability/CHANGELOG.md
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Sep 25, 2024
    Configuration menu
    Copy the full SHA
    9ddda8c View commit details
    Browse the repository at this point in the history