本文整理汇总了Golang中github.com/keybase/client/go/libkb.Delegator.Run方法的典型用法代码示例。如果您正苦于以下问题:Golang Delegator.Run方法的具体用法?Golang Delegator.Run怎么用?Golang Delegator.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/keybase/client/go/libkb.Delegator
的用法示例。
在下文中一共展示了Delegator.Run方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Run
func (e *PGPUpdateEngine) Run(ctx *Context) error {
if e.all && len(e.selectedFingerprints) > 0 {
return fmt.Errorf("Cannot use explicit fingerprints with --all.")
}
me, err := libkb.LoadMe(libkb.NewLoadUserArg(e.G()))
if err != nil {
return err
}
fingerprints := me.GetActivePGPFingerprints(false /* not just sibkeys */)
if len(fingerprints) > 1 && !e.all && len(e.selectedFingerprints) == 0 {
return fmt.Errorf("You have more than one PGP key. To update all of them, use --all.")
}
gpgCLI := libkb.NewGpgCLI(libkb.GpgCLIArg{
LogUI: ctx.LogUI,
})
err = gpgCLI.Configure()
if err != nil {
return err
}
del := libkb.Delegator{
DelegationType: libkb.PGPUpdateType,
Me: me,
Expire: libkb.KeyExpireIn,
Contextified: libkb.NewContextified(e.G()),
}
err = del.LoadSigningKey(ctx.LoginContext, ctx.SecretUI)
if err != nil {
return err
}
for _, fingerprint := range fingerprints {
if len(e.selectedFingerprints) > 0 && !e.selectedFingerprints[fingerprint.String()] {
ctx.LogUI.Warning("Skipping update for key %s", fingerprint.String())
continue
}
bundle, err := gpgCLI.ImportKey(false /* secret */, fingerprint)
if err != nil {
_, isNoKey := err.(libkb.NoKeyError)
if isNoKey {
ctx.LogUI.Warning(
"No key matching fingerprint %s found in the GPG keyring.",
fingerprint.String())
continue
} else {
return err
}
}
del.NewKey = bundle
ctx.LogUI.Info("Posting update for key %s.", fingerprint.String())
if err := del.Run(ctx.LoginContext); err != nil {
if appStatusErr, ok := err.(libkb.AppStatusError); ok && appStatusErr.Code == libkb.SCKeyDuplicateUpdate {
ctx.LogUI.Info("Key was already up to date.")
e.duplicatedFingerprints = append(e.duplicatedFingerprints, fingerprint)
continue
}
return err
}
ctx.LogUI.Info("Update succeeded for key %s.", fingerprint)
}
return nil
}