vendor: github.com/docker/cli-docs-tool v0.9.0

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2025-01-13 17:53:44 +01:00
parent 807d15ff9d
commit 8a472c6c9d
10 changed files with 72 additions and 37 deletions

View File

@ -104,7 +104,7 @@ func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering
node.Parent.Prev.Type == blackfriday.Heading &&
node.Parent.Prev.FirstChild != nil &&
bytes.EqualFold(node.Parent.Prev.FirstChild.Literal, []byte("NAME")) {
before, after, found := bytes.Cut(node.Literal, []byte(" - "))
before, after, found := bytesCut(node.Literal, []byte(" - "))
escapeSpecialChars(w, before)
if found {
out(w, ` \- `)
@ -406,3 +406,12 @@ func escapeSpecialCharsLine(w io.Writer, text []byte) {
w.Write([]byte{'\\', text[i]}) // nolint: errcheck
}
}
// bytesCut is a copy of [bytes.Cut] to provide compatibility with go1.17
// and older. We can remove this once we drop support for go1.17 and older.
func bytesCut(s, sep []byte) (before, after []byte, found bool) {
if i := bytes.Index(s, sep); i >= 0 {
return s[:i], s[i+len(sep):], true
}
return s, nil, false
}

View File

@ -3,7 +3,6 @@ run:
linters:
enable:
- deadcode
- depguard
- gofmt
- goimports
@ -13,7 +12,6 @@ linters:
- ineffassign
- misspell
- typecheck
- varcheck
- errname
- makezero
- whitespace
@ -21,12 +19,11 @@ linters:
linters-settings:
depguard:
list-type: blacklist
include-go-root: true
packages:
# The io/ioutil package has been deprecated.
# https://go.dev/doc/go1.16#ioutil
- io/ioutil
rules:
main:
deny:
- pkg: io/ioutil
desc: The io/ioutil package has been deprecated, see https://go.dev/doc/go1.16#ioutil
importas:
no-unaliased: true

View File

@ -14,20 +14,37 @@
# See the License for the specific language governing permissions and
# limitations under the License.
ARG GO_VERSION="1.18"
ARG GOLANGCI_LINT_VERSION="v1.45"
ARG ADDLICENSE_VERSION="v1.0.0"
ARG GO_VERSION="1.23"
ARG XX_VERSION="1.6.1"
ARG GOLANGCI_LINT_VERSION="v1.62"
ARG ADDLICENSE_VERSION="v1.1.1"
ARG LICENSE_ARGS="-c cli-docs-tool -l apache"
ARG LICENSE_FILES=".*\(Dockerfile\|\.go\|\.hcl\|\.sh\)"
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint
FROM ghcr.io/google/addlicense:${ADDLICENSE_VERSION} AS addlicense
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
FROM golang:${GO_VERSION}-alpine AS base
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS base
RUN apk add --no-cache cpio findutils git linux-headers
ENV CGO_ENABLED=0
WORKDIR /src
COPY --link --from=xx / /
FROM base AS addlicense
ARG ADDLICENSE_VERSION
ARG TARGETPLATFORM
RUN --mount=target=/root/.cache,type=cache \
--mount=type=cache,target=/go/pkg/mod <<EOT
set -ex
xx-go install "github.com/google/addlicense@${ADDLICENSE_VERSION}"
mkdir /out
if ! xx-info is-cross; then
mv /go/bin/addlicense /out
else
mv /go/bin/*/addlicense* /out
fi
EOT
FROM base AS vendored
RUN --mount=type=bind,target=.,rw \
@ -40,15 +57,15 @@ COPY --from=vendored /out /
FROM vendored AS vendor-validate
RUN --mount=type=bind,target=.,rw <<EOT
set -e
git add -A
cp -rf /out/* .
diff=$(git status --porcelain -- go.mod go.sum)
if [ -n "$diff" ]; then
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor"'
echo "$diff"
exit 1
fi
set -e
git add -A
cp -rf /out/* .
diff=$(git status --porcelain -- go.mod go.sum)
if [ -n "$diff" ]; then
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor"'
echo "$diff"
exit 1
fi
EOT
FROM base AS lint
@ -61,7 +78,7 @@ FROM base AS license-set
ARG LICENSE_ARGS
ARG LICENSE_FILES
RUN --mount=type=bind,target=.,rw \
--mount=from=addlicense,source=/app/addlicense,target=/usr/bin/addlicense \
--mount=from=addlicense,source=/out/addlicense,target=/usr/bin/addlicense \
find . -regex "${LICENSE_FILES}" | xargs addlicense ${LICENSE_ARGS} \
&& mkdir /out \
&& find . -regex "${LICENSE_FILES}" | cpio -pdm /out
@ -73,7 +90,7 @@ FROM base AS license-validate
ARG LICENSE_ARGS
ARG LICENSE_FILES
RUN --mount=type=bind,target=. \
--mount=from=addlicense,source=/app/addlicense,target=/usr/bin/addlicense \
--mount=from=addlicense,source=/out/addlicense,target=/usr/bin/addlicense \
find . -regex "${LICENSE_FILES}" | xargs addlicense -check ${LICENSE_ARGS}
FROM vendored AS test

View File

@ -65,7 +65,7 @@ func New(opts Options) (*Client, error) {
} else {
c.target = opts.TargetDir
}
if err := os.MkdirAll(c.target, 0755); err != nil {
if err := os.MkdirAll(c.target, 0o755); err != nil {
return nil, err
}
return c, nil

View File

@ -94,7 +94,7 @@ func (c *Client) GenMarkdownTree(cmd *cobra.Command) error {
}); err != nil {
return err
}
if err = os.WriteFile(targetPath, icBuf.Bytes(), 0644); err != nil {
if err = os.WriteFile(targetPath, icBuf.Bytes(), 0o644); err != nil {
return err
}
} else if err := copyFile(sourcePath, targetPath); err != nil {

View File

@ -77,7 +77,7 @@ type cmdDoc struct {
// subcmds, `sub` and `sub-third`, and `sub` has a subcommand called `third`
// it is undefined which help output will be in the file `cmd-sub-third.1`.
func (c *Client) GenYamlTree(cmd *cobra.Command) error {
emptyStr := func(s string) string { return "" }
emptyStr := func(string) string { return "" }
if err := c.loadLongDescription(cmd, "yaml"); err != nil {
return err
}

View File

@ -12,6 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
target "_common" {
args = {
BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
}
}
group "default" {
targets = ["test"]
}
@ -21,31 +27,37 @@ group "validate" {
}
target "lint" {
inherits = ["_common"]
target = "lint"
output = ["type=cacheonly"]
}
target "vendor-validate" {
inherits = ["_common"]
target = "vendor-validate"
output = ["type=cacheonly"]
}
target "vendor-update" {
inherits = ["_common"]
target = "vendor-update"
output = ["."]
}
target "test" {
inherits = ["_common"]
target = "test-coverage"
output = ["."]
}
target "license-validate" {
inherits = ["_common"]
target = "license-validate"
output = ["type=cacheonly"]
}
target "license-update" {
inherits = ["_common"]
target = "license-update"
output = ["."]
}