/
selfListIngressKeys.go
50 lines (39 loc) · 1.46 KB
/
selfListIngressKeys.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package cmd
import (
"fmt"
"github.com/inpher/sb/internal/commands"
"github.com/inpher/sb/internal/helpers"
"github.com/inpher/sb/internal/models"
)
// SelfListIngressKeys describes the selfListIngressKeys command
type SelfListIngressKeys struct{}
func init() {
commands.RegisterCommand("self ingress-keys list", func() (c commands.Command, r models.Right, h helpers.Helper, args map[string]commands.Argument) {
return new(SelfListIngressKeys), models.Public, helpers.Helper{
Header: "list your ingress public keys (you -> sb)",
Usage: "self ingress-keys list [--public-key 'ssh key text']",
Description: "list your ingress public keys (you -> sb)",
Aliases: []string{"selfListIngressKeys"},
}, map[string]commands.Argument{}
})
}
// Checks checks whether or not the user can execute this method
func (c *SelfListIngressKeys) Checks(ct *commands.Context) error {
// No specific rights needed but a sb account
return nil
}
// Execute executes the command
func (c *SelfListIngressKeys) Execute(ct *commands.Context) (repl models.ReplicationData, cmdError error, err error) {
str, _, err := ct.User.DisplayPubKeys("ingress")
if err != nil {
return
}
fmt.Printf("Here is the list of your current ingress public SSH keys (you -> sb):\n%s\n", str)
return
}
func (c *SelfListIngressKeys) PostExecute(repl models.ReplicationData) (err error) {
return
}
func (c *SelfListIngressKeys) Replicate(repl models.ReplicationData) (err error) {
return
}