Add YAML-docs generator
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Родитель
28aa8d80a0
Коммит
22d660fa7f
|
@ -8,13 +8,13 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/buildx/commands"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/commands"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
const descriptionSourcePath = "docs/reference/commandline/"
|
||||
const descriptionSourcePath = "docs/reference/"
|
||||
|
||||
func generateCliYaml(opts *options) error {
|
||||
dockerCLI, err := command.NewDockerCli()
|
||||
|
@ -25,7 +25,7 @@ func generateCliYaml(opts *options) error {
|
|||
Use: "docker [OPTIONS] COMMAND [ARG...]",
|
||||
Short: "The base command for the Docker CLI.",
|
||||
}
|
||||
commands.AddCommands(cmd, dockerCLI)
|
||||
cmd.AddCommand(commands.NewRootCmd("buildx", true, dockerCLI))
|
||||
disableFlagsInUseLine(cmd)
|
||||
source := filepath.Join(opts.source, descriptionSourcePath)
|
||||
fmt.Println("Markdown source:", source)
|
||||
|
|
|
@ -86,9 +86,9 @@ func GenYamlTreeCustom(cmd *cobra.Command, dir string, filePrepender func(string
|
|||
// the "docker" command, and is a "dummy" with no flags, and only a single
|
||||
// subcommand (the plugin's top command). For plugins, we should skip the
|
||||
// root command altogether, to prevent generating a useless YAML file.
|
||||
// if !cmd.HasParent() {
|
||||
// return nil
|
||||
// }
|
||||
if !cmd.HasParent() {
|
||||
return nil
|
||||
}
|
||||
|
||||
basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".yaml"
|
||||
filename := filepath.Join(dir, basename)
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
# syntax = docker/dockerfile:1.2
|
||||
|
||||
FROM golang:1.16-alpine AS yamlgen
|
||||
WORKDIR /src
|
||||
RUN --mount=target=. \
|
||||
--mount=target=/root/.cache,type=cache \
|
||||
go build -mod=vendor -o /out/yamlgen ./docs/yamlgen
|
||||
|
||||
FROM alpine AS gen
|
||||
RUN apk add --no-cache rsync git
|
||||
WORKDIR /src
|
||||
COPY --from=yamlgen /out/yamlgen /usr/bin
|
||||
RUN --mount=target=/context \
|
||||
--mount=target=.,type=tmpfs,readwrite \
|
||||
rsync -a /context/. . \
|
||||
&& yamlgen --target /out/yaml
|
||||
|
||||
FROM scratch AS update
|
||||
COPY --from=gen /out /
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
. "$(dirname "$0")"/util
|
||||
set -eu
|
||||
|
||||
buildxCmd build \
|
||||
--output "type=local,dest=./bin/docs/" \
|
||||
--file "./hack/dockerfiles/yamldocs.Dockerfile" \
|
||||
--progress=plain \
|
||||
.
|
Загрузка…
Ссылка в новой задаче