本文整理汇总了Golang中github.com/lxc/lxd/shared.FindOrGenCert函数的典型用法代码示例。如果您正苦于以下问题:Golang FindOrGenCert函数的具体用法?Golang FindOrGenCert怎么用?Golang FindOrGenCert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FindOrGenCert函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: readMyCert
func readMyCert() (string, string, error) {
certf := ConfigPath("client.crt")
keyf := ConfigPath("client.key")
err := shared.FindOrGenCert(certf, keyf)
return certf, keyf, err
}
开发者ID:Malizor,项目名称:lxd,代码行数:8,代码来源:client.go
示例2: readMyCert
func readMyCert(configDir string) (string, string, error) {
certf := path.Join(configDir, "client.crt")
keyf := path.Join(configDir, "client.key")
err := shared.FindOrGenCert(certf, keyf)
return certf, keyf, err
}
开发者ID:djibi2,项目名称:lxd,代码行数:8,代码来源:client.go
示例3: readMyCert
func readMyCert() (string, string, error) {
certf := shared.VarPath("server.crt")
keyf := shared.VarPath("server.key")
shared.LogDebug("Looking for existing certificates", log.Ctx{"cert": certf, "key": keyf})
err := shared.FindOrGenCert(certf, keyf, false)
return certf, keyf, err
}
开发者ID:akshaykarle,项目名称:lxd,代码行数:8,代码来源:daemon.go
示例4: readMyCert
func readMyCert() (string, string, error) {
certf := shared.VarPath("server.crt")
keyf := shared.VarPath("server.key")
shared.Debugf("looking for existing certificates: %s %s", certf, keyf)
err := shared.FindOrGenCert(certf, keyf)
return certf, keyf, err
}
开发者ID:Ramzec,项目名称:lxd,代码行数:9,代码来源:daemon.go
示例5: generateClientCertificate
func generateClientCertificate(config *lxd.Config) error {
// Generate a client certificate if necessary. The default repositories are
// either local or public, neither of which requires a client certificate.
// Generation of the cert is delayed to avoid unnecessary overhead, e.g in
// testing scenarios where only the default repositories are used.
certf := config.ConfigPath("client.crt")
keyf := config.ConfigPath("client.key")
if !shared.PathExists(certf) || !shared.PathExists(keyf) {
fmt.Fprintf(os.Stderr, i18n.G("Generating a client certificate. This may take a minute...")+"\n")
return shared.FindOrGenCert(certf, keyf, true)
}
return nil
}
开发者ID:vahe,项目名称:lxd,代码行数:14,代码来源:remote.go
示例6: run
func run() error {
gettext.BindTextdomain("lxd", "", nil)
gettext.Textdomain("lxd")
verbose := gnuflag.Bool("verbose", false, gettext.Gettext("Enables verbose mode."))
debug := gnuflag.Bool("debug", false, gettext.Gettext("Enables debug mode."))
forceLocal := gnuflag.Bool("force-local", false, gettext.Gettext("Enables debug mode."))
gnuflag.StringVar(&lxd.ConfigDir, "config", lxd.ConfigDir, gettext.Gettext("Alternate config directory."))
if len(os.Args) >= 3 && os.Args[1] == "config" && os.Args[2] == "profile" {
fmt.Fprintf(os.Stderr, "`lxc config profile` is deprecated, please use `lxc profile`\n")
os.Args = append(os.Args[:1], os.Args[2:]...)
}
if len(os.Args) >= 2 && (os.Args[1] == "-h" || os.Args[1] == "--help") {
os.Args[1] = "help"
}
if len(os.Args) >= 2 && (os.Args[1] == "--all") {
os.Args[1] = "help"
os.Args = append(os.Args, "--all")
}
if len(os.Args) == 2 && os.Args[1] == "--version" {
os.Args[1] = "version"
}
if len(os.Args) < 2 {
commands["help"].run(nil, nil)
os.Exit(1)
}
name := os.Args[1]
cmd, ok := commands[name]
if !ok {
fmt.Fprintf(os.Stderr, gettext.Gettext("error: unknown command: %s\n"), name)
commands["help"].run(nil, nil)
os.Exit(1)
}
cmd.flags()
gnuflag.Usage = func() {
fmt.Fprintf(os.Stderr, gettext.Gettext("Usage: %s\n\nOptions:\n\n"), strings.TrimSpace(cmd.usage()))
gnuflag.PrintDefaults()
}
os.Args = os.Args[1:]
gnuflag.Parse(true)
shared.SetLogger("", "", *verbose, *debug)
var config *lxd.Config
var err error
if *forceLocal {
config = &lxd.DefaultConfig
} else {
config, err = lxd.LoadConfig()
if err != nil {
return err
}
}
certf := lxd.ConfigPath("client.crt")
keyf := lxd.ConfigPath("client.key")
if !*forceLocal && os.Args[0] != "help" && os.Args[0] != "version" && (!shared.PathExists(certf) || !shared.PathExists(keyf)) {
fmt.Fprintf(os.Stderr, gettext.Gettext("Generating a client certificate. This may take a minute...\n"))
err = shared.FindOrGenCert(certf, keyf)
if err != nil {
return err
}
fmt.Fprintf(os.Stderr, gettext.Gettext("If this is your first run, you will need to import images using the 'lxd-images' script.\n"))
fmt.Fprintf(os.Stderr, gettext.Gettext("For example: 'lxd-images import ubuntu --alias ubuntu'.\n"))
}
err = cmd.run(config, gnuflag.Args())
if err == errArgs {
fmt.Fprintf(os.Stderr, gettext.Gettext("error: %v\n%s"), err, cmd.usage())
os.Exit(1)
}
return err
}
开发者ID:jumpstarter-io,项目名称:lxd,代码行数:84,代码来源:main.go
示例7: run
func run() error {
verbose := gnuflag.Bool("verbose", false, i18n.G("Enables verbose mode."))
debug := gnuflag.Bool("debug", false, i18n.G("Enables debug mode."))
forceLocal := gnuflag.Bool("force-local", false, i18n.G("Force using the local unix socket."))
noAlias := gnuflag.Bool("no-alias", false, i18n.G("Ignore aliases when determining what command to run."))
configDir := "$HOME/.config/lxc"
if os.Getenv("LXD_CONF") != "" {
configDir = os.Getenv("LXD_CONF")
}
configPath = os.ExpandEnv(path.Join(configDir, "config.yml"))
if len(os.Args) >= 3 && os.Args[1] == "config" && os.Args[2] == "profile" {
fmt.Fprintf(os.Stderr, i18n.G("`lxc config profile` is deprecated, please use `lxc profile`")+"\n")
os.Args = append(os.Args[:1], os.Args[2:]...)
}
if len(os.Args) >= 2 && (os.Args[1] == "-h" || os.Args[1] == "--help") {
os.Args[1] = "help"
}
if len(os.Args) >= 2 && (os.Args[1] == "--all") {
os.Args[1] = "help"
os.Args = append(os.Args, "--all")
}
if len(os.Args) == 2 && os.Args[1] == "--version" {
os.Args[1] = "version"
}
if len(os.Args) < 2 {
commands["help"].run(nil, nil)
os.Exit(1)
}
var config *lxd.Config
var err error
if *forceLocal {
config = &lxd.DefaultConfig
} else {
config, err = lxd.LoadConfig(configPath)
if err != nil {
return err
}
}
// This is quite impolite, but it seems gnuflag needs us to shift our
// own exename out of the arguments before parsing them. However, this
// is useful for execIfAlias, which wants to know exactly the command
// line we received, and in some cases is called before this shift, and
// in others after. So, let's save the original args.
origArgs := os.Args
name := os.Args[1]
/* at this point we haven't parsed the args, so we have to look for
* --no-alias by hand.
*/
if !shared.StringInSlice("--no-alias", origArgs) {
execIfAliases(config, origArgs)
}
cmd, ok := commands[name]
if !ok {
commands["help"].run(nil, nil)
fmt.Fprintf(os.Stderr, "\n"+i18n.G("error: unknown command: %s")+"\n", name)
os.Exit(1)
}
cmd.flags()
gnuflag.Usage = func() {
fmt.Fprintf(os.Stderr, i18n.G("Usage: %s")+"\n\n"+i18n.G("Options:")+"\n\n", strings.TrimSpace(cmd.usage()))
gnuflag.PrintDefaults()
}
os.Args = os.Args[1:]
gnuflag.Parse(true)
shared.Log, err = logging.GetLogger("", "", *verbose, *debug, nil)
if err != nil {
return err
}
certf := config.ConfigPath("client.crt")
keyf := config.ConfigPath("client.key")
if !*forceLocal && os.Args[0] != "help" && os.Args[0] != "version" && (!shared.PathExists(certf) || !shared.PathExists(keyf)) {
fmt.Fprintf(os.Stderr, i18n.G("Generating a client certificate. This may take a minute...")+"\n")
err = shared.FindOrGenCert(certf, keyf)
if err != nil {
return err
}
}
err = cmd.run(config, gnuflag.Args())
if err == errArgs {
/* If we got an error about invalid arguments, let's try to
* expand this as an alias
*/
if !*noAlias {
execIfAliases(config, origArgs)
//.........这里部分代码省略.........
开发者ID:jameinel,项目名称:lxd,代码行数:101,代码来源:main.go
示例8: run
func run() error {
verbose := gnuflag.Bool("verbose", false, i18n.G("Enables verbose mode."))
debug := gnuflag.Bool("debug", false, i18n.G("Enables debug mode."))
forceLocal := gnuflag.Bool("force-local", false, i18n.G("Force using the local unix socket."))
configDir := os.Getenv("LXD_CONF")
if configDir != "" {
lxd.ConfigDir = configDir
}
if len(os.Args) >= 3 && os.Args[1] == "config" && os.Args[2] == "profile" {
fmt.Fprintf(os.Stderr, i18n.G("`lxc config profile` is deprecated, please use `lxc profile`")+"\n")
os.Args = append(os.Args[:1], os.Args[2:]...)
}
if len(os.Args) >= 2 && (os.Args[1] == "-h" || os.Args[1] == "--help") {
os.Args[1] = "help"
}
if len(os.Args) >= 2 && (os.Args[1] == "--all") {
os.Args[1] = "help"
os.Args = append(os.Args, "--all")
}
if len(os.Args) == 2 && os.Args[1] == "--version" {
os.Args[1] = "version"
}
if len(os.Args) < 2 {
commands["help"].run(nil, nil)
os.Exit(1)
}
var config *lxd.Config
var err error
if *forceLocal {
config = &lxd.DefaultConfig
} else {
config, err = lxd.LoadConfig()
if err != nil {
return err
}
// One time migration from old config
if config.DefaultRemote == "" {
_, ok := config.Remotes["local"]
if !ok {
config.Remotes["local"] = lxd.LocalRemote
}
config.DefaultRemote = "local"
lxd.SaveConfig(config)
}
}
// This is quite impolite, but it seems gnuflag needs us to shift our
// own exename out of the arguments before parsing them. However, this
// is useful for execIfAlias, which wants to know exactly the command
// line we received, and in some cases is called before this shift, and
// in others after. So, let's save the original args.
origArgs := os.Args
name := os.Args[1]
cmd, ok := commands[name]
if !ok {
execIfAliases(config, origArgs)
fmt.Fprintf(os.Stderr, i18n.G("error: unknown command: %s")+"\n", name)
commands["help"].run(nil, nil)
os.Exit(1)
}
cmd.flags()
gnuflag.Usage = func() {
fmt.Fprintf(os.Stderr, i18n.G("Usage: %s")+"\n\n"+i18n.G("Options:")+"\n\n", strings.TrimSpace(cmd.usage()))
gnuflag.PrintDefaults()
}
os.Args = os.Args[1:]
gnuflag.Parse(true)
shared.SetLogger("", "", *verbose, *debug, nil)
certf := lxd.ConfigPath("client.crt")
keyf := lxd.ConfigPath("client.key")
if !*forceLocal && os.Args[0] != "help" && os.Args[0] != "version" && (!shared.PathExists(certf) || !shared.PathExists(keyf)) {
fmt.Fprintf(os.Stderr, i18n.G("Generating a client certificate. This may take a minute...")+"\n")
err = shared.FindOrGenCert(certf, keyf)
if err != nil {
return err
}
fmt.Fprintf(os.Stderr, i18n.G("If this is your first run, you will need to import images using the 'lxd-images' script.")+"\n")
fmt.Fprintf(os.Stderr, i18n.G("For example: 'lxd-images import ubuntu --alias ubuntu'.")+"\n")
}
err = cmd.run(config, gnuflag.Args())
if err == errArgs {
/* If we got an error about invalid arguments, let's try to
* expand this as an alias
*/
//.........这里部分代码省略.........
开发者ID:HPCNow,项目名称:lxd,代码行数:101,代码来源:main.go
注:本文中的github.com/lxc/lxd/shared.FindOrGenCert函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论