Skip to content

Commit 22a6f49

Browse files
committed
Prepare for extraction
Signed-off-by: David Gageot <[email protected]>
1 parent 21bf425 commit 22a6f49

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

cmd/docker-mcp/secret-management/secret/export.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import (
1111
"github.com/docker/mcp-gateway/cmd/docker-mcp/internal/docker"
1212
)
1313

14-
func ExportCommand(docker docker.Client) *cobra.Command {
14+
func exportCommand(docker docker.Client) *cobra.Command {
1515
return &cobra.Command{
1616
Use: "export [server1] [server2] ...",
1717
Short: "Export secrets for the specified servers",
1818
Hidden: true,
1919
Args: cobra.MinimumNArgs(1),
2020
RunE: func(cmd *cobra.Command, args []string) error {
21-
secrets, err := exportSecrets(cmd.Context(), docker, args)
21+
secrets, err := Export(cmd.Context(), docker, args)
2222
if err != nil {
2323
return err
2424
}
@@ -32,7 +32,7 @@ func ExportCommand(docker docker.Client) *cobra.Command {
3232
}
3333
}
3434

35-
func exportSecrets(ctx context.Context, docker docker.Client, serverNames []string) (map[string]string, error) {
35+
func Export(ctx context.Context, docker docker.Client, serverNames []string) (map[string]string, error) {
3636
catalog, err := catalog.Get(ctx)
3737
if err != nil {
3838
return nil, err

cmd/docker-mcp/secret-management/secret/list.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@ import (
1111
"github.com/docker/mcp-gateway/cmd/docker-mcp/secret-management/formatting"
1212
)
1313

14-
type listOptions struct {
14+
type ListOptions struct {
1515
JSON bool
1616
}
1717

18-
func ListCommand() *cobra.Command {
19-
opts := listOptions{}
18+
func listCommand() *cobra.Command {
19+
var opts ListOptions
2020
cmd := &cobra.Command{
2121
Use: "ls",
2222
Short: "List all secret names in Docker Desktop's secret store",
2323
Args: cobra.NoArgs,
2424
RunE: func(cmd *cobra.Command, _ []string) error {
25-
return runList(cmd.Context(), opts)
25+
return List(cmd.Context(), opts)
2626
},
2727
}
2828
flags := cmd.Flags()
2929
flags.BoolVar(&opts.JSON, "json", false, "Print as JSON.")
3030
return cmd
3131
}
3232

33-
func runList(ctx context.Context, opts listOptions) error {
33+
func List(ctx context.Context, opts ListOptions) error {
3434
l, err := desktop.NewSecretsClient().ListJfsSecrets(ctx)
3535
if err != nil {
3636
return err

cmd/docker-mcp/secret-management/secret/rm.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,35 @@ import (
1010
"github.com/docker/mcp-gateway/cmd/docker-mcp/internal/desktop"
1111
)
1212

13-
type rmOpts struct {
13+
type RmOpts struct {
1414
All bool
1515
}
1616

17-
func RmCommand() *cobra.Command {
18-
opts := rmOpts{}
17+
func rmCommand() *cobra.Command {
18+
var opts RmOpts
1919
cmd := &cobra.Command{
2020
Use: "rm name1 name2 ...",
2121
Short: "Remove secrets from Docker Desktop's secret store",
2222
RunE: func(cmd *cobra.Command, args []string) error {
2323
if err := validateArgs(args, opts); err != nil {
2424
return err
2525
}
26-
return runRm(cmd.Context(), args, opts)
26+
return Remove(cmd.Context(), args, opts)
2727
},
2828
}
2929
flags := cmd.Flags()
3030
flags.BoolVar(&opts.All, "all", false, "Remove all secrets")
3131
return cmd
3232
}
3333

34-
func validateArgs(args []string, opts rmOpts) error {
34+
func validateArgs(args []string, opts RmOpts) error {
3535
if len(args) == 0 && !opts.All {
3636
return errors.New("either provide a secret name or use --all to remove all secrets")
3737
}
3838
return nil
3939
}
4040

41-
func runRm(ctx context.Context, names []string, opts rmOpts) error {
41+
func Remove(ctx context.Context, names []string, opts RmOpts) error {
4242
c := desktop.NewSecretsClient()
4343
if opts.All && len(names) == 0 {
4444
l, err := c.ListJfsSecrets(ctx)

cmd/docker-mcp/secret-management/secret/root.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ func NewSecretsCmd(docker docker.Client) *cobra.Command {
1414
Short: "Manage secrets",
1515
Example: strings.Trim(setExample, "\n"),
1616
}
17-
cmd.AddCommand(RmCommand())
18-
cmd.AddCommand(ListCommand())
19-
cmd.AddCommand(SetCommand())
20-
cmd.AddCommand(ExportCommand(docker))
17+
cmd.AddCommand(rmCommand())
18+
cmd.AddCommand(listCommand())
19+
cmd.AddCommand(setCommand())
20+
cmd.AddCommand(exportCommand(docker))
2121
return cmd
2222
}

cmd/docker-mcp/secret-management/secret/set.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ const (
2626
Credstore = "credstore"
2727
)
2828

29-
type setOpts struct {
29+
type SetOpts struct {
3030
Provider string
3131
}
3232

33-
func SetCommand() *cobra.Command {
34-
opts := &setOpts{}
33+
func setCommand() *cobra.Command {
34+
opts := &SetOpts{}
3535
cmd := &cobra.Command{
3636
Use: "set key[=value]",
3737
Short: "Set a secret in Docker Desktop's secret store",
@@ -55,15 +55,15 @@ func SetCommand() *cobra.Command {
5555
}
5656
s = *val
5757
}
58-
return runSet(cmd.Context(), s, *opts)
58+
return Set(cmd.Context(), s, *opts)
5959
},
6060
}
6161
flags := cmd.Flags()
6262
flags.StringVar(&opts.Provider, "provider", "", "Supported: credstore, oauth/<provider>")
6363
return cmd
6464
}
6565

66-
func isNotImplicitReadFromStdinSyntax(args []string, opts setOpts) bool {
66+
func isNotImplicitReadFromStdinSyntax(args []string, opts SetOpts) bool {
6767
return strings.Contains(args[0], "=") || len(args) > 1 || opts.Provider != ""
6868
}
6969

@@ -84,7 +84,7 @@ type secret struct {
8484
val string
8585
}
8686

87-
func parseArg(arg string, opts setOpts) (*secret, error) {
87+
func parseArg(arg string, opts SetOpts) (*secret, error) {
8888
if !isDirectValueProvider(opts.Provider) && strings.Contains(arg, "=") {
8989
return nil, fmt.Errorf("provider cannot be used with key=value pairs: %s", arg)
9090
}
@@ -102,7 +102,7 @@ func isDirectValueProvider(provider string) bool {
102102
return provider == "" || provider == Credstore
103103
}
104104

105-
func runSet(ctx context.Context, s secret, opts setOpts) error {
105+
func Set(ctx context.Context, s secret, opts SetOpts) error {
106106
if opts.Provider == Credstore {
107107
p := NewCredStoreProvider()
108108
if err := p.SetSecret(s.key, s.val); err != nil {

0 commit comments

Comments
 (0)