-
Notifications
You must be signed in to change notification settings - Fork 19
/
db_cacertificate.go
49 lines (35 loc) · 1.17 KB
/
db_cacertificate.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
package cmd
import (
"fmt"
exoapi "github.com/exoscale/egoscale/v2/api"
"github.com/spf13/cobra"
)
type dbCACertificateCmd struct {
cliCommandSettings `cli-cmd:"-"`
_ bool `cli-cmd:"ca-certificate"`
Zone string `cli-short:"z"`
}
func (c *dbCACertificateCmd) cmdAliases() []string { return nil }
func (c *dbCACertificateCmd) cmdShort() string { return "Retrieve the Database CA certificate" }
func (c *dbCACertificateCmd) cmdLong() string {
return `This command retrieves the global CA certificate required to access Database
Services using a TLS connection.`
}
func (c *dbCACertificateCmd) cmdPreRun(cmd *cobra.Command, args []string) error {
cmdSetZoneFlagFromDefault(cmd)
return cliCommandDefaultPreRun(c, cmd, args)
}
func (c *dbCACertificateCmd) cmdRun(_ *cobra.Command, _ []string) error {
ctx := exoapi.WithEndpoint(gContext, exoapi.NewReqEndpoint(gCurrentAccount.Environment, c.Zone))
dbCACertificate, err := cs.GetDatabaseCACertificate(ctx, c.Zone)
if err != nil {
return err
}
_, _ = fmt.Print(dbCACertificate)
return nil
}
func init() {
cobra.CheckErr(registerCLICommand(dbCmd, &dbCACertificateCmd{
cliCommandSettings: defaultCLICmdSettings(),
}))
}