Update Docker and containerd. OBS-URL: https://build.opensuse.org/request/show/1120879 OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/docker?expand=0&rev=397
31968 lines
1.1 MiB
31968 lines
1.1 MiB
From 8d493d2edca8a36e0957d6d5566a0fbc02261e69 Mon Sep 17 00:00:00 2001
|
||
From: Aleksa Sarai <asarai@suse.de>
|
||
Date: Wed, 26 Apr 2023 10:13:48 +1000
|
||
Subject: [PATCH] docs: include required tools in source tree
|
||
|
||
In order to be able to build the documentation without internet access
|
||
(as is required by some distribution build systems), all of the source
|
||
code needed for the build needs to be available in the source tarball.
|
||
|
||
This used to be possible with the docker-cli sources but was
|
||
accidentally broken with some CI changes that switched to downloading
|
||
the tools (by modifying go.mod as part of the docs build script).
|
||
|
||
This pattern also maked documentation builds less reproducible since the
|
||
tool version used was not based on the source code version.
|
||
|
||
Fixes: commit 7dc35c03fca5 ("validate manpages target")
|
||
Fixes: commit a650f4ddd008 ("switch to cli-docs-tool for yaml docs generation")
|
||
Signed-off-by: Aleksa Sarai <asarai@suse.de>
|
||
---
|
||
docs/generate/go.mod | 13 -
|
||
docs/generate/tools.go | 8 -
|
||
import.go | 17 +
|
||
man/tools.go | 11 -
|
||
scripts/docs/generate-man.sh | 33 +-
|
||
scripts/docs/generate-md.sh | 27 +-
|
||
scripts/docs/generate-yaml.sh | 29 +-
|
||
vendor.mod | 13 +-
|
||
vendor.sum | 46 +-
|
||
vendor/github.com/cespare/xxhash/v2/README.md | 31 +-
|
||
.../github.com/cespare/xxhash/v2/testall.sh | 10 +
|
||
vendor/github.com/cespare/xxhash/v2/xxhash.go | 47 +-
|
||
.../cespare/xxhash/v2/xxhash_amd64.s | 336 +-
|
||
.../cespare/xxhash/v2/xxhash_arm64.s | 183 +
|
||
.../v2/{xxhash_amd64.go => xxhash_asm.go} | 2 +
|
||
.../cespare/xxhash/v2/xxhash_other.go | 22 +-
|
||
.../cespare/xxhash/v2/xxhash_safe.go | 1 +
|
||
.../cespare/xxhash/v2/xxhash_unsafe.go | 3 +-
|
||
.../cpuguy83/go-md2man/v2/.gitignore | 2 +
|
||
.../cpuguy83/go-md2man/v2/.golangci.yml | 6 +
|
||
.../cpuguy83/go-md2man/v2/Dockerfile | 20 +
|
||
.../cpuguy83/go-md2man/v2/LICENSE.md | 21 +
|
||
.../github.com/cpuguy83/go-md2man/v2/Makefile | 35 +
|
||
.../cpuguy83/go-md2man/v2/README.md | 15 +
|
||
.../cpuguy83/go-md2man/v2/go-md2man.1.md | 28 +
|
||
.../cpuguy83/go-md2man/v2/md2man.go | 53 +
|
||
.../cpuguy83/go-md2man/v2/md2man/md2man.go | 16 +
|
||
.../cpuguy83/go-md2man/v2/md2man/roff.go | 348 ++
|
||
.../docker/cli-docs-tool/.dockerignore | 2 +
|
||
.../docker/cli-docs-tool/.gitignore | 2 +
|
||
.../docker/cli-docs-tool/.golangci.yml | 37 +
|
||
.../docker/cli-docs-tool/Dockerfile | 86 +
|
||
.../github.com/docker/cli-docs-tool/LICENSE | 202 ++
|
||
.../github.com/docker/cli-docs-tool/README.md | 67 +
|
||
.../cli-docs-tool/annotation/annotation.go | 25 +
|
||
.../docker/cli-docs-tool/clidocstool.go | 123 +
|
||
.../docker/cli-docs-tool/clidocstool_md.go | 280 ++
|
||
.../docker/cli-docs-tool/clidocstool_yaml.go | 435 +++
|
||
.../docker/cli-docs-tool/docker-bake.hcl | 51 +
|
||
.../docker/cli-docs-tool/markdown.go | 87 +
|
||
.../russross/blackfriday/v2/.gitignore | 8 +
|
||
.../russross/blackfriday/v2/.travis.yml | 17 +
|
||
.../russross/blackfriday/v2/LICENSE.txt | 29 +
|
||
.../russross/blackfriday/v2/README.md | 335 ++
|
||
.../russross/blackfriday/v2/block.go | 1612 +++++++++
|
||
.../github.com/russross/blackfriday/v2/doc.go | 46 +
|
||
.../russross/blackfriday/v2/entities.go | 2236 ++++++++++++
|
||
.../github.com/russross/blackfriday/v2/esc.go | 70 +
|
||
.../russross/blackfriday/v2/html.go | 952 ++++++
|
||
.../russross/blackfriday/v2/inline.go | 1228 +++++++
|
||
.../russross/blackfriday/v2/markdown.go | 950 ++++++
|
||
.../russross/blackfriday/v2/node.go | 360 ++
|
||
.../russross/blackfriday/v2/smartypants.go | 457 +++
|
||
vendor/github.com/spf13/cobra/doc/README.md | 17 +
|
||
vendor/github.com/spf13/cobra/doc/man_docs.go | 246 ++
|
||
vendor/github.com/spf13/cobra/doc/man_docs.md | 31 +
|
||
vendor/github.com/spf13/cobra/doc/md_docs.go | 156 +
|
||
vendor/github.com/spf13/cobra/doc/md_docs.md | 115 +
|
||
.../github.com/spf13/cobra/doc/rest_docs.go | 186 +
|
||
.../github.com/spf13/cobra/doc/rest_docs.md | 114 +
|
||
vendor/github.com/spf13/cobra/doc/util.go | 52 +
|
||
.../github.com/spf13/cobra/doc/yaml_docs.go | 175 +
|
||
.../github.com/spf13/cobra/doc/yaml_docs.md | 112 +
|
||
.../googleapis/rpc/status/status.pb.go | 10 +-
|
||
.../grpc/attributes/attributes.go | 2 +-
|
||
vendor/google.golang.org/grpc/backoff.go | 2 +-
|
||
.../grpc/balancer/balancer.go | 31 +
|
||
.../grpc/balancer/base/balancer.go | 4 +-
|
||
.../grpc/balancer/conn_state_evaluator.go | 12 +-
|
||
.../grpc/balancer_conn_wrappers.go | 71 +-
|
||
.../grpc_binarylog_v1/binarylog.pb.go | 20 +-
|
||
.../grpc/channelz/channelz.go | 2 +-
|
||
vendor/google.golang.org/grpc/clientconn.go | 173 +-
|
||
.../grpc/credentials/credentials.go | 20 +-
|
||
.../google.golang.org/grpc/credentials/tls.go | 6 +-
|
||
vendor/google.golang.org/grpc/dialoptions.go | 25 +-
|
||
.../grpc/encoding/encoding.go | 7 +-
|
||
.../grpc/grpclog/loggerv2.go | 9 +-
|
||
.../grpc/internal/binarylog/env_config.go | 18 +-
|
||
.../grpc/internal/binarylog/method_logger.go | 128 +-
|
||
.../grpc/internal/binarylog/sink.go | 12 +-
|
||
.../grpc/internal/channelz/types.go | 16 +-
|
||
.../grpc/internal/envconfig/envconfig.go | 39 +-
|
||
.../grpc/internal/envconfig/xds.go | 31 +-
|
||
.../grpc/internal/grpclog/grpclog.go | 2 +-
|
||
.../grpc/internal/grpcsync/oncefunc.go | 32 +
|
||
.../grpc/internal/grpcutil/compressor.go | 47 +
|
||
.../grpc/internal/grpcutil/method.go | 1 -
|
||
.../grpc/internal/internal.go | 3 +
|
||
.../internal/resolver/dns/dns_resolver.go | 6 +-
|
||
.../resolver/passthrough/passthrough.go | 11 +-
|
||
.../grpc/internal/resolver/unix/unix.go | 4 +-
|
||
.../internal/serviceconfig/serviceconfig.go | 8 +-
|
||
.../grpc/internal/status/status.go | 10 +
|
||
.../grpc/internal/transport/controlbuf.go | 62 +-
|
||
.../grpc/internal/transport/defaults.go | 6 +
|
||
.../grpc/internal/transport/handler_server.go | 53 +-
|
||
.../grpc/internal/transport/http2_client.go | 261 +-
|
||
.../grpc/internal/transport/http2_server.go | 142 +-
|
||
.../grpc/internal/transport/transport.go | 16 +-
|
||
.../grpc/metadata/metadata.go | 20 +-
|
||
.../google.golang.org/grpc/picker_wrapper.go | 35 +-
|
||
vendor/google.golang.org/grpc/pickfirst.go | 6 +-
|
||
vendor/google.golang.org/grpc/preloader.go | 2 +-
|
||
vendor/google.golang.org/grpc/regenerate.sh | 7 +-
|
||
.../grpc/resolver/resolver.go | 36 +-
|
||
vendor/google.golang.org/grpc/rpc_util.go | 56 +-
|
||
vendor/google.golang.org/grpc/server.go | 79 +-
|
||
.../google.golang.org/grpc/service_config.go | 10 +-
|
||
.../grpc/serviceconfig/serviceconfig.go | 2 +-
|
||
.../google.golang.org/grpc/status/status.go | 12 +-
|
||
vendor/google.golang.org/grpc/stream.go | 62 +-
|
||
vendor/google.golang.org/grpc/tap/tap.go | 2 +-
|
||
vendor/google.golang.org/grpc/version.go | 2 +-
|
||
vendor/google.golang.org/grpc/vet.sh | 29 +-
|
||
.../protobuf/encoding/protojson/doc.go | 2 +-
|
||
.../encoding/protojson/well_known_types.go | 12 +-
|
||
.../protobuf/encoding/protowire/wire.go | 8 +-
|
||
.../protobuf/internal/encoding/json/decode.go | 2 +-
|
||
.../protobuf/internal/encoding/text/decode.go | 5 +-
|
||
.../internal/encoding/text/decode_number.go | 43 +-
|
||
.../protobuf/internal/genid/descriptor_gen.go | 90 +-
|
||
.../protobuf/internal/impl/convert.go | 1 -
|
||
.../protobuf/internal/strs/strings_unsafe.go | 2 +-
|
||
.../protobuf/internal/version/version.go | 4 +-
|
||
.../google.golang.org/protobuf/proto/doc.go | 9 +-
|
||
.../google.golang.org/protobuf/proto/equal.go | 172 +-
|
||
.../reflect/protoreflect/source_gen.go | 14 +
|
||
.../protobuf/reflect/protoreflect/value.go | 2 +-
|
||
.../reflect/protoreflect/value_equal.go | 168 +
|
||
.../reflect/protoreflect/value_union.go | 4 +-
|
||
.../reflect/protoregistry/registry.go | 2 +-
|
||
.../types/descriptorpb/descriptor.pb.go | 1547 +++++----
|
||
.../protobuf/types/known/anypb/any.pb.go | 135 +-
|
||
.../types/known/durationpb/duration.pb.go | 63 +-
|
||
.../types/known/timestamppb/timestamp.pb.go | 61 +-
|
||
vendor/gopkg.in/yaml.v3/LICENSE | 50 +
|
||
vendor/gopkg.in/yaml.v3/NOTICE | 13 +
|
||
vendor/gopkg.in/yaml.v3/README.md | 150 +
|
||
vendor/gopkg.in/yaml.v3/apic.go | 747 ++++
|
||
vendor/gopkg.in/yaml.v3/decode.go | 1000 ++++++
|
||
vendor/gopkg.in/yaml.v3/emitterc.go | 2020 +++++++++++
|
||
vendor/gopkg.in/yaml.v3/encode.go | 577 ++++
|
||
vendor/gopkg.in/yaml.v3/parserc.go | 1258 +++++++
|
||
vendor/gopkg.in/yaml.v3/readerc.go | 434 +++
|
||
vendor/gopkg.in/yaml.v3/resolve.go | 326 ++
|
||
vendor/gopkg.in/yaml.v3/scannerc.go | 3038 +++++++++++++++++
|
||
vendor/gopkg.in/yaml.v3/sorter.go | 134 +
|
||
vendor/gopkg.in/yaml.v3/writerc.go | 48 +
|
||
vendor/gopkg.in/yaml.v3/yaml.go | 698 ++++
|
||
vendor/gopkg.in/yaml.v3/yamlh.go | 807 +++++
|
||
vendor/gopkg.in/yaml.v3/yamlprivateh.go | 198 ++
|
||
vendor/modules.txt | 25 +-
|
||
153 files changed, 25896 insertions(+), 1912 deletions(-)
|
||
delete mode 100644 docs/generate/go.mod
|
||
delete mode 100644 docs/generate/tools.go
|
||
create mode 100644 import.go
|
||
delete mode 100644 man/tools.go
|
||
create mode 100644 vendor/github.com/cespare/xxhash/v2/testall.sh
|
||
create mode 100644 vendor/github.com/cespare/xxhash/v2/xxhash_arm64.s
|
||
rename vendor/github.com/cespare/xxhash/v2/{xxhash_amd64.go => xxhash_asm.go} (73%)
|
||
create mode 100644 vendor/github.com/cpuguy83/go-md2man/v2/.gitignore
|
||
create mode 100644 vendor/github.com/cpuguy83/go-md2man/v2/.golangci.yml
|
||
create mode 100644 vendor/github.com/cpuguy83/go-md2man/v2/Dockerfile
|
||
create mode 100644 vendor/github.com/cpuguy83/go-md2man/v2/LICENSE.md
|
||
create mode 100644 vendor/github.com/cpuguy83/go-md2man/v2/Makefile
|
||
create mode 100644 vendor/github.com/cpuguy83/go-md2man/v2/README.md
|
||
create mode 100644 vendor/github.com/cpuguy83/go-md2man/v2/go-md2man.1.md
|
||
create mode 100644 vendor/github.com/cpuguy83/go-md2man/v2/md2man.go
|
||
create mode 100644 vendor/github.com/cpuguy83/go-md2man/v2/md2man/md2man.go
|
||
create mode 100644 vendor/github.com/cpuguy83/go-md2man/v2/md2man/roff.go
|
||
create mode 100644 vendor/github.com/docker/cli-docs-tool/.dockerignore
|
||
create mode 100644 vendor/github.com/docker/cli-docs-tool/.gitignore
|
||
create mode 100644 vendor/github.com/docker/cli-docs-tool/.golangci.yml
|
||
create mode 100644 vendor/github.com/docker/cli-docs-tool/Dockerfile
|
||
create mode 100644 vendor/github.com/docker/cli-docs-tool/LICENSE
|
||
create mode 100644 vendor/github.com/docker/cli-docs-tool/README.md
|
||
create mode 100644 vendor/github.com/docker/cli-docs-tool/annotation/annotation.go
|
||
create mode 100644 vendor/github.com/docker/cli-docs-tool/clidocstool.go
|
||
create mode 100644 vendor/github.com/docker/cli-docs-tool/clidocstool_md.go
|
||
create mode 100644 vendor/github.com/docker/cli-docs-tool/clidocstool_yaml.go
|
||
create mode 100644 vendor/github.com/docker/cli-docs-tool/docker-bake.hcl
|
||
create mode 100644 vendor/github.com/docker/cli-docs-tool/markdown.go
|
||
create mode 100644 vendor/github.com/russross/blackfriday/v2/.gitignore
|
||
create mode 100644 vendor/github.com/russross/blackfriday/v2/.travis.yml
|
||
create mode 100644 vendor/github.com/russross/blackfriday/v2/LICENSE.txt
|
||
create mode 100644 vendor/github.com/russross/blackfriday/v2/README.md
|
||
create mode 100644 vendor/github.com/russross/blackfriday/v2/block.go
|
||
create mode 100644 vendor/github.com/russross/blackfriday/v2/doc.go
|
||
create mode 100644 vendor/github.com/russross/blackfriday/v2/entities.go
|
||
create mode 100644 vendor/github.com/russross/blackfriday/v2/esc.go
|
||
create mode 100644 vendor/github.com/russross/blackfriday/v2/html.go
|
||
create mode 100644 vendor/github.com/russross/blackfriday/v2/inline.go
|
||
create mode 100644 vendor/github.com/russross/blackfriday/v2/markdown.go
|
||
create mode 100644 vendor/github.com/russross/blackfriday/v2/node.go
|
||
create mode 100644 vendor/github.com/russross/blackfriday/v2/smartypants.go
|
||
create mode 100644 vendor/github.com/spf13/cobra/doc/README.md
|
||
create mode 100644 vendor/github.com/spf13/cobra/doc/man_docs.go
|
||
create mode 100644 vendor/github.com/spf13/cobra/doc/man_docs.md
|
||
create mode 100644 vendor/github.com/spf13/cobra/doc/md_docs.go
|
||
create mode 100644 vendor/github.com/spf13/cobra/doc/md_docs.md
|
||
create mode 100644 vendor/github.com/spf13/cobra/doc/rest_docs.go
|
||
create mode 100644 vendor/github.com/spf13/cobra/doc/rest_docs.md
|
||
create mode 100644 vendor/github.com/spf13/cobra/doc/util.go
|
||
create mode 100644 vendor/github.com/spf13/cobra/doc/yaml_docs.go
|
||
create mode 100644 vendor/github.com/spf13/cobra/doc/yaml_docs.md
|
||
create mode 100644 vendor/google.golang.org/grpc/internal/grpcsync/oncefunc.go
|
||
create mode 100644 vendor/google.golang.org/grpc/internal/grpcutil/compressor.go
|
||
create mode 100644 vendor/google.golang.org/protobuf/reflect/protoreflect/value_equal.go
|
||
create mode 100644 vendor/gopkg.in/yaml.v3/LICENSE
|
||
create mode 100644 vendor/gopkg.in/yaml.v3/NOTICE
|
||
create mode 100644 vendor/gopkg.in/yaml.v3/README.md
|
||
create mode 100644 vendor/gopkg.in/yaml.v3/apic.go
|
||
create mode 100644 vendor/gopkg.in/yaml.v3/decode.go
|
||
create mode 100644 vendor/gopkg.in/yaml.v3/emitterc.go
|
||
create mode 100644 vendor/gopkg.in/yaml.v3/encode.go
|
||
create mode 100644 vendor/gopkg.in/yaml.v3/parserc.go
|
||
create mode 100644 vendor/gopkg.in/yaml.v3/readerc.go
|
||
create mode 100644 vendor/gopkg.in/yaml.v3/resolve.go
|
||
create mode 100644 vendor/gopkg.in/yaml.v3/scannerc.go
|
||
create mode 100644 vendor/gopkg.in/yaml.v3/sorter.go
|
||
create mode 100644 vendor/gopkg.in/yaml.v3/writerc.go
|
||
create mode 100644 vendor/gopkg.in/yaml.v3/yaml.go
|
||
create mode 100644 vendor/gopkg.in/yaml.v3/yamlh.go
|
||
create mode 100644 vendor/gopkg.in/yaml.v3/yamlprivateh.go
|
||
|
||
diff --git a/docs/generate/go.mod b/docs/generate/go.mod
|
||
deleted file mode 100644
|
||
index d62ff455713a..000000000000
|
||
--- a/docs/generate/go.mod
|
||
+++ /dev/null
|
||
@@ -1,13 +0,0 @@
|
||
-module github.com/docker/cli/docs/generate
|
||
-
|
||
-// dummy go.mod to avoid dealing with dependencies specific
|
||
-// to docs generation and not really part of the project.
|
||
-
|
||
-go 1.16
|
||
-
|
||
-//require (
|
||
-// github.com/docker/cli v0.0.0+incompatible
|
||
-// github.com/docker/cli-docs-tool v0.5.0
|
||
-//)
|
||
-//
|
||
-//replace github.com/docker/cli v0.0.0+incompatible => ../../
|
||
diff --git a/docs/generate/tools.go b/docs/generate/tools.go
|
||
deleted file mode 100644
|
||
index 47510bc49a89..000000000000
|
||
--- a/docs/generate/tools.go
|
||
+++ /dev/null
|
||
@@ -1,8 +0,0 @@
|
||
-//go:build tools
|
||
-// +build tools
|
||
-
|
||
-package main
|
||
-
|
||
-import (
|
||
- _ "github.com/docker/cli-docs-tool"
|
||
-)
|
||
diff --git a/import.go b/import.go
|
||
new file mode 100644
|
||
index 000000000000..662a6055146c
|
||
--- /dev/null
|
||
+++ b/import.go
|
||
@@ -0,0 +1,17 @@
|
||
+// This is only used to define imports we need for doc generation.
|
||
+
|
||
+//go:build never
|
||
+// +build never
|
||
+
|
||
+package cli
|
||
+
|
||
+import (
|
||
+ // Used for md and yaml doc generation.
|
||
+ _ "github.com/docker/cli-docs-tool"
|
||
+
|
||
+ // Used for man page generation.
|
||
+ _ "github.com/cpuguy83/go-md2man/v2"
|
||
+ _ "github.com/spf13/cobra"
|
||
+ _ "github.com/spf13/cobra/doc"
|
||
+ _ "github.com/spf13/pflag"
|
||
+)
|
||
diff --git a/man/tools.go b/man/tools.go
|
||
deleted file mode 100644
|
||
index 3cafe6533aff..000000000000
|
||
--- a/man/tools.go
|
||
+++ /dev/null
|
||
@@ -1,11 +0,0 @@
|
||
-//go:build tools
|
||
-// +build tools
|
||
-
|
||
-package main
|
||
-
|
||
-import (
|
||
- _ "github.com/cpuguy83/go-md2man/v2"
|
||
- _ "github.com/spf13/cobra"
|
||
- _ "github.com/spf13/cobra/doc"
|
||
- _ "github.com/spf13/pflag"
|
||
-)
|
||
diff --git a/scripts/docs/generate-man.sh b/scripts/docs/generate-man.sh
|
||
index 12a4b81199db..1e12a95e9c9a 100755
|
||
--- a/scripts/docs/generate-man.sh
|
||
+++ b/scripts/docs/generate-man.sh
|
||
@@ -1,35 +1,22 @@
|
||
#!/usr/bin/env bash
|
||
|
||
-set -eu
|
||
-
|
||
-: "${MD2MAN_VERSION=v2.0.3}"
|
||
+set -Eeuo pipefail
|
||
|
||
export GO111MODULE=auto
|
||
|
||
-function clean {
|
||
- rm -rf "$buildir"
|
||
+# temporary "go.mod" to make -modfile= work
|
||
+touch go.mod
|
||
+
|
||
+function clean() {
|
||
+ rm -f "$(pwd)/go.mod"
|
||
}
|
||
|
||
-buildir=$(mktemp -d -t docker-cli-docsgen.XXXXXXXXXX)
|
||
trap clean EXIT
|
||
|
||
-(
|
||
- set -x
|
||
- cp -r . "$buildir/"
|
||
- cd "$buildir"
|
||
- # init dummy go.mod
|
||
- ./scripts/vendor init
|
||
- # install go-md2man and copy man/tools.go in root folder
|
||
- # to be able to fetch the required dependencies
|
||
- go mod edit -modfile=vendor.mod -require=github.com/cpuguy83/go-md2man/v2@${MD2MAN_VERSION}
|
||
- cp man/tools.go .
|
||
- # update vendor
|
||
- ./scripts/vendor update
|
||
- # build gen-manpages
|
||
- go build -mod=vendor -modfile=vendor.mod -tags manpages -o /tmp/gen-manpages ./man/generate.go
|
||
- # build go-md2man
|
||
- go build -mod=vendor -modfile=vendor.mod -o /tmp/go-md2man ./vendor/github.com/cpuguy83/go-md2man/v2
|
||
-)
|
||
+# build gen-manpages
|
||
+go build -mod=vendor -modfile=vendor.mod -tags manpages -o /tmp/gen-manpages ./man/generate.go
|
||
+# build go-md2man
|
||
+go build -mod=vendor -modfile=vendor.mod -o /tmp/go-md2man ./vendor/github.com/cpuguy83/go-md2man/v2
|
||
|
||
mkdir -p man/man1
|
||
(set -x ; /tmp/gen-manpages --root "." --target "$(pwd)/man/man1")
|
||
diff --git a/scripts/docs/generate-md.sh b/scripts/docs/generate-md.sh
|
||
index 7b49c39341ec..0af86843bbe4 100755
|
||
--- a/scripts/docs/generate-md.sh
|
||
+++ b/scripts/docs/generate-md.sh
|
||
@@ -1,36 +1,23 @@
|
||
#!/usr/bin/env bash
|
||
|
||
-set -eu
|
||
-
|
||
-: "${CLI_DOCS_TOOL_VERSION=v0.6.0}"
|
||
+set -Eeuo pipefail
|
||
|
||
export GO111MODULE=auto
|
||
|
||
+# temporary "go.mod" to make -modfile= work
|
||
+touch go.mod
|
||
+
|
||
function clean {
|
||
- rm -rf "$buildir"
|
||
+ rm -f "$(pwd)/go.mod"
|
||
if [ -f "$(pwd)/docs/reference/commandline/docker.md" ]; then
|
||
mv "$(pwd)/docs/reference/commandline/docker.md" "$(pwd)/docs/reference/commandline/cli.md"
|
||
fi
|
||
}
|
||
|
||
-buildir=$(mktemp -d -t docker-cli-docsgen.XXXXXXXXXX)
|
||
trap clean EXIT
|
||
|
||
-(
|
||
- set -x
|
||
- cp -r . "$buildir/"
|
||
- cd "$buildir"
|
||
- # init dummy go.mod
|
||
- ./scripts/vendor init
|
||
- # install cli-docs-tool and copy docs/tools.go in root folder
|
||
- # to be able to fetch the required depedencies
|
||
- go mod edit -modfile=vendor.mod -require=github.com/docker/cli-docs-tool@${CLI_DOCS_TOOL_VERSION}
|
||
- cp docs/generate/tools.go .
|
||
- # update vendor
|
||
- ./scripts/vendor update
|
||
- # build docsgen
|
||
- go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate/generate.go
|
||
-)
|
||
+# build docsgen
|
||
+go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate/generate.go
|
||
|
||
# yaml generation on docs repo needs the cli.md file: https://github.com/docker/cli/pull/3924#discussion_r1059986605
|
||
# but markdown generation docker.md atm. While waiting for a fix in cli-docs-tool
|
||
diff --git a/scripts/docs/generate-yaml.sh b/scripts/docs/generate-yaml.sh
|
||
index 4d0006e43e79..7d98e161df5d 100755
|
||
--- a/scripts/docs/generate-yaml.sh
|
||
+++ b/scripts/docs/generate-yaml.sh
|
||
@@ -1,33 +1,20 @@
|
||
#!/usr/bin/env bash
|
||
|
||
-set -eu
|
||
-
|
||
-: "${CLI_DOCS_TOOL_VERSION=v0.5.1}"
|
||
+set -Eeuo pipefail
|
||
|
||
export GO111MODULE=auto
|
||
|
||
-function clean {
|
||
- rm -rf "$buildir"
|
||
+# temporary "go.mod" to make -modfile= work
|
||
+touch go.mod
|
||
+
|
||
+function clean() {
|
||
+ rm -f "$(pwd)/go.mod"
|
||
}
|
||
|
||
-buildir=$(mktemp -d -t docker-cli-docsgen.XXXXXXXXXX)
|
||
trap clean EXIT
|
||
|
||
-(
|
||
- set -x
|
||
- cp -r . "$buildir/"
|
||
- cd "$buildir"
|
||
- # init dummy go.mod
|
||
- ./scripts/vendor init
|
||
- # install cli-docs-tool and copy docs/tools.go in root folder
|
||
- # to be able to fetch the required depedencies
|
||
- go mod edit -modfile=vendor.mod -require=github.com/docker/cli-docs-tool@${CLI_DOCS_TOOL_VERSION}
|
||
- cp docs/generate/tools.go .
|
||
- # update vendor
|
||
- ./scripts/vendor update
|
||
- # build docsgen
|
||
- go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate/generate.go
|
||
-)
|
||
+# build docsgen
|
||
+go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate/generate.go
|
||
|
||
mkdir -p docs/yaml
|
||
set -x
|
||
diff --git a/vendor.mod b/vendor.mod
|
||
index faa76e36787e..0c724da90ad8 100644
|
||
--- a/vendor.mod
|
||
+++ b/vendor.mod
|
||
@@ -9,6 +9,7 @@ go 1.19
|
||
require (
|
||
github.com/containerd/containerd v1.6.21
|
||
github.com/creack/pty v1.1.18
|
||
+ github.com/docker/cli-docs-tool v0.6.0
|
||
github.com/docker/distribution v2.8.2+incompatible
|
||
github.com/docker/docker v24.0.6+incompatible
|
||
github.com/docker/docker-credential-helpers v0.7.0
|
||
@@ -45,11 +46,13 @@ require (
|
||
gotest.tools/v3 v3.5.0
|
||
)
|
||
|
||
+require github.com/cpuguy83/go-md2man/v2 v2.0.3
|
||
+
|
||
require (
|
||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
|
||
github.com/Microsoft/go-winio v0.5.2 // indirect
|
||
github.com/beorn7/perks v1.0.1 // indirect
|
||
- github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||
+ github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect
|
||
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
|
||
github.com/docker/go-metrics v0.0.1 // indirect
|
||
@@ -67,13 +70,15 @@ require (
|
||
github.com/prometheus/common v0.37.0 // indirect
|
||
github.com/prometheus/procfs v0.8.0 // indirect
|
||
github.com/rivo/uniseg v0.2.0 // indirect
|
||
+ github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||
go.etcd.io/etcd/raft/v3 v3.5.6 // indirect
|
||
golang.org/x/crypto v0.14.0 // indirect
|
||
golang.org/x/net v0.17.0 // indirect
|
||
golang.org/x/time v0.3.0 // indirect
|
||
- google.golang.org/genproto v0.0.0-20220706185917-7780775163c4 // indirect
|
||
- google.golang.org/grpc v1.50.1 // indirect
|
||
- google.golang.org/protobuf v1.28.1 // indirect
|
||
+ google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
|
||
+ google.golang.org/grpc v1.53.0 // indirect
|
||
+ google.golang.org/protobuf v1.30.0 // indirect
|
||
+ gopkg.in/yaml.v3 v3.0.1 // indirect
|
||
)
|
||
diff --git a/vendor.sum b/vendor.sum
|
||
index 0c5e44d643ce..1102efc6b68d 100644
|
||
--- a/vendor.sum
|
||
+++ b/vendor.sum
|
||
@@ -47,7 +47,6 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
|
||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||
-github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||
@@ -65,8 +64,9 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA
|
||
github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
|
||
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
|
||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||
-github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||
+github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||
+github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||
@@ -74,11 +74,6 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
|
||
github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004/go.mod h1:yMWuSON2oQp+43nFtAV/uvKQIFpSPerB57DCt9t8sSA=
|
||
github.com/cloudflare/cfssl v0.0.0-20180323000720-5d63dbd981b5 h1:PqZ3bA4yzwywivzk7PBQWngJp2/PAS0bWRZerKteicY=
|
||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||
-github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||
-github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
|
||
-github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||
-github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||
-github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||
github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo=
|
||
github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA=
|
||
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
|
||
@@ -86,6 +81,8 @@ github.com/containerd/containerd v1.6.21 h1:eSTAmnvDKRPWan+MpSSfNyrtleXd86ogK9X8
|
||
github.com/containerd/containerd v1.6.21/go.mod h1:apei1/i5Ux2FzrK6+DM/suEsGuK/MeVOfy8tR2q7Wnw=
|
||
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||
+github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM=
|
||
+github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
|
||
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
|
||
@@ -93,6 +90,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||
github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||
+github.com/docker/cli-docs-tool v0.6.0 h1:Z9x10SaZgFaB6jHgz3OWooynhSa40CsWkpe5hEnG/qA=
|
||
+github.com/docker/cli-docs-tool v0.6.0/go.mod h1:zMjqTFCU361PRh8apiXzeAZ1Q/xupbIwTusYpzCXS/o=
|
||
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
|
||
github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||
@@ -117,15 +116,12 @@ github.com/dvsekhvalnov/jose2go v0.0.0-20170216131308-f21a8cedbbae/go.mod h1:7Bv
|
||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||
-github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||
-github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
|
||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||
github.com/fvbommel/sortorder v1.0.2 h1:mV4o8B2hKboCdkJm+a7uX/SIpZob4JzUpc5GGnM45eo=
|
||
github.com/fvbommel/sortorder v1.0.2/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0=
|
||
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
|
||
-github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||
@@ -190,7 +186,6 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||
-github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||
@@ -206,13 +201,11 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf
|
||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
|
||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
|
||
-github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||
github.com/gorilla/mux v1.7.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
||
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||
-github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
|
||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
|
||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||
@@ -348,8 +341,8 @@ github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5
|
||
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
|
||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||
-github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||
+github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||
github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
|
||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||
@@ -403,7 +396,6 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||
-go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
|
||
@@ -478,7 +470,6 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R
|
||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||
-golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||
@@ -540,12 +531,9 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w
|
||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||
-golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||
-golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||
-golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||
@@ -565,7 +553,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||
-golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||
@@ -667,15 +654,14 @@ google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfG
|
||
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||
-google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
|
||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
|
||
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||
-google.golang.org/genproto v0.0.0-20220706185917-7780775163c4 h1:7YDGQC/0sigNGzsEWyb9s72jTxlFdwVEYNJHbfQ+Dtg=
|
||
-google.golang.org/genproto v0.0.0-20220706185917-7780775163c4/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA=
|
||
+google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT/emMP1BRJPHHKFi5akj/nbx/zNTA=
|
||
+google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s=
|
||
google.golang.org/grpc v1.0.5/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||
@@ -689,11 +675,8 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa
|
||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||
-google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||
-google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||
-google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
|
||
-google.golang.org/grpc v1.50.1 h1:DS/BukOZWp8s6p4Dt/tOaJaTQyPyOoCcrjroHuCeLzY=
|
||
-google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
|
||
+google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc=
|
||
+google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw=
|
||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||
@@ -706,10 +689,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
|
||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||
-google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||
-google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||
-google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
||
-google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||
+google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
|
||
+google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
|
||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||
gopkg.in/cenkalti/backoff.v2 v2.2.1 h1:eJ9UAg01/HIHG987TwxvnzK2MgxXq97YY6rYDpY9aII=
|
||
@@ -727,7 +708,6 @@ gopkg.in/rethinkdb/rethinkdb-go.v6 v6.2.1/go.mod h1:WbjuEoo1oadwzQ4apSDU+JTvmllE
|
||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||
-gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||
diff --git a/vendor/github.com/cespare/xxhash/v2/README.md b/vendor/github.com/cespare/xxhash/v2/README.md
|
||
index 792b4a60b346..8bf0e5b78153 100644
|
||
--- a/vendor/github.com/cespare/xxhash/v2/README.md
|
||
+++ b/vendor/github.com/cespare/xxhash/v2/README.md
|
||
@@ -3,8 +3,7 @@
|
||
[](https://pkg.go.dev/github.com/cespare/xxhash/v2)
|
||
[](https://github.com/cespare/xxhash/actions/workflows/test.yml)
|
||
|
||
-xxhash is a Go implementation of the 64-bit
|
||
-[xxHash](http://cyan4973.github.io/xxHash/) algorithm, XXH64. This is a
|
||
+xxhash is a Go implementation of the 64-bit [xxHash] algorithm, XXH64. This is a
|
||
high-quality hashing algorithm that is much faster than anything in the Go
|
||
standard library.
|
||
|
||
@@ -25,8 +24,11 @@ func (*Digest) WriteString(string) (int, error)
|
||
func (*Digest) Sum64() uint64
|
||
```
|
||
|
||
-This implementation provides a fast pure-Go implementation and an even faster
|
||
-assembly implementation for amd64.
|
||
+The package is written with optimized pure Go and also contains even faster
|
||
+assembly implementations for amd64 and arm64. If desired, the `purego` build tag
|
||
+opts into using the Go code even on those architectures.
|
||
+
|
||
+[xxHash]: http://cyan4973.github.io/xxHash/
|
||
|
||
## Compatibility
|
||
|
||
@@ -45,19 +47,20 @@ I recommend using the latest release of Go.
|
||
Here are some quick benchmarks comparing the pure-Go and assembly
|
||
implementations of Sum64.
|
||
|
||
-| input size | purego | asm |
|
||
-| --- | --- | --- |
|
||
-| 5 B | 979.66 MB/s | 1291.17 MB/s |
|
||
-| 100 B | 7475.26 MB/s | 7973.40 MB/s |
|
||
-| 4 KB | 17573.46 MB/s | 17602.65 MB/s |
|
||
-| 10 MB | 17131.46 MB/s | 17142.16 MB/s |
|
||
+| input size | purego | asm |
|
||
+| ---------- | --------- | --------- |
|
||
+| 4 B | 1.3 GB/s | 1.2 GB/s |
|
||
+| 16 B | 2.9 GB/s | 3.5 GB/s |
|
||
+| 100 B | 6.9 GB/s | 8.1 GB/s |
|
||
+| 4 KB | 11.7 GB/s | 16.7 GB/s |
|
||
+| 10 MB | 12.0 GB/s | 17.3 GB/s |
|
||
|
||
-These numbers were generated on Ubuntu 18.04 with an Intel i7-8700K CPU using
|
||
-the following commands under Go 1.11.2:
|
||
+These numbers were generated on Ubuntu 20.04 with an Intel Xeon Platinum 8252C
|
||
+CPU using the following commands under Go 1.19.2:
|
||
|
||
```
|
||
-$ go test -tags purego -benchtime 10s -bench '/xxhash,direct,bytes'
|
||
-$ go test -benchtime 10s -bench '/xxhash,direct,bytes'
|
||
+benchstat <(go test -tags purego -benchtime 500ms -count 15 -bench 'Sum64$')
|
||
+benchstat <(go test -benchtime 500ms -count 15 -bench 'Sum64$')
|
||
```
|
||
|
||
## Projects using this package
|
||
diff --git a/vendor/github.com/cespare/xxhash/v2/testall.sh b/vendor/github.com/cespare/xxhash/v2/testall.sh
|
||
new file mode 100644
|
||
index 000000000000..94b9c443987c
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/cespare/xxhash/v2/testall.sh
|
||
@@ -0,0 +1,10 @@
|
||
+#!/bin/bash
|
||
+set -eu -o pipefail
|
||
+
|
||
+# Small convenience script for running the tests with various combinations of
|
||
+# arch/tags. This assumes we're running on amd64 and have qemu available.
|
||
+
|
||
+go test ./...
|
||
+go test -tags purego ./...
|
||
+GOARCH=arm64 go test
|
||
+GOARCH=arm64 go test -tags purego
|
||
diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash.go b/vendor/github.com/cespare/xxhash/v2/xxhash.go
|
||
index 15c835d5417c..a9e0d45c9dcc 100644
|
||
--- a/vendor/github.com/cespare/xxhash/v2/xxhash.go
|
||
+++ b/vendor/github.com/cespare/xxhash/v2/xxhash.go
|
||
@@ -16,19 +16,11 @@ const (
|
||
prime5 uint64 = 2870177450012600261
|
||
)
|
||
|
||
-// NOTE(caleb): I'm using both consts and vars of the primes. Using consts where
|
||
-// possible in the Go code is worth a small (but measurable) performance boost
|
||
-// by avoiding some MOVQs. Vars are needed for the asm and also are useful for
|
||
-// convenience in the Go code in a few places where we need to intentionally
|
||
-// avoid constant arithmetic (e.g., v1 := prime1 + prime2 fails because the
|
||
-// result overflows a uint64).
|
||
-var (
|
||
- prime1v = prime1
|
||
- prime2v = prime2
|
||
- prime3v = prime3
|
||
- prime4v = prime4
|
||
- prime5v = prime5
|
||
-)
|
||
+// Store the primes in an array as well.
|
||
+//
|
||
+// The consts are used when possible in Go code to avoid MOVs but we need a
|
||
+// contiguous array of the assembly code.
|
||
+var primes = [...]uint64{prime1, prime2, prime3, prime4, prime5}
|
||
|
||
// Digest implements hash.Hash64.
|
||
type Digest struct {
|
||
@@ -50,10 +42,10 @@ func New() *Digest {
|
||
|
||
// Reset clears the Digest's state so that it can be reused.
|
||
func (d *Digest) Reset() {
|
||
- d.v1 = prime1v + prime2
|
||
+ d.v1 = primes[0] + prime2
|
||
d.v2 = prime2
|
||
d.v3 = 0
|
||
- d.v4 = -prime1v
|
||
+ d.v4 = -primes[0]
|
||
d.total = 0
|
||
d.n = 0
|
||
}
|
||
@@ -69,21 +61,23 @@ func (d *Digest) Write(b []byte) (n int, err error) {
|
||
n = len(b)
|
||
d.total += uint64(n)
|
||
|
||
+ memleft := d.mem[d.n&(len(d.mem)-1):]
|
||
+
|
||
if d.n+n < 32 {
|
||
// This new data doesn't even fill the current block.
|
||
- copy(d.mem[d.n:], b)
|
||
+ copy(memleft, b)
|
||
d.n += n
|
||
return
|
||
}
|
||
|
||
if d.n > 0 {
|
||
// Finish off the partial block.
|
||
- copy(d.mem[d.n:], b)
|
||
+ c := copy(memleft, b)
|
||
d.v1 = round(d.v1, u64(d.mem[0:8]))
|
||
d.v2 = round(d.v2, u64(d.mem[8:16]))
|
||
d.v3 = round(d.v3, u64(d.mem[16:24]))
|
||
d.v4 = round(d.v4, u64(d.mem[24:32]))
|
||
- b = b[32-d.n:]
|
||
+ b = b[c:]
|
||
d.n = 0
|
||
}
|
||
|
||
@@ -133,21 +127,20 @@ func (d *Digest) Sum64() uint64 {
|
||
|
||
h += d.total
|
||
|
||
- i, end := 0, d.n
|
||
- for ; i+8 <= end; i += 8 {
|
||
- k1 := round(0, u64(d.mem[i:i+8]))
|
||
+ b := d.mem[:d.n&(len(d.mem)-1)]
|
||
+ for ; len(b) >= 8; b = b[8:] {
|
||
+ k1 := round(0, u64(b[:8]))
|
||
h ^= k1
|
||
h = rol27(h)*prime1 + prime4
|
||
}
|
||
- if i+4 <= end {
|
||
- h ^= uint64(u32(d.mem[i:i+4])) * prime1
|
||
+ if len(b) >= 4 {
|
||
+ h ^= uint64(u32(b[:4])) * prime1
|
||
h = rol23(h)*prime2 + prime3
|
||
- i += 4
|
||
+ b = b[4:]
|
||
}
|
||
- for i < end {
|
||
- h ^= uint64(d.mem[i]) * prime5
|
||
+ for ; len(b) > 0; b = b[1:] {
|
||
+ h ^= uint64(b[0]) * prime5
|
||
h = rol11(h) * prime1
|
||
- i++
|
||
}
|
||
|
||
h ^= h >> 33
|
||
diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s b/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s
|
||
index be8db5bf7960..3e8b132579ec 100644
|
||
--- a/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s
|
||
+++ b/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s
|
||
@@ -1,215 +1,209 @@
|
||
+//go:build !appengine && gc && !purego
|
||
// +build !appengine
|
||
// +build gc
|
||
// +build !purego
|
||
|
||
#include "textflag.h"
|
||
|
||
-// Register allocation:
|
||
-// AX h
|
||
-// SI pointer to advance through b
|
||
-// DX n
|
||
-// BX loop end
|
||
-// R8 v1, k1
|
||
-// R9 v2
|
||
-// R10 v3
|
||
-// R11 v4
|
||
-// R12 tmp
|
||
-// R13 prime1v
|
||
-// R14 prime2v
|
||
-// DI prime4v
|
||
-
|
||
-// round reads from and advances the buffer pointer in SI.
|
||
-// It assumes that R13 has prime1v and R14 has prime2v.
|
||
-#define round(r) \
|
||
- MOVQ (SI), R12 \
|
||
- ADDQ $8, SI \
|
||
- IMULQ R14, R12 \
|
||
- ADDQ R12, r \
|
||
- ROLQ $31, r \
|
||
- IMULQ R13, r
|
||
-
|
||
-// mergeRound applies a merge round on the two registers acc and val.
|
||
-// It assumes that R13 has prime1v, R14 has prime2v, and DI has prime4v.
|
||
-#define mergeRound(acc, val) \
|
||
- IMULQ R14, val \
|
||
- ROLQ $31, val \
|
||
- IMULQ R13, val \
|
||
- XORQ val, acc \
|
||
- IMULQ R13, acc \
|
||
- ADDQ DI, acc
|
||
+// Registers:
|
||
+#define h AX
|
||
+#define d AX
|
||
+#define p SI // pointer to advance through b
|
||
+#define n DX
|
||
+#define end BX // loop end
|
||
+#define v1 R8
|
||
+#define v2 R9
|
||
+#define v3 R10
|
||
+#define v4 R11
|
||
+#define x R12
|
||
+#define prime1 R13
|
||
+#define prime2 R14
|
||
+#define prime4 DI
|
||
+
|
||
+#define round(acc, x) \
|
||
+ IMULQ prime2, x \
|
||
+ ADDQ x, acc \
|
||
+ ROLQ $31, acc \
|
||
+ IMULQ prime1, acc
|
||
+
|
||
+// round0 performs the operation x = round(0, x).
|
||
+#define round0(x) \
|
||
+ IMULQ prime2, x \
|
||
+ ROLQ $31, x \
|
||
+ IMULQ prime1, x
|
||
+
|
||
+// mergeRound applies a merge round on the two registers acc and x.
|
||
+// It assumes that prime1, prime2, and prime4 have been loaded.
|
||
+#define mergeRound(acc, x) \
|
||
+ round0(x) \
|
||
+ XORQ x, acc \
|
||
+ IMULQ prime1, acc \
|
||
+ ADDQ prime4, acc
|
||
+
|
||
+// blockLoop processes as many 32-byte blocks as possible,
|
||
+// updating v1, v2, v3, and v4. It assumes that there is at least one block
|
||
+// to process.
|
||
+#define blockLoop() \
|
||
+loop: \
|
||
+ MOVQ +0(p), x \
|
||
+ round(v1, x) \
|
||
+ MOVQ +8(p), x \
|
||
+ round(v2, x) \
|
||
+ MOVQ +16(p), x \
|
||
+ round(v3, x) \
|
||
+ MOVQ +24(p), x \
|
||
+ round(v4, x) \
|
||
+ ADDQ $32, p \
|
||
+ CMPQ p, end \
|
||
+ JLE loop
|
||
|
||
// func Sum64(b []byte) uint64
|
||
-TEXT ·Sum64(SB), NOSPLIT, $0-32
|
||
+TEXT ·Sum64(SB), NOSPLIT|NOFRAME, $0-32
|
||
// Load fixed primes.
|
||
- MOVQ ·prime1v(SB), R13
|
||
- MOVQ ·prime2v(SB), R14
|
||
- MOVQ ·prime4v(SB), DI
|
||
+ MOVQ ·primes+0(SB), prime1
|
||
+ MOVQ ·primes+8(SB), prime2
|
||
+ MOVQ ·primes+24(SB), prime4
|
||
|
||
// Load slice.
|
||
- MOVQ b_base+0(FP), SI
|
||
- MOVQ b_len+8(FP), DX
|
||
- LEAQ (SI)(DX*1), BX
|
||
+ MOVQ b_base+0(FP), p
|
||
+ MOVQ b_len+8(FP), n
|
||
+ LEAQ (p)(n*1), end
|
||
|
||
// The first loop limit will be len(b)-32.
|
||
- SUBQ $32, BX
|
||
+ SUBQ $32, end
|
||
|
||
// Check whether we have at least one block.
|
||
- CMPQ DX, $32
|
||
+ CMPQ n, $32
|
||
JLT noBlocks
|
||
|
||
// Set up initial state (v1, v2, v3, v4).
|
||
- MOVQ R13, R8
|
||
- ADDQ R14, R8
|
||
- MOVQ R14, R9
|
||
- XORQ R10, R10
|
||
- XORQ R11, R11
|
||
- SUBQ R13, R11
|
||
-
|
||
- // Loop until SI > BX.
|
||
-blockLoop:
|
||
- round(R8)
|
||
- round(R9)
|
||
- round(R10)
|
||
- round(R11)
|
||
-
|
||
- CMPQ SI, BX
|
||
- JLE blockLoop
|
||
-
|
||
- MOVQ R8, AX
|
||
- ROLQ $1, AX
|
||
- MOVQ R9, R12
|
||
- ROLQ $7, R12
|
||
- ADDQ R12, AX
|
||
- MOVQ R10, R12
|
||
- ROLQ $12, R12
|
||
- ADDQ R12, AX
|
||
- MOVQ R11, R12
|
||
- ROLQ $18, R12
|
||
- ADDQ R12, AX
|
||
-
|
||
- mergeRound(AX, R8)
|
||
- mergeRound(AX, R9)
|
||
- mergeRound(AX, R10)
|
||
- mergeRound(AX, R11)
|
||
+ MOVQ prime1, v1
|
||
+ ADDQ prime2, v1
|
||
+ MOVQ prime2, v2
|
||
+ XORQ v3, v3
|
||
+ XORQ v4, v4
|
||
+ SUBQ prime1, v4
|
||
+
|
||
+ blockLoop()
|
||
+
|
||
+ MOVQ v1, h
|
||
+ ROLQ $1, h
|
||
+ MOVQ v2, x
|
||
+ ROLQ $7, x
|
||
+ ADDQ x, h
|
||
+ MOVQ v3, x
|
||
+ ROLQ $12, x
|
||
+ ADDQ x, h
|
||
+ MOVQ v4, x
|
||
+ ROLQ $18, x
|
||
+ ADDQ x, h
|
||
+
|
||
+ mergeRound(h, v1)
|
||
+ mergeRound(h, v2)
|
||
+ mergeRound(h, v3)
|
||
+ mergeRound(h, v4)
|
||
|
||
JMP afterBlocks
|
||
|
||
noBlocks:
|
||
- MOVQ ·prime5v(SB), AX
|
||
+ MOVQ ·primes+32(SB), h
|
||
|
||
afterBlocks:
|
||
- ADDQ DX, AX
|
||
-
|
||
- // Right now BX has len(b)-32, and we want to loop until SI > len(b)-8.
|
||
- ADDQ $24, BX
|
||
-
|
||
- CMPQ SI, BX
|
||
- JG fourByte
|
||
-
|
||
-wordLoop:
|
||
- // Calculate k1.
|
||
- MOVQ (SI), R8
|
||
- ADDQ $8, SI
|
||
- IMULQ R14, R8
|
||
- ROLQ $31, R8
|
||
- IMULQ R13, R8
|
||
-
|
||
- XORQ R8, AX
|
||
- ROLQ $27, AX
|
||
- IMULQ R13, AX
|
||
- ADDQ DI, AX
|
||
-
|
||
- CMPQ SI, BX
|
||
- JLE wordLoop
|
||
-
|
||
-fourByte:
|
||
- ADDQ $4, BX
|
||
- CMPQ SI, BX
|
||
- JG singles
|
||
-
|
||
- MOVL (SI), R8
|
||
- ADDQ $4, SI
|
||
- IMULQ R13, R8
|
||
- XORQ R8, AX
|
||
-
|
||
- ROLQ $23, AX
|
||
- IMULQ R14, AX
|
||
- ADDQ ·prime3v(SB), AX
|
||
-
|
||
-singles:
|
||
- ADDQ $4, BX
|
||
- CMPQ SI, BX
|
||
+ ADDQ n, h
|
||
+
|
||
+ ADDQ $24, end
|
||
+ CMPQ p, end
|
||
+ JG try4
|
||
+
|
||
+loop8:
|
||
+ MOVQ (p), x
|
||
+ ADDQ $8, p
|
||
+ round0(x)
|
||
+ XORQ x, h
|
||
+ ROLQ $27, h
|
||
+ IMULQ prime1, h
|
||
+ ADDQ prime4, h
|
||
+
|
||
+ CMPQ p, end
|
||
+ JLE loop8
|
||
+
|
||
+try4:
|
||
+ ADDQ $4, end
|
||
+ CMPQ p, end
|
||
+ JG try1
|
||
+
|
||
+ MOVL (p), x
|
||
+ ADDQ $4, p
|
||
+ IMULQ prime1, x
|
||
+ XORQ x, h
|
||
+
|
||
+ ROLQ $23, h
|
||
+ IMULQ prime2, h
|
||
+ ADDQ ·primes+16(SB), h
|
||
+
|
||
+try1:
|
||
+ ADDQ $4, end
|
||
+ CMPQ p, end
|
||
JGE finalize
|
||
|
||
-singlesLoop:
|
||
- MOVBQZX (SI), R12
|
||
- ADDQ $1, SI
|
||
- IMULQ ·prime5v(SB), R12
|
||
- XORQ R12, AX
|
||
+loop1:
|
||
+ MOVBQZX (p), x
|
||
+ ADDQ $1, p
|
||
+ IMULQ ·primes+32(SB), x
|
||
+ XORQ x, h
|
||
+ ROLQ $11, h
|
||
+ IMULQ prime1, h
|
||
|
||
- ROLQ $11, AX
|
||
- IMULQ R13, AX
|
||
-
|
||
- CMPQ SI, BX
|
||
- JL singlesLoop
|
||
+ CMPQ p, end
|
||
+ JL loop1
|
||
|
||
finalize:
|
||
- MOVQ AX, R12
|
||
- SHRQ $33, R12
|
||
- XORQ R12, AX
|
||
- IMULQ R14, AX
|
||
- MOVQ AX, R12
|
||
- SHRQ $29, R12
|
||
- XORQ R12, AX
|
||
- IMULQ ·prime3v(SB), AX
|
||
- MOVQ AX, R12
|
||
- SHRQ $32, R12
|
||
- XORQ R12, AX
|
||
-
|
||
- MOVQ AX, ret+24(FP)
|
||
+ MOVQ h, x
|
||
+ SHRQ $33, x
|
||
+ XORQ x, h
|
||
+ IMULQ prime2, h
|
||
+ MOVQ h, x
|
||
+ SHRQ $29, x
|
||
+ XORQ x, h
|
||
+ IMULQ ·primes+16(SB), h
|
||
+ MOVQ h, x
|
||
+ SHRQ $32, x
|
||
+ XORQ x, h
|
||
+
|
||
+ MOVQ h, ret+24(FP)
|
||
RET
|
||
|
||
-// writeBlocks uses the same registers as above except that it uses AX to store
|
||
-// the d pointer.
|
||
-
|
||
// func writeBlocks(d *Digest, b []byte) int
|
||
-TEXT ·writeBlocks(SB), NOSPLIT, $0-40
|
||
+TEXT ·writeBlocks(SB), NOSPLIT|NOFRAME, $0-40
|
||
// Load fixed primes needed for round.
|
||
- MOVQ ·prime1v(SB), R13
|
||
- MOVQ ·prime2v(SB), R14
|
||
+ MOVQ ·primes+0(SB), prime1
|
||
+ MOVQ ·primes+8(SB), prime2
|
||
|
||
// Load slice.
|
||
- MOVQ b_base+8(FP), SI
|
||
- MOVQ b_len+16(FP), DX
|
||
- LEAQ (SI)(DX*1), BX
|
||
- SUBQ $32, BX
|
||
+ MOVQ b_base+8(FP), p
|
||
+ MOVQ b_len+16(FP), n
|
||
+ LEAQ (p)(n*1), end
|
||
+ SUBQ $32, end
|
||
|
||
// Load vN from d.
|
||
- MOVQ d+0(FP), AX
|
||
- MOVQ 0(AX), R8 // v1
|
||
- MOVQ 8(AX), R9 // v2
|
||
- MOVQ 16(AX), R10 // v3
|
||
- MOVQ 24(AX), R11 // v4
|
||
+ MOVQ s+0(FP), d
|
||
+ MOVQ 0(d), v1
|
||
+ MOVQ 8(d), v2
|
||
+ MOVQ 16(d), v3
|
||
+ MOVQ 24(d), v4
|
||
|
||
// We don't need to check the loop condition here; this function is
|
||
// always called with at least one block of data to process.
|
||
-blockLoop:
|
||
- round(R8)
|
||
- round(R9)
|
||
- round(R10)
|
||
- round(R11)
|
||
-
|
||
- CMPQ SI, BX
|
||
- JLE blockLoop
|
||
+ blockLoop()
|
||
|
||
// Copy vN back to d.
|
||
- MOVQ R8, 0(AX)
|
||
- MOVQ R9, 8(AX)
|
||
- MOVQ R10, 16(AX)
|
||
- MOVQ R11, 24(AX)
|
||
-
|
||
- // The number of bytes written is SI minus the old base pointer.
|
||
- SUBQ b_base+8(FP), SI
|
||
- MOVQ SI, ret+32(FP)
|
||
+ MOVQ v1, 0(d)
|
||
+ MOVQ v2, 8(d)
|
||
+ MOVQ v3, 16(d)
|
||
+ MOVQ v4, 24(d)
|
||
+
|
||
+ // The number of bytes written is p minus the old base pointer.
|
||
+ SUBQ b_base+8(FP), p
|
||
+ MOVQ p, ret+32(FP)
|
||
|
||
RET
|
||
diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_arm64.s b/vendor/github.com/cespare/xxhash/v2/xxhash_arm64.s
|
||
new file mode 100644
|
||
index 000000000000..7e3145a22186
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/cespare/xxhash/v2/xxhash_arm64.s
|
||
@@ -0,0 +1,183 @@
|
||
+//go:build !appengine && gc && !purego
|
||
+// +build !appengine
|
||
+// +build gc
|
||
+// +build !purego
|
||
+
|
||
+#include "textflag.h"
|
||
+
|
||
+// Registers:
|
||
+#define digest R1
|
||
+#define h R2 // return value
|
||
+#define p R3 // input pointer
|
||
+#define n R4 // input length
|
||
+#define nblocks R5 // n / 32
|
||
+#define prime1 R7
|
||
+#define prime2 R8
|
||
+#define prime3 R9
|
||
+#define prime4 R10
|
||
+#define prime5 R11
|
||
+#define v1 R12
|
||
+#define v2 R13
|
||
+#define v3 R14
|
||
+#define v4 R15
|
||
+#define x1 R20
|
||
+#define x2 R21
|
||
+#define x3 R22
|
||
+#define x4 R23
|
||
+
|
||
+#define round(acc, x) \
|
||
+ MADD prime2, acc, x, acc \
|
||
+ ROR $64-31, acc \
|
||
+ MUL prime1, acc
|
||
+
|
||
+// round0 performs the operation x = round(0, x).
|
||
+#define round0(x) \
|
||
+ MUL prime2, x \
|
||
+ ROR $64-31, x \
|
||
+ MUL prime1, x
|
||
+
|
||
+#define mergeRound(acc, x) \
|
||
+ round0(x) \
|
||
+ EOR x, acc \
|
||
+ MADD acc, prime4, prime1, acc
|
||
+
|
||
+// blockLoop processes as many 32-byte blocks as possible,
|
||
+// updating v1, v2, v3, and v4. It assumes that n >= 32.
|
||
+#define blockLoop() \
|
||
+ LSR $5, n, nblocks \
|
||
+ PCALIGN $16 \
|
||
+ loop: \
|
||
+ LDP.P 16(p), (x1, x2) \
|
||
+ LDP.P 16(p), (x3, x4) \
|
||
+ round(v1, x1) \
|
||
+ round(v2, x2) \
|
||
+ round(v3, x3) \
|
||
+ round(v4, x4) \
|
||
+ SUB $1, nblocks \
|
||
+ CBNZ nblocks, loop
|
||
+
|
||
+// func Sum64(b []byte) uint64
|
||
+TEXT ·Sum64(SB), NOSPLIT|NOFRAME, $0-32
|
||
+ LDP b_base+0(FP), (p, n)
|
||
+
|
||
+ LDP ·primes+0(SB), (prime1, prime2)
|
||
+ LDP ·primes+16(SB), (prime3, prime4)
|
||
+ MOVD ·primes+32(SB), prime5
|
||
+
|
||
+ CMP $32, n
|
||
+ CSEL LT, prime5, ZR, h // if n < 32 { h = prime5 } else { h = 0 }
|
||
+ BLT afterLoop
|
||
+
|
||
+ ADD prime1, prime2, v1
|
||
+ MOVD prime2, v2
|
||
+ MOVD $0, v3
|
||
+ NEG prime1, v4
|
||
+
|
||
+ blockLoop()
|
||
+
|
||
+ ROR $64-1, v1, x1
|
||
+ ROR $64-7, v2, x2
|
||
+ ADD x1, x2
|
||
+ ROR $64-12, v3, x3
|
||
+ ROR $64-18, v4, x4
|
||
+ ADD x3, x4
|
||
+ ADD x2, x4, h
|
||
+
|
||
+ mergeRound(h, v1)
|
||
+ mergeRound(h, v2)
|
||
+ mergeRound(h, v3)
|
||
+ mergeRound(h, v4)
|
||
+
|
||
+afterLoop:
|
||
+ ADD n, h
|
||
+
|
||
+ TBZ $4, n, try8
|
||
+ LDP.P 16(p), (x1, x2)
|
||
+
|
||
+ round0(x1)
|
||
+
|
||
+ // NOTE: here and below, sequencing the EOR after the ROR (using a
|
||
+ // rotated register) is worth a small but measurable speedup for small
|
||
+ // inputs.
|
||
+ ROR $64-27, h
|
||
+ EOR x1 @> 64-27, h, h
|
||
+ MADD h, prime4, prime1, h
|
||
+
|
||
+ round0(x2)
|
||
+ ROR $64-27, h
|
||
+ EOR x2 @> 64-27, h, h
|
||
+ MADD h, prime4, prime1, h
|
||
+
|
||
+try8:
|
||
+ TBZ $3, n, try4
|
||
+ MOVD.P 8(p), x1
|
||
+
|
||
+ round0(x1)
|
||
+ ROR $64-27, h
|
||
+ EOR x1 @> 64-27, h, h
|
||
+ MADD h, prime4, prime1, h
|
||
+
|
||
+try4:
|
||
+ TBZ $2, n, try2
|
||
+ MOVWU.P 4(p), x2
|
||
+
|
||
+ MUL prime1, x2
|
||
+ ROR $64-23, h
|
||
+ EOR x2 @> 64-23, h, h
|
||
+ MADD h, prime3, prime2, h
|
||
+
|
||
+try2:
|
||
+ TBZ $1, n, try1
|
||
+ MOVHU.P 2(p), x3
|
||
+ AND $255, x3, x1
|
||
+ LSR $8, x3, x2
|
||
+
|
||
+ MUL prime5, x1
|
||
+ ROR $64-11, h
|
||
+ EOR x1 @> 64-11, h, h
|
||
+ MUL prime1, h
|
||
+
|
||
+ MUL prime5, x2
|
||
+ ROR $64-11, h
|
||
+ EOR x2 @> 64-11, h, h
|
||
+ MUL prime1, h
|
||
+
|
||
+try1:
|
||
+ TBZ $0, n, finalize
|
||
+ MOVBU (p), x4
|
||
+
|
||
+ MUL prime5, x4
|
||
+ ROR $64-11, h
|
||
+ EOR x4 @> 64-11, h, h
|
||
+ MUL prime1, h
|
||
+
|
||
+finalize:
|
||
+ EOR h >> 33, h
|
||
+ MUL prime2, h
|
||
+ EOR h >> 29, h
|
||
+ MUL prime3, h
|
||
+ EOR h >> 32, h
|
||
+
|
||
+ MOVD h, ret+24(FP)
|
||
+ RET
|
||
+
|
||
+// func writeBlocks(d *Digest, b []byte) int
|
||
+TEXT ·writeBlocks(SB), NOSPLIT|NOFRAME, $0-40
|
||
+ LDP ·primes+0(SB), (prime1, prime2)
|
||
+
|
||
+ // Load state. Assume v[1-4] are stored contiguously.
|
||
+ MOVD d+0(FP), digest
|
||
+ LDP 0(digest), (v1, v2)
|
||
+ LDP 16(digest), (v3, v4)
|
||
+
|
||
+ LDP b_base+8(FP), (p, n)
|
||
+
|
||
+ blockLoop()
|
||
+
|
||
+ // Store updated state.
|
||
+ STP (v1, v2), 0(digest)
|
||
+ STP (v3, v4), 16(digest)
|
||
+
|
||
+ BIC $31, n
|
||
+ MOVD n, ret+32(FP)
|
||
+ RET
|
||
diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.go b/vendor/github.com/cespare/xxhash/v2/xxhash_asm.go
|
||
similarity index 73%
|
||
rename from vendor/github.com/cespare/xxhash/v2/xxhash_amd64.go
|
||
rename to vendor/github.com/cespare/xxhash/v2/xxhash_asm.go
|
||
index ad14b807f4d9..9216e0a40c1a 100644
|
||
--- a/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.go
|
||
+++ b/vendor/github.com/cespare/xxhash/v2/xxhash_asm.go
|
||
@@ -1,3 +1,5 @@
|
||
+//go:build (amd64 || arm64) && !appengine && gc && !purego
|
||
+// +build amd64 arm64
|
||
// +build !appengine
|
||
// +build gc
|
||
// +build !purego
|
||
diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_other.go b/vendor/github.com/cespare/xxhash/v2/xxhash_other.go
|
||
index 4a5a821603e5..26df13bba4b7 100644
|
||
--- a/vendor/github.com/cespare/xxhash/v2/xxhash_other.go
|
||
+++ b/vendor/github.com/cespare/xxhash/v2/xxhash_other.go
|
||
@@ -1,4 +1,5 @@
|
||
-// +build !amd64 appengine !gc purego
|
||
+//go:build (!amd64 && !arm64) || appengine || !gc || purego
|
||
+// +build !amd64,!arm64 appengine !gc purego
|
||
|
||
package xxhash
|
||
|
||
@@ -14,10 +15,10 @@ func Sum64(b []byte) uint64 {
|
||
var h uint64
|
||
|
||
if n >= 32 {
|
||
- v1 := prime1v + prime2
|
||
+ v1 := primes[0] + prime2
|
||
v2 := prime2
|
||
v3 := uint64(0)
|
||
- v4 := -prime1v
|
||
+ v4 := -primes[0]
|
||
for len(b) >= 32 {
|
||
v1 = round(v1, u64(b[0:8:len(b)]))
|
||
v2 = round(v2, u64(b[8:16:len(b)]))
|
||
@@ -36,19 +37,18 @@ func Sum64(b []byte) uint64 {
|
||
|
||
h += uint64(n)
|
||
|
||
- i, end := 0, len(b)
|
||
- for ; i+8 <= end; i += 8 {
|
||
- k1 := round(0, u64(b[i:i+8:len(b)]))
|
||
+ for ; len(b) >= 8; b = b[8:] {
|
||
+ k1 := round(0, u64(b[:8]))
|
||
h ^= k1
|
||
h = rol27(h)*prime1 + prime4
|
||
}
|
||
- if i+4 <= end {
|
||
- h ^= uint64(u32(b[i:i+4:len(b)])) * prime1
|
||
+ if len(b) >= 4 {
|
||
+ h ^= uint64(u32(b[:4])) * prime1
|
||
h = rol23(h)*prime2 + prime3
|
||
- i += 4
|
||
+ b = b[4:]
|
||
}
|
||
- for ; i < end; i++ {
|
||
- h ^= uint64(b[i]) * prime5
|
||
+ for ; len(b) > 0; b = b[1:] {
|
||
+ h ^= uint64(b[0]) * prime5
|
||
h = rol11(h) * prime1
|
||
}
|
||
|
||
diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_safe.go b/vendor/github.com/cespare/xxhash/v2/xxhash_safe.go
|
||
index fc9bea7a31f2..e86f1b5fd8e4 100644
|
||
--- a/vendor/github.com/cespare/xxhash/v2/xxhash_safe.go
|
||
+++ b/vendor/github.com/cespare/xxhash/v2/xxhash_safe.go
|
||
@@ -1,3 +1,4 @@
|
||
+//go:build appengine
|
||
// +build appengine
|
||
|
||
// This file contains the safe implementations of otherwise unsafe-using code.
|
||
diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go b/vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go
|
||
index 376e0ca2e497..1c1638fd88a1 100644
|
||
--- a/vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go
|
||
+++ b/vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go
|
||
@@ -1,3 +1,4 @@
|
||
+//go:build !appengine
|
||
// +build !appengine
|
||
|
||
// This file encapsulates usage of unsafe.
|
||
@@ -11,7 +12,7 @@ import (
|
||
|
||
// In the future it's possible that compiler optimizations will make these
|
||
// XxxString functions unnecessary by realizing that calls such as
|
||
-// Sum64([]byte(s)) don't need to copy s. See https://golang.org/issue/2205.
|
||
+// Sum64([]byte(s)) don't need to copy s. See https://go.dev/issue/2205.
|
||
// If that happens, even if we keep these functions they can be replaced with
|
||
// the trivial safe code.
|
||
|
||
diff --git a/vendor/github.com/cpuguy83/go-md2man/v2/.gitignore b/vendor/github.com/cpuguy83/go-md2man/v2/.gitignore
|
||
new file mode 100644
|
||
index 000000000000..30f97c3d73ab
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/cpuguy83/go-md2man/v2/.gitignore
|
||
@@ -0,0 +1,2 @@
|
||
+go-md2man
|
||
+bin
|
||
diff --git a/vendor/github.com/cpuguy83/go-md2man/v2/.golangci.yml b/vendor/github.com/cpuguy83/go-md2man/v2/.golangci.yml
|
||
new file mode 100644
|
||
index 000000000000..71f073f3c6b9
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/cpuguy83/go-md2man/v2/.golangci.yml
|
||
@@ -0,0 +1,6 @@
|
||
+# For documentation, see https://golangci-lint.run/usage/configuration/
|
||
+
|
||
+linters:
|
||
+ enable:
|
||
+ - gofumpt
|
||
+
|
||
diff --git a/vendor/github.com/cpuguy83/go-md2man/v2/Dockerfile b/vendor/github.com/cpuguy83/go-md2man/v2/Dockerfile
|
||
new file mode 100644
|
||
index 000000000000..7181c5306f41
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/cpuguy83/go-md2man/v2/Dockerfile
|
||
@@ -0,0 +1,20 @@
|
||
+ARG GO_VERSION=1.18
|
||
+ARG GO_IMAGE=golang:${GO_VERSION}
|
||
+
|
||
+FROM --platform=$BUILDPLATFORM $GO_IMAGE AS build
|
||
+COPY . /go/src/github.com/cpuguy83/go-md2man
|
||
+WORKDIR /go/src/github.com/cpuguy83/go-md2man
|
||
+ARG TARGETOS
|
||
+ARG TARGETARCH
|
||
+ARG TARGETVARIANT
|
||
+RUN \
|
||
+ export GOOS="${TARGETOS}"; \
|
||
+ export GOARCH="${TARGETARCH}"; \
|
||
+ if [ "${TARGETARCH}" = "arm" ] && [ "${TARGETVARIANT}" ]; then \
|
||
+ export GOARM="${TARGETVARIANT#v}"; \
|
||
+ fi; \
|
||
+ CGO_ENABLED=0 go build
|
||
+
|
||
+FROM scratch
|
||
+COPY --from=build /go/src/github.com/cpuguy83/go-md2man/go-md2man /go-md2man
|
||
+ENTRYPOINT ["/go-md2man"]
|
||
diff --git a/vendor/github.com/cpuguy83/go-md2man/v2/LICENSE.md b/vendor/github.com/cpuguy83/go-md2man/v2/LICENSE.md
|
||
new file mode 100644
|
||
index 000000000000..1cade6cef6a1
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/cpuguy83/go-md2man/v2/LICENSE.md
|
||
@@ -0,0 +1,21 @@
|
||
+The MIT License (MIT)
|
||
+
|
||
+Copyright (c) 2014 Brian Goff
|
||
+
|
||
+Permission is hereby granted, free of charge, to any person obtaining a copy
|
||
+of this software and associated documentation files (the "Software"), to deal
|
||
+in the Software without restriction, including without limitation the rights
|
||
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||
+copies of the Software, and to permit persons to whom the Software is
|
||
+furnished to do so, subject to the following conditions:
|
||
+
|
||
+The above copyright notice and this permission notice shall be included in all
|
||
+copies or substantial portions of the Software.
|
||
+
|
||
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||
+SOFTWARE.
|
||
diff --git a/vendor/github.com/cpuguy83/go-md2man/v2/Makefile b/vendor/github.com/cpuguy83/go-md2man/v2/Makefile
|
||
new file mode 100644
|
||
index 000000000000..437fc9997926
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/cpuguy83/go-md2man/v2/Makefile
|
||
@@ -0,0 +1,35 @@
|
||
+GO111MODULE ?= on
|
||
+LINTER_BIN ?= golangci-lint
|
||
+
|
||
+export GO111MODULE
|
||
+
|
||
+.PHONY:
|
||
+build: bin/go-md2man
|
||
+
|
||
+.PHONY: clean
|
||
+clean:
|
||
+ @rm -rf bin/*
|
||
+
|
||
+.PHONY: test
|
||
+test:
|
||
+ @go test $(TEST_FLAGS) ./...
|
||
+
|
||
+bin/go-md2man: actual_build_flags := $(BUILD_FLAGS) -o bin/go-md2man
|
||
+bin/go-md2man: bin
|
||
+ @CGO_ENABLED=0 go build $(actual_build_flags)
|
||
+
|
||
+bin:
|
||
+ @mkdir ./bin
|
||
+
|
||
+.PHONY: mod
|
||
+mod:
|
||
+ @go mod tidy
|
||
+
|
||
+.PHONY: check-mod
|
||
+check-mod: # verifies that module changes for go.mod and go.sum are checked in
|
||
+ @hack/ci/check_mods.sh
|
||
+
|
||
+.PHONY: vendor
|
||
+vendor: mod
|
||
+ @go mod vendor -v
|
||
+
|
||
diff --git a/vendor/github.com/cpuguy83/go-md2man/v2/README.md b/vendor/github.com/cpuguy83/go-md2man/v2/README.md
|
||
new file mode 100644
|
||
index 000000000000..0e30d341483c
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/cpuguy83/go-md2man/v2/README.md
|
||
@@ -0,0 +1,15 @@
|
||
+go-md2man
|
||
+=========
|
||
+
|
||
+Converts markdown into roff (man pages).
|
||
+
|
||
+Uses blackfriday to process markdown into man pages.
|
||
+
|
||
+### Usage
|
||
+
|
||
+./md2man -in /path/to/markdownfile.md -out /manfile/output/path
|
||
+
|
||
+### How to contribute
|
||
+
|
||
+We use go modules to manage dependencies.
|
||
+As such you must be using at lest go1.11.
|
||
diff --git a/vendor/github.com/cpuguy83/go-md2man/v2/go-md2man.1.md b/vendor/github.com/cpuguy83/go-md2man/v2/go-md2man.1.md
|
||
new file mode 100644
|
||
index 000000000000..aa4587e279ff
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/cpuguy83/go-md2man/v2/go-md2man.1.md
|
||
@@ -0,0 +1,28 @@
|
||
+go-md2man 1 "January 2015" go-md2man "User Manual"
|
||
+==================================================
|
||
+
|
||
+# NAME
|
||
+go-md2man - Convert markdown files into manpages
|
||
+
|
||
+# SYNOPSIS
|
||
+**go-md2man** [**-in**=*/path/to/md/file*] [**-out**=*/path/to/output*]
|
||
+
|
||
+# DESCRIPTION
|
||
+**go-md2man** converts standard markdown formatted documents into manpages. It is
|
||
+written purely in Go so as to reduce dependencies on 3rd party libs.
|
||
+
|
||
+By default, the input is stdin and the output is stdout.
|
||
+
|
||
+# EXAMPLES
|
||
+Convert the markdown file *go-md2man.1.md* into a manpage:
|
||
+```
|
||
+go-md2man < go-md2man.1.md > go-md2man.1
|
||
+```
|
||
+
|
||
+Same, but using command line arguments instead of shell redirection:
|
||
+```
|
||
+go-md2man -in=go-md2man.1.md -out=go-md2man.1
|
||
+```
|
||
+
|
||
+# HISTORY
|
||
+January 2015, Originally compiled by Brian Goff (cpuguy83@gmail.com).
|
||
diff --git a/vendor/github.com/cpuguy83/go-md2man/v2/md2man.go b/vendor/github.com/cpuguy83/go-md2man/v2/md2man.go
|
||
new file mode 100644
|
||
index 000000000000..4ff873b8e767
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/cpuguy83/go-md2man/v2/md2man.go
|
||
@@ -0,0 +1,53 @@
|
||
+package main
|
||
+
|
||
+import (
|
||
+ "flag"
|
||
+ "fmt"
|
||
+ "io/ioutil"
|
||
+ "os"
|
||
+
|
||
+ "github.com/cpuguy83/go-md2man/v2/md2man"
|
||
+)
|
||
+
|
||
+var (
|
||
+ inFilePath = flag.String("in", "", "Path to file to be processed (default: stdin)")
|
||
+ outFilePath = flag.String("out", "", "Path to output processed file (default: stdout)")
|
||
+)
|
||
+
|
||
+func main() {
|
||
+ var err error
|
||
+ flag.Parse()
|
||
+
|
||
+ inFile := os.Stdin
|
||
+ if *inFilePath != "" {
|
||
+ inFile, err = os.Open(*inFilePath)
|
||
+ if err != nil {
|
||
+ fmt.Println(err)
|
||
+ os.Exit(1)
|
||
+ }
|
||
+ }
|
||
+ defer inFile.Close() // nolint: errcheck
|
||
+
|
||
+ doc, err := ioutil.ReadAll(inFile)
|
||
+ if err != nil {
|
||
+ fmt.Println(err)
|
||
+ os.Exit(1)
|
||
+ }
|
||
+
|
||
+ out := md2man.Render(doc)
|
||
+
|
||
+ outFile := os.Stdout
|
||
+ if *outFilePath != "" {
|
||
+ outFile, err = os.Create(*outFilePath)
|
||
+ if err != nil {
|
||
+ fmt.Println(err)
|
||
+ os.Exit(1)
|
||
+ }
|
||
+ defer outFile.Close() // nolint: errcheck
|
||
+ }
|
||
+ _, err = outFile.Write(out)
|
||
+ if err != nil {
|
||
+ fmt.Println(err)
|
||
+ os.Exit(1)
|
||
+ }
|
||
+}
|
||
diff --git a/vendor/github.com/cpuguy83/go-md2man/v2/md2man/md2man.go b/vendor/github.com/cpuguy83/go-md2man/v2/md2man/md2man.go
|
||
new file mode 100644
|
||
index 000000000000..42bf32aab003
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/cpuguy83/go-md2man/v2/md2man/md2man.go
|
||
@@ -0,0 +1,16 @@
|
||
+package md2man
|
||
+
|
||
+import (
|
||
+ "github.com/russross/blackfriday/v2"
|
||
+)
|
||
+
|
||
+// Render converts a markdown document into a roff formatted document.
|
||
+func Render(doc []byte) []byte {
|
||
+ renderer := NewRoffRenderer()
|
||
+
|
||
+ return blackfriday.Run(doc,
|
||
+ []blackfriday.Option{
|
||
+ blackfriday.WithRenderer(renderer),
|
||
+ blackfriday.WithExtensions(renderer.GetExtensions()),
|
||
+ }...)
|
||
+}
|
||
diff --git a/vendor/github.com/cpuguy83/go-md2man/v2/md2man/roff.go b/vendor/github.com/cpuguy83/go-md2man/v2/md2man/roff.go
|
||
new file mode 100644
|
||
index 000000000000..4b19188d90fd
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/cpuguy83/go-md2man/v2/md2man/roff.go
|
||
@@ -0,0 +1,348 @@
|
||
+package md2man
|
||
+
|
||
+import (
|
||
+ "bytes"
|
||
+ "fmt"
|
||
+ "io"
|
||
+ "os"
|
||
+ "strings"
|
||
+
|
||
+ "github.com/russross/blackfriday/v2"
|
||
+)
|
||
+
|
||
+// roffRenderer implements the blackfriday.Renderer interface for creating
|
||
+// roff format (manpages) from markdown text
|
||
+type roffRenderer struct {
|
||
+ extensions blackfriday.Extensions
|
||
+ listCounters []int
|
||
+ firstHeader bool
|
||
+ firstDD bool
|
||
+ listDepth int
|
||
+}
|
||
+
|
||
+const (
|
||
+ titleHeader = ".TH "
|
||
+ topLevelHeader = "\n\n.SH "
|
||
+ secondLevelHdr = "\n.SH "
|
||
+ otherHeader = "\n.SS "
|
||
+ crTag = "\n"
|
||
+ emphTag = "\\fI"
|
||
+ emphCloseTag = "\\fP"
|
||
+ strongTag = "\\fB"
|
||
+ strongCloseTag = "\\fP"
|
||
+ breakTag = "\n.br\n"
|
||
+ paraTag = "\n.PP\n"
|
||
+ hruleTag = "\n.ti 0\n\\l'\\n(.lu'\n"
|
||
+ linkTag = "\n\\[la]"
|
||
+ linkCloseTag = "\\[ra]"
|
||
+ codespanTag = "\\fB"
|
||
+ codespanCloseTag = "\\fR"
|
||
+ codeTag = "\n.EX\n"
|
||
+ codeCloseTag = "\n.EE\n"
|
||
+ quoteTag = "\n.PP\n.RS\n"
|
||
+ quoteCloseTag = "\n.RE\n"
|
||
+ listTag = "\n.RS\n"
|
||
+ listCloseTag = "\n.RE\n"
|
||
+ dtTag = "\n.TP\n"
|
||
+ dd2Tag = "\n"
|
||
+ tableStart = "\n.TS\nallbox;\n"
|
||
+ tableEnd = ".TE\n"
|
||
+ tableCellStart = "T{\n"
|
||
+ tableCellEnd = "\nT}\n"
|
||
+)
|
||
+
|
||
+// NewRoffRenderer creates a new blackfriday Renderer for generating roff documents
|
||
+// from markdown
|
||
+func NewRoffRenderer() *roffRenderer { // nolint: golint
|
||
+ var extensions blackfriday.Extensions
|
||
+
|
||
+ extensions |= blackfriday.NoIntraEmphasis
|
||
+ extensions |= blackfriday.Tables
|
||
+ extensions |= blackfriday.FencedCode
|
||
+ extensions |= blackfriday.SpaceHeadings
|
||
+ extensions |= blackfriday.Footnotes
|
||
+ extensions |= blackfriday.Titleblock
|
||
+ extensions |= blackfriday.DefinitionLists
|
||
+ return &roffRenderer{
|
||
+ extensions: extensions,
|
||
+ }
|
||
+}
|
||
+
|
||
+// GetExtensions returns the list of extensions used by this renderer implementation
|
||
+func (r *roffRenderer) GetExtensions() blackfriday.Extensions {
|
||
+ return r.extensions
|
||
+}
|
||
+
|
||
+// RenderHeader handles outputting the header at document start
|
||
+func (r *roffRenderer) RenderHeader(w io.Writer, ast *blackfriday.Node) {
|
||
+ // disable hyphenation
|
||
+ out(w, ".nh\n")
|
||
+}
|
||
+
|
||
+// RenderFooter handles outputting the footer at the document end; the roff
|
||
+// renderer has no footer information
|
||
+func (r *roffRenderer) RenderFooter(w io.Writer, ast *blackfriday.Node) {
|
||
+}
|
||
+
|
||
+// RenderNode is called for each node in a markdown document; based on the node
|
||
+// type the equivalent roff output is sent to the writer
|
||
+func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
|
||
+ walkAction := blackfriday.GoToNext
|
||
+
|
||
+ switch node.Type {
|
||
+ case blackfriday.Text:
|
||
+ escapeSpecialChars(w, node.Literal)
|
||
+ case blackfriday.Softbreak:
|
||
+ out(w, crTag)
|
||
+ case blackfriday.Hardbreak:
|
||
+ out(w, breakTag)
|
||
+ case blackfriday.Emph:
|
||
+ if entering {
|
||
+ out(w, emphTag)
|
||
+ } else {
|
||
+ out(w, emphCloseTag)
|
||
+ }
|
||
+ case blackfriday.Strong:
|
||
+ if entering {
|
||
+ out(w, strongTag)
|
||
+ } else {
|
||
+ out(w, strongCloseTag)
|
||
+ }
|
||
+ case blackfriday.Link:
|
||
+ // Don't render the link text for automatic links, because this
|
||
+ // will only duplicate the URL in the roff output.
|
||
+ // See https://daringfireball.net/projects/markdown/syntax#autolink
|
||
+ if !bytes.Equal(node.LinkData.Destination, node.FirstChild.Literal) {
|
||
+ out(w, string(node.FirstChild.Literal))
|
||
+ }
|
||
+ // Hyphens in a link must be escaped to avoid word-wrap in the rendered man page.
|
||
+ escapedLink := strings.ReplaceAll(string(node.LinkData.Destination), "-", "\\-")
|
||
+ out(w, linkTag+escapedLink+linkCloseTag)
|
||
+ walkAction = blackfriday.SkipChildren
|
||
+ case blackfriday.Image:
|
||
+ // ignore images
|
||
+ walkAction = blackfriday.SkipChildren
|
||
+ case blackfriday.Code:
|
||
+ out(w, codespanTag)
|
||
+ escapeSpecialChars(w, node.Literal)
|
||
+ out(w, codespanCloseTag)
|
||
+ case blackfriday.Document:
|
||
+ break
|
||
+ case blackfriday.Paragraph:
|
||
+ // roff .PP markers break lists
|
||
+ if r.listDepth > 0 {
|
||
+ return blackfriday.GoToNext
|
||
+ }
|
||
+ if entering {
|
||
+ out(w, paraTag)
|
||
+ } else {
|
||
+ out(w, crTag)
|
||
+ }
|
||
+ case blackfriday.BlockQuote:
|
||
+ if entering {
|
||
+ out(w, quoteTag)
|
||
+ } else {
|
||
+ out(w, quoteCloseTag)
|
||
+ }
|
||
+ case blackfriday.Heading:
|
||
+ r.handleHeading(w, node, entering)
|
||
+ case blackfriday.HorizontalRule:
|
||
+ out(w, hruleTag)
|
||
+ case blackfriday.List:
|
||
+ r.handleList(w, node, entering)
|
||
+ case blackfriday.Item:
|
||
+ r.handleItem(w, node, entering)
|
||
+ case blackfriday.CodeBlock:
|
||
+ out(w, codeTag)
|
||
+ escapeSpecialChars(w, node.Literal)
|
||
+ out(w, codeCloseTag)
|
||
+ case blackfriday.Table:
|
||
+ r.handleTable(w, node, entering)
|
||
+ case blackfriday.TableHead:
|
||
+ case blackfriday.TableBody:
|
||
+ case blackfriday.TableRow:
|
||
+ // no action as cell entries do all the nroff formatting
|
||
+ return blackfriday.GoToNext
|
||
+ case blackfriday.TableCell:
|
||
+ r.handleTableCell(w, node, entering)
|
||
+ case blackfriday.HTMLSpan:
|
||
+ // ignore other HTML tags
|
||
+ case blackfriday.HTMLBlock:
|
||
+ if bytes.HasPrefix(node.Literal, []byte("<!--")) {
|
||
+ break // ignore comments, no warning
|
||
+ }
|
||
+ fmt.Fprintln(os.Stderr, "WARNING: go-md2man does not handle node type "+node.Type.String())
|
||
+ default:
|
||
+ fmt.Fprintln(os.Stderr, "WARNING: go-md2man does not handle node type "+node.Type.String())
|
||
+ }
|
||
+ return walkAction
|
||
+}
|
||
+
|
||
+func (r *roffRenderer) handleHeading(w io.Writer, node *blackfriday.Node, entering bool) {
|
||
+ if entering {
|
||
+ switch node.Level {
|
||
+ case 1:
|
||
+ if !r.firstHeader {
|
||
+ out(w, titleHeader)
|
||
+ r.firstHeader = true
|
||
+ break
|
||
+ }
|
||
+ out(w, topLevelHeader)
|
||
+ case 2:
|
||
+ out(w, secondLevelHdr)
|
||
+ default:
|
||
+ out(w, otherHeader)
|
||
+ }
|
||
+ }
|
||
+}
|
||
+
|
||
+func (r *roffRenderer) handleList(w io.Writer, node *blackfriday.Node, entering bool) {
|
||
+ openTag := listTag
|
||
+ closeTag := listCloseTag
|
||
+ if node.ListFlags&blackfriday.ListTypeDefinition != 0 {
|
||
+ // tags for definition lists handled within Item node
|
||
+ openTag = ""
|
||
+ closeTag = ""
|
||
+ }
|
||
+ if entering {
|
||
+ r.listDepth++
|
||
+ if node.ListFlags&blackfriday.ListTypeOrdered != 0 {
|
||
+ r.listCounters = append(r.listCounters, 1)
|
||
+ }
|
||
+ out(w, openTag)
|
||
+ } else {
|
||
+ if node.ListFlags&blackfriday.ListTypeOrdered != 0 {
|
||
+ r.listCounters = r.listCounters[:len(r.listCounters)-1]
|
||
+ }
|
||
+ out(w, closeTag)
|
||
+ r.listDepth--
|
||
+ }
|
||
+}
|
||
+
|
||
+func (r *roffRenderer) handleItem(w io.Writer, node *blackfriday.Node, entering bool) {
|
||
+ if entering {
|
||
+ if node.ListFlags&blackfriday.ListTypeOrdered != 0 {
|
||
+ out(w, fmt.Sprintf(".IP \"%3d.\" 5\n", r.listCounters[len(r.listCounters)-1]))
|
||
+ r.listCounters[len(r.listCounters)-1]++
|
||
+ } else if node.ListFlags&blackfriday.ListTypeTerm != 0 {
|
||
+ // DT (definition term): line just before DD (see below).
|
||
+ out(w, dtTag)
|
||
+ r.firstDD = true
|
||
+ } else if node.ListFlags&blackfriday.ListTypeDefinition != 0 {
|
||
+ // DD (definition description): line that starts with ": ".
|
||
+ //
|
||
+ // We have to distinguish between the first DD and the
|
||
+ // subsequent ones, as there should be no vertical
|
||
+ // whitespace between the DT and the first DD.
|
||
+ if r.firstDD {
|
||
+ r.firstDD = false
|
||
+ } else {
|
||
+ out(w, dd2Tag)
|
||
+ }
|
||
+ } else {
|
||
+ out(w, ".IP \\(bu 2\n")
|
||
+ }
|
||
+ } else {
|
||
+ out(w, "\n")
|
||
+ }
|
||
+}
|
||
+
|
||
+func (r *roffRenderer) handleTable(w io.Writer, node *blackfriday.Node, entering bool) {
|
||
+ if entering {
|
||
+ out(w, tableStart)
|
||
+ // call walker to count cells (and rows?) so format section can be produced
|
||
+ columns := countColumns(node)
|
||
+ out(w, strings.Repeat("l ", columns)+"\n")
|
||
+ out(w, strings.Repeat("l ", columns)+".\n")
|
||
+ } else {
|
||
+ out(w, tableEnd)
|
||
+ }
|
||
+}
|
||
+
|
||
+func (r *roffRenderer) handleTableCell(w io.Writer, node *blackfriday.Node, entering bool) {
|
||
+ if entering {
|
||
+ var start string
|
||
+ if node.Prev != nil && node.Prev.Type == blackfriday.TableCell {
|
||
+ start = "\t"
|
||
+ }
|
||
+ if node.IsHeader {
|
||
+ start += strongTag
|
||
+ } else if nodeLiteralSize(node) > 30 {
|
||
+ start += tableCellStart
|
||
+ }
|
||
+ out(w, start)
|
||
+ } else {
|
||
+ var end string
|
||
+ if node.IsHeader {
|
||
+ end = strongCloseTag
|
||
+ } else if nodeLiteralSize(node) > 30 {
|
||
+ end = tableCellEnd
|
||
+ }
|
||
+ if node.Next == nil && end != tableCellEnd {
|
||
+ // Last cell: need to carriage return if we are at the end of the
|
||
+ // header row and content isn't wrapped in a "tablecell"
|
||
+ end += crTag
|
||
+ }
|
||
+ out(w, end)
|
||
+ }
|
||
+}
|
||
+
|
||
+func nodeLiteralSize(node *blackfriday.Node) int {
|
||
+ total := 0
|
||
+ for n := node.FirstChild; n != nil; n = n.FirstChild {
|
||
+ total += len(n.Literal)
|
||
+ }
|
||
+ return total
|
||
+}
|
||
+
|
||
+// because roff format requires knowing the column count before outputting any table
|
||
+// data we need to walk a table tree and count the columns
|
||
+func countColumns(node *blackfriday.Node) int {
|
||
+ var columns int
|
||
+
|
||
+ node.Walk(func(node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
|
||
+ switch node.Type {
|
||
+ case blackfriday.TableRow:
|
||
+ if !entering {
|
||
+ return blackfriday.Terminate
|
||
+ }
|
||
+ case blackfriday.TableCell:
|
||
+ if entering {
|
||
+ columns++
|
||
+ }
|
||
+ default:
|
||
+ }
|
||
+ return blackfriday.GoToNext
|
||
+ })
|
||
+ return columns
|
||
+}
|
||
+
|
||
+func out(w io.Writer, output string) {
|
||
+ io.WriteString(w, output) // nolint: errcheck
|
||
+}
|
||
+
|
||
+func escapeSpecialChars(w io.Writer, text []byte) {
|
||
+ for i := 0; i < len(text); i++ {
|
||
+ // escape initial apostrophe or period
|
||
+ if len(text) >= 1 && (text[0] == '\'' || text[0] == '.') {
|
||
+ out(w, "\\&")
|
||
+ }
|
||
+
|
||
+ // directly copy normal characters
|
||
+ org := i
|
||
+
|
||
+ for i < len(text) && text[i] != '\\' {
|
||
+ i++
|
||
+ }
|
||
+ if i > org {
|
||
+ w.Write(text[org:i]) // nolint: errcheck
|
||
+ }
|
||
+
|
||
+ // escape a character
|
||
+ if i >= len(text) {
|
||
+ break
|
||
+ }
|
||
+
|
||
+ w.Write([]byte{'\\', text[i]}) // nolint: errcheck
|
||
+ }
|
||
+}
|
||
diff --git a/vendor/github.com/docker/cli-docs-tool/.dockerignore b/vendor/github.com/docker/cli-docs-tool/.dockerignore
|
||
new file mode 100644
|
||
index 000000000000..c8c323c89663
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/docker/cli-docs-tool/.dockerignore
|
||
@@ -0,0 +1,2 @@
|
||
+/coverage.txt
|
||
+/example/docs
|
||
diff --git a/vendor/github.com/docker/cli-docs-tool/.gitignore b/vendor/github.com/docker/cli-docs-tool/.gitignore
|
||
new file mode 100644
|
||
index 000000000000..c8c323c89663
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/docker/cli-docs-tool/.gitignore
|
||
@@ -0,0 +1,2 @@
|
||
+/coverage.txt
|
||
+/example/docs
|
||
diff --git a/vendor/github.com/docker/cli-docs-tool/.golangci.yml b/vendor/github.com/docker/cli-docs-tool/.golangci.yml
|
||
new file mode 100644
|
||
index 000000000000..6c6557176b28
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/docker/cli-docs-tool/.golangci.yml
|
||
@@ -0,0 +1,37 @@
|
||
+run:
|
||
+ timeout: 10m
|
||
+
|
||
+linters:
|
||
+ enable:
|
||
+ - deadcode
|
||
+ - depguard
|
||
+ - gofmt
|
||
+ - goimports
|
||
+ - revive
|
||
+ - govet
|
||
+ - importas
|
||
+ - ineffassign
|
||
+ - misspell
|
||
+ - typecheck
|
||
+ - varcheck
|
||
+ - errname
|
||
+ - makezero
|
||
+ - whitespace
|
||
+ disable-all: true
|
||
+
|
||
+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
|
||
+ importas:
|
||
+ no-unaliased: true
|
||
+
|
||
+issues:
|
||
+ exclude-rules:
|
||
+ - linters:
|
||
+ - revive
|
||
+ text: "stutters"
|
||
diff --git a/vendor/github.com/docker/cli-docs-tool/Dockerfile b/vendor/github.com/docker/cli-docs-tool/Dockerfile
|
||
new file mode 100644
|
||
index 000000000000..f0e2739faa7c
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/docker/cli-docs-tool/Dockerfile
|
||
@@ -0,0 +1,86 @@
|
||
+# syntax=docker/dockerfile:1
|
||
+
|
||
+# Copyright 2021 cli-docs-tool authors
|
||
+#
|
||
+# Licensed under the Apache License, Version 2.0 (the "License");
|
||
+# you may not use this file except in compliance with the License.
|
||
+# You may obtain a copy of the License at
|
||
+#
|
||
+# http://www.apache.org/licenses/LICENSE-2.0
|
||
+#
|
||
+# Unless required by applicable law or agreed to in writing, software
|
||
+# distributed under the License is distributed on an "AS IS" BASIS,
|
||
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
+# 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 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 golang:${GO_VERSION}-alpine AS base
|
||
+RUN apk add --no-cache cpio findutils git linux-headers
|
||
+ENV CGO_ENABLED=0
|
||
+WORKDIR /src
|
||
+
|
||
+FROM base AS vendored
|
||
+RUN --mount=type=bind,target=.,rw \
|
||
+ --mount=type=cache,target=/go/pkg/mod \
|
||
+ go mod tidy && go mod download && \
|
||
+ mkdir /out && cp go.mod go.sum /out
|
||
+
|
||
+FROM scratch AS vendor-update
|
||
+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
|
||
+EOT
|
||
+
|
||
+FROM base AS lint
|
||
+RUN --mount=type=bind,target=. \
|
||
+ --mount=type=cache,target=/root/.cache \
|
||
+ --mount=from=golangci-lint,source=/usr/bin/golangci-lint,target=/usr/bin/golangci-lint \
|
||
+ golangci-lint run ./...
|
||
+
|
||
+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 \
|
||
+ find . -regex "${LICENSE_FILES}" | xargs addlicense ${LICENSE_ARGS} \
|
||
+ && mkdir /out \
|
||
+ && find . -regex "${LICENSE_FILES}" | cpio -pdm /out
|
||
+
|
||
+FROM scratch AS license-update
|
||
+COPY --from=set /out /
|
||
+
|
||
+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 \
|
||
+ find . -regex "${LICENSE_FILES}" | xargs addlicense -check ${LICENSE_ARGS}
|
||
+
|
||
+FROM vendored AS test
|
||
+RUN --mount=type=bind,target=. \
|
||
+ --mount=type=cache,target=/root/.cache \
|
||
+ --mount=type=cache,target=/go/pkg/mod \
|
||
+ go test -v -coverprofile=/tmp/coverage.txt -covermode=atomic ./...
|
||
+
|
||
+FROM scratch AS test-coverage
|
||
+COPY --from=test /tmp/coverage.txt /coverage.txt
|
||
diff --git a/vendor/github.com/docker/cli-docs-tool/LICENSE b/vendor/github.com/docker/cli-docs-tool/LICENSE
|
||
new file mode 100644
|
||
index 000000000000..d64569567334
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/docker/cli-docs-tool/LICENSE
|
||
@@ -0,0 +1,202 @@
|
||
+
|
||
+ Apache License
|
||
+ Version 2.0, January 2004
|
||
+ http://www.apache.org/licenses/
|
||
+
|
||
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||
+
|
||
+ 1. Definitions.
|
||
+
|
||
+ "License" shall mean the terms and conditions for use, reproduction,
|
||
+ and distribution as defined by Sections 1 through 9 of this document.
|
||
+
|
||
+ "Licensor" shall mean the copyright owner or entity authorized by
|
||
+ the copyright owner that is granting the License.
|
||
+
|
||
+ "Legal Entity" shall mean the union of the acting entity and all
|
||
+ other entities that control, are controlled by, or are under common
|
||
+ control with that entity. For the purposes of this definition,
|
||
+ "control" means (i) the power, direct or indirect, to cause the
|
||
+ direction or management of such entity, whether by contract or
|
||
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||
+ outstanding shares, or (iii) beneficial ownership of such entity.
|
||
+
|
||
+ "You" (or "Your") shall mean an individual or Legal Entity
|
||
+ exercising permissions granted by this License.
|
||
+
|
||
+ "Source" form shall mean the preferred form for making modifications,
|
||
+ including but not limited to software source code, documentation
|
||
+ source, and configuration files.
|
||
+
|
||
+ "Object" form shall mean any form resulting from mechanical
|
||
+ transformation or translation of a Source form, including but
|
||
+ not limited to compiled object code, generated documentation,
|
||
+ and conversions to other media types.
|
||
+
|
||
+ "Work" shall mean the work of authorship, whether in Source or
|
||
+ Object form, made available under the License, as indicated by a
|
||
+ copyright notice that is included in or attached to the work
|
||
+ (an example is provided in the Appendix below).
|
||
+
|
||
+ "Derivative Works" shall mean any work, whether in Source or Object
|
||
+ form, that is based on (or derived from) the Work and for which the
|
||
+ editorial revisions, annotations, elaborations, or other modifications
|
||
+ represent, as a whole, an original work of authorship. For the purposes
|
||
+ of this License, Derivative Works shall not include works that remain
|
||
+ separable from, or merely link (or bind by name) to the interfaces of,
|
||
+ the Work and Derivative Works thereof.
|
||
+
|
||
+ "Contribution" shall mean any work of authorship, including
|
||
+ the original version of the Work and any modifications or additions
|
||
+ to that Work or Derivative Works thereof, that is intentionally
|
||
+ submitted to Licensor for inclusion in the Work by the copyright owner
|
||
+ or by an individual or Legal Entity authorized to submit on behalf of
|
||
+ the copyright owner. For the purposes of this definition, "submitted"
|
||
+ means any form of electronic, verbal, or written communication sent
|
||
+ to the Licensor or its representatives, including but not limited to
|
||
+ communication on electronic mailing lists, source code control systems,
|
||
+ and issue tracking systems that are managed by, or on behalf of, the
|
||
+ Licensor for the purpose of discussing and improving the Work, but
|
||
+ excluding communication that is conspicuously marked or otherwise
|
||
+ designated in writing by the copyright owner as "Not a Contribution."
|
||
+
|
||
+ "Contributor" shall mean Licensor and any individual or Legal Entity
|
||
+ on behalf of whom a Contribution has been received by Licensor and
|
||
+ subsequently incorporated within the Work.
|
||
+
|
||
+ 2. Grant of Copyright License. Subject to the terms and conditions of
|
||
+ this License, each Contributor hereby grants to You a perpetual,
|
||
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||
+ copyright license to reproduce, prepare Derivative Works of,
|
||
+ publicly display, publicly perform, sublicense, and distribute the
|
||
+ Work and such Derivative Works in Source or Object form.
|
||
+
|
||
+ 3. Grant of Patent License. Subject to the terms and conditions of
|
||
+ this License, each Contributor hereby grants to You a perpetual,
|
||
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||
+ (except as stated in this section) patent license to make, have made,
|
||
+ use, offer to sell, sell, import, and otherwise transfer the Work,
|
||
+ where such license applies only to those patent claims licensable
|
||
+ by such Contributor that are necessarily infringed by their
|
||
+ Contribution(s) alone or by combination of their Contribution(s)
|
||
+ with the Work to which such Contribution(s) was submitted. If You
|
||
+ institute patent litigation against any entity (including a
|
||
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||
+ or a Contribution incorporated within the Work constitutes direct
|
||
+ or contributory patent infringement, then any patent licenses
|
||
+ granted to You under this License for that Work shall terminate
|
||
+ as of the date such litigation is filed.
|
||
+
|
||
+ 4. Redistribution. You may reproduce and distribute copies of the
|
||
+ Work or Derivative Works thereof in any medium, with or without
|
||
+ modifications, and in Source or Object form, provided that You
|
||
+ meet the following conditions:
|
||
+
|
||
+ (a) You must give any other recipients of the Work or
|
||
+ Derivative Works a copy of this License; and
|
||
+
|
||
+ (b) You must cause any modified files to carry prominent notices
|
||
+ stating that You changed the files; and
|
||
+
|
||
+ (c) You must retain, in the Source form of any Derivative Works
|
||
+ that You distribute, all copyright, patent, trademark, and
|
||
+ attribution notices from the Source form of the Work,
|
||
+ excluding those notices that do not pertain to any part of
|
||
+ the Derivative Works; and
|
||
+
|
||
+ (d) If the Work includes a "NOTICE" text file as part of its
|
||
+ distribution, then any Derivative Works that You distribute must
|
||
+ include a readable copy of the attribution notices contained
|
||
+ within such NOTICE file, excluding those notices that do not
|
||
+ pertain to any part of the Derivative Works, in at least one
|
||
+ of the following places: within a NOTICE text file distributed
|
||
+ as part of the Derivative Works; within the Source form or
|
||
+ documentation, if provided along with the Derivative Works; or,
|
||
+ within a display generated by the Derivative Works, if and
|
||
+ wherever such third-party notices normally appear. The contents
|
||
+ of the NOTICE file are for informational purposes only and
|
||
+ do not modify the License. You may add Your own attribution
|
||
+ notices within Derivative Works that You distribute, alongside
|
||
+ or as an addendum to the NOTICE text from the Work, provided
|
||
+ that such additional attribution notices cannot be construed
|
||
+ as modifying the License.
|
||
+
|
||
+ You may add Your own copyright statement to Your modifications and
|
||
+ may provide additional or different license terms and conditions
|
||
+ for use, reproduction, or distribution of Your modifications, or
|
||
+ for any such Derivative Works as a whole, provided Your use,
|
||
+ reproduction, and distribution of the Work otherwise complies with
|
||
+ the conditions stated in this License.
|
||
+
|
||
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
|
||
+ any Contribution intentionally submitted for inclusion in the Work
|
||
+ by You to the Licensor shall be under the terms and conditions of
|
||
+ this License, without any additional terms or conditions.
|
||
+ Notwithstanding the above, nothing herein shall supersede or modify
|
||
+ the terms of any separate license agreement you may have executed
|
||
+ with Licensor regarding such Contributions.
|
||
+
|
||
+ 6. Trademarks. This License does not grant permission to use the trade
|
||
+ names, trademarks, service marks, or product names of the Licensor,
|
||
+ except as required for reasonable and customary use in describing the
|
||
+ origin of the Work and reproducing the content of the NOTICE file.
|
||
+
|
||
+ 7. Disclaimer of Warranty. Unless required by applicable law or
|
||
+ agreed to in writing, Licensor provides the Work (and each
|
||
+ Contributor provides its Contributions) on an "AS IS" BASIS,
|
||
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||
+ implied, including, without limitation, any warranties or conditions
|
||
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||
+ PARTICULAR PURPOSE. You are solely responsible for determining the
|
||
+ appropriateness of using or redistributing the Work and assume any
|
||
+ risks associated with Your exercise of permissions under this License.
|
||
+
|
||
+ 8. Limitation of Liability. In no event and under no legal theory,
|
||
+ whether in tort (including negligence), contract, or otherwise,
|
||
+ unless required by applicable law (such as deliberate and grossly
|
||
+ negligent acts) or agreed to in writing, shall any Contributor be
|
||
+ liable to You for damages, including any direct, indirect, special,
|
||
+ incidental, or consequential damages of any character arising as a
|
||
+ result of this License or out of the use or inability to use the
|
||
+ Work (including but not limited to damages for loss of goodwill,
|
||
+ work stoppage, computer failure or malfunction, or any and all
|
||
+ other commercial damages or losses), even if such Contributor
|
||
+ has been advised of the possibility of such damages.
|
||
+
|
||
+ 9. Accepting Warranty or Additional Liability. While redistributing
|
||
+ the Work or Derivative Works thereof, You may choose to offer,
|
||
+ and charge a fee for, acceptance of support, warranty, indemnity,
|
||
+ or other liability obligations and/or rights consistent with this
|
||
+ License. However, in accepting such obligations, You may act only
|
||
+ on Your own behalf and on Your sole responsibility, not on behalf
|
||
+ of any other Contributor, and only if You agree to indemnify,
|
||
+ defend, and hold each Contributor harmless for any liability
|
||
+ incurred by, or claims asserted against, such Contributor by reason
|
||
+ of your accepting any such warranty or additional liability.
|
||
+
|
||
+ END OF TERMS AND CONDITIONS
|
||
+
|
||
+ APPENDIX: How to apply the Apache License to your work.
|
||
+
|
||
+ To apply the Apache License to your work, attach the following
|
||
+ boilerplate notice, with the fields enclosed by brackets "[]"
|
||
+ replaced with your own identifying information. (Don't include
|
||
+ the brackets!) The text should be enclosed in the appropriate
|
||
+ comment syntax for the file format. We also recommend that a
|
||
+ file or class name and description of purpose be included on the
|
||
+ same "printed page" as the copyright notice for easier
|
||
+ identification within third-party archives.
|
||
+
|
||
+ Copyright [yyyy] [name of copyright owner]
|
||
+
|
||
+ Licensed under the Apache License, Version 2.0 (the "License");
|
||
+ you may not use this file except in compliance with the License.
|
||
+ You may obtain a copy of the License at
|
||
+
|
||
+ http://www.apache.org/licenses/LICENSE-2.0
|
||
+
|
||
+ Unless required by applicable law or agreed to in writing, software
|
||
+ distributed under the License is distributed on an "AS IS" BASIS,
|
||
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
+ See the License for the specific language governing permissions and
|
||
+ limitations under the License.
|
||
diff --git a/vendor/github.com/docker/cli-docs-tool/README.md b/vendor/github.com/docker/cli-docs-tool/README.md
|
||
new file mode 100644
|
||
index 000000000000..4d5ee6474f8f
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/docker/cli-docs-tool/README.md
|
||
@@ -0,0 +1,67 @@
|
||
+[](https://pkg.go.dev/github.com/docker/cli-docs-tool)
|
||
+[](https://github.com/docker/cli-docs-tool/actions?query=workflow%3Atest)
|
||
+[](https://goreportcard.com/report/github.com/docker/cli-docs-tool)
|
||
+
|
||
+## About
|
||
+
|
||
+This is a library containing utilities to generate (reference) documentation
|
||
+for the [`docker` CLI](https://github.com/docker/cli) on [docs.docker.com](https://docs.docker.com/reference/).
|
||
+
|
||
+## Disclaimer
|
||
+
|
||
+This library is intended for use by Docker's CLIs, and is not intended to be a
|
||
+general-purpose utility. Various bits are hard-coded or make assumptions that
|
||
+are very specific to our use-case. Contributions are welcome, but we will not
|
||
+accept contributions to make this a general-purpose module.
|
||
+
|
||
+## Usage
|
||
+
|
||
+To generate the documentation it's recommended to do so using a Go submodule
|
||
+in your repository.
|
||
+
|
||
+We will use the example of `docker/buildx` and create a Go submodule in a
|
||
+`docs` folder (recommended):
|
||
+
|
||
+```console
|
||
+$ mkdir docs
|
||
+$ cd ./docs
|
||
+$ go mod init github.com/docker/buildx/docs
|
||
+$ go get github.com/docker/cli-docs-tool
|
||
+```
|
||
+
|
||
+Your `go.mod` should look like this:
|
||
+
|
||
+```text
|
||
+module github.com/docker/buildx/docs
|
||
+
|
||
+go 1.16
|
||
+
|
||
+require (
|
||
+ github.com/docker/cli-docs-tool v0.0.0
|
||
+)
|
||
+```
|
||
+
|
||
+Next, create a file named `main.go` inside that directory containing the
|
||
+following Go code from [`example/main.go`](example/main.go).
|
||
+
|
||
+Running this example should produce the following output:
|
||
+
|
||
+```console
|
||
+$ go run main.go
|
||
+INFO: Generating Markdown for "docker buildx bake"
|
||
+INFO: Generating Markdown for "docker buildx build"
|
||
+INFO: Generating Markdown for "docker buildx create"
|
||
+INFO: Generating Markdown for "docker buildx du"
|
||
+...
|
||
+INFO: Generating YAML for "docker buildx uninstall"
|
||
+INFO: Generating YAML for "docker buildx use"
|
||
+INFO: Generating YAML for "docker buildx version"
|
||
+INFO: Generating YAML for "docker buildx"
|
||
+```
|
||
+
|
||
+Generated docs will be available in the `./docs` folder of the project.
|
||
+
|
||
+## Contributing
|
||
+
|
||
+Want to contribute? Awesome! You can find information about contributing to
|
||
+this project in the [CONTRIBUTING.md](/.github/CONTRIBUTING.md)
|
||
diff --git a/vendor/github.com/docker/cli-docs-tool/annotation/annotation.go b/vendor/github.com/docker/cli-docs-tool/annotation/annotation.go
|
||
new file mode 100644
|
||
index 000000000000..021846af6e07
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/docker/cli-docs-tool/annotation/annotation.go
|
||
@@ -0,0 +1,25 @@
|
||
+// Copyright 2021 cli-docs-tool authors
|
||
+//
|
||
+// Licensed under the Apache License, Version 2.0 (the "License");
|
||
+// you may not use this file except in compliance with the License.
|
||
+// You may obtain a copy of the License at
|
||
+//
|
||
+// http://www.apache.org/licenses/LICENSE-2.0
|
||
+//
|
||
+// Unless required by applicable law or agreed to in writing, software
|
||
+// distributed under the License is distributed on an "AS IS" BASIS,
|
||
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
+// See the License for the specific language governing permissions and
|
||
+// limitations under the License.
|
||
+
|
||
+package annotation
|
||
+
|
||
+const (
|
||
+ // ExternalURL specifies an external link annotation
|
||
+ ExternalURL = "docs.external.url"
|
||
+ // CodeDelimiter specifies the char that will be converted as code backtick.
|
||
+ // Can be used on cmd for inheritance or a specific flag.
|
||
+ CodeDelimiter = "docs.code-delimiter"
|
||
+ // DefaultValue specifies the default value for a flag.
|
||
+ DefaultValue = "docs.default-value"
|
||
+)
|
||
diff --git a/vendor/github.com/docker/cli-docs-tool/clidocstool.go b/vendor/github.com/docker/cli-docs-tool/clidocstool.go
|
||
new file mode 100644
|
||
index 000000000000..d4aeaba3f126
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/docker/cli-docs-tool/clidocstool.go
|
||
@@ -0,0 +1,123 @@
|
||
+// Copyright 2017 cli-docs-tool authors
|
||
+//
|
||
+// Licensed under the Apache License, Version 2.0 (the "License");
|
||
+// you may not use this file except in compliance with the License.
|
||
+// You may obtain a copy of the License at
|
||
+//
|
||
+// http://www.apache.org/licenses/LICENSE-2.0
|
||
+//
|
||
+// Unless required by applicable law or agreed to in writing, software
|
||
+// distributed under the License is distributed on an "AS IS" BASIS,
|
||
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
+// See the License for the specific language governing permissions and
|
||
+// limitations under the License.
|
||
+
|
||
+package clidocstool
|
||
+
|
||
+import (
|
||
+ "errors"
|
||
+ "io"
|
||
+ "os"
|
||
+ "strings"
|
||
+
|
||
+ "github.com/spf13/cobra"
|
||
+)
|
||
+
|
||
+// Options defines options for cli-docs-tool
|
||
+type Options struct {
|
||
+ Root *cobra.Command
|
||
+ SourceDir string
|
||
+ TargetDir string
|
||
+ Plugin bool
|
||
+}
|
||
+
|
||
+// Client represents an active cli-docs-tool object
|
||
+type Client struct {
|
||
+ root *cobra.Command
|
||
+ source string
|
||
+ target string
|
||
+ plugin bool
|
||
+}
|
||
+
|
||
+// New initializes a new cli-docs-tool client
|
||
+func New(opts Options) (*Client, error) {
|
||
+ if opts.Root == nil {
|
||
+ return nil, errors.New("root cmd required")
|
||
+ }
|
||
+ if len(opts.SourceDir) == 0 {
|
||
+ return nil, errors.New("source dir required")
|
||
+ }
|
||
+ c := &Client{
|
||
+ root: opts.Root,
|
||
+ source: opts.SourceDir,
|
||
+ plugin: opts.Plugin,
|
||
+ }
|
||
+ if len(opts.TargetDir) == 0 {
|
||
+ c.target = c.source
|
||
+ } else {
|
||
+ c.target = opts.TargetDir
|
||
+ }
|
||
+ if err := os.MkdirAll(c.target, 0755); err != nil {
|
||
+ return nil, err
|
||
+ }
|
||
+ return c, nil
|
||
+}
|
||
+
|
||
+// GenAllTree creates all structured ref files for this command and
|
||
+// all descendants in the directory given.
|
||
+func (c *Client) GenAllTree() error {
|
||
+ var err error
|
||
+ if err = c.GenMarkdownTree(c.root); err != nil {
|
||
+ return err
|
||
+ }
|
||
+ if err = c.GenYamlTree(c.root); err != nil {
|
||
+ return err
|
||
+ }
|
||
+ return nil
|
||
+}
|
||
+
|
||
+func fileExists(f string) bool {
|
||
+ info, err := os.Stat(f)
|
||
+ if os.IsNotExist(err) {
|
||
+ return false
|
||
+ }
|
||
+ return !info.IsDir()
|
||
+}
|
||
+
|
||
+func copyFile(src string, dst string) error {
|
||
+ sf, err := os.Open(src)
|
||
+ if err != nil {
|
||
+ return err
|
||
+ }
|
||
+ defer sf.Close()
|
||
+ df, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY, 0o600)
|
||
+ if err != nil {
|
||
+ return err
|
||
+ }
|
||
+ defer df.Close()
|
||
+ _, err = io.Copy(df, sf)
|
||
+ return err
|
||
+}
|
||
+
|
||
+func getAliases(cmd *cobra.Command) []string {
|
||
+ if a := cmd.Annotations["aliases"]; a != "" {
|
||
+ aliases := strings.Split(a, ",")
|
||
+ for i := 0; i < len(aliases); i++ {
|
||
+ aliases[i] = strings.TrimSpace(aliases[i])
|
||
+ }
|
||
+ return aliases
|
||
+ }
|
||
+ if len(cmd.Aliases) == 0 {
|
||
+ return cmd.Aliases
|
||
+ }
|
||
+
|
||
+ var parentPath string
|
||
+ if cmd.HasParent() {
|
||
+ parentPath = cmd.Parent().CommandPath() + " "
|
||
+ }
|
||
+ aliases := []string{cmd.CommandPath()}
|
||
+ for _, a := range cmd.Aliases {
|
||
+ aliases = append(aliases, parentPath+a)
|
||
+ }
|
||
+ return aliases
|
||
+}
|
||
diff --git a/vendor/github.com/docker/cli-docs-tool/clidocstool_md.go b/vendor/github.com/docker/cli-docs-tool/clidocstool_md.go
|
||
new file mode 100644
|
||
index 000000000000..1dee58c06ca1
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/docker/cli-docs-tool/clidocstool_md.go
|
||
@@ -0,0 +1,280 @@
|
||
+// Copyright 2021 cli-docs-tool authors
|
||
+//
|
||
+// Licensed under the Apache License, Version 2.0 (the "License");
|
||
+// you may not use this file except in compliance with the License.
|
||
+// You may obtain a copy of the License at
|
||
+//
|
||
+// http://www.apache.org/licenses/LICENSE-2.0
|
||
+//
|
||
+// Unless required by applicable law or agreed to in writing, software
|
||
+// distributed under the License is distributed on an "AS IS" BASIS,
|
||
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
+// See the License for the specific language governing permissions and
|
||
+// limitations under the License.
|
||
+
|
||
+package clidocstool
|
||
+
|
||
+import (
|
||
+ "bytes"
|
||
+ "fmt"
|
||
+ "log"
|
||
+ "os"
|
||
+ "path/filepath"
|
||
+ "regexp"
|
||
+ "strings"
|
||
+ "text/tabwriter"
|
||
+ "text/template"
|
||
+
|
||
+ "github.com/docker/cli-docs-tool/annotation"
|
||
+ "github.com/spf13/cobra"
|
||
+ "github.com/spf13/pflag"
|
||
+)
|
||
+
|
||
+var (
|
||
+ nlRegexp = regexp.MustCompile(`\r?\n`)
|
||
+ adjustSep = regexp.MustCompile(`\|:---(\s+)`)
|
||
+)
|
||
+
|
||
+// GenMarkdownTree will generate a markdown page for this command and all
|
||
+// descendants in the directory given.
|
||
+func (c *Client) GenMarkdownTree(cmd *cobra.Command) error {
|
||
+ for _, sc := range cmd.Commands() {
|
||
+ if err := c.GenMarkdownTree(sc); err != nil {
|
||
+ return err
|
||
+ }
|
||
+ }
|
||
+
|
||
+ // always disable the addition of [flags] to the usage
|
||
+ cmd.DisableFlagsInUseLine = true
|
||
+
|
||
+ // Skip the root command altogether, to prevent generating a useless
|
||
+ // md file for plugins.
|
||
+ if c.plugin && !cmd.HasParent() {
|
||
+ return nil
|
||
+ }
|
||
+
|
||
+ // Skip hidden command
|
||
+ if cmd.Hidden {
|
||
+ log.Printf("INFO: Skipping Markdown for %q (hidden command)", cmd.CommandPath())
|
||
+ return nil
|
||
+ }
|
||
+
|
||
+ log.Printf("INFO: Generating Markdown for %q", cmd.CommandPath())
|
||
+ mdFile := mdFilename(cmd)
|
||
+ sourcePath := filepath.Join(c.source, mdFile)
|
||
+ targetPath := filepath.Join(c.target, mdFile)
|
||
+
|
||
+ // check recursively to handle inherited annotations
|
||
+ for curr := cmd; curr != nil; curr = curr.Parent() {
|
||
+ if _, ok := cmd.Annotations[annotation.CodeDelimiter]; !ok {
|
||
+ if cd, cok := curr.Annotations[annotation.CodeDelimiter]; cok {
|
||
+ if cmd.Annotations == nil {
|
||
+ cmd.Annotations = map[string]string{}
|
||
+ }
|
||
+ cmd.Annotations[annotation.CodeDelimiter] = cd
|
||
+ }
|
||
+ }
|
||
+ }
|
||
+
|
||
+ if !fileExists(sourcePath) {
|
||
+ var icBuf bytes.Buffer
|
||
+ icTpl, err := template.New("ic").Option("missingkey=error").Parse(`# {{ .Command }}
|
||
+
|
||
+<!---MARKER_GEN_START-->
|
||
+<!---MARKER_GEN_END-->
|
||
+
|
||
+`)
|
||
+ if err != nil {
|
||
+ return err
|
||
+ }
|
||
+ if err = icTpl.Execute(&icBuf, struct {
|
||
+ Command string
|
||
+ }{
|
||
+ Command: cmd.CommandPath(),
|
||
+ }); err != nil {
|
||
+ return err
|
||
+ }
|
||
+ if err = os.WriteFile(targetPath, icBuf.Bytes(), 0644); err != nil {
|
||
+ return err
|
||
+ }
|
||
+ } else if err := copyFile(sourcePath, targetPath); err != nil {
|
||
+ return err
|
||
+ }
|
||
+
|
||
+ content, err := os.ReadFile(targetPath)
|
||
+ if err != nil {
|
||
+ return err
|
||
+ }
|
||
+
|
||
+ cs := string(content)
|
||
+
|
||
+ start := strings.Index(cs, "<!---MARKER_GEN_START-->")
|
||
+ end := strings.Index(cs, "<!---MARKER_GEN_END-->")
|
||
+
|
||
+ if start == -1 {
|
||
+ return fmt.Errorf("no start marker in %s", mdFile)
|
||
+ }
|
||
+ if end == -1 {
|
||
+ return fmt.Errorf("no end marker in %s", mdFile)
|
||
+ }
|
||
+
|
||
+ out, err := mdCmdOutput(cmd, cs)
|
||
+ if err != nil {
|
||
+ return err
|
||
+ }
|
||
+ cont := cs[:start] + "<!---MARKER_GEN_START-->" + "\n" + out + "\n" + cs[end:]
|
||
+
|
||
+ fi, err := os.Stat(targetPath)
|
||
+ if err != nil {
|
||
+ return err
|
||
+ }
|
||
+ if err = os.WriteFile(targetPath, []byte(cont), fi.Mode()); err != nil {
|
||
+ return fmt.Errorf("failed to write %s: %w", targetPath, err)
|
||
+ }
|
||
+
|
||
+ return nil
|
||
+}
|
||
+
|
||
+func mdFilename(cmd *cobra.Command) string {
|
||
+ name := cmd.CommandPath()
|
||
+ if i := strings.Index(name, " "); i >= 0 {
|
||
+ name = name[i+1:]
|
||
+ }
|
||
+ return strings.ReplaceAll(name, " ", "_") + ".md"
|
||
+}
|
||
+
|
||
+func mdMakeLink(txt, link string, f *pflag.Flag, isAnchor bool) string {
|
||
+ link = "#" + link
|
||
+ annotations, ok := f.Annotations[annotation.ExternalURL]
|
||
+ if ok && len(annotations) > 0 {
|
||
+ link = annotations[0]
|
||
+ } else {
|
||
+ if !isAnchor {
|
||
+ return txt
|
||
+ }
|
||
+ }
|
||
+
|
||
+ return "[" + txt + "](" + link + ")"
|
||
+}
|
||
+
|
||
+type mdTable struct {
|
||
+ out *strings.Builder
|
||
+ tabWriter *tabwriter.Writer
|
||
+}
|
||
+
|
||
+func newMdTable(headers ...string) *mdTable {
|
||
+ w := &strings.Builder{}
|
||
+ t := &mdTable{
|
||
+ out: w,
|
||
+ // Using tabwriter.Debug, which uses "|" as separator instead of tabs,
|
||
+ // which is what we want. It's a bit of a hack, but does the job :)
|
||
+ tabWriter: tabwriter.NewWriter(w, 5, 5, 1, ' ', tabwriter.Debug),
|
||
+ }
|
||
+ t.addHeader(headers...)
|
||
+ return t
|
||
+}
|
||
+
|
||
+func (t *mdTable) addHeader(cols ...string) {
|
||
+ t.AddRow(cols...)
|
||
+ _, _ = t.tabWriter.Write([]byte("|" + strings.Repeat(":---\t", len(cols)) + "\n"))
|
||
+}
|
||
+
|
||
+func (t *mdTable) AddRow(cols ...string) {
|
||
+ for i := range cols {
|
||
+ cols[i] = mdEscapePipe(cols[i])
|
||
+ }
|
||
+ _, _ = t.tabWriter.Write([]byte("| " + strings.Join(cols, "\t ") + "\t\n"))
|
||
+}
|
||
+
|
||
+func (t *mdTable) String() string {
|
||
+ _ = t.tabWriter.Flush()
|
||
+ return adjustSep.ReplaceAllStringFunc(t.out.String()+"\n", func(in string) string {
|
||
+ return strings.ReplaceAll(in, " ", "-")
|
||
+ })
|
||
+}
|
||
+
|
||
+func mdCmdOutput(cmd *cobra.Command, old string) (string, error) {
|
||
+ b := &strings.Builder{}
|
||
+
|
||
+ desc := cmd.Short
|
||
+ if cmd.Long != "" {
|
||
+ desc = cmd.Long
|
||
+ }
|
||
+ if desc != "" {
|
||
+ b.WriteString(desc + "\n\n")
|
||
+ }
|
||
+
|
||
+ if aliases := getAliases(cmd); len(aliases) != 0 {
|
||
+ b.WriteString("### Aliases\n\n")
|
||
+ b.WriteString("`" + strings.Join(aliases, "`, `") + "`")
|
||
+ b.WriteString("\n\n")
|
||
+ }
|
||
+
|
||
+ if len(cmd.Commands()) != 0 {
|
||
+ b.WriteString("### Subcommands\n\n")
|
||
+ table := newMdTable("Name", "Description")
|
||
+ for _, c := range cmd.Commands() {
|
||
+ if c.Hidden {
|
||
+ continue
|
||
+ }
|
||
+ table.AddRow(fmt.Sprintf("[`%s`](%s)", c.Name(), mdFilename(c)), c.Short)
|
||
+ }
|
||
+ b.WriteString(table.String() + "\n")
|
||
+ }
|
||
+
|
||
+ // add inherited flags before checking for flags availability
|
||
+ cmd.Flags().AddFlagSet(cmd.InheritedFlags())
|
||
+
|
||
+ if cmd.Flags().HasAvailableFlags() {
|
||
+ b.WriteString("### Options\n\n")
|
||
+ table := newMdTable("Name", "Type", "Default", "Description")
|
||
+ cmd.Flags().VisitAll(func(f *pflag.Flag) {
|
||
+ if f.Hidden {
|
||
+ return
|
||
+ }
|
||
+ isLink := strings.Contains(old, "<a name=\""+f.Name+"\"></a>")
|
||
+ var name string
|
||
+ if f.Shorthand != "" {
|
||
+ name = mdMakeLink("`-"+f.Shorthand+"`", f.Name, f, isLink)
|
||
+ name += ", "
|
||
+ }
|
||
+ name += mdMakeLink("`--"+f.Name+"`", f.Name, f, isLink)
|
||
+
|
||
+ var ftype string
|
||
+ if f.Value.Type() != "bool" {
|
||
+ ftype = "`" + f.Value.Type() + "`"
|
||
+ }
|
||
+
|
||
+ var defval string
|
||
+ if v, ok := f.Annotations[annotation.DefaultValue]; ok && len(v) > 0 {
|
||
+ defval = v[0]
|
||
+ if cd, ok := f.Annotations[annotation.CodeDelimiter]; ok {
|
||
+ defval = strings.ReplaceAll(defval, cd[0], "`")
|
||
+ } else if cd, ok := cmd.Annotations[annotation.CodeDelimiter]; ok {
|
||
+ defval = strings.ReplaceAll(defval, cd, "`")
|
||
+ }
|
||
+ } else if f.DefValue != "" && (f.Value.Type() != "bool" && f.DefValue != "true") && f.DefValue != "[]" {
|
||
+ defval = "`" + f.DefValue + "`"
|
||
+ }
|
||
+
|
||
+ usage := f.Usage
|
||
+ if cd, ok := f.Annotations[annotation.CodeDelimiter]; ok {
|
||
+ usage = strings.ReplaceAll(usage, cd[0], "`")
|
||
+ } else if cd, ok := cmd.Annotations[annotation.CodeDelimiter]; ok {
|
||
+ usage = strings.ReplaceAll(usage, cd, "`")
|
||
+ }
|
||
+ table.AddRow(name, ftype, defval, mdReplaceNewline(usage))
|
||
+ })
|
||
+ b.WriteString(table.String())
|
||
+ }
|
||
+
|
||
+ return b.String(), nil
|
||
+}
|
||
+
|
||
+func mdEscapePipe(s string) string {
|
||
+ return strings.ReplaceAll(s, `|`, `\|`)
|
||
+}
|
||
+
|
||
+func mdReplaceNewline(s string) string {
|
||
+ return nlRegexp.ReplaceAllString(s, "<br>")
|
||
+}
|
||
diff --git a/vendor/github.com/docker/cli-docs-tool/clidocstool_yaml.go b/vendor/github.com/docker/cli-docs-tool/clidocstool_yaml.go
|
||
new file mode 100644
|
||
index 000000000000..523524297af4
|
||
--- /dev/null
|
||
+++ b/vendor/github.com/docker/cli-docs-tool/clidocstool_yaml.go
|
||
@@ -0,0 +1,435 @@
|
||
+// Copyright 2017 cli-docs-tool authors
|
||
+//
|
||
+// Licensed under the Apache License, Version 2.0 (the "License");
|
||
+// you may not use this file except in compliance with the License.
|
||
+// You may obtain a copy of the License at
|
||
+//
|
||
+// http://www.apache.org/licenses/LICENSE-2.0
|
||
+//
|
||
+// Unless required by applicable law or agreed to in writing, software
|
||
+// distributed under the License is distributed on an "AS IS" BASIS,
|
||
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
+// See the License for the specific language governing permissions and
|
||
+// limitations under the License.
|
||
+
|
||
+package clidocstool
|
||
+
|
||
+import (
|
||
+ "fmt"
|
||
+ "io"
|
||
+ "log"
|
||
+ "os"
|
||
+ "path/filepath"
|
||
+ "sort"
|
||
+ "strings"
|
||
+
|
||
+ "github.com/docker/cli-docs-tool/annotation"
|
||
+ "github.com/spf13/cobra"
|
||
+ "github.com/spf13/pflag"
|
||
+ "gopkg.in/yaml.v3"
|
||
+)
|
||
+
|
||
+type cmdOption struct {
|
||
+ Option string
|
||
+ Shorthand string `yaml:",omitempty"`
|
||
+ ValueType string `yaml:"value_type,omitempty"`
|
||
+ DefaultValue string `yaml:"default_value,omitempty"`
|
||
+ Description string `yaml:",omitempty"`
|
||
+ DetailsURL string `yaml:"details_url,omitempty"` // DetailsURL contains an anchor-id or link for more information on this flag
|
||
+ Deprecated bool
|
||
+ Hidden bool
|
||
+ MinAPIVersion string `yaml:"min_api_version,omitempty"`
|
||
+ Experimental bool
|
||
+ ExperimentalCLI bool
|
||
+ Kubernetes bool
|
||
+ Swarm bool
|
||
+ OSType string `yaml:"os_type,omitempty"`
|
||
+}
|
||
+
|
||
+type cmdDoc struct {
|
||
+ Name string `yaml:"command"`
|
||
+ SeeAlso []string `yaml:"parent,omitempty"`
|
||
+ Version string `yaml:"engine_version,omitempty"`
|
||
+ Aliases string `yaml:",omitempty"`
|
||
+ Short string `yaml:",omitempty"`
|
||
+ Long string `yaml:",omitempty"`
|
||
+ Usage string `yaml:",omitempty"`
|
||
+ Pname string `yaml:",omitempty"`
|
||
+ Plink string `yaml:",omitempty"`
|
||
+ Cname []string `yaml:",omitempty"`
|
||
+ Clink []string `yaml:",omitempty"`
|
||
+ Options []cmdOption `yaml:",omitempty"`
|
||
+ InheritedOptions []cmdOption `yaml:"inherited_options,omitempty"`
|
||
+ Example string `yaml:"examples,omitempty"`
|
||
+ Deprecated bool
|
||
+ Hidden bool
|
||
+ MinAPIVersion string `yaml:"min_api_version,omitempty"`
|
||
+ Experimental bool
|
||
+ ExperimentalCLI bool
|
||
+ Kubernetes bool
|
||
+ Swarm bool
|
||
+ OSType string `yaml:"os_type,omitempty"`
|
||
+}
|
||
+
|
||
+// GenYamlTree creates yaml structured ref files for this command and all descendants
|
||
+// in the directory given. This function may not work
|
||
+// correctly if your command names have `-` in them. If you have `cmd` with two
|
||
+// 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 "" }
|
||
+ if err := c.loadLongDescription(cmd); err != nil {
|
||
+ return err
|
||
+ }
|
||
+ return c.genYamlTreeCustom(cmd, emptyStr)
|
||
+}
|
||
+
|
||
+// genYamlTreeCustom creates yaml structured ref files.
|
||
+func (c *Client) genYamlTreeCustom(cmd *cobra.Command, filePrepender func(string) string) error {
|
||
+ for _, sc := range cmd.Commands() {
|
||
+ if !sc.Runnable() && !sc.HasAvailableSubCommands() {
|
||
+ // skip non-runnable commands without subcommands
|
||
+ // but *do* generate YAML for hidden and deprecated commands
|
||
+ // the YAML will have those included as metadata, so that the
|
||
+ // documentation repository can decide whether or not to present them
|
||
+ continue
|
||
+ }
|
||
+ if err := c.genYamlTreeCustom(sc, filePrepender); err != nil {
|
||
+ return err
|
||
+ }
|
||
+ }
|
||
+
|
||
+ // always disable the addition of [flags] to the usage
|
||
+ cmd.DisableFlagsInUseLine = true
|
||
+
|
||
+ // The "root" command used in the generator is just a "stub", and only has a
|
||
+ // list of subcommands, but not (e.g.) global options/flags. We should fix
|
||
+ // that, so that the YAML file for the docker "root" command contains the
|
||
+ // global flags.
|
||
+
|
||
+ // Skip the root command altogether, to prevent generating a useless
|
||
+ // YAML file for plugins.
|
||
+ if c.plugin && !cmd.HasParent() {
|
||
+ return nil
|
||
+ }
|
||
+
|
||
+ log.Printf("INFO: Generating YAML for %q", cmd.CommandPath())
|
||
+ basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".yaml"
|
||
+ target := filepath.Join(c.target, basename)
|
||
+ f, err := os.Create(target)
|
||
+ if err != nil {
|
||
+ return err
|
||
+ }
|
||
+ defer f.Close()
|
||
+
|
||
+ if _, err := io.WriteString(f, filePrepender(target)); err != nil {
|
||
+ return err
|
||
+ }
|
||
+ return c.genYamlCustom(cmd, f)
|
||
+}
|
||
+
|
||
+// genYamlCustom creates custom yaml output.
|
||
+// nolint: gocyclo
|
||
+func (c *Client) genYamlCustom(cmd *cobra.Command, w io.Writer) error {
|
||
+ const (
|
||
+ // shortMaxWidth is the maximum width for the "Short" description before
|
||
+ // we force YAML to use multi-line syntax. The goal is to make the total
|
||
+ // width fit within 80 characters. This value is based on 80 characters
|
||
+ // minus the with of the field, colon, and whitespace ('short: ').
|
||
+ shortMaxWidth = 73
|
||
+
|
||
+ // longMaxWidth is the maximum width for the "Short" description before
|
||
+ // we force YAML to use multi-line syntax. The goal is to make the total
|
||
+ // width fit within 80 characters. This value is based on 80 characters
|
||
+ // minus the with of the field, colon, and whitespace ('long: ').
|
||
+ longMaxWidth = 74
|
||
+ )
|
||
+
|
||
+ // necessary to add inherited flags otherwise some
|
||
+ // fields are not properly declared like usage
|
||
+ cmd.Flags().AddFlagSet(cmd.InheritedFlags())
|
||
+
|
||
+ cliDoc := cmdDoc{
|
||
+ Name: cmd.CommandPath(),
|
||
+ Aliases: strings.Join(getAliases(cmd), ", "),
|
||
+ Short: forceMultiLine(cmd.Short, shortMaxWidth),
|
||
+ Long: forceMultiLine(cmd.Long, longMaxWidth),
|
||
+ Example: cmd.Example,
|
||
+ Deprecated: len(cmd.Deprecated) > 0,
|
||
+ Hidden: cmd.Hidden,
|
||
+ }
|
||
+
|
||
+ if len(cliDoc.Long) == 0 {
|
||
+ cliDoc.Long = cliDoc.Short
|
||
+ }
|
||
+
|
||
+ if cmd.Runnable() {
|
||
+ cliDoc.Usage = cmd.UseLine()
|
||
+ }
|
||
+
|
||
+ // check recursively to handle inherited annotations
|
||
+ for curr := cmd; curr != nil; curr = curr.Parent() {
|
||
+ if v, ok := curr.Annotations["version"]; ok && cliDoc.MinAPIVersion == "" {
|
||
+ cliDoc.MinAPIVersion = v
|
||
+ }
|
||
+ if _, ok := curr.Annotations["experimental"]; ok && !cliDoc.Experimental {
|
||
+ cliDoc.Experimental = true
|
||
+ }
|
||
+ if _, ok := curr.Annotations["experimentalCLI"]; ok && !cliDoc.ExperimentalCLI {
|
||
+ cliDoc.ExperimentalCLI = true
|
||
+ }
|
||
+ if _, ok := curr.Annotations["kubernetes"]; ok && !cliDoc.Kubernetes {
|
||
+ cliDoc.Kubernetes = true
|
||
+ }
|
||
+ if _, ok := curr.Annotations["swarm"]; ok && !cliDoc.Swarm {
|
||
+ cliDoc.Swarm = true
|
||
+ }
|
||
+ if o, ok := curr.Annotations["ostype"]; ok && cliDoc.OSType == "" {
|
||
+ cliDoc.OSType = o
|
||
+ }
|
||
+ if _, ok := cmd.Annotations[annotation.CodeDelimiter]; !ok {
|
||
+ if cd, cok := curr.Annotations[annotation.CodeDelimiter]; cok {
|
||
+ if cmd.Annotations == nil {
|
||
+ cmd.Annotations = map[string]string{}
|
||
+ }
|
||
+ cmd.Annotations[annotation.CodeDelimiter] = cd
|
||
+ }
|
||
+ }
|
||
+ }
|
||
+
|
||
+ anchors := make(map[string]struct{})
|
||
+ if a, ok := cmd.Annotations["anchors"]; ok && a != "" {
|
||
+ for _, anchor := range strings.Split(a, ",") {
|
||
+ anchors[anchor] = struct{}{}
|
||
+ }
|
||
+ }
|
||
+
|
||
+ flags := cmd.NonInheritedFlags()
|
||
+ if flags.HasFlags() {
|
||
+ cliDoc.Options = genFlagResult(cmd, flags, anchors)
|
||
+ }
|
||
+ flags = cmd.InheritedFlags()
|
||
+ if flags.HasFlags() {
|
||
+ cliDoc.InheritedOptions = genFlagResult(cmd, flags, anchors)
|
||
+ }
|
||
+
|
||
+ if hasSeeAlso(cmd) {
|
||
+ if cmd.HasParent() {
|
||
+ parent := cmd.Parent()
|
||
+ cliDoc.Pname = parent.CommandPath()
|
||
+ cliDoc.Plink = strings.Replace(cliDoc.Pname, " ", "_", -1) + ".yaml"
|
||
+ cmd.VisitParents(func(c *cobra.Command) {
|
||
+ if c.DisableAutoGenTag {
|
||
+ cmd.DisableAutoGenTag = c.DisableAutoGenTag
|
||
+ }
|
||
+ })
|
||
+ }
|
||
+
|
||
+ children := cmd.Commands()
|
||
+ sort.Sort(byName(children))
|
||
+
|
||
+ for _, child := range children {
|
||
+ if !child.IsAvailableCommand() || child.IsAdditionalHelpTopicCommand() {
|
||
+ continue
|
||
+ }
|
||
+ cliDoc.Cname = append(cliDoc.Cname, cliDoc.Name+" "+child.Name())
|
||
+ cliDoc.Clink = append(cliDoc.Clink, strings.Replace(cliDoc.Name+"_"+child.Name(), " ", "_", -1)+".yaml")
|
||
+ }
|
||
+ }
|
||
+
|
||
+ final, err := yaml.Marshal(&cliDoc)
|
||
+ if err != nil {
|
||
+ fmt.Println(err)
|
||
+ os.Exit(1)
|
||
+ }
|
||
+ if _, err := fmt.Fprintln(w, string(final)); err != nil {
|
||
+ return err
|
||
+ }
|
||
+ return nil
|
||
+}
|
||
+
|
||
+func genFlagResult(cmd *cobra.Command, flags *pflag.FlagSet, anchors map[string]struct{}) []cmdOption {
|
||
+ var (
|
||
+ result []cmdOption
|
||
+ opt cmdOption
|
||
+ )
|
||
+
|
||
+ const (
|
||
+ // shortMaxWidth is the maximum width for the "Short" description before
|
||
+ // we force YAML to use multi-line syntax. The goal is to make the total
|
||
+ // width fit within 80 characters. This value is based on 80 characters
|
||
+ // minus the with of the field, colon, and whitespace (' default_value: ').
|
||
+ defaultValueMaxWidth = 64
|
||
+
|
||
+ // longMaxWidth is the maximum width for the "Short" description before
|
||
+ // we force YAML to use multi-line syntax. The goal is to make the total
|
||
+ // width fit within 80 characters. This value is based on 80 characters
|
||
+ // minus the with of the field, colon, and whitespace (' description: ').
|
||
+ descriptionMaxWidth = 66
|
||
+ )
|
||
+
|
||
+ flags.VisitAll(func(flag *pflag.Flag) {
|
||
+ opt = cmdOption{
|
||
+ Option: flag.Name,
|
||
+ ValueType: flag.Value.Type(),
|
||
+ Deprecated: len(flag.Deprecated) > 0,
|
||
+ Hidden: flag.Hidden,
|
||
+ }
|
||
+
|
||
+ var defval string
|
||
+ if v, ok := flag.Annotations[annotation.DefaultValue]; ok && len(v) > 0 {
|
||
+ defval = v[0]
|
||
+ if cd, ok := flag.Annotations[annotation.CodeDelimiter]; ok {
|
||
+ defval = strings.ReplaceAll(defval, cd[0], "`")
|
||