-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathgpg.go
More file actions
62 lines (52 loc) · 1.79 KB
/
Copy pathgpg.go
File metadata and controls
62 lines (52 loc) · 1.79 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
// SPDX-FileCopyrightText: 2026 SUSE LLC
//
// SPDX-License-Identifier: Apache-2.0
package gpg
import (
"github.com/spf13/cobra"
"github.com/uyuni-project/uyuni-tools/shared/api"
. "github.com/uyuni-project/uyuni-tools/shared/l10n"
"github.com/uyuni-project/uyuni-tools/shared/types"
"github.com/uyuni-project/uyuni-tools/shared/utils"
)
type apiFlags struct {
api.ConnectionDetails `mapstructure:"api"`
}
func NewCommand(globalFlags *types.GlobalFlags) *cobra.Command {
var flags apiFlags
gpgCmd := &cobra.Command{
Use: "gpg",
Short: L("GPG key management commands"),
}
gpgUploadKeyCmd := &cobra.Command{
Use: "upload [path or URL]",
Short: L("Upload a GPG key to the server"),
Long: L(`Uploads an armored GPG key to the server from a local file or a remote URL.`),
RunE: func(cmd *cobra.Command, args []string) error {
return utils.CommandHelper(globalFlags, cmd, args, &flags, nil, runGpgKeyUpload)
},
Args: cobra.ExactArgs(1),
}
gpgListKeysCmd := &cobra.Command{
Use: "list",
Short: L("List all GPG keys on the server"),
Long: L(`Retrieves a list of registered and/or previously uploaded GPG keys.`),
RunE: func(cmd *cobra.Command, args []string) error {
return utils.CommandHelper(globalFlags, cmd, args, &flags, nil, runGpgKeyList)
},
}
gpgRemoveKeyCmd := &cobra.Command{
Use: "remove [fingerprint]",
Short: L("Remove a GPG key from the server"),
Long: L(`Removes a key identified by its fingerprint from the server's GPG keyring.`),
RunE: func(cmd *cobra.Command, args []string) error {
return utils.CommandHelper(globalFlags, cmd, args, &flags, nil, runGpgKeyRemove)
},
Args: cobra.ExactArgs(1),
}
gpgCmd.AddCommand(gpgUploadKeyCmd)
gpgCmd.AddCommand(gpgListKeysCmd)
gpgCmd.AddCommand(gpgRemoveKeyCmd)
api.AddAPIFlags(gpgCmd)
return gpgCmd
}