本文整理汇总了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)