Docker Swarm 源码分析 flags.go

发布于 2025-01-01 12:22:17 字数 3177 浏览 3 评论 0

定义一些 flag 变量以及相关的处理方法。

var (
    flStore = cli.StringFlag{
        Name:  "rootdir",
        Value: homepath(".swarm"),
        Usage: "",
    }
    flJoinAdvertise = cli.StringFlag{
        Name:   "advertise, addr",
        Usage:  "Address of the Docker Engine joining the cluster. Swarm manager(s) MUST be able to reach the Docker Engine at this address.",
        EnvVar: "SWARM_ADVERTISE",
    }
    flManageAdvertise = cli.StringFlag{
        Name:   "advertise, addr",
        Usage:  "Address of the swarm manager joining the cluster. Other swarm manager(s) MUST be able to reach the swarm manager at this address.",
        EnvVar: "SWARM_ADVERTISE",
    }
    // hack for go vet
    flHostsValue = cli.StringSlice([]string{"tcp://127.0.0.1:2375"})

    flHosts = cli.StringSliceFlag{
        Name:   "host, H",
        Value:  &flHostsValue,
        Usage:  "ip/socket to listen on",
        EnvVar: "SWARM_HOST",
    }
    flHeartBeat = cli.StringFlag{
        Name:  "heartbeat",
        Value: "20s",
        Usage: "period between each heartbeat",
    }
    flTTL = cli.StringFlag{
        Name:  "ttl",
        Value: "60s",
        Usage: "sets the expiration of an ephemeral node",
    }
    flTimeout = cli.StringFlag{
        Name:  "timeout",
        Value: "10s",
        Usage: "timeout period",
    }
    flEnableCors = cli.BoolFlag{
        Name:  "api-enable-cors, cors",
        Usage: "enable CORS headers in the remote API",
    }
    flTLS = cli.BoolFlag{
        Name:  "tls",
        Usage: "use TLS; implied by --tlsverify=true",
    }
    flTLSCaCert = cli.StringFlag{
        Name:  "tlscacert",
        Usage: "trust only remotes providing a certificate signed by the CA given here",
    }
    flTLSCert = cli.StringFlag{
        Name:  "tlscert",
        Usage: "path to TLS certificate file",
    }
    flTLSKey = cli.StringFlag{
        Name:  "tlskey",
        Usage: "path to TLS key file",
    }
    flTLSVerify = cli.BoolFlag{
        Name:  "tlsverify",
        Usage: "use TLS and verify the remote",
    }
    flStrategy = cli.StringFlag{
        Name:  "strategy",
        Usage: "placement strategy to use [" + strings.Join(strategy.List(), ", ") + "]",
        Value: strategy.List()[0],
    }

    // hack for go vet
    flFilterValue = cli.StringSlice(filter.List())
    // DefaultFilterNumber is exported
    DefaultFilterNumber = len(flFilterValue)

    flFilter = cli.StringSliceFlag{
        Name:  "filter, f",
        Usage: "filter to use [" + strings.Join(filter.List(), ", ") + "]",
        Value: &flFilterValue,
    }

    flCluster = cli.StringFlag{
        Name:  "cluster-driver, c",
        Usage: "cluster driver to use [swarm, mesos-experimental]",
        Value: "swarm",
    }
    flClusterOpt = cli.StringSliceFlag{
        Name:  "cluster-opt",
        Usage: "cluster driver options",
        Value: &cli.StringSlice{},
    }

    flLeaderElection = cli.BoolFlag{
        Name:  "replication",
        Usage: "Enable Swarm manager replication",
    }
)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

关于作者

感情旳空白

暂无简介

文章
评论
2464 人气
更多

推荐作者

微信用户

文章 0 评论 0

小情绪

文章 0 评论 0

ゞ记忆︶ㄣ

文章 0 评论 0

笨死的猪

文章 0 评论 0

彭明超

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文