2021-01-11 20:54:49 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/thegeeklab/drone-docker-buildx/plugin"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// settingsFlags has the cli.Flags for the plugin.Settings.
|
2022-06-02 19:26:34 +00:00
|
|
|
func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
2021-01-11 20:54:49 +00:00
|
|
|
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",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Dryrun,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Daemon.Mirror,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "daemon.storage-driver",
|
|
|
|
EnvVars: []string{"PLUGIN_STORAGE_DRIVER"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "docker daemon storage driver",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Daemon.StorageDriver,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "daemon.storage-path",
|
|
|
|
EnvVars: []string{"PLUGIN_STORAGE_PATH"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "docker daemon storage path",
|
2021-09-11 19:15:02 +00:00
|
|
|
Value: "/var/lib/docker",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Daemon.StoragePath,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Daemon.Bip,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "daemon.mtu",
|
|
|
|
EnvVars: []string{"PLUGIN_MTU"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "docker daemon custom mtu setting",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Daemon.MTU,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&cli.StringSliceFlag{
|
|
|
|
Name: "daemon.dns",
|
|
|
|
EnvVars: []string{"PLUGIN_CUSTOM_DNS"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "custom docker daemon dns server",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Daemon.DNS,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Daemon.DNSSearch,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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,
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Daemon.Insecure,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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,
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Daemon.IPv6,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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,
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Daemon.Experimental,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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,
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Daemon.Debug,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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,
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Daemon.Disabled,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
2021-07-08 07:00:51 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "daemon.buildkit-config",
|
|
|
|
EnvVars: []string{"PLUGIN_BUILDKIT_CONFIG"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "content of the docker buildkit json config",
|
2021-07-08 07:00:51 +00:00
|
|
|
Destination: &settings.Daemon.BuildkitConfig,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-07-08 07:00:51 +00:00
|
|
|
},
|
2021-01-11 20:54:49 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "dockerfile",
|
|
|
|
EnvVars: []string{"PLUGIN_DOCKERFILE"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "dockerfile to use for the image build",
|
2021-09-11 19:15:02 +00:00
|
|
|
Value: "Dockerfile",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Build.Dockerfile,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "context",
|
|
|
|
EnvVars: []string{"PLUGIN_CONTEXT"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "path of the build context",
|
2021-09-11 19:15:02 +00:00
|
|
|
Value: ".",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Build.Context,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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",
|
2021-01-11 20:54:49 +00:00
|
|
|
FilePath: ".tags",
|
|
|
|
Destination: &settings.Build.Tags,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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,
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Build.TagsAuto,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Build.TagsSuffix,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&cli.StringSliceFlag{
|
|
|
|
Name: "args",
|
|
|
|
EnvVars: []string{"PLUGIN_BUILD_ARGS"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "custom build arguments for the build",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Build.Args,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Build.ArgsEnv,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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,
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Build.Quiet,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
2022-01-27 20:53:46 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "output",
|
|
|
|
EnvVars: []string{"PLUGIN_OUTPUT"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "export action for the build result",
|
2022-01-27 20:53:46 +00:00
|
|
|
Destination: &settings.Build.Output,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2022-01-27 20:53:46 +00:00
|
|
|
},
|
2021-01-11 20:54:49 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "target",
|
|
|
|
EnvVars: []string{"PLUGIN_TARGET"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "build target to use",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Build.Target,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&cli.StringSliceFlag{
|
|
|
|
Name: "cache-from",
|
|
|
|
EnvVars: []string{"PLUGIN_CACHE_FROM"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "images to consider as cache sources",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Build.CacheFrom,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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",
|
2021-01-11 20:54:49 +00:00
|
|
|
Value: true,
|
|
|
|
Destination: &settings.Build.Pull,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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,
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Build.Compress,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "repo",
|
|
|
|
EnvVars: []string{"PLUGIN_REPO"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "repository name for the image",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Build.Repo,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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",
|
2021-09-11 19:15:02 +00:00
|
|
|
Value: "https://index.docker.io/v1/",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Login.Registry,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "docker.username",
|
|
|
|
EnvVars: []string{"PLUGIN_USERNAME", "DOCKER_USERNAME"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "username for registry authentication",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Login.Username,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "docker.password",
|
|
|
|
EnvVars: []string{"PLUGIN_PASSWORD", "DOCKER_PASSWORD"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "password for registry authentication",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Login.Password,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Login.Email,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Login.Config,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&cli.BoolFlag{
|
|
|
|
Name: "docker.purge",
|
|
|
|
EnvVars: []string{"PLUGIN_PURGE"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "enable cleanup of the docker environment at the end of a build",
|
2021-01-11 20:54:49 +00:00
|
|
|
Value: true,
|
|
|
|
Destination: &settings.Cleanup,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&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,
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Build.NoCache,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&cli.StringSliceFlag{
|
|
|
|
Name: "add-host",
|
|
|
|
EnvVars: []string{"PLUGIN_ADD_HOST"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "additional host:ip mapping",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Build.AddHost,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
&cli.StringSliceFlag{
|
|
|
|
Name: "platforms",
|
|
|
|
EnvVars: []string{"PLUGIN_PLATFORMS"},
|
2022-06-02 19:48:53 +00:00
|
|
|
Usage: "target platform for build",
|
2021-01-11 20:54:49 +00:00
|
|
|
Destination: &settings.Build.Platforms,
|
2022-06-02 19:26:34 +00:00
|
|
|
Category: category,
|
2021-01-11 20:54:49 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|