Make flag defs easier to read
This commit is contained in:
parent
7e6b429362
commit
0bd5f19ac0
|
|
@ -56,94 +56,133 @@ var flManual = pflag.Bool("man", false, "print the full manual and exit")
|
||||||
var flVerbose = pflag.IntP("verbose", "v", 0,
|
var flVerbose = pflag.IntP("verbose", "v", 0,
|
||||||
"logs at this V level and lower will be printed")
|
"logs at this V level and lower will be printed")
|
||||||
|
|
||||||
var flRepo = pflag.String("repo", envString("", "GITSYNC_REPO", "GIT_SYNC_REPO"),
|
var flRepo = pflag.String("repo",
|
||||||
|
envString("", "GITSYNC_REPO", "GIT_SYNC_REPO"),
|
||||||
"the git repository to sync (required)")
|
"the git repository to sync (required)")
|
||||||
var flRef = pflag.String("ref", envString("HEAD", "GITSYNC_REF"),
|
var flRef = pflag.String("ref",
|
||||||
|
envString("HEAD", "GITSYNC_REF"),
|
||||||
"the git revision (branch, tag, or hash) to sync")
|
"the git revision (branch, tag, or hash) to sync")
|
||||||
var flDepth = pflag.Int("depth", envInt(1, "GITSYNC_DEPTH", "GIT_SYNC_DEPTH"),
|
var flDepth = pflag.Int("depth",
|
||||||
|
envInt(1, "GITSYNC_DEPTH", "GIT_SYNC_DEPTH"),
|
||||||
"create a shallow clone with history truncated to the specified number of commits")
|
"create a shallow clone with history truncated to the specified number of commits")
|
||||||
var flSubmodules = pflag.String("submodules", envString("recursive", "GITSYNC_SUBMODULES", "GIT_SYNC_SUBMODULES"),
|
var flSubmodules = pflag.String("submodules",
|
||||||
|
envString("recursive", "GITSYNC_SUBMODULES", "GIT_SYNC_SUBMODULES"),
|
||||||
"git submodule behavior: one of 'recursive', 'shallow', or 'off'")
|
"git submodule behavior: one of 'recursive', 'shallow', or 'off'")
|
||||||
|
|
||||||
var flRoot = pflag.String("root", envString("", "GITSYNC_ROOT", "GIT_SYNC_ROOT"),
|
var flRoot = pflag.String("root",
|
||||||
|
envString("", "GITSYNC_ROOT", "GIT_SYNC_ROOT"),
|
||||||
"the root directory for git-sync operations (required)")
|
"the root directory for git-sync operations (required)")
|
||||||
var flLink = pflag.String("link", envString("", "GITSYNC_LINK", "GIT_SYNC_LINK"),
|
var flLink = pflag.String("link",
|
||||||
|
envString("", "GITSYNC_LINK", "GIT_SYNC_LINK"),
|
||||||
"the path (absolute or relative to --root) at which to create a symlink to the directory holding the checked-out files (defaults to the leaf dir of --repo)")
|
"the path (absolute or relative to --root) at which to create a symlink to the directory holding the checked-out files (defaults to the leaf dir of --repo)")
|
||||||
var flErrorFile = pflag.String("error-file", envString("", "GITSYNC_ERROR_FILE", "GIT_SYNC_ERROR_FILE"),
|
var flErrorFile = pflag.String("error-file",
|
||||||
|
envString("", "GITSYNC_ERROR_FILE", "GIT_SYNC_ERROR_FILE"),
|
||||||
"the path (absolute or relative to --root) to an optional file into which errors will be written (defaults to disabled)")
|
"the path (absolute or relative to --root) to an optional file into which errors will be written (defaults to disabled)")
|
||||||
var flPeriod = pflag.Duration("period", envDuration(10*time.Second, "GITSYNC_PERIOD", "GIT_SYNC_PERIOD"),
|
var flPeriod = pflag.Duration("period",
|
||||||
|
envDuration(10*time.Second, "GITSYNC_PERIOD", "GIT_SYNC_PERIOD"),
|
||||||
"how long to wait between syncs, must be >= 10ms; --wait overrides this")
|
"how long to wait between syncs, must be >= 10ms; --wait overrides this")
|
||||||
var flSyncTimeout = pflag.Duration("sync-timeout", envDuration(120*time.Second, "GITSYNC_SYNC_TIMEOUT", "GIT_SYNC_SYNC_TIMEOUT"),
|
var flSyncTimeout = pflag.Duration("sync-timeout",
|
||||||
|
envDuration(120*time.Second, "GITSYNC_SYNC_TIMEOUT", "GIT_SYNC_SYNC_TIMEOUT"),
|
||||||
"the total time allowed for one complete sync, must be >= 10ms; --timeout overrides this")
|
"the total time allowed for one complete sync, must be >= 10ms; --timeout overrides this")
|
||||||
var flOneTime = pflag.Bool("one-time", envBool(false, "GITSYNC_ONE_TIME", "GIT_SYNC_ONE_TIME"),
|
var flOneTime = pflag.Bool("one-time",
|
||||||
|
envBool(false, "GITSYNC_ONE_TIME", "GIT_SYNC_ONE_TIME"),
|
||||||
"exit after the first sync")
|
"exit after the first sync")
|
||||||
var flSyncOnSignal = pflag.String("sync-on-signal", envString("", "GITSYNC_SYNC_ON_SIGNAL", "GIT_SYNC_SYNC_ON_SIGNAL"),
|
var flSyncOnSignal = pflag.String("sync-on-signal",
|
||||||
|
envString("", "GITSYNC_SYNC_ON_SIGNAL", "GIT_SYNC_SYNC_ON_SIGNAL"),
|
||||||
"sync on receipt of the specified signal (e.g. SIGHUP)")
|
"sync on receipt of the specified signal (e.g. SIGHUP)")
|
||||||
var flMaxFailures = pflag.Int("max-failures", envInt(0, "GITSYNC_MAX_FAILURES", "GIT_SYNC_MAX_FAILURES"),
|
var flMaxFailures = pflag.Int("max-failures",
|
||||||
|
envInt(0, "GITSYNC_MAX_FAILURES", "GIT_SYNC_MAX_FAILURES"),
|
||||||
"the number of consecutive failures allowed before aborting (the first sync must succeed, -1 will retry forever")
|
"the number of consecutive failures allowed before aborting (the first sync must succeed, -1 will retry forever")
|
||||||
var flChmod = pflag.Int("change-permissions", envInt(0, "GITSYNC_PERMISSIONS", "GIT_SYNC_PERMISSIONS"),
|
var flChmod = pflag.Int("change-permissions",
|
||||||
|
envInt(0, "GITSYNC_PERMISSIONS", "GIT_SYNC_PERMISSIONS"),
|
||||||
"optionally change permissions on the checked-out files to the specified mode")
|
"optionally change permissions on the checked-out files to the specified mode")
|
||||||
|
|
||||||
var flTouchFile = pflag.String("touch-file", envString("", "GITSYNC_TOUCH_FILE", "GIT_SYNC_TOUCH_FILE"),
|
var flTouchFile = pflag.String("touch-file",
|
||||||
|
envString("", "GITSYNC_TOUCH_FILE", "GIT_SYNC_TOUCH_FILE"),
|
||||||
"the path (absolute or relative to --root) to an optional file which will be touched whenever a sync completes (defaults to disabled)")
|
"the path (absolute or relative to --root) to an optional file which will be touched whenever a sync completes (defaults to disabled)")
|
||||||
|
|
||||||
var flSparseCheckoutFile = pflag.String("sparse-checkout-file", envString("", "GITSYNC_SPARSE_CHECKOUT_FILE", "GIT_SYNC_SPARSE_CHECKOUT_FILE"),
|
var flSparseCheckoutFile = pflag.String("sparse-checkout-file",
|
||||||
|
envString("", "GITSYNC_SPARSE_CHECKOUT_FILE", "GIT_SYNC_SPARSE_CHECKOUT_FILE"),
|
||||||
"the path to a sparse-checkout file")
|
"the path to a sparse-checkout file")
|
||||||
|
|
||||||
var flExechookCommand = pflag.String("exechook-command", envString("", "GITSYNC_EXECHOOK_COMMAND", "GIT_SYNC_EXECHOOK_COMMAND"),
|
var flExechookCommand = pflag.String("exechook-command",
|
||||||
|
envString("", "GITSYNC_EXECHOOK_COMMAND", "GIT_SYNC_EXECHOOK_COMMAND"),
|
||||||
"an optional command to be run when syncs complete")
|
"an optional command to be run when syncs complete")
|
||||||
var flExechookTimeout = pflag.Duration("exechook-timeout", envDuration(30*time.Second, "GITSYNC_EXECHOOK_TIMEOUT", "GIT_SYNC_EXECHOOK_TIMEOUT"),
|
var flExechookTimeout = pflag.Duration("exechook-timeout",
|
||||||
|
envDuration(30*time.Second, "GITSYNC_EXECHOOK_TIMEOUT", "GIT_SYNC_EXECHOOK_TIMEOUT"),
|
||||||
"the timeout for the exechook")
|
"the timeout for the exechook")
|
||||||
var flExechookBackoff = pflag.Duration("exechook-backoff", envDuration(3*time.Second, "GITSYNC_EXECHOOK_BACKOFF", "GIT_SYNC_EXECHOOK_BACKOFF"),
|
var flExechookBackoff = pflag.Duration("exechook-backoff",
|
||||||
|
envDuration(3*time.Second, "GITSYNC_EXECHOOK_BACKOFF", "GIT_SYNC_EXECHOOK_BACKOFF"),
|
||||||
"the time to wait before retrying a failed exechook")
|
"the time to wait before retrying a failed exechook")
|
||||||
|
|
||||||
var flWebhookURL = pflag.String("webhook-url", envString("", "GITSYNC_WEBHOOK_URL", "GIT_SYNC_WEBHOOK_URL"),
|
var flWebhookURL = pflag.String("webhook-url",
|
||||||
|
envString("", "GITSYNC_WEBHOOK_URL", "GIT_SYNC_WEBHOOK_URL"),
|
||||||
"a URL for optional webhook notifications when syncs complete")
|
"a URL for optional webhook notifications when syncs complete")
|
||||||
var flWebhookMethod = pflag.String("webhook-method", envString("POST", "GITSYNC_WEBHOOK_METHOD", "GIT_SYNC_WEBHOOK_METHOD"),
|
var flWebhookMethod = pflag.String("webhook-method",
|
||||||
|
envString("POST", "GITSYNC_WEBHOOK_METHOD", "GIT_SYNC_WEBHOOK_METHOD"),
|
||||||
"the HTTP method for the webhook")
|
"the HTTP method for the webhook")
|
||||||
var flWebhookStatusSuccess = pflag.Int("webhook-success-status", envInt(200, "GITSYNC_WEBHOOK_SUCCESS_STATUS", "GIT_SYNC_WEBHOOK_SUCCESS_STATUS"),
|
var flWebhookStatusSuccess = pflag.Int("webhook-success-status",
|
||||||
|
envInt(200, "GITSYNC_WEBHOOK_SUCCESS_STATUS", "GIT_SYNC_WEBHOOK_SUCCESS_STATUS"),
|
||||||
"the HTTP status code indicating a successful webhook (0 disables success checks")
|
"the HTTP status code indicating a successful webhook (0 disables success checks")
|
||||||
var flWebhookTimeout = pflag.Duration("webhook-timeout", envDuration(1*time.Second, "GITSYNC_WEBHOOK_TIMEOUT", "GIT_SYNC_WEBHOOK_TIMEOUT"),
|
var flWebhookTimeout = pflag.Duration("webhook-timeout",
|
||||||
|
envDuration(1*time.Second, "GITSYNC_WEBHOOK_TIMEOUT", "GIT_SYNC_WEBHOOK_TIMEOUT"),
|
||||||
"the timeout for the webhook")
|
"the timeout for the webhook")
|
||||||
var flWebhookBackoff = pflag.Duration("webhook-backoff", envDuration(3*time.Second, "GITSYNC_WEBHOOK_BACKOFF", "GIT_SYNC_WEBHOOK_BACKOFF"),
|
var flWebhookBackoff = pflag.Duration("webhook-backoff",
|
||||||
|
envDuration(3*time.Second, "GITSYNC_WEBHOOK_BACKOFF", "GIT_SYNC_WEBHOOK_BACKOFF"),
|
||||||
"the time to wait before retrying a failed webhook")
|
"the time to wait before retrying a failed webhook")
|
||||||
|
|
||||||
var flUsername = pflag.String("username", envString("", "GITSYNC_USERNAME", "GIT_SYNC_USERNAME"),
|
var flUsername = pflag.String("username",
|
||||||
|
envString("", "GITSYNC_USERNAME", "GIT_SYNC_USERNAME"),
|
||||||
"the username to use for git auth")
|
"the username to use for git auth")
|
||||||
var flPassword = pflag.String("password", envString("", "GITSYNC_PASSWORD", "GIT_SYNC_PASSWORD"),
|
var flPassword = pflag.String("password",
|
||||||
|
envString("", "GITSYNC_PASSWORD", "GIT_SYNC_PASSWORD"),
|
||||||
"the password or personal access token to use for git auth (prefer --password-file or this env var)")
|
"the password or personal access token to use for git auth (prefer --password-file or this env var)")
|
||||||
var flPasswordFile = pflag.String("password-file", envString("", "GITSYNC_PASSWORD_FILE", "GIT_SYNC_PASSWORD_FILE"),
|
var flPasswordFile = pflag.String("password-file",
|
||||||
|
envString("", "GITSYNC_PASSWORD_FILE", "GIT_SYNC_PASSWORD_FILE"),
|
||||||
"the file from which the password or personal access token for git auth will be sourced")
|
"the file from which the password or personal access token for git auth will be sourced")
|
||||||
|
|
||||||
var flSSH = pflag.Bool("ssh", envBool(false, "GITSYNC_SSH", "GIT_SYNC_SSH"),
|
var flSSH = pflag.Bool("ssh",
|
||||||
|
envBool(false, "GITSYNC_SSH", "GIT_SYNC_SSH"),
|
||||||
"use SSH for git operations")
|
"use SSH for git operations")
|
||||||
var flSSHKeyFile = pflag.String("ssh-key-file", envString("/etc/git-secret/ssh", "GITSYNC_SSH_KEY_FILE", "GIT_SYNC_SSH_KEY_FILE", "GIT_SSH_KEY_FILE"),
|
var flSSHKeyFile = pflag.String("ssh-key-file",
|
||||||
|
envString("/etc/git-secret/ssh", "GITSYNC_SSH_KEY_FILE", "GIT_SYNC_SSH_KEY_FILE", "GIT_SSH_KEY_FILE"),
|
||||||
"the SSH key to use")
|
"the SSH key to use")
|
||||||
var flSSHKnownHosts = pflag.Bool("ssh-known-hosts", envBool(true, "GITSYNC_SSH_KNOWN_HOSTS", "GIT_SYNC_KNOWN_HOSTS", "GIT_KNOWN_HOSTS"),
|
var flSSHKnownHosts = pflag.Bool("ssh-known-hosts",
|
||||||
|
envBool(true, "GITSYNC_SSH_KNOWN_HOSTS", "GIT_SYNC_KNOWN_HOSTS", "GIT_KNOWN_HOSTS"),
|
||||||
"enable SSH known_hosts verification")
|
"enable SSH known_hosts verification")
|
||||||
var flSSHKnownHostsFile = pflag.String("ssh-known-hosts-file", envString("/etc/git-secret/known_hosts", "GITSYNC_SSH_KNOWN_HOSTS_FILE", "GIT_SYNC_SSH_KNOWN_HOSTS_FILE", "GIT_SSH_KNOWN_HOSTS_FILE"),
|
var flSSHKnownHostsFile = pflag.String("ssh-known-hosts-file",
|
||||||
|
envString("/etc/git-secret/known_hosts", "GITSYNC_SSH_KNOWN_HOSTS_FILE", "GIT_SYNC_SSH_KNOWN_HOSTS_FILE", "GIT_SSH_KNOWN_HOSTS_FILE"),
|
||||||
"the known_hosts file to use")
|
"the known_hosts file to use")
|
||||||
var flAddUser = pflag.Bool("add-user", envBool(false, "GITSYNC_ADD_USER", "GIT_SYNC_ADD_USER"),
|
var flAddUser = pflag.Bool("add-user",
|
||||||
|
envBool(false, "GITSYNC_ADD_USER", "GIT_SYNC_ADD_USER"),
|
||||||
"add a record to /etc/passwd for the current UID/GID (needed to use SSH with an arbitrary UID)")
|
"add a record to /etc/passwd for the current UID/GID (needed to use SSH with an arbitrary UID)")
|
||||||
|
|
||||||
var flCookieFile = pflag.Bool("cookie-file", envBool(false, "GITSYNC_COOKIE_FILE", "GIT_SYNC_COOKIE_FILE", "GIT_COOKIE_FILE"),
|
var flCookieFile = pflag.Bool("cookie-file",
|
||||||
|
envBool(false, "GITSYNC_COOKIE_FILE", "GIT_SYNC_COOKIE_FILE", "GIT_COOKIE_FILE"),
|
||||||
"use a git cookiefile (/etc/git-secret/cookie_file) for authentication")
|
"use a git cookiefile (/etc/git-secret/cookie_file) for authentication")
|
||||||
|
|
||||||
var flAskPassURL = pflag.String("askpass-url", envString("", "GITSYNC_ASKPASS_URL", "GIT_SYNC_ASKPASS_URL", "GIT_ASKPASS_URL"),
|
var flAskPassURL = pflag.String("askpass-url",
|
||||||
|
envString("", "GITSYNC_ASKPASS_URL", "GIT_SYNC_ASKPASS_URL", "GIT_ASKPASS_URL"),
|
||||||
"a URL to query for git credentials (username=<value> and password=<value>)")
|
"a URL to query for git credentials (username=<value> and password=<value>)")
|
||||||
|
|
||||||
var flGitCmd = pflag.String("git", envString("git", "GITSYNC_GIT", "GIT_SYNC_GIT"),
|
var flGitCmd = pflag.String("git",
|
||||||
|
envString("git", "GITSYNC_GIT", "GIT_SYNC_GIT"),
|
||||||
"the git command to run (subject to PATH search, mostly for testing)")
|
"the git command to run (subject to PATH search, mostly for testing)")
|
||||||
var flGitConfig = pflag.String("git-config", envString("", "GITSYNC_GIT_CONFIG", "GIT_SYNC_GIT_CONFIG"),
|
var flGitConfig = pflag.String("git-config",
|
||||||
|
envString("", "GITSYNC_GIT_CONFIG", "GIT_SYNC_GIT_CONFIG"),
|
||||||
"additional git config options in 'section.var1:val1,\"section.sub.var2\":\"val2\"' format")
|
"additional git config options in 'section.var1:val1,\"section.sub.var2\":\"val2\"' format")
|
||||||
var flGitGC = pflag.String("git-gc", envString("always", "GITSYNC_GIT_GC", "GIT_SYNC_GIT_GC"),
|
var flGitGC = pflag.String("git-gc",
|
||||||
|
envString("always", "GITSYNC_GIT_GC", "GIT_SYNC_GIT_GC"),
|
||||||
"git garbage collection behavior: one of 'auto', 'always', 'aggressive', or 'off'")
|
"git garbage collection behavior: one of 'auto', 'always', 'aggressive', or 'off'")
|
||||||
|
|
||||||
var flHTTPBind = pflag.String("http-bind", envString("", "GITSYNC_HTTP_BIND", "GIT_SYNC_HTTP_BIND"),
|
var flHTTPBind = pflag.String("http-bind",
|
||||||
|
envString("", "GITSYNC_HTTP_BIND", "GIT_SYNC_HTTP_BIND"),
|
||||||
"the bind address (including port) for git-sync's HTTP endpoint")
|
"the bind address (including port) for git-sync's HTTP endpoint")
|
||||||
var flHTTPMetrics = pflag.Bool("http-metrics", envBool(false, "GITSYNC_HTTP_METRICS", "GIT_SYNC_HTTP_METRICS"),
|
var flHTTPMetrics = pflag.Bool("http-metrics",
|
||||||
|
envBool(false, "GITSYNC_HTTP_METRICS", "GIT_SYNC_HTTP_METRICS"),
|
||||||
"enable metrics on git-sync's HTTP endpoint")
|
"enable metrics on git-sync's HTTP endpoint")
|
||||||
var flHTTPprof = pflag.Bool("http-pprof", envBool(false, "GITSYNC_HTTP_PPROF", "GIT_SYNC_HTTP_PPROF"),
|
var flHTTPprof = pflag.Bool("http-pprof",
|
||||||
|
envBool(false, "GITSYNC_HTTP_PPROF", "GIT_SYNC_HTTP_PPROF"),
|
||||||
"enable the pprof debug endpoints on git-sync's HTTP endpoint")
|
"enable the pprof debug endpoints on git-sync's HTTP endpoint")
|
||||||
|
|
||||||
// Obsolete flags, kept for compat.
|
// Obsolete flags, kept for compat.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue