chore: cleanup docs and use cmd trace from plugin lib (#94)

This commit is contained in:
Robert Kaussow 2024-01-03 21:23:07 +01:00 committed by GitHub
parent a6c41b061c
commit 7cb1fdfd01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 426 additions and 215 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
/dist
/release
/wp-docker-buildx*
docs/data/data-raw.yaml
coverage.out
CHANGELOG.md

View File

@ -67,6 +67,10 @@ lint: golangci-lint
generate:
$(GO) generate $(GENERATE)
.PHONY: generate-docs
generate-docs:
$(GO) generate ./cmd/$(EXECUTABLE)/flags.go
.PHONY: test
test:
$(GO) run $(GOTESTSUM_PACKAGE) --no-color=false -- -coverprofile=coverage.out $(PACKAGES)

View File

@ -0,0 +1,58 @@
//go:build generate
// +build generate
package main
import (
"bytes"
"embed"
"fmt"
"os"
"text/template"
"github.com/thegeeklab/wp-docker-buildx/plugin"
"github.com/thegeeklab/wp-plugin-go/docs"
wp "github.com/thegeeklab/wp-plugin-go/plugin"
wp_template "github.com/thegeeklab/wp-plugin-go/template"
"github.com/urfave/cli/v2"
)
//go:embed templates/docs-data.yaml.tmpl
var yamlTemplate embed.FS
func main() {
settings := &plugin.Settings{}
app := &cli.App{
Flags: settingsFlags(settings, wp.FlagsPluginCategory),
}
out, err := toYAML(app)
if err != nil {
panic(err)
}
fi, err := os.Create("../../docs/data/data-raw.yaml")
if err != nil {
panic(err)
}
defer fi.Close()
if _, err := fi.WriteString(out); err != nil {
panic(err)
}
}
func toYAML(app *cli.App) (string, error) {
var w bytes.Buffer
yamlTmpl, err := template.New("docs").Funcs(wp_template.LoadFuncMap()).ParseFS(yamlTemplate, "templates/docs-data.yaml.tmpl")
if err != nil {
fmt.Println(yamlTmpl)
return "", err
}
if err := yamlTmpl.ExecuteTemplate(&w, "docs-data.yaml.tmpl", docs.GetTemplateData(app)); err != nil {
return "", err
}
return w.String(), nil
}

View File

@ -9,6 +9,7 @@ import (
// settingsFlags has the cli.Flags for the plugin.Settings.
//
//nolint:maintidx
//go:generate go run docs.go flags.go
func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
@ -23,6 +24,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
EnvVars: []string{"PLUGIN_MIRROR", "DOCKER_PLUGIN_MIRROR"},
Usage: "registry mirror to pull images",
Destination: &settings.Daemon.Mirror,
DefaultText: "$DOCKER_PLUGIN_MIRROR",
Category: category,
},
&cli.StringFlag{
@ -43,28 +45,28 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
&cli.StringFlag{
Name: "daemon.bip",
EnvVars: []string{"PLUGIN_BIP"},
Usage: "allow the docker daemon to bride ip address",
Usage: "allow the docker daemon to bride IP address",
Destination: &settings.Daemon.Bip,
Category: category,
},
&cli.StringFlag{
Name: "daemon.mtu",
EnvVars: []string{"PLUGIN_MTU"},
Usage: "docker daemon custom mtu setting",
Usage: "docker daemon custom MTU setting",
Destination: &settings.Daemon.MTU,
Category: category,
},
&cli.StringSliceFlag{
Name: "daemon.dns",
EnvVars: []string{"PLUGIN_CUSTOM_DNS"},
Usage: "custom docker daemon dns server",
Usage: "custom docker daemon DNS server",
Destination: &settings.Daemon.DNS,
Category: category,
},
&cli.StringSliceFlag{
Name: "daemon.dns-search",
EnvVars: []string{"PLUGIN_CUSTOM_DNS_SEARCH"},
Usage: "custom docker daemon dns search domain",
Usage: "custom docker daemon DNS search domain",
Destination: &settings.Daemon.DNSSearch,
Category: category,
},
@ -147,7 +149,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
},
&cli.StringSliceFlag{
Name: "tags",
EnvVars: []string{"PLUGIN_TAG", "PLUGIN_TAGS"},
EnvVars: []string{"PLUGIN_TAGS", "PLUGIN_TAG"},
Usage: "repository tags to use for the image",
FilePath: ".tags",
Destination: &settings.Build.Tags,
@ -155,7 +157,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
},
&cli.BoolFlag{
Name: "tags.auto",
EnvVars: []string{"PLUGIN_DEFAULT_TAGS", "PLUGIN_AUTO_TAG"},
EnvVars: []string{"PLUGIN_AUTO_TAG", "PLUGIN_DEFAULT_TAGS"},
Usage: "generate tag names automatically based on git branch and git tag",
Value: false,
Destination: &settings.Build.TagsAuto,
@ -163,7 +165,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
},
&cli.StringFlag{
Name: "tags.suffix",
EnvVars: []string{"PLUGIN_DEFAULT_SUFFIX", "PLUGIN_AUTO_TAG_SUFFIX"},
EnvVars: []string{"PLUGIN_AUTO_TAG_SUFFIX", "PLUGIN_DEFAULT_SUFFIX"},
Usage: "generate tag names with the given suffix",
Destination: &settings.Build.TagsSuffix,
Category: category,
@ -262,6 +264,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
EnvVars: []string{"PLUGIN_USERNAME", "DOCKER_USERNAME"},
Usage: "username for registry authentication",
Destination: &settings.Login.Username,
DefaultText: "$DOCKER_USERNAME",
Category: category,
},
&cli.StringFlag{
@ -269,6 +272,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
EnvVars: []string{"PLUGIN_PASSWORD", "DOCKER_PASSWORD"},
Usage: "password for registry authentication",
Destination: &settings.Login.Password,
DefaultText: "$DOCKER_PASSWORD",
Category: category,
},
&cli.StringFlag{
@ -276,6 +280,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
EnvVars: []string{"PLUGIN_EMAIL", "DOCKER_EMAIL"},
Usage: "email address for registry authentication",
Destination: &settings.Login.Email,
DefaultText: "$DOCKER_EMAIL",
Category: category,
},
&cli.StringFlag{
@ -283,6 +288,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
EnvVars: []string{"PLUGIN_CONFIG", "DOCKER_PLUGIN_CONFIG"},
Usage: "content of the docker daemon json config",
Destination: &settings.Login.Config,
DefaultText: "$DOCKER_PLUGIN_CONFIG",
Category: category,
},
&cli.BoolFlag{
@ -296,7 +302,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
&cli.StringSliceFlag{
Name: "add-host",
EnvVars: []string{"PLUGIN_ADD_HOST"},
Usage: "additional host:ip mapping",
Usage: "additional `host:ip` mapping",
Destination: &settings.Build.AddHost,
Category: category,
},
@ -324,7 +330,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
&cli.StringFlag{
Name: "sbom",
EnvVars: []string{"PLUGIN_SBOM"},
Usage: "generates sbom attestation for the build",
Usage: "generates SBOM attestation for the build",
Destination: &settings.Build.SBOM,
Category: category,
},

View File

@ -0,0 +1,18 @@
---
{{- if .GlobalArgs }}
properties:
{{- range $v := .GlobalArgs }}
- name: {{ $v.Name }}
{{- with $v.Description }}
description: |
{{ . | ToSentence }}
{{- end }}
{{- with $v.Type }}
type: {{ . }}
{{- end }}
{{- with $v.Default }}
defaultvalue: {{ . }}
{{- end }}
required: {{ default false $v.Required }}
{{ end -}}
{{ end -}}

View File

@ -30,7 +30,7 @@ name: default
steps:
- name: docker
image: thegeeklab/wp-docker-buildx:23
image: quay.io/thegeeklab/wp-docker-buildx
privileged: true
settings:
username: octocat
@ -61,7 +61,7 @@ name: default
steps:
- name: docker
image: thegeeklab/wp-docker-buildx:23
image: quay.io/thegeeklab/wp-docker-buildx
privileged: true
settings:
registry: ghcr.io
@ -79,7 +79,7 @@ name: default
steps:
- name: docker
image: thegeeklab/wp-docker-buildx:23
image: quay.io/thegeeklab/wp-docker-buildx
privileged: true
environment:
AWS_ACCESS_KEY_ID:

View File

@ -1,76 +1,49 @@
---
properties:
- name: dry_run
description: Disable docker push.
- name: add_host
description: |
Additional `host:ip` mapping.
type: list
required: false
- name: auto_tag
description: |
Generate tag names automatically based on git branch and git tag.
When this feature is enabled and the event type is `tag`, the plugin will automatically tag
the image using the standard semVer convention. For example:
- `1.0.0` produces docker tags `1`, `1.0`, `1.0.0`
- `1.0.0-rc.1` produces docker tags `1.0.0-rc.1`
When the event type is `push` and the target branch is your default branch, the plugin will
automatically tag the image as `latest`. All other event types and branches are ignored.
type: bool
defaultvalue: false
required: false
- name: mirror
description: Use a registry mirror to pull images.
type: string
required: false
- name: storage_driver
description: The docker daemon storage driver.
type: string
required: false
- name: storage_path
description: The docker daemon storage path.
defaultValue: /var/lib/docker
- name: auto_tag_suffix
description: |
Generate tag names with the given suffix.
type: string
required: false
- name: bip
description: Allows the docker daemon to bride IP address.
description: |
Allow the docker daemon to bride IP address.
type: string
required: false
- name: mtu
description: A docker daemon custom MTU.
type: string
required: false
- name: custom_dns
description: Custom docker daemon DNS server.
- name: build_args
description: |
Custom build arguments for the build.
type: list
required: false
- name: custom_dns_search
description: Custom docker daemon DNS search domain.
- name: build_args_from_env
description: |
Forward environment variables as custom arguments to the build.
type: list
required: false
- name: insecure
description: Enable the usage of insecure registries.
type: bool
defaultValue: false
required: false
- name: ipv6
description: Enable docker daemon IPv6 support.
type: bool
defaultValue: false
required: false
- name: experimental
description: Enable docker daemon experimental mode.
type: bool
defaultValue: false
required: false
- name: debug
description: Enable verbose debug mode for the docker daemon.
type: string
defaultValue: false
required: false
- name: daemon_off
description: Disable the startup of the docker daemon.
type: string
defaultValue: false
required: false
- name: buildkit_config
description: |
Content of the docker buildkit toml [config](https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md). Example:
@ -78,7 +51,7 @@ properties:
```yaml
steps:
- name: Build
image: thegeeklab/wp-docker-buildx:23
image: quay.io/thegeeklab/wp-docker-buildx
settings:
repo: example/repo
buildkit_config: |
@ -87,83 +60,6 @@ properties:
insecure = true
```
type: string
defaultValue: false
required: false
- name: max_concurrent_uploads
description: |
By default the Docker daemon will push five layers of an image at a time. If you are on a low bandwidth connection this may cause
timeout issues and you may want to lower with this option.
type: string
required: false
- name: containerfile
description: Set the containerfile to use for the image build.
defaultValue: Containerfile
type: string
required: false
- name: context
description: Set the path of the build context to use.
defaultValue: .
type: string
required: false
- name: named_context
description: Set additional named [build contexts](https://docs.docker.com/engine/reference/commandline/buildx_build/#build-context) (e.g., name=path).
type: list
required: false
- name: tags
description: Set repository tags to use for the image. Tags can also be loaded from a `.tags` file.
defaultValue: latest
type: list
required: false
- name: auto_tag
description: |
Generate tag names automatically based on git branch and git tag. When this feature is enabled and the event type is `tag`,
the plugin will automatically tag the image using the standard semVer convention. For example:
- `1.0.0` produces docker tags `1`, `1.0`, `1.0.0`
- `1.0.0-rc.1` produces docker tags `1.0.0-rc.1`
When the event type is `push` and the target branch is your default branch, the plugin will automatically tag the image
as `latest`. All other event types and branches are ignored.
defaultValue: false
type: bool
required: false
- name: auto_tag_suffix
description: Generate tag names with the given suffix.
type: string
required: false
- name: extra_tags
description: |
Set additional tags to be used for the image. Additional tags can also be loaded from an `.extratags` file. This function can be used
to push images to multiple registries at once. Therefore, it is necessary to use the `config` flag to provide a configuration file
that contains the authentication information for all used registries.
type: list
required: false
- name: build_args
description: Custom build arguments to pass to the build.
type: list
required: false
- name: build_args_from_env
description: Forward environment variables as custom arguments to the build.
type: list
required: false
- name: quiet
description: Enable suppression of the build output.
defaultValue: false
type: bool
required: false
- name: target
description: The docker build target.
type: string
required: false
- name: cache_from
@ -174,7 +70,7 @@ properties:
```yaml
steps:
- name: Build
image: thegeeklab/wp-docker-buildx:23
image: quay.io/thegeeklab/wp-docker-buildx
settings:
repo: example/repo
cache_from:
@ -191,87 +87,205 @@ properties:
type: string
required: false
- name: pull_image
description: Enforce to pull the base image at build time.
defaultValue: true
- name: compress
description: |
Enable compression of the build context using gzip.
type: bool
defaultvalue: false
required: false
- name: compress
description: Enable compression of the build context using gzip.
defaultValue: false
- name: config
description: |
Content of the docker daemon json config.
type: string
defaultvalue: $DOCKER_PLUGIN_CONFIG
required: false
- name: containerfile
description: |
Containerfile to use for the image build.
type: string
defaultvalue: "Containerfile"
required: false
- name: context
description: |
Path of the build context.
type: string
defaultvalue: "."
required: false
- name: custom_dns
description: |
Custom docker daemon dns server.
type: list
required: false
- name: custom_dns_search
description: |
Custom docker daemon dns search domain.
type: list
required: false
- name: daemon_off
description: |
Disable the startup of the docker daemon.
type: bool
defaultvalue: false
required: false
- name: debug
description: |
Enable verbose debug mode for the docker daemon.
type: bool
defaultvalue: false
required: false
- name: dry_run
description: |
Disable docker push.
type: bool
defaultvalue: false
required: false
- name: email
description: |
Email address for registry authentication.
type: string
defaultvalue: $DOCKER_EMAIL
required: false
- name: experimental
description: |
Enable docker daemon experimental mode.
type: bool
defaultvalue: false
required: false
- name: extra_tags
description: |
Additional tags to use for the image including registry.
Additional tags can also be loaded from an `.extratags` file. This function can be used to push
images to multiple registries at once. Therefore, it is necessary to use the `config` flag to
provide a configuration file that contains the authentication information for all used registries.
type: list
required: false
- name: insecure
description: |
Allow the docker daemon to use insecure registries.
type: bool
defaultvalue: false
required: false
- name: ipv6
description: |
Enable docker daemon IPv6 support.
type: bool
defaultvalue: false
required: false
- name: labels
description: |
Labels to add to image.
type: list
required: false
- name: max_concurrent_uploads
description: |
Max concurrent uploads for each push.
By default the Docker daemon will push five layers of an image at a time. If you are on a low bandwidth connection this may cause
timeout issues and you may want to lower with this option.
type: string
required: false
- name: mirror
description: |
Registry mirror to pull images.
type: string
defaultvalue: $DOCKER_PLUGIN_MIRROR
required: false
- name: mtu
description: |
Docker daemon custom MTU setting.
type: string
required: false
- name: named_context
description: |
Additional named [build contexts](https://docs.docker.com/engine/reference/commandline/buildx_build/#build-context) (format: `name=path`).
type: list
required: false
- name: no_cache
description: |
Disable the usage of cached intermediate containers.
type: bool
defaultvalue: false
required: false
- name: output
description: |
[Export action](https://docs.docker.com/engine/reference/commandline/buildx_build/#output) for the build result
(format: `path` or `type=TYPE[,KEY=VALUE]`).
defaultValue: false
type: bool
required: false
- name: repo
description: |
Repository name for the image. If the image is to be pushed to registries other than the default DockerHub,
it is necessary to set `repo` as fully-qualified name.
type: string
required: false
- name: registry
description: Docker registry to upload images.
defaultValue: https://index.docker.io/v1/
type: string
required: false
- name: username
description: Username for authentication with the registry.
type: string
required: false
- name: password
description: Password for authentication with the registry.
description: |
Password for registry authentication.
type: string
required: false
- name: email
description: E-Mail address for authentication with the registry.
type: string
required: false
- name: config
description: Content of the docker daemon json config.
type: string
required: false
- name: no_cache
description: Disable the usage of cached intermediate containers.
defaultValue: false
type: string
required: false
- name: add_host
description: Additional `host:ip` mapping.
type: list
defaultvalue: $DOCKER_PASSWORD
required: false
- name: platforms
description: Target platforms for build.
type: list
required: false
- name: labels
description: Labels to add to the image.
description: |
Target platform for build.
type: list
required: false
- name: provenance
description: Generate [provenance](https://docs.docker.com/build/attestations/slsa-provenance/) attestation for the build (shorthand for `--attest=type=provenance`).
description: |
Generate [provenance](https://docs.docker.com/build/attestations/slsa-provenance/) attestation for the build (shorthand for `--attest=type=provenance`).
type: string
required: false
- name: pull_image
description: |
Enforce to pull base image at build time.
type: bool
defaultvalue: true
required: false
- name: quiet
description: |
Enable suppression of the build output.
type: bool
defaultvalue: false
required: false
- name: registry
description: |
Docker registry to authenticate with.
type: string
defaultvalue: "https://index.docker.io/v1/"
required: false
- name: repo
description: |
Repository name for the image.
If the image is to be pushed to registries other than the default DockerHub,
it is necessary to set `repo` as fully-qualified name.
type: string
required: false
- name: sbom
description: Generate [sbom](https://docs.docker.com/build/attestations/sbom/) attestation for the build (shorthand for `--attest type=sbom`).
description: |
Generate [SBOM](https://docs.docker.com/build/attestations/sbom/) attestation for the build (shorthand for `--attest type=sbom`).
type: string
required: false
@ -283,7 +297,7 @@ properties:
```yaml
steps:
- name: Build
image: thegeeklab/wp-docker-buildx:23
image: quay.io/thegeeklab/wp-docker-buildx
privileged: true
environment:
SECURE_TOKEN:
@ -300,3 +314,37 @@ properties:
This should be used with caution and avoided whenever possible.
type: list
required: false
- name: storage_driver
description: |
Docker daemon storage driver.
type: string
required: false
- name: storage_path
description: |
Docker daemon storage path.
type: string
defaultvalue: "/var/lib/docker"
required: false
- name: tags
description: |
Repository tags to use for the image.
Tags can also be loaded from a `.tags` file.
type: list
required: false
- name: target
description: |
Build target to use.
type: string
required: false
- name: username
description: |
Username for registry authentication.
type: string
defaultvalue: $DOCKER_USERNAME
required: false

12
go.mod
View File

@ -5,18 +5,28 @@ go 1.21
require (
github.com/cenkalti/backoff/v4 v4.2.1
github.com/rs/zerolog v1.31.0
github.com/thegeeklab/wp-plugin-go v1.3.0
github.com/thegeeklab/wp-plugin-go v1.5.0
github.com/urfave/cli/v2 v2.27.1
golang.org/x/sys v0.15.0
)
require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/net v0.19.0 // indirect
)

71
go.sum
View File

@ -1,11 +1,27 @@
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4=
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
@ -13,22 +29,73 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY=
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
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/thegeeklab/wp-plugin-go v1.3.0 h1:Yhz0dTDwXcbeaoyoPOXNDf2RzSoUixHuE+ML27cYy2E=
github.com/thegeeklab/wp-plugin-go v1.3.0/go.mod h1:EUOH6XJ8G/bcd6gmM6a6vLeta+keyX9ul1Es0F0r2Lc=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/thegeeklab/wp-plugin-go v1.5.0 h1:fA/kQwQrntjxdxePKKGecMRnPbj1xwpy6D2JrrPD2qA=
github.com/thegeeklab/wp-plugin-go v1.5.0/go.mod h1:ULBD5SNC7bkIB/UbLMQpcPWj7iZObCTWg8bqXf1zqsA=
github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho=
github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -5,6 +5,8 @@ import (
"net"
"os"
"os/exec"
"github.com/thegeeklab/wp-plugin-go/trace"
)
func (p Plugin) startCoredns() {
@ -18,7 +20,7 @@ func (p Plugin) startCoredns() {
}
go func() {
trace(cmd)
trace.Cmd(cmd)
_ = cmd.Run()
}()
}

View File

@ -3,6 +3,8 @@ package plugin
import (
"io"
"os"
"github.com/thegeeklab/wp-plugin-go/trace"
)
const (
@ -23,7 +25,7 @@ func (p Plugin) startDaemon() {
}
go func() {
trace(cmd)
trace.Cmd(cmd)
_ = cmd.Run()
}()
}

View File

@ -259,9 +259,3 @@ func commandDaemon(daemon Daemon) *execabs.Cmd {
return execabs.Command(dockerdBin, args...)
}
// trace writes each command to stdout with the command wrapped in an xml
// tag so that it can be extracted and displayed in the logs.
func trace(cmd *execabs.Cmd) {
fmt.Fprintf(os.Stdout, "+ %s\n", strings.Join(cmd.Args, " "))
}

View File

@ -11,6 +11,7 @@ import (
"github.com/cenkalti/backoff/v4"
"github.com/rs/zerolog/log"
"github.com/thegeeklab/wp-plugin-go/tag"
"github.com/thegeeklab/wp-plugin-go/trace"
"github.com/thegeeklab/wp-plugin-go/types"
"github.com/urfave/cli/v2"
"golang.org/x/sys/execabs"
@ -162,7 +163,7 @@ func (p *Plugin) Execute() error {
versionCmd.Stdout = os.Stdout
versionCmd.Stderr = os.Stderr
trace(versionCmd)
trace.Cmd(versionCmd)
return versionCmd.Run()
}
@ -184,7 +185,7 @@ func (p *Plugin) Execute() error {
for _, cmd := range batchCmd {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
trace(cmd)
trace.Cmd(cmd)
err := cmd.Run()
if err != nil {