From 67f51b2549b729eb2d221e779a1eafca4f22ab30 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Fri, 20 Sep 2024 09:48:13 -0700 Subject: [PATCH 1/3] capability: improve documentation Add cross-references, and use tabs in code examples. Signed-off-by: Kir Kolyshkin --- capability/capability.go | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/capability/capability.go b/capability/capability.go index 2c46b8e..08e0ace 100644 --- a/capability/capability.go +++ b/capability/capability.go @@ -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) @@ -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) @@ -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) } From b8be1f6612253526390b71e5e9cff3f47d28b103 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Fri, 20 Sep 2024 10:44:18 -0700 Subject: [PATCH 2/3] capabilities: add link to changelog to README Signed-off-by: Kir Kolyshkin --- capability/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/capability/README.md b/capability/README.md index 47489f9..84b7487 100644 --- a/capability/README.md +++ b/capability/README.md @@ -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 From cf0f98c93317ba1f814b9b901dc9bf40a8bf2535 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Fri, 20 Sep 2024 10:45:07 -0700 Subject: [PATCH 3/3] capability: CHANGELOG: add link to 0.2.0 release Signed-off-by: Kir Kolyshkin --- capability/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/capability/CHANGELOG.md b/capability/CHANGELOG.md index c508d03..7e5aed8 100644 --- a/capability/CHANGELOG.md +++ b/capability/CHANGELOG.md @@ -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. @@ -55,6 +55,7 @@ This is an initial release since the fork. [LastCap]: https://pkg.go.dev/github.com/moby/sys/capability#LastCap +[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