drone-docker/cmd/drone-docker/config.go

267 lines
8.3 KiB
Go
Raw Normal View History

2021-01-17 13:06:23 +01:00
package main
import (
"github.com/thegeeklab/drone-docker/plugin"
"github.com/urfave/cli/v2"
)
// settingsFlags has the cli.Flags for the plugin.Settings.
func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
2021-01-17 13:06:23 +01:00
return []cli.Flag{
&cli.BoolFlag{
Name: "dry-run",
EnvVars: []string{"PLUGIN_DRY_RUN"},
2022-05-29 23:37:56 +02:00
Usage: "disable docker push",
2021-01-17 13:06:23 +01:00
Destination: &settings.Dryrun,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringFlag{
Name: "daemon.mirror",
EnvVars: []string{"PLUGIN_MIRROR", "DOCKER_PLUGIN_MIRROR"},
2022-05-29 23:37:56 +02:00
Usage: "registry mirror to pull images",
2021-01-17 13:06:23 +01:00
Destination: &settings.Daemon.Mirror,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringFlag{
Name: "daemon.storage-driver",
EnvVars: []string{"PLUGIN_STORAGE_DRIVER"},
2022-05-29 23:37:56 +02:00
Usage: "docker daemon storage driver",
2021-01-17 13:06:23 +01:00
Destination: &settings.Daemon.StorageDriver,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringFlag{
Name: "daemon.storage-path",
EnvVars: []string{"PLUGIN_STORAGE_PATH"},
2022-05-29 23:37:56 +02:00
Usage: "docker daemon storage path",
Value: "/var/lib/docker",
2021-01-17 13:06:23 +01:00
Destination: &settings.Daemon.StoragePath,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringFlag{
Name: "daemon.bip",
EnvVars: []string{"PLUGIN_BIP"},
2022-05-29 23:37:56 +02:00
Usage: "allow the docker daemon to bride ip address",
2021-01-17 13:06:23 +01:00
Destination: &settings.Daemon.Bip,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringFlag{
Name: "daemon.mtu",
EnvVars: []string{"PLUGIN_MTU"},
2022-05-29 23:37:56 +02:00
Usage: "docker daemon custom mtu setting",
2021-01-17 13:06:23 +01:00
Destination: &settings.Daemon.MTU,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringSliceFlag{
Name: "daemon.dns",
EnvVars: []string{"PLUGIN_CUSTOM_DNS"},
2022-05-29 23:37:56 +02:00
Usage: "custom docker daemon dns server",
2021-01-17 13:06:23 +01:00
Destination: &settings.Daemon.DNS,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringSliceFlag{
Name: "daemon.dns-search",
EnvVars: []string{"PLUGIN_CUSTOM_DNS_SEARCH"},
2022-05-29 23:37:56 +02:00
Usage: "custom docker daemon dns search domain",
2021-01-17 13:06:23 +01:00
Destination: &settings.Daemon.DNSSearch,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.BoolFlag{
Name: "daemon.insecure",
EnvVars: []string{"PLUGIN_INSECURE"},
2022-05-29 23:37:56 +02:00
Usage: "allow the docker daemon to use insecure registries",
Value: false,
2021-01-17 13:06:23 +01:00
Destination: &settings.Daemon.Insecure,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.BoolFlag{
Name: "daemon.ipv6",
EnvVars: []string{"PLUGIN_IPV6"},
2022-05-29 23:37:56 +02:00
Usage: "enable docker daemon IPv6 support",
Value: false,
2021-01-17 13:06:23 +01:00
Destination: &settings.Daemon.IPv6,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.BoolFlag{
Name: "daemon.experimental",
EnvVars: []string{"PLUGIN_EXPERIMENTAL"},
2022-05-29 23:37:56 +02:00
Usage: "enable docker daemon experimental mode",
Value: false,
2021-01-17 13:06:23 +01:00
Destination: &settings.Daemon.Experimental,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.BoolFlag{
Name: "daemon.debug",
EnvVars: []string{"PLUGIN_DEBUG", "DOCKER_LAUNCH_DEBUG"},
2022-05-29 23:37:56 +02:00
Usage: "enable verbose debug mode for the docker daemon",
Value: false,
2021-01-17 13:06:23 +01:00
Destination: &settings.Daemon.Debug,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.BoolFlag{
Name: "daemon.off",
EnvVars: []string{"PLUGIN_DAEMON_OFF"},
2022-05-29 23:37:56 +02:00
Usage: "disable the startup of the docker daemon",
Value: false,
2021-01-17 13:06:23 +01:00
Destination: &settings.Daemon.Disabled,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringFlag{
Name: "dockerfile",
EnvVars: []string{"PLUGIN_DOCKERFILE"},
2022-05-29 23:37:56 +02:00
Usage: "dockerfile to use for the image build",
Value: "Dockerfile",
2021-01-17 13:06:23 +01:00
Destination: &settings.Build.Dockerfile,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringFlag{
Name: "context",
EnvVars: []string{"PLUGIN_CONTEXT"},
2022-05-29 23:37:56 +02:00
Usage: "path of the build context",
Value: ".",
2021-01-17 13:06:23 +01:00
Destination: &settings.Build.Context,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringSliceFlag{
Name: "tags",
EnvVars: []string{"PLUGIN_TAG", "PLUGIN_TAGS"},
2022-05-29 23:37:56 +02:00
Usage: "repository tags to use for the image",
2021-01-17 13:06:23 +01:00
FilePath: ".tags",
Destination: &settings.Build.Tags,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.BoolFlag{
Name: "tags.auto",
EnvVars: []string{"PLUGIN_DEFAULT_TAGS", "PLUGIN_AUTO_TAG"},
2022-05-29 23:37:56 +02:00
Usage: "generate tag names automatically based on git branch and git tag",
Value: false,
2021-01-17 13:06:23 +01:00
Destination: &settings.Build.TagsAuto,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringFlag{
Name: "tags.suffix",
EnvVars: []string{"PLUGIN_DEFAULT_SUFFIX", "PLUGIN_AUTO_TAG_SUFFIX"},
2022-05-29 23:37:56 +02:00
Usage: "generate tag names with the given suffix",
2021-01-17 13:06:23 +01:00
Destination: &settings.Build.TagsSuffix,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringSliceFlag{
Name: "args",
EnvVars: []string{"PLUGIN_BUILD_ARGS"},
2022-05-29 23:37:56 +02:00
Usage: "custom build arguments for the build",
2021-01-17 13:06:23 +01:00
Destination: &settings.Build.Args,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringSliceFlag{
Name: "args-from-env",
EnvVars: []string{"PLUGIN_BUILD_ARGS_FROM_ENV"},
2022-05-29 23:37:56 +02:00
Usage: "forward environment variables as custom arguments to the build",
2021-01-17 13:06:23 +01:00
Destination: &settings.Build.ArgsEnv,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.BoolFlag{
Name: "quiet",
EnvVars: []string{"PLUGIN_QUIET"},
2022-05-29 23:37:56 +02:00
Usage: "enable suppression of the build output",
Value: false,
2021-01-17 13:06:23 +01:00
Destination: &settings.Build.Quiet,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringFlag{
Name: "target",
EnvVars: []string{"PLUGIN_TARGET"},
2022-05-29 23:37:56 +02:00
Usage: "build target to use",
2021-01-17 13:06:23 +01:00
Destination: &settings.Build.Target,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringSliceFlag{
Name: "cache-from",
EnvVars: []string{"PLUGIN_CACHE_FROM"},
2022-05-29 23:37:56 +02:00
Usage: "images to consider as cache sources",
2021-01-17 13:06:23 +01:00
Destination: &settings.Build.CacheFrom,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.BoolFlag{
Name: "pull-image",
EnvVars: []string{"PLUGIN_PULL_IMAGE"},
2022-05-29 23:37:56 +02:00
Usage: "enforce to pull base image at build time",
2021-01-17 13:06:23 +01:00
Value: true,
Destination: &settings.Build.Pull,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.BoolFlag{
Name: "compress",
EnvVars: []string{"PLUGIN_COMPRESS"},
2022-06-02 21:51:35 +02:00
Usage: "enable compression of the build context using gzip",
2022-05-29 23:37:56 +02:00
Value: false,
2021-01-17 13:06:23 +01:00
Destination: &settings.Build.Compress,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringFlag{
Name: "repo",
EnvVars: []string{"PLUGIN_REPO"},
2022-05-29 23:37:56 +02:00
Usage: "repository name for the image",
2021-01-17 13:06:23 +01:00
Destination: &settings.Build.Repo,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringFlag{
Name: "docker.registry",
EnvVars: []string{"PLUGIN_REGISTRY", "DOCKER_REGISTRY"},
2022-05-29 23:37:56 +02:00
Usage: "docker registry to authenticate with",
Value: "https://index.docker.io/v1/",
2021-01-17 13:06:23 +01:00
Destination: &settings.Login.Registry,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringFlag{
Name: "docker.username",
EnvVars: []string{"PLUGIN_USERNAME", "DOCKER_USERNAME"},
2022-05-29 23:37:56 +02:00
Usage: "username for registry authentication",
2021-01-17 13:06:23 +01:00
Destination: &settings.Login.Username,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringFlag{
Name: "docker.password",
EnvVars: []string{"PLUGIN_PASSWORD", "DOCKER_PASSWORD"},
2022-05-29 23:37:56 +02:00
Usage: "password for registry authentication",
2021-01-17 13:06:23 +01:00
Destination: &settings.Login.Password,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringFlag{
Name: "docker.email",
EnvVars: []string{"PLUGIN_EMAIL", "DOCKER_EMAIL"},
2022-05-29 23:37:56 +02:00
Usage: "email address for registry authentication",
2021-01-17 13:06:23 +01:00
Destination: &settings.Login.Email,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringFlag{
Name: "docker.config",
EnvVars: []string{"PLUGIN_CONFIG", "DOCKER_PLUGIN_CONFIG"},
2022-05-29 23:37:56 +02:00
Usage: "content of the docker daemon json config",
2021-01-17 13:06:23 +01:00
Destination: &settings.Login.Config,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.BoolFlag{
Name: "docker.purge",
EnvVars: []string{"PLUGIN_PURGE"},
2022-05-29 23:37:56 +02:00
Usage: "enable cleanup of the docker environment at the end of a build",
2021-01-17 13:06:23 +01:00
Value: true,
Destination: &settings.Cleanup,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.BoolFlag{
Name: "no-cache",
EnvVars: []string{"PLUGIN_NO_CACHE"},
2022-05-29 23:37:56 +02:00
Usage: "disable the usage of cached intermediate containers",
Value: false,
2021-01-17 13:06:23 +01:00
Destination: &settings.Build.NoCache,
Category: category,
2021-01-17 13:06:23 +01:00
},
&cli.StringSliceFlag{
Name: "add-host",
EnvVars: []string{"PLUGIN_ADD_HOST"},
2022-05-29 23:37:56 +02:00
Usage: "additional host:ip mapping",
2021-01-17 13:06:23 +01:00
Destination: &settings.Build.AddHost,
Category: category,
2021-01-17 13:06:23 +01:00
},
}
}