本文整理匯總了Golang中github.com/coreos/etcd-ca/Godeps/_workspace/src/github.com/codegangsta/cli.Context.Bool方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.Bool方法的具體用法?Golang Context.Bool怎麽用?Golang Context.Bool使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/coreos/etcd-ca/Godeps/_workspace/src/github.com/codegangsta/cli.Context
的用法示例。
在下文中一共展示了Context.Bool方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getAuthFiles
func getAuthFiles(c *cli.Context) ([]*TarFile, error) {
name := "ca"
tarFiles := make([]*TarFile, 0)
crtFile, err := d.GetFile(depot.AuthCrtTag())
if err != nil {
return nil, errors.New("Get CA certificate error: " + err.Error())
}
crtTarFile, err := generateTarFile(crtFile, name+crtSuffix)
if err != nil {
return nil, errors.New("Generate certificate tar file error: " + err.Error())
}
tarFiles = append(tarFiles, crtTarFile)
keyFile, err := d.GetFile(depot.AuthPrivKeyTag())
if err != nil {
return nil, errors.New("Get CA key error: " + err.Error())
}
keyTarFile, err := generateTarFile(keyFile, name+keySuffix)
if err != nil {
return nil, errors.New("Generate key tar file error: " + err.Error())
}
if c.Bool("insecure") {
if keyTarFile, err = decryptEncryptedKeyTarFile(keyTarFile, getPassPhrase(c, name+" key")); err != nil {
return nil, errors.New("Get decrypted CA key error: " + err.Error())
}
}
tarFiles = append(tarFiles, keyTarFile)
return tarFiles, nil
}
示例2: newSignAction
func newSignAction(c *cli.Context) {
if len(c.Args()) != 1 {
fmt.Fprintln(os.Stderr, "One host name must be provided.")
os.Exit(1)
}
name := c.Args()[0]
if depot.CheckCertificateHost(d, name) {
fmt.Fprintln(os.Stderr, "Certificate has existed!")
os.Exit(1)
}
csr, err := depot.GetCertificateSigningRequest(d, name)
if err != nil {
fmt.Fprintln(os.Stderr, "Get certificate request error:", err)
os.Exit(1)
}
crt, err := depot.GetCertificateAuthority(d)
if err != nil {
fmt.Fprintln(os.Stderr, "Get CA certificate error:", err)
if isFileNotExist(err) {
fmt.Fprintln(os.Stderr, "Please run 'etcd-ca init' to initial the depot.")
}
os.Exit(1)
}
info, err := depot.GetCertificateAuthorityInfo(d)
if err != nil {
fmt.Fprintln(os.Stderr, "Get CA certificate info error:", err)
os.Exit(1)
}
key, err := depot.GetEncryptedPrivateKeyAuthority(d, getPassPhrase(c, "CA key"))
if err != nil {
fmt.Fprintln(os.Stderr, "Get CA key error:", err)
os.Exit(1)
}
crtHost, err := pkix.CreateCertificateHost(crt, info, key, csr, c.Int("years"), c.Bool("server"), c.Bool("client"))
if err != nil {
fmt.Fprintln(os.Stderr, "Create certificate error:", err)
os.Exit(1)
} else {
fmt.Printf("Created %s/crt from %s/csr signed by ca/key\n", name, name)
}
if err = depot.PutCertificateHost(d, name, crtHost); err != nil {
fmt.Fprintln(os.Stderr, "Save certificate error:", err)
}
if err = depot.UpdateCertificateAuthorityInfo(d, info); err != nil {
fmt.Fprintln(os.Stderr, "Update CA info error:", err)
}
}