Skip to content

Commit

Permalink
Merge pull request #151 from kolyshkin/cap-docs
Browse files Browse the repository at this point in the history
capability: doc improvements
  • Loading branch information
kolyshkin authored Sep 21, 2024
2 parents 7d73c88 + cf0f98c commit 8c5f336
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
3 changes: 2 additions & 1 deletion capability/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from https://github.com/syndtr/gocapability/commit/42c35b4376354fd5.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.2.0 - 2024-09-16
## [0.2.0] - 2024-09-16

This is the first release after the move to a new home in
github.com/moby/sys/capability.
Expand Down Expand Up @@ -55,6 +55,7 @@ This is an initial release since the fork.
[LastCap]: https://pkg.go.dev/github.com/moby/sys/capability#LastCap

<!-- Minor releases. -->
[0.2.0]: https://github.com/moby/sys/releases/tag/capability%2Fv0.2.0
[0.1.1]: https://github.com/kolyshkin/capability/compare/v0.1.0...v0.1.1
[0.1.0]: https://github.com/kolyshkin/capability/compare/42c35b4376354fd5...v0.1.0

Expand Down
2 changes: 2 additions & 0 deletions capability/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ This is a fork of (apparently no longer maintained)
https://github.com/syndtr/gocapability package. It provides basic primitives to
work with [Linux capabilities][capabilities(7)].

For changes, see [CHANGELOG.md](./CHANGELOG.md).

[![Go Reference](https://pkg.go.dev/badge/github.com/moby/sys/capability/capability.svg)](https://pkg.go.dev/github.com/moby/sys/capability)

## Alternatives
Expand Down
32 changes: 17 additions & 15 deletions capability/capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,26 @@ type Capabilities interface {
Apply(kind CapType) error
}

// NewPid initializes a new Capabilities object for given pid when
// NewPid initializes a new [Capabilities] object for given pid when
// it is nonzero, or for the current process if pid is 0.
//
// Deprecated: Replace with NewPid2. For example, replace:
// Deprecated: Replace with [NewPid2] followed by [Capabilities.Load].
// For example, replace:
//
// c, err := NewPid(0)
// if err != nil {
// return err
// return err
// }
//
// with:
//
// c, err := NewPid2(0)
// if err != nil {
// return err
// return err
// }
// err = c.Load()
// if err != nil {
// return err
// return err
// }
func NewPid(pid int) (Capabilities, error) {
c, err := newPid(pid)
Expand All @@ -90,32 +91,33 @@ func NewPid(pid int) (Capabilities, error) {
return c, err
}

// NewPid2 initializes a new Capabilities object for given pid when
// it is nonzero, or for the current process if pid is 0. This
// NewPid2 initializes a new [Capabilities] object for given pid when
// it is nonzero, or for the current process if pid is 0. This
// does not load the process's current capabilities; to do that you
// must call Load explicitly.
// must call [Capabilities.Load] explicitly.
func NewPid2(pid int) (Capabilities, error) {
return newPid(pid)
}

// NewFile initializes a new Capabilities object for given file path.
//
// Deprecated: Replace with NewFile2. For example, replace:
// Deprecated: Replace with [NewFile2] followed by [Capabilities.Load].
// For example, replace:
//
// c, err := NewFile(path)
// if err != nil {
// return err
// return err
// }
//
// with:
//
// c, err := NewFile2(path)
// if err != nil {
// return err
// return err
// }
// err = c.Load()
// if err != nil {
// return err
// return err
// }
func NewFile(path string) (Capabilities, error) {
c, err := newFile(path)
Expand All @@ -126,9 +128,9 @@ func NewFile(path string) (Capabilities, error) {
return c, err
}

// NewFile2 creates a new initialized Capabilities object for given
// file path. This does not load the process's current capabilities;
// to do that you must call Load explicitly.
// NewFile2 creates a new initialized [Capabilities] object for given
// file path. This does not load the process's current capabilities;
// to do that you must call [Capabilities.Load] explicitly.
func NewFile2(path string) (Capabilities, error) {
return newFile(path)
}

0 comments on commit 8c5f336

Please sign in to comment.