本文整理汇总了Golang中github.com/docker/docker/pkg/mflag.Bool函数的典型用法代码示例。如果您正苦于以下问题:Golang Bool函数的具体用法?Golang Bool怎么用?Golang Bool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Bool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
flag.Bool([]string{"h", "-help"}, false, "Display help")
flag.BoolVar(&verbose, []string{"v", "-verbose"}, false, "Switch to verbose output")
flag.BoolVar(&print_digest, []string{"d", "-digest"}, false, "Print also digest of manifest")
flag.StringVar(&key, []string{"k", "-key-file"}, "", "Private key with which to sign")
flag.Parse()
}
开发者ID:TomasTomecek,项目名称:docker-manifest,代码行数:7,代码来源:main.go
示例2: init
func init() {
flag.Bool([]string{"#hp", "#-halp"}, false, "display the halp")
flag.BoolVar(&b, []string{"b", "#bal", "#bol", "-bal"}, false, "a simple bool")
flag.BoolVar(&b, []string{"g", "#gil"}, false, "a simple bool")
flag.BoolVar(&b2, []string{"#-bool"}, false, "a simple bool")
flag.IntVar(&i, []string{"-integer", "-number"}, -1, "a simple integer")
flag.StringVar(&str, []string{"s", "#hidden", "-string"}, "", "a simple string") //-s -hidden and --string will work, but -hidden won't be in the usage
flag.BoolVar(&h, []string{"h", "#help", "-help"}, false, "display the help")
flag.StringVar(&str, []string{"mode"}, "mode1", "set the mode\nmode1: use the mode1\nmode2: use the mode2\nmode3: use the mode3")
flag.Parse()
}
开发者ID:maxim28,项目名称:docker,代码行数:11,代码来源:example.go
示例3: handleGlobalDaemonFlag
"github.com/docker/docker/daemon/logger"
"github.com/docker/docker/opts"
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/pkg/pidfile"
"github.com/docker/docker/pkg/signal"
"github.com/docker/docker/pkg/system"
"github.com/docker/docker/pkg/timeutils"
"github.com/docker/docker/pkg/tlsconfig"
"github.com/docker/docker/registry"
"github.com/docker/docker/utils"
)
const daemonUsage = " docker daemon [ --help | ... ]\n"
var (
flDaemon = flag.Bool([]string{"#d", "#-daemon"}, false, "Enable daemon mode (deprecated; use docker daemon)")
daemonCli cli.Handler = NewDaemonCli()
)
// TODO: remove once `-d` is retired
func handleGlobalDaemonFlag() {
// This block makes sure that if the deprecated daemon flag `--daemon` is absent,
// then all daemon-specific flags are absent as well.
if !*flDaemon && daemonFlags != nil {
flag.CommandLine.Visit(func(fl *flag.Flag) {
for _, name := range fl.Names {
name := strings.TrimPrefix(name, "#")
if daemonFlags.Lookup(name) != nil {
// daemon flag was NOT specified, but daemon-specific flags were
// so let's error out
fmt.Fprintf(os.Stderr, "docker: the daemon flag '-%s' must follow the 'docker daemon' command.\n", name)
开发者ID:set321go,项目名称:docker,代码行数:31,代码来源:daemon.go
示例4: init
func init() {
if dockerCertPath == "" {
dockerCertPath = filepath.Join(homedir.Get(), ".docker")
}
}
func getDaemonConfDir() string {
// TODO: update for Windows daemon
if runtime.GOOS == "windows" {
return filepath.Join(homedir.Get(), ".docker")
}
return "/etc/docker"
}
var (
flVersion = flag.Bool([]string{"v", "-version"}, false, "Print version information and quit")
flDaemon = flag.Bool([]string{"d", "-daemon"}, false, "Enable daemon mode")
flDebug = flag.Bool([]string{"D", "-debug"}, false, "Enable debug mode")
flLogLevel = flag.String([]string{"l", "-log-level"}, "info", "Set the logging level")
flTls = flag.Bool([]string{"-tls"}, false, "Use TLS; implied by --tlsverify flag")
flHelp = flag.Bool([]string{"h", "-help"}, false, "Print usage")
flTlsVerify = flag.Bool([]string{"-tlsverify"}, dockerTlsVerify, "Use TLS and verify the remote")
// these are initialized in init() below since their default values depend on dockerCertPath which isn't fully initialized until init() runs
flTrustKey *string
flCa *string
flCert *string
flKey *string
flHosts []string
)
开发者ID:hgschmie,项目名称:docker,代码行数:30,代码来源:flags.go
示例5: Len
package main
import (
flag "github.com/docker/docker/pkg/mflag"
"github.com/docking/cli"
"sort"
)
var (
flHelp = flag.Bool([]string{"h", "-help"}, false, "Print usage")
flVersion = flag.Bool([]string{"v", "-version"}, false, "Print version information and quit")
)
type byName []cli.Command
func (a byName) Len() int { return len(a) }
func (a byName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a byName) Less(i, j int) bool { return a[i].Name < a[j].Name }
var dockingCommands []cli.Command
func init() {
for _, cmd := range cli.DockingCommands {
dockingCommands = append(dockingCommands, cmd)
}
sort.Sort(byName(dockingCommands))
}
开发者ID:docking-tools,项目名称:docking-tools,代码行数:27,代码来源:flags.go
示例6: init
func init() {
if dockerCertPath == "" {
dockerCertPath = filepath.Join(getHomeDir(), ".docker")
}
}
func getHomeDir() string {
if runtime.GOOS == "windows" {
return os.Getenv("USERPROFILE")
}
return os.Getenv("HOME")
}
var (
flVersion = flag.Bool([]string{"v", "-version"}, false, "Print version information and quit")
flDaemon = flag.Bool([]string{"d", "-daemon"}, false, "Enable daemon mode")
flDebug = flag.Bool([]string{"D", "-debug"}, false, "Enable debug mode")
flSocketGroup = flag.String([]string{"G", "-group"}, "docker", "Group to assign the unix socket specified by -H when running in daemon mode\nuse '' (the empty string) to disable setting of a group")
flLogLevel = flag.String([]string{"l", "-log-level"}, "info", "Set the logging level")
flEnableCors = flag.Bool([]string{"#api-enable-cors", "-api-enable-cors"}, false, "Enable CORS headers in the remote API")
flTls = flag.Bool([]string{"-tls"}, false, "Use TLS; implied by --tlsverify flag")
flTlsVerify = flag.Bool([]string{"-tlsverify"}, dockerTlsVerify, "Use TLS and verify the remote (daemon: verify client, client: verify daemon)")
// these are initialized in init() below since their default values depend on dockerCertPath which isn't fully initialized until init() runs
flTrustKey *string
flCa *string
flCert *string
flKey *string
flHosts []string
)
开发者ID:NERSC,项目名称:docker,代码行数:30,代码来源:flags.go
示例7: init
"github.com/docker/docker/opts"
flag "github.com/docker/docker/pkg/mflag"
)
var (
dockerConfDir = os.Getenv("DOCKER_CONFIG")
)
func init() {
if dockerConfDir == "" {
dockerConfDir = filepath.Join(os.Getenv("HOME"), ".docker")
}
}
var (
flVersion = flag.Bool([]string{"v", "-version"}, false, "Print version information and quit")
flDaemon = flag.Bool([]string{"d", "-daemon"}, false, "Enable daemon mode")
flGraphOpts opts.ListOpts
flDebug = flag.Bool([]string{"D", "-debug"}, false, "Enable debug mode")
flAutoRestart = flag.Bool([]string{"r", "-restart"}, true, "Restart previously running containers")
bridgeName = flag.String([]string{"b", "-bridge"}, "", "Attach containers to a pre-existing network bridge\nuse 'none' to disable container networking")
bridgeIp = flag.String([]string{"#bip", "-bip"}, "", "Use this CIDR notation address for the network bridge's IP, not compatible with -b")
pidfile = flag.String([]string{"p", "-pidfile"}, "/var/run/docker.pid", "Path to use for daemon PID file")
flRoot = flag.String([]string{"g", "-graph"}, "/var/lib/docker", "Path to use as the root of the Docker runtime")
flSocketGroup = flag.String([]string{"G", "-group"}, "docker", "Group to assign the unix socket specified by -H when running in daemon mode\nuse '' (the empty string) to disable setting of a group")
flEnableCors = flag.Bool([]string{"#api-enable-cors", "-api-enable-cors"}, false, "Enable CORS headers in the remote API")
flDns = opts.NewListOpts(opts.ValidateIPAddress)
flDnsSearch = opts.NewListOpts(opts.ValidateDnsSearch)
flEnableIptables = flag.Bool([]string{"#iptables", "-iptables"}, true, "Enable Docker's addition of iptables rules")
flEnableIpForward = flag.Bool([]string{"#ip-forward", "-ip-forward"}, true, "Enable net.ipv4.ip_forward")
flDefaultIp = flag.String([]string{"#ip", "-ip"}, "0.0.0.0", "Default IP address to use when binding container ports")
开发者ID:rhopman,项目名称:docker,代码行数:31,代码来源:flags.go
示例8: Start
"time"
"github.com/Sirupsen/logrus"
flag "github.com/docker/docker/pkg/mflag"
"github.com/hashicorp/go-version"
"github.com/scaleway/scaleway-cli/pkg/api"
"github.com/scaleway/scaleway-cli/pkg/commands"
"github.com/scaleway/scaleway-cli/pkg/config"
"github.com/scaleway/scaleway-cli/pkg/scwversion"
"github.com/scaleway/scaleway-cli/pkg/utils"
)
// global options
var (
flDebug = flag.Bool([]string{"D", "-debug"}, false, "Enable debug mode")
flVerbose = flag.Bool([]string{"V", "-verbose"}, false, "Enable verbose mode")
flVersion = flag.Bool([]string{"v", "-version"}, false, "Print version information and quit")
flQuiet = flag.Bool([]string{"q", "-quiet"}, false, "Enable quiet mode")
flSensitive = flag.Bool([]string{"-sensitive"}, false, "Show sensitive data in outputs, i.e. API Token/Organization")
)
// Start is the entrypoint
func Start(rawArgs []string, streams *commands.Streams) (int, error) {
checkVersion()
if streams == nil {
streams = &commands.Streams{
Stdin: os.Stdin,
Stdout: os.Stdout,
Stderr: os.Stderr,
}
开发者ID:moul,项目名称:scaleway-cli,代码行数:31,代码来源:main.go
示例9: init
import (
"fmt"
"os"
flag "github.com/docker/docker/pkg/mflag"
)
type command struct {
name string
description string
}
type byName []command
var (
flDaemon = flag.Bool([]string{"d", "-daemon"}, false, "Enable daemon mode")
flHost = flag.String([]string{"H", "-Host"}, "", "Daemon socket to connect to")
flLogLevel = flag.String([]string{"l", "-log-level"}, "info", "Set the logging level")
flDebug = flag.Bool([]string{"D", "-debug"}, false, "Enable debug mode")
flHelp = flag.Bool([]string{"h", "-help"}, false, "Print usage")
dnetCommands = []command{
{"network", "Network management commands"},
}
)
func init() {
flag.Usage = func() {
fmt.Fprint(os.Stdout, "Usage: dnet [OPTIONS] COMMAND [arg...]\n\nA self-sufficient runtime for container networking.\n\nOptions:\n")
flag.CommandLine.SetOutput(os.Stdout)
开发者ID:choldrim,项目名称:docker,代码行数:31,代码来源:flags.go
示例10:
blog "github.com/ccpaging/log4go"
flag "github.com/docker/docker/pkg/mflag"
)
const (
// Console logging level
CONSOLELOGLEVEL = blog.INFO
// File logging level
FILELOGLEVEL = blog.FINEST
// Number of docker images to process in a single batch.
IMAGEBATCH = 5
)
var (
LOGFILENAME = config.BANYANDIR() + "/hostcollector/collector.log"
fileLog = flag.Bool([]string{"-filelog"}, false, "Log output to "+LOGFILENAME)
imageList = flag.String([]string{"#-imagelist"}, config.BANYANDIR()+"/hostcollector/imagelist",
"List of previously collected images (file)")
repoList = flag.String([]string{"r", "-repolist"}, config.BANYANDIR()+"/hostcollector/repolist",
"File containing list of repos to process")
// Configuration parameters for speed/efficiency
removeThresh = flag.Int([]string{"-removethresh"}, 5,
"Number of images that get pulled before removal")
maxImages = flag.Int([]string{"-maximages"}, 0, "Maximum number of new images to process per repository (0=unlimited)")
//nextMaxImages int
poll = flag.Int64([]string{"p", "-poll"}, 60, "Polling interval in seconds")
// Docker remote API related parameters
dockerProto = flag.String([]string{"-dockerproto"}, "unix",
"Socket protocol for Docker Remote API (\"unix\" or \"tcp\")")
开发者ID:TheRemoteLab,项目名称:collector,代码行数:31,代码来源:main.go
示例11:
"strings"
"github.com/GoogleCloudPlatform/kubernetes/pkg/credentialprovider"
except "github.com/banyanops/collector/except"
gcr "github.com/banyanops/collector/gcr"
flag "github.com/docker/docker/pkg/mflag"
)
const ()
var (
// HubAPI indicates whether to use the Docker Hub API.
HubAPI bool
// LocalHost indicates whether to collect images from local host
LocalHost bool
HTTPSRegistry = flag.Bool([]string{"-registryhttps"}, true,
"Set to false if registry does not need HTTPS (SSL/TLS)")
AuthRegistry = flag.Bool([]string{"-registryauth"}, true,
"Set to false if registry does not need authentication")
RegistryProto = flag.String([]string{"-registryproto"}, "v1",
"Select the registry protocol to use: v1, v2, quay")
RegistryTokenAuth = flag.Bool([]string{"-registrytokenauth"}, false,
"Registry uses v1 Token Auth, e.g., Docker Hub, Google Container Registry")
RegistryTLSNoVerify = flag.Bool([]string{"-registrytlsnoverify"}, false,
"True to trust the registry without verifying certificate")
GCEMetadata = flag.Bool([]string{"-gce-metadata"}, false,
"True to query GCE instance metadata for Docker credentials")
GCEKeyFile = flag.String([]string{"-gce-key-file"}, "",
"Set to the pathname of the GCE service account JSON key")
// registryspec is the host.domainname of the registry
RegistrySpec string
// registryAPIURL is the http(s)://[user:[email protected]]host.domainname of the registry
开发者ID:TheRemoteLab,项目名称:collector,代码行数:32,代码来源:registryauth.go
示例12: main
func main() {
if len(dockerConfDir) == 0 {
dockerConfDir = filepath.Join(os.Getenv("HOME"), ".docker")
}
if selfPath := utils.SelfPath(); strings.Contains(selfPath, ".dockerinit") {
// Running in init mode
sysinit.SysInit()
return
}
var (
flVersion = flag.Bool([]string{"v", "-version"}, false, "Print version information and quit")
flDaemon = flag.Bool([]string{"d", "-daemon"}, false, "Enable daemon mode")
flGraphOpts opts.ListOpts
flDebug = flag.Bool([]string{"D", "-debug"}, false, "Enable debug mode")
flAutoRestart = flag.Bool([]string{"r", "-restart"}, true, "Restart previously running containers")
bridgeName = flag.String([]string{"b", "-bridge"}, "", "Attach containers to a pre-existing network bridge\nuse 'none' to disable container networking")
bridgeIp = flag.String([]string{"#bip", "-bip"}, "", "Use this CIDR notation address for the network bridge's IP, not compatible with -b")
pidfile = flag.String([]string{"p", "-pidfile"}, "/var/run/docker.pid", "Path to use for daemon PID file")
flRoot = flag.String([]string{"g", "-graph"}, "/var/lib/docker", "Path to use as the root of the Docker runtime")
flSocketGroup = flag.String([]string{"G", "-group"}, "docker", "Group to assign the unix socket specified by -H when running in daemon mode\nuse '' (the empty string) to disable setting of a group")
flEnableCors = flag.Bool([]string{"#api-enable-cors", "-api-enable-cors"}, false, "Enable CORS headers in the remote API")
flDns = opts.NewListOpts(opts.ValidateIPAddress)
flDnsSearch = opts.NewListOpts(opts.ValidateDnsSearch)
flEnableIptables = flag.Bool([]string{"#iptables", "-iptables"}, true, "Enable Docker's addition of iptables rules")
flEnableIpForward = flag.Bool([]string{"#ip-forward", "-ip-forward"}, true, "Enable net.ipv4.ip_forward")
flDefaultIp = flag.String([]string{"#ip", "-ip"}, "0.0.0.0", "Default IP address to use when binding container ports")
flInterContainerComm = flag.Bool([]string{"#icc", "-icc"}, true, "Enable inter-container communication")
flGraphDriver = flag.String([]string{"s", "-storage-driver"}, "", "Force the Docker runtime to use a specific storage driver")
flExecDriver = flag.String([]string{"e", "-exec-driver"}, "native", "Force the Docker runtime to use a specific exec driver")
flHosts = opts.NewListOpts(api.ValidateHost)
flMtu = flag.Int([]string{"#mtu", "-mtu"}, 0, "Set the containers network MTU\nif no value is provided: default to the default route MTU or 1500 if no default route is available")
flTls = flag.Bool([]string{"-tls"}, false, "Use TLS; implied by tls-verify flags")
flTlsVerify = flag.Bool([]string{"-tlsverify"}, false, "Use TLS and verify the remote (daemon: verify client, client: verify daemon)")
flCa = flag.String([]string{"-tlscacert"}, filepath.Join(dockerConfDir, defaultCaFile), "Trust only remotes providing a certificate signed by the CA given here")
flCert = flag.String([]string{"-tlscert"}, filepath.Join(dockerConfDir, defaultCertFile), "Path to TLS certificate file")
flKey = flag.String([]string{"-tlskey"}, filepath.Join(dockerConfDir, defaultKeyFile), "Path to TLS key file")
flSelinuxEnabled = flag.Bool([]string{"-selinux-enabled"}, false, "Enable selinux support. SELinux does not presently support the BTRFS storage driver")
)
flag.Var(&flDns, []string{"#dns", "-dns"}, "Force Docker to use specific DNS servers")
flag.Var(&flDnsSearch, []string{"-dns-search"}, "Force Docker to use specific DNS search domains")
flag.Var(&flHosts, []string{"H", "-host"}, "The socket(s) to bind to in daemon mode\nspecified using one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd.")
flag.Var(&flGraphOpts, []string{"-storage-opt"}, "Set storage driver options")
flag.Parse()
if *flVersion {
showVersion()
return
}
if flHosts.Len() == 0 {
defaultHost := os.Getenv("DOCKER_HOST")
if defaultHost == "" || *flDaemon {
// If we do not have a host, default to unix socket
defaultHost = fmt.Sprintf("unix://%s", api.DEFAULTUNIXSOCKET)
}
if _, err := api.ValidateHost(defaultHost); err != nil {
log.Fatal(err)
}
flHosts.Set(defaultHost)
}
if *bridgeName != "" && *bridgeIp != "" {
log.Fatal("You specified -b & --bip, mutually exclusive options. Please specify only one.")
}
if !*flEnableIptables && !*flInterContainerComm {
log.Fatal("You specified --iptables=false with --icc=false. ICC uses iptables to function. Please set --icc or --iptables to true.")
}
if net.ParseIP(*flDefaultIp) == nil {
log.Fatalf("Specified --ip=%s is not in correct format \"0.0.0.0\".", *flDefaultIp)
}
if *flDebug {
os.Setenv("DEBUG", "1")
}
if *flDaemon {
if runtime.GOOS != "linux" {
log.Fatalf("The Docker daemon is only supported on linux")
}
if os.Geteuid() != 0 {
log.Fatalf("The Docker daemon needs to be run as root")
}
if flag.NArg() != 0 {
flag.Usage()
return
}
// set up the TempDir to use a canonical path
tmp := os.TempDir()
realTmp, err := utils.ReadSymlinkedDirectory(tmp)
if err != nil {
log.Fatalf("Unable to get the full path to the TempDir (%s): %s", tmp, err)
}
os.Setenv("TMPDIR", realTmp)
//.........这里部分代码省略.........
开发者ID:hsrd,项目名称:docker,代码行数:101,代码来源:docker.go
示例13:
"os/exec"
"path/filepath"
"syscall"
"github.com/Sirupsen/logrus"
flag "github.com/docker/docker/pkg/mflag"
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/svc"
"golang.org/x/sys/windows/svc/debug"
"golang.org/x/sys/windows/svc/eventlog"
"golang.org/x/sys/windows/svc/mgr"
)
var (
flServiceName = flag.String([]string{"-service-name"}, "docker", "Set the Windows service name")
flRegisterService = flag.Bool([]string{"-register-service"}, false, "Register the service and exit")
flUnregisterService = flag.Bool([]string{"-unregister-service"}, false, "Unregister the service and exit")
flRunService = flag.Bool([]string{"-run-service"}, false, "")
setStdHandle = syscall.NewLazyDLL("kernel32.dll").NewProc("SetStdHandle")
oldStderr syscall.Handle
panicFile *os.File
service *handler
)
const (
// These should match the values in event_messages.mc.
eventInfo = 1
eventWarn = 1
eventError = 1
开发者ID:RAMESHBABUK,项目名称:docker,代码行数:31,代码来源:service_windows.go
示例14: init
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/pkg/term"
dmachine "github.com/weibocom/dockerf/machine"
)
const (
defaultTrustKeyFile = "key.json"
defaultCaFile = "ca.pem"
defaultKeyFile = "key.pem"
defaultCertFile = "cert.pem"
)
var (
// all docker command except help must give '--machine' flag
flMachine = flag.String([]string{"-machine"}, "", "Machine name where docker run. 'dockerf machine ls' to display all machines. ")
flSwarm = flag.Bool([]string{"-swarm"}, false, "Manage container by swarm")
)
func init() {
}
func (dcli *DockerfCli) CmdContainer(args ...string) error {
flag.CommandLine.Parse(args)
if *flVersion {
showVersion()
os.Exit(1)
}
开发者ID:jiangshengwu,项目名称:dockerf,代码行数:30,代码来源:cmd_container.go
示例15: Start
package cli
import (
"flag"
"fmt"
"os"
"github.com/QuentinPerez/url2bitly/pkg/command"
"github.com/docker/docker/pkg/mflag"
)
var (
flDebug = mflag.Bool([]string{"D", "-debug"}, false, "Enable debug mode")
)
func Start(rawArgs []string, streams *command.Streams) (int, error) {
if streams == nil {
streams = &command.Streams{
Stdin: os.Stdin,
Stdout: os.Stdout,
Stderr: os.Stderr,
}
}
if err := mflag.CommandLine.Parse(rawArgs); err != nil {
return 1, fmt.Errorf("Start.Parse: %v", err)
}
if *flDebug {
os.Setenv("DEBUG", "1")
}
args := flag.Args()
if len(args) < 1 {
开发者ID:QuentinPerez,项目名称:url2bitly,代码行数:31,代码来源:url2bitly.go
注:本文中的github.com/docker/docker/pkg/mflag.Bool函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论