func (c *DeleteKeysCommand) Run(context *cmd.Context) error { client, err := juju.NewKeyManagerClient(c.EnvName) if err != nil { return err } defer client.Close() results, err := client.DeleteKeys(c.user, c.keyIds...) if err != nil { return err } for i, result := range results { if result.Error != nil { fmt.Fprintf(context.Stderr, "cannot delete key id %q: %v\n", c.keyIds[i], result.Error) } } return nil }
func (c *ListKeysCommand) Run(context *cmd.Context) error { client, err := juju.NewKeyManagerClient(c.EnvName) if err != nil { return err } defer client.Close() mode := ssh.Fingerprints if c.showFullKey { mode = ssh.FullKeys } results, err := client.ListKeys(mode, c.user) if err != nil { return err } result := results[0] if result.Error != nil { return result.Error } fmt.Fprintf(context.Stdout, "Keys for user %s:\n", c.user) fmt.Fprintln(context.Stdout, strings.Join(result.Result, "\n")) return nil }