本文整理匯總了Golang中postmaster/mailbox.AccessKey.Name方法的典型用法代碼示例。如果您正苦於以下問題:Golang AccessKey.Name方法的具體用法?Golang AccessKey.Name怎麽用?Golang AccessKey.Name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類postmaster/mailbox.AccessKey
的用法示例。
在下文中一共展示了AccessKey.Name方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
// accessCmd represents the access command
var accessCmd = &cobra.Command{
Use: "access [name]",
Short: "Generate an administrative access key the local server.",
Long: `This generates and returns a administrative API access key for the
local Conduit server. This key gives full access to the Conduit API and should
be used for administrative purposes in a Conduit client or by an external system
that can manage the Conduit service.
For audit purposes the access key can be given a name. If no name is specified a
randomly generated identifier will be used.`,
Run: func(cmd *cobra.Command, args []string) {
mailbox.OpenDB()
key := mailbox.AccessKey{FullAccess: true}
if len(args) > 0 {
key.Name = args[0]
}
err := key.Create()
if err != nil {
log.Debug(err.Error())
log.Fatal("Could not create access key.")
}
log.Info("Access key created: ")
log.Info(" Access key name: " + key.Name)
log.Info(" Access key: " + key.Secret)
},
}
func init() {
serverCmd.AddCommand(accessCmd)