mirror of
https://github.com/thegeeklab/drone-docker.git
synced 2024-11-23 13:20:40 +00:00
refactor: add plugin flags to category (#51)
This commit is contained in:
parent
eedb9aee12
commit
7bd5096b3e
@ -6,31 +6,35 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// settingsFlags has the cli.Flags for the plugin.Settings.
|
// settingsFlags has the cli.Flags for the plugin.Settings.
|
||||||
func settingsFlags(settings *plugin.Settings) []cli.Flag {
|
func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
||||||
return []cli.Flag{
|
return []cli.Flag{
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "dry-run",
|
Name: "dry-run",
|
||||||
EnvVars: []string{"PLUGIN_DRY_RUN"},
|
EnvVars: []string{"PLUGIN_DRY_RUN"},
|
||||||
Usage: "disables docker push",
|
Usage: "disables docker push",
|
||||||
Destination: &settings.Dryrun,
|
Destination: &settings.Dryrun,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "remote.url",
|
Name: "remote.url",
|
||||||
EnvVars: []string{"DRONE_REMOTE_URL"},
|
EnvVars: []string{"DRONE_REMOTE_URL"},
|
||||||
Usage: "sets the git remote url",
|
Usage: "sets the git remote url",
|
||||||
Destination: &settings.Build.Remote,
|
Destination: &settings.Build.Remote,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "daemon.mirror",
|
Name: "daemon.mirror",
|
||||||
EnvVars: []string{"PLUGIN_MIRROR", "DOCKER_PLUGIN_MIRROR"},
|
EnvVars: []string{"PLUGIN_MIRROR", "DOCKER_PLUGIN_MIRROR"},
|
||||||
Usage: "sets a registry mirror to pull images",
|
Usage: "sets a registry mirror to pull images",
|
||||||
Destination: &settings.Daemon.Mirror,
|
Destination: &settings.Daemon.Mirror,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "daemon.storage-driver",
|
Name: "daemon.storage-driver",
|
||||||
EnvVars: []string{"PLUGIN_STORAGE_DRIVER"},
|
EnvVars: []string{"PLUGIN_STORAGE_DRIVER"},
|
||||||
Usage: "sets the docker daemon storage driver",
|
Usage: "sets the docker daemon storage driver",
|
||||||
Destination: &settings.Daemon.StorageDriver,
|
Destination: &settings.Daemon.StorageDriver,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "daemon.storage-path",
|
Name: "daemon.storage-path",
|
||||||
@ -38,60 +42,70 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
|
|||||||
Usage: "sets the docker daemon storage path",
|
Usage: "sets the docker daemon storage path",
|
||||||
Value: "/var/lib/docker",
|
Value: "/var/lib/docker",
|
||||||
Destination: &settings.Daemon.StoragePath,
|
Destination: &settings.Daemon.StoragePath,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "daemon.bip",
|
Name: "daemon.bip",
|
||||||
EnvVars: []string{"PLUGIN_BIP"},
|
EnvVars: []string{"PLUGIN_BIP"},
|
||||||
Usage: "allows the docker daemon to bride ip address",
|
Usage: "allows the docker daemon to bride ip address",
|
||||||
Destination: &settings.Daemon.Bip,
|
Destination: &settings.Daemon.Bip,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "daemon.mtu",
|
Name: "daemon.mtu",
|
||||||
EnvVars: []string{"PLUGIN_MTU"},
|
EnvVars: []string{"PLUGIN_MTU"},
|
||||||
Usage: "sets docker daemon custom mtu setting",
|
Usage: "sets docker daemon custom mtu setting",
|
||||||
Destination: &settings.Daemon.MTU,
|
Destination: &settings.Daemon.MTU,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
Name: "daemon.dns",
|
Name: "daemon.dns",
|
||||||
EnvVars: []string{"PLUGIN_CUSTOM_DNS"},
|
EnvVars: []string{"PLUGIN_CUSTOM_DNS"},
|
||||||
Usage: "sets custom docker daemon dns server",
|
Usage: "sets custom docker daemon dns server",
|
||||||
Destination: &settings.Daemon.DNS,
|
Destination: &settings.Daemon.DNS,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
Name: "daemon.dns-search",
|
Name: "daemon.dns-search",
|
||||||
EnvVars: []string{"PLUGIN_CUSTOM_DNS_SEARCH"},
|
EnvVars: []string{"PLUGIN_CUSTOM_DNS_SEARCH"},
|
||||||
Usage: "sets custom docker daemon dns search domain",
|
Usage: "sets custom docker daemon dns search domain",
|
||||||
Destination: &settings.Daemon.DNSSearch,
|
Destination: &settings.Daemon.DNSSearch,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "daemon.insecure",
|
Name: "daemon.insecure",
|
||||||
EnvVars: []string{"PLUGIN_INSECURE"},
|
EnvVars: []string{"PLUGIN_INSECURE"},
|
||||||
Usage: "allows the docker daemon to use insecure registries",
|
Usage: "allows the docker daemon to use insecure registries",
|
||||||
Destination: &settings.Daemon.Insecure,
|
Destination: &settings.Daemon.Insecure,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "daemon.ipv6",
|
Name: "daemon.ipv6",
|
||||||
EnvVars: []string{"PLUGIN_IPV6"},
|
EnvVars: []string{"PLUGIN_IPV6"},
|
||||||
Usage: "enables docker daemon IPv6 support",
|
Usage: "enables docker daemon IPv6 support",
|
||||||
Destination: &settings.Daemon.IPv6,
|
Destination: &settings.Daemon.IPv6,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "daemon.experimental",
|
Name: "daemon.experimental",
|
||||||
EnvVars: []string{"PLUGIN_EXPERIMENTAL"},
|
EnvVars: []string{"PLUGIN_EXPERIMENTAL"},
|
||||||
Usage: "enables docker daemon experimental mode",
|
Usage: "enables docker daemon experimental mode",
|
||||||
Destination: &settings.Daemon.Experimental,
|
Destination: &settings.Daemon.Experimental,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "daemon.debug",
|
Name: "daemon.debug",
|
||||||
EnvVars: []string{"PLUGIN_DEBUG", "DOCKER_LAUNCH_DEBUG"},
|
EnvVars: []string{"PLUGIN_DEBUG", "DOCKER_LAUNCH_DEBUG"},
|
||||||
Usage: "enables verbose debug mode for the docker daemon",
|
Usage: "enables verbose debug mode for the docker daemon",
|
||||||
Destination: &settings.Daemon.Debug,
|
Destination: &settings.Daemon.Debug,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "daemon.off",
|
Name: "daemon.off",
|
||||||
EnvVars: []string{"PLUGIN_DAEMON_OFF"},
|
EnvVars: []string{"PLUGIN_DAEMON_OFF"},
|
||||||
Usage: "disables the startup of the docker daemon",
|
Usage: "disables the startup of the docker daemon",
|
||||||
Destination: &settings.Daemon.Disabled,
|
Destination: &settings.Daemon.Disabled,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "dockerfile",
|
Name: "dockerfile",
|
||||||
@ -99,6 +113,7 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
|
|||||||
Usage: "sets dockerfile to use for the image build",
|
Usage: "sets dockerfile to use for the image build",
|
||||||
Value: "Dockerfile",
|
Value: "Dockerfile",
|
||||||
Destination: &settings.Build.Dockerfile,
|
Destination: &settings.Build.Dockerfile,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "context",
|
Name: "context",
|
||||||
@ -106,6 +121,7 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
|
|||||||
Usage: "sets the path of the build context to use",
|
Usage: "sets the path of the build context to use",
|
||||||
Value: ".",
|
Value: ".",
|
||||||
Destination: &settings.Build.Context,
|
Destination: &settings.Build.Context,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
Name: "tags",
|
Name: "tags",
|
||||||
@ -113,48 +129,56 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
|
|||||||
Usage: "sets repository tags to use for the image",
|
Usage: "sets repository tags to use for the image",
|
||||||
FilePath: ".tags",
|
FilePath: ".tags",
|
||||||
Destination: &settings.Build.Tags,
|
Destination: &settings.Build.Tags,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "tags.auto",
|
Name: "tags.auto",
|
||||||
EnvVars: []string{"PLUGIN_DEFAULT_TAGS", "PLUGIN_AUTO_TAG"},
|
EnvVars: []string{"PLUGIN_DEFAULT_TAGS", "PLUGIN_AUTO_TAG"},
|
||||||
Usage: "generates tag names automatically based on git branch and git tag",
|
Usage: "generates tag names automatically based on git branch and git tag",
|
||||||
Destination: &settings.Build.TagsAuto,
|
Destination: &settings.Build.TagsAuto,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "tags.suffix",
|
Name: "tags.suffix",
|
||||||
EnvVars: []string{"PLUGIN_DEFAULT_SUFFIX", "PLUGIN_AUTO_TAG_SUFFIX"},
|
EnvVars: []string{"PLUGIN_DEFAULT_SUFFIX", "PLUGIN_AUTO_TAG_SUFFIX"},
|
||||||
Usage: "generates tag names with the given suffix",
|
Usage: "generates tag names with the given suffix",
|
||||||
Destination: &settings.Build.TagsSuffix,
|
Destination: &settings.Build.TagsSuffix,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
Name: "args",
|
Name: "args",
|
||||||
EnvVars: []string{"PLUGIN_BUILD_ARGS"},
|
EnvVars: []string{"PLUGIN_BUILD_ARGS"},
|
||||||
Usage: "sets custom build arguments for the build",
|
Usage: "sets custom build arguments for the build",
|
||||||
Destination: &settings.Build.Args,
|
Destination: &settings.Build.Args,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
Name: "args-from-env",
|
Name: "args-from-env",
|
||||||
EnvVars: []string{"PLUGIN_BUILD_ARGS_FROM_ENV"},
|
EnvVars: []string{"PLUGIN_BUILD_ARGS_FROM_ENV"},
|
||||||
Usage: "forwards environment variables as custom arguments to the build",
|
Usage: "forwards environment variables as custom arguments to the build",
|
||||||
Destination: &settings.Build.ArgsEnv,
|
Destination: &settings.Build.ArgsEnv,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "quiet",
|
Name: "quiet",
|
||||||
EnvVars: []string{"PLUGIN_QUIET"},
|
EnvVars: []string{"PLUGIN_QUIET"},
|
||||||
Usage: "enables suppression of the build output",
|
Usage: "enables suppression of the build output",
|
||||||
Destination: &settings.Build.Quiet,
|
Destination: &settings.Build.Quiet,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "target",
|
Name: "target",
|
||||||
EnvVars: []string{"PLUGIN_TARGET"},
|
EnvVars: []string{"PLUGIN_TARGET"},
|
||||||
Usage: "sets the build target to use",
|
Usage: "sets the build target to use",
|
||||||
Destination: &settings.Build.Target,
|
Destination: &settings.Build.Target,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
Name: "cache-from",
|
Name: "cache-from",
|
||||||
EnvVars: []string{"PLUGIN_CACHE_FROM"},
|
EnvVars: []string{"PLUGIN_CACHE_FROM"},
|
||||||
Usage: "sets images to consider as cache sources",
|
Usage: "sets images to consider as cache sources",
|
||||||
Destination: &settings.Build.CacheFrom,
|
Destination: &settings.Build.CacheFrom,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "pull-image",
|
Name: "pull-image",
|
||||||
@ -162,18 +186,21 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
|
|||||||
Usage: "enforces to pull base image at build time",
|
Usage: "enforces to pull base image at build time",
|
||||||
Value: true,
|
Value: true,
|
||||||
Destination: &settings.Build.Pull,
|
Destination: &settings.Build.Pull,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "compress",
|
Name: "compress",
|
||||||
EnvVars: []string{"PLUGIN_COMPRESS"},
|
EnvVars: []string{"PLUGIN_COMPRESS"},
|
||||||
Usage: "enables compression og the build context using gzip",
|
Usage: "enables compression og the build context using gzip",
|
||||||
Destination: &settings.Build.Compress,
|
Destination: &settings.Build.Compress,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "repo",
|
Name: "repo",
|
||||||
EnvVars: []string{"PLUGIN_REPO"},
|
EnvVars: []string{"PLUGIN_REPO"},
|
||||||
Usage: "sets repository name for the image",
|
Usage: "sets repository name for the image",
|
||||||
Destination: &settings.Build.Repo,
|
Destination: &settings.Build.Repo,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "docker.registry",
|
Name: "docker.registry",
|
||||||
@ -181,30 +208,35 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
|
|||||||
Usage: "sets docker registry to authenticate with",
|
Usage: "sets docker registry to authenticate with",
|
||||||
Value: "https://index.docker.io/v1/",
|
Value: "https://index.docker.io/v1/",
|
||||||
Destination: &settings.Login.Registry,
|
Destination: &settings.Login.Registry,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "docker.username",
|
Name: "docker.username",
|
||||||
EnvVars: []string{"PLUGIN_USERNAME", "DOCKER_USERNAME"},
|
EnvVars: []string{"PLUGIN_USERNAME", "DOCKER_USERNAME"},
|
||||||
Usage: "sets username to authenticates with",
|
Usage: "sets username to authenticates with",
|
||||||
Destination: &settings.Login.Username,
|
Destination: &settings.Login.Username,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "docker.password",
|
Name: "docker.password",
|
||||||
EnvVars: []string{"PLUGIN_PASSWORD", "DOCKER_PASSWORD"},
|
EnvVars: []string{"PLUGIN_PASSWORD", "DOCKER_PASSWORD"},
|
||||||
Usage: "sets password to authenticates with",
|
Usage: "sets password to authenticates with",
|
||||||
Destination: &settings.Login.Password,
|
Destination: &settings.Login.Password,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "docker.email",
|
Name: "docker.email",
|
||||||
EnvVars: []string{"PLUGIN_EMAIL", "DOCKER_EMAIL"},
|
EnvVars: []string{"PLUGIN_EMAIL", "DOCKER_EMAIL"},
|
||||||
Usage: "sets email address to authenticates with",
|
Usage: "sets email address to authenticates with",
|
||||||
Destination: &settings.Login.Email,
|
Destination: &settings.Login.Email,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "docker.config",
|
Name: "docker.config",
|
||||||
EnvVars: []string{"PLUGIN_CONFIG", "DOCKER_PLUGIN_CONFIG"},
|
EnvVars: []string{"PLUGIN_CONFIG", "DOCKER_PLUGIN_CONFIG"},
|
||||||
Usage: "sets content of the docker daemon json config",
|
Usage: "sets content of the docker daemon json config",
|
||||||
Destination: &settings.Login.Config,
|
Destination: &settings.Login.Config,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "docker.purge",
|
Name: "docker.purge",
|
||||||
@ -212,18 +244,21 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
|
|||||||
Usage: "enables cleanup of the docker environment at the end of a build",
|
Usage: "enables cleanup of the docker environment at the end of a build",
|
||||||
Value: true,
|
Value: true,
|
||||||
Destination: &settings.Cleanup,
|
Destination: &settings.Cleanup,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "no-cache",
|
Name: "no-cache",
|
||||||
EnvVars: []string{"PLUGIN_NO_CACHE"},
|
EnvVars: []string{"PLUGIN_NO_CACHE"},
|
||||||
Usage: "disables the usage of cached intermediate containers",
|
Usage: "disables the usage of cached intermediate containers",
|
||||||
Destination: &settings.Build.NoCache,
|
Destination: &settings.Build.NoCache,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
Name: "add-host",
|
Name: "add-host",
|
||||||
EnvVars: []string{"PLUGIN_ADD_HOST"},
|
EnvVars: []string{"PLUGIN_ADD_HOST"},
|
||||||
Usage: "sets additional host:ip mapping",
|
Usage: "sets additional host:ip mapping",
|
||||||
Destination: &settings.Build.AddHost,
|
Destination: &settings.Build.AddHost,
|
||||||
|
Category: category,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ func main() {
|
|||||||
Name: "drone-docker",
|
Name: "drone-docker",
|
||||||
Usage: "build docker container with DinD",
|
Usage: "build docker container with DinD",
|
||||||
Version: BuildVersion,
|
Version: BuildVersion,
|
||||||
Flags: append(settingsFlags(settings), urfave.Flags()...),
|
Flags: append(settingsFlags(settings, urfave.FlagsPluginCategory), urfave.Flags()...),
|
||||||
Action: run(settings),
|
Action: run(settings),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user