0
0
mirror of https://github.com/thegeeklab/wp-docker-buildx.git synced 2024-11-25 09:10:39 +00:00
wp-docker-buildx/cmd/drone-docker-buildx/config.go

326 lines
10 KiB
Go
Raw Normal View History

package main
import (
"github.com/thegeeklab/drone-docker-buildx/plugin"
"github.com/thegeeklab/drone-plugin-lib/v2/drone"
"github.com/urfave/cli/v2"
)
// settingsFlags has the cli.Flags for the plugin.Settings.
//
//nolint:maintidx
2022-06-02 19:26:34 +00:00
func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "dry-run",
EnvVars: []string{"PLUGIN_DRY_RUN"},
2022-06-02 19:48:53 +00:00
Usage: "disable docker push",
Destination: &settings.Dryrun,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "daemon.mirror",
EnvVars: []string{"PLUGIN_MIRROR", "DOCKER_PLUGIN_MIRROR"},
2022-06-02 19:48:53 +00:00
Usage: "registry mirror to pull images",
Destination: &settings.Daemon.Mirror,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "daemon.storage-driver",
EnvVars: []string{"PLUGIN_STORAGE_DRIVER"},
2022-06-02 19:48:53 +00:00
Usage: "docker daemon storage driver",
Destination: &settings.Daemon.StorageDriver,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "daemon.storage-path",
EnvVars: []string{"PLUGIN_STORAGE_PATH"},
2022-06-02 19:48:53 +00:00
Usage: "docker daemon storage path",
Value: "/var/lib/docker",
Destination: &settings.Daemon.StoragePath,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "daemon.bip",
EnvVars: []string{"PLUGIN_BIP"},
2022-06-02 19:48:53 +00:00
Usage: "allow the docker daemon to bride ip address",
Destination: &settings.Daemon.Bip,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "daemon.mtu",
EnvVars: []string{"PLUGIN_MTU"},
2022-06-02 19:48:53 +00:00
Usage: "docker daemon custom mtu setting",
Destination: &settings.Daemon.MTU,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringSliceFlag{
Name: "daemon.dns",
EnvVars: []string{"PLUGIN_CUSTOM_DNS"},
2022-06-02 19:48:53 +00:00
Usage: "custom docker daemon dns server",
Destination: &settings.Daemon.DNS,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringSliceFlag{
Name: "daemon.dns-search",
EnvVars: []string{"PLUGIN_CUSTOM_DNS_SEARCH"},
2022-06-02 19:48:53 +00:00
Usage: "custom docker daemon dns search domain",
Destination: &settings.Daemon.DNSSearch,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.BoolFlag{
Name: "daemon.insecure",
EnvVars: []string{"PLUGIN_INSECURE"},
2022-06-02 19:48:53 +00:00
Usage: "allow the docker daemon to use insecure registries",
Value: false,
Destination: &settings.Daemon.Insecure,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.BoolFlag{
Name: "daemon.ipv6",
EnvVars: []string{"PLUGIN_IPV6"},
2022-06-02 19:48:53 +00:00
Usage: "enable docker daemon IPv6 support",
Value: false,
Destination: &settings.Daemon.IPv6,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.BoolFlag{
Name: "daemon.experimental",
EnvVars: []string{"PLUGIN_EXPERIMENTAL"},
2022-06-02 19:48:53 +00:00
Usage: "enable docker daemon experimental mode",
Value: false,
Destination: &settings.Daemon.Experimental,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.BoolFlag{
Name: "daemon.debug",
2022-06-02 19:48:53 +00:00
EnvVars: []string{"PLUGIN_DEBUG"},
Usage: "enable verbose debug mode for the docker daemon",
Value: false,
Destination: &settings.Daemon.Debug,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.BoolFlag{
Name: "daemon.off",
EnvVars: []string{"PLUGIN_DAEMON_OFF"},
2022-06-02 19:48:53 +00:00
Usage: "disable the startup of the docker daemon",
Value: false,
Destination: &settings.Daemon.Disabled,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "daemon.buildkit-config",
EnvVars: []string{"PLUGIN_BUILDKIT_CONFIG"},
Usage: "content of the docker buildkit toml config",
Destination: &settings.Daemon.BuildkitConfig,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "dockerfile",
EnvVars: []string{"PLUGIN_DOCKERFILE"},
2022-06-02 19:48:53 +00:00
Usage: "dockerfile to use for the image build",
Value: "Dockerfile",
Destination: &settings.Build.Dockerfile,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "context",
EnvVars: []string{"PLUGIN_CONTEXT"},
2022-06-02 19:48:53 +00:00
Usage: "path of the build context",
Value: ".",
Destination: &settings.Build.Context,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringSliceFlag{
Name: "named-context",
EnvVars: []string{"PLUGIN_NAMED_CONTEXT"},
Usage: "additional named build context",
Destination: &settings.Build.NamedContext,
Category: category,
},
&cli.StringSliceFlag{
Name: "tags",
EnvVars: []string{"PLUGIN_TAG", "PLUGIN_TAGS"},
2022-06-02 19:48:53 +00:00
Usage: "repository tags to use for the image",
FilePath: ".tags",
Destination: &settings.Build.Tags,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.BoolFlag{
Name: "tags.auto",
EnvVars: []string{"PLUGIN_DEFAULT_TAGS", "PLUGIN_AUTO_TAG"},
2022-06-02 19:48:53 +00:00
Usage: "generate tag names automatically based on git branch and git tag",
Value: false,
Destination: &settings.Build.TagsAuto,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "tags.suffix",
EnvVars: []string{"PLUGIN_DEFAULT_SUFFIX", "PLUGIN_AUTO_TAG_SUFFIX"},
2022-06-02 19:48:53 +00:00
Usage: "generate tag names with the given suffix",
Destination: &settings.Build.TagsSuffix,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringSliceFlag{
Name: "extra.tags",
EnvVars: []string{"PLUGIN_EXTRA_TAGS"},
Usage: "additional tags to use for the image including registry",
FilePath: ".extratags",
Destination: &settings.Build.ExtraTags,
Category: category,
},
&cli.StringSliceFlag{
Name: "args",
EnvVars: []string{"PLUGIN_BUILD_ARGS"},
2022-06-02 19:48:53 +00:00
Usage: "custom build arguments for the build",
Destination: &settings.Build.Args,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringSliceFlag{
Name: "args-from-env",
EnvVars: []string{"PLUGIN_BUILD_ARGS_FROM_ENV"},
2022-06-02 19:48:53 +00:00
Usage: "forward environment variables as custom arguments to the build",
Destination: &settings.Build.ArgsEnv,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.BoolFlag{
Name: "quiet",
EnvVars: []string{"PLUGIN_QUIET"},
2022-06-02 19:48:53 +00:00
Usage: "enable suppression of the build output",
Value: false,
Destination: &settings.Build.Quiet,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "output",
EnvVars: []string{"PLUGIN_OUTPUT"},
2022-06-02 19:48:53 +00:00
Usage: "export action for the build result",
Destination: &settings.Build.Output,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "target",
EnvVars: []string{"PLUGIN_TARGET"},
2022-06-02 19:48:53 +00:00
Usage: "build target to use",
Destination: &settings.Build.Target,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.GenericFlag{
Name: "cache-from",
EnvVars: []string{"PLUGIN_CACHE_FROM"},
Usage: "images to consider as cache sources",
Value: &drone.StringSliceFlag{},
Category: category,
},
&cli.StringFlag{
Name: "cache-to",
EnvVars: []string{"PLUGIN_CACHE_TO"},
Usage: "cache destination for the build cache",
Destination: &settings.Build.CacheTo,
Category: category,
},
&cli.BoolFlag{
Name: "pull-image",
EnvVars: []string{"PLUGIN_PULL_IMAGE"},
2022-06-02 19:48:53 +00:00
Usage: "enforce to pull base image at build time",
Value: true,
Destination: &settings.Build.Pull,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.BoolFlag{
Name: "compress",
EnvVars: []string{"PLUGIN_COMPRESS"},
2022-06-02 19:50:32 +00:00
Usage: "enable compression of the build context using gzip",
2022-06-02 19:48:53 +00:00
Value: false,
Destination: &settings.Build.Compress,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "repo",
EnvVars: []string{"PLUGIN_REPO"},
2022-06-02 19:48:53 +00:00
Usage: "repository name for the image",
Destination: &settings.Build.Repo,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "docker.registry",
EnvVars: []string{"PLUGIN_REGISTRY", "DOCKER_REGISTRY"},
2022-06-02 19:48:53 +00:00
Usage: "docker registry to authenticate with",
Value: "https://index.docker.io/v1/",
Destination: &settings.Login.Registry,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "docker.username",
EnvVars: []string{"PLUGIN_USERNAME", "DOCKER_USERNAME"},
2022-06-02 19:48:53 +00:00
Usage: "username for registry authentication",
Destination: &settings.Login.Username,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "docker.password",
EnvVars: []string{"PLUGIN_PASSWORD", "DOCKER_PASSWORD"},
2022-06-02 19:48:53 +00:00
Usage: "password for registry authentication",
Destination: &settings.Login.Password,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "docker.email",
EnvVars: []string{"PLUGIN_EMAIL", "DOCKER_EMAIL"},
2022-06-02 19:48:53 +00:00
Usage: "email address for registry authentication",
Destination: &settings.Login.Email,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringFlag{
Name: "docker.config",
EnvVars: []string{"PLUGIN_CONFIG", "DOCKER_PLUGIN_CONFIG"},
2022-06-02 19:48:53 +00:00
Usage: "content of the docker daemon json config",
Destination: &settings.Login.Config,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.BoolFlag{
Name: "no-cache",
EnvVars: []string{"PLUGIN_NO_CACHE"},
2022-06-02 19:48:53 +00:00
Usage: "disable the usage of cached intermediate containers",
Value: false,
Destination: &settings.Build.NoCache,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringSliceFlag{
Name: "add-host",
EnvVars: []string{"PLUGIN_ADD_HOST"},
2022-06-02 19:48:53 +00:00
Usage: "additional host:ip mapping",
Destination: &settings.Build.AddHost,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringSliceFlag{
Name: "platforms",
EnvVars: []string{"PLUGIN_PLATFORMS"},
2022-06-02 19:48:53 +00:00
Usage: "target platform for build",
Destination: &settings.Build.Platforms,
2022-06-02 19:26:34 +00:00
Category: category,
},
&cli.StringSliceFlag{
Name: "labels",
EnvVars: []string{"PLUGIN_LABELS"},
Usage: "labels to add to image",
Destination: &settings.Build.Labels,
Category: category,
},
&cli.StringFlag{
Name: "provenance",
EnvVars: []string{"PLUGIN_PROVENANCE"},
Usage: "generates provenance attestation for the build",
Destination: &settings.Build.Provenance,
Category: category,
},
&cli.StringFlag{
Name: "sbom",
EnvVars: []string{"PLUGIN_SBOM"},
Usage: "generates sbom attestation for the build",
Destination: &settings.Build.SBOM,
Category: category,
},
}
}