Skip to content

Commit 3f62020

Browse files
committed
Lint fix
1 parent e2bb24c commit 3f62020

File tree

146 files changed

+1646
-1533
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+1646
-1533
lines changed

cmd/docker-mcp/catalog/add.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func ValidateArgs(args ParsedAddArgs) error {
2727
if args.Dst == DockerCatalogName {
2828
return fmt.Errorf("cannot add servers to catalog '%s' as it is managed by Docker", args.Dst)
2929
}
30-
30+
3131
cfg, err := ReadConfig()
3232
if err != nil {
3333
return err

cmd/docker-mcp/catalog/bootstrap.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,23 @@ func Bootstrap(ctx context.Context, outputPath string) error {
3737
// Extract registry section
3838
registryInterface, ok := dockerCatalog["registry"]
3939
if !ok {
40-
return fmt.Errorf("Docker catalog missing 'registry' section")
40+
return fmt.Errorf("docker catalog missing 'registry' section")
4141
}
4242

4343
registry, ok := registryInterface.(map[string]interface{})
4444
if !ok {
45-
return fmt.Errorf("Docker catalog 'registry' section is not a map")
45+
return fmt.Errorf("docker catalog 'registry' section is not a map")
4646
}
4747

4848
// Extract Docker and Docker Hub servers
4949
dockerHubServer, hasDockerHub := registry[DockerHubServerName]
5050
dockerCLIServer, hasDockerCLI := registry[DockerCLIServerName]
5151

5252
if !hasDockerHub {
53-
return fmt.Errorf("Docker catalog missing '%s' server", DockerHubServerName)
53+
return fmt.Errorf("docker catalog missing '%s' server", DockerHubServerName)
5454
}
5555
if !hasDockerCLI {
56-
return fmt.Errorf("Docker catalog missing '%s' server", DockerCLIServerName)
56+
return fmt.Errorf("docker catalog missing '%s' server", DockerCLIServerName)
5757
}
5858

5959
// Create bootstrap catalog with just the Docker servers
@@ -72,14 +72,14 @@ func Bootstrap(ctx context.Context, outputPath string) error {
7272

7373
// Create output directory if it doesn't exist
7474
outputDir := filepath.Dir(outputPath)
75-
if err := os.MkdirAll(outputDir, 0755); err != nil {
75+
if err := os.MkdirAll(outputDir, 0o755); err != nil {
7676
return fmt.Errorf("failed to create output directory: %w", err)
7777
}
7878

7979
// Write the bootstrap catalog file
80-
if err := os.WriteFile(outputPath, bootstrapData, 0644); err != nil {
80+
if err := os.WriteFile(outputPath, bootstrapData, 0o644); err != nil {
8181
return fmt.Errorf("failed to write bootstrap catalog file: %w", err)
8282
}
8383

8484
return nil
85-
}
85+
}

cmd/docker-mcp/catalog/catalog.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const (
1212
DockerCatalogName = "docker-mcp"
1313
DockerCatalogURL = "https://desktop.docker.com/mcp/catalog/v2/catalog.yaml"
1414
DockerCatalogFilename = "docker-mcp.yaml"
15-
15+
1616
// Docker server names for bootstrap command
1717
DockerHubServerName = "dockerhub"
1818
DockerCLIServerName = "docker"

cmd/docker-mcp/catalog/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ func Create(name string) error {
99
if name == DockerCatalogName {
1010
return fmt.Errorf("cannot create catalog '%s' as it is reserved for Docker's official catalog", name)
1111
}
12-
12+
1313
cfg, err := ReadConfig()
1414
if err != nil {
1515
return err

cmd/docker-mcp/catalog/export.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ import (
1515

1616
// Export exports a configured catalog to a file
1717
// This function only allows exporting user-managed catalogs, not the Docker catalog
18-
func Export(ctx context.Context, catalogName, outputPath string) error {
18+
func Export(_ context.Context, catalogName, outputPath string) error {
1919
// Validate that we're not trying to export the Docker catalog
2020
if catalogName == DockerCatalogName || catalogName == DockerCatalogFilename {
2121
return fmt.Errorf("cannot export the Docker MCP catalog as it is managed by Docker")
2222
}
23-
23+
2424
// Get configured catalogs to verify the catalog exists
2525
configuredCatalogs, err := getConfiguredCatalogs()
2626
if err != nil {
2727
return fmt.Errorf("failed to read configured catalogs: %w", err)
2828
}
29-
29+
3030
// Check if the catalog exists in the configured catalogs
3131
catalogFileName := catalogName + ".yaml"
3232
found := false
@@ -36,40 +36,40 @@ func Export(ctx context.Context, catalogName, outputPath string) error {
3636
break
3737
}
3838
}
39-
39+
4040
if !found {
4141
return fmt.Errorf("catalog '%s' not found in configured catalogs", catalogName)
4242
}
43-
43+
4444
// Read the catalog file
4545
homeDir, err := user.HomeDir()
4646
if err != nil {
4747
return fmt.Errorf("failed to get home directory: %w", err)
4848
}
49-
49+
5050
catalogPath := filepath.Join(homeDir, ".docker", "mcp", "catalogs", catalogFileName)
5151
catalogData, err := os.ReadFile(catalogPath)
5252
if err != nil {
5353
return fmt.Errorf("failed to read catalog file: %w", err)
5454
}
55-
55+
5656
// Parse the catalog to validate it
5757
var catalogContent catalog.Catalog
5858
if err := yaml.Unmarshal(catalogData, &catalogContent); err != nil {
5959
return fmt.Errorf("failed to parse catalog: %w", err)
6060
}
61-
61+
6262
// Create output directory if it doesn't exist
6363
outputDir := filepath.Dir(outputPath)
64-
if err := os.MkdirAll(outputDir, 0755); err != nil {
64+
if err := os.MkdirAll(outputDir, 0o755); err != nil {
6565
return fmt.Errorf("failed to create output directory: %w", err)
6666
}
67-
67+
6868
// Write the catalog to the output file
69-
if err := os.WriteFile(outputPath, catalogData, 0644); err != nil {
69+
if err := os.WriteFile(outputPath, catalogData, 0o644); err != nil {
7070
return fmt.Errorf("failed to write export file: %w", err)
7171
}
72-
72+
7373
fmt.Printf("Catalog '%s' exported to '%s'\n", catalogName, outputPath)
7474
return nil
7575
}
@@ -80,9 +80,9 @@ func getConfiguredCatalogs() ([]string, error) {
8080
if err != nil {
8181
return nil, fmt.Errorf("failed to get home directory: %w", err)
8282
}
83-
83+
8484
catalogRegistryPath := filepath.Join(homeDir, ".docker", "mcp", "catalog.json")
85-
85+
8686
// Read the catalog registry file
8787
data, err := os.ReadFile(catalogRegistryPath)
8888
if err != nil {
@@ -91,7 +91,7 @@ func getConfiguredCatalogs() ([]string, error) {
9191
}
9292
return nil, fmt.Errorf("failed to read catalog registry: %w", err)
9393
}
94-
94+
9595
// Parse the registry
9696
var registry struct {
9797
Catalogs map[string]struct {
@@ -100,16 +100,16 @@ func getConfiguredCatalogs() ([]string, error) {
100100
LastUpdate string `json:"lastUpdate"`
101101
} `json:"catalogs"`
102102
}
103-
103+
104104
if err := json.Unmarshal(data, &registry); err != nil {
105105
return nil, fmt.Errorf("failed to parse catalog registry: %w", err)
106106
}
107-
107+
108108
// Convert catalog names to file paths
109109
var catalogFiles []string
110110
for catalogName := range registry.Catalogs {
111111
catalogFiles = append(catalogFiles, catalogName+".yaml")
112112
}
113-
113+
114114
return catalogFiles, nil
115-
}
115+
}

cmd/docker-mcp/catalog/fork.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,19 @@ func Fork(src, dst string) error {
99
if dst == DockerCatalogName {
1010
return fmt.Errorf("cannot create catalog '%s' as it is reserved for Docker's official catalog", dst)
1111
}
12-
12+
1313
cfg, err := ReadConfig()
1414
if err != nil {
1515
return err
1616
}
17-
17+
1818
// Special handling for Docker catalog - it exists but not in cfg.Catalogs
19-
if src == DockerCatalogName {
20-
// Allow forking from Docker catalog, but it won't be in cfg.Catalogs
21-
// We'll read it directly from the DockerCatalogName
22-
} else {
19+
if src != DockerCatalogName {
2320
if _, ok := cfg.Catalogs[src]; !ok {
2421
return fmt.Errorf("catalog %q not found", src)
2522
}
2623
}
27-
24+
2825
if _, ok := cfg.Catalogs[dst]; ok {
2926
return fmt.Errorf("catalog %q already exists", dst)
3027
}

cmd/docker-mcp/catalog/rm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func Rm(name string) error {
1111
if name == DockerCatalogName {
1212
return fmt.Errorf("cannot remove catalog '%s' as it is managed by Docker", name)
1313
}
14-
14+
1515
cfg, err := ReadConfig()
1616
if err != nil {
1717
return err

cmd/docker-mcp/commands/bootstrap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ import it or use it as a source for the 'catalog add' command.`,
2121
return catalog.Bootstrap(cmd.Context(), args[0])
2222
},
2323
}
24-
}
24+
}

cmd/docker-mcp/commands/bootstrap_test.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,39 @@ func TestBootstrapCatalogCommand(t *testing.T) {
2525
setupTestDockerCatalog(t, tempHome)
2626

2727
ctx := context.Background()
28-
28+
2929
// Test bootstrapping a catalog
3030
outputFile := filepath.Join(tempHome, "bootstrap-catalog.yaml")
31-
31+
3232
// Create and execute bootstrap command
3333
cmd := bootstrapCatalogCommand()
3434
cmd.SetArgs([]string{outputFile})
3535
cmd.SetContext(ctx)
36-
36+
3737
err := cmd.Execute()
3838
require.NoError(t, err, "bootstrap command should succeed")
39-
39+
4040
// Verify the bootstrap file exists and has correct content
4141
assert.FileExists(t, outputFile, "bootstrap catalog file should exist")
42-
42+
4343
// Read and verify the bootstrap content
4444
content, err := os.ReadFile(outputFile)
4545
require.NoError(t, err)
46-
46+
4747
bootstrapContent := string(content)
4848
assert.Contains(t, bootstrapContent, "registry:", "bootstrap catalog should have registry section")
4949
assert.Contains(t, bootstrapContent, catalog.DockerHubServerName, "bootstrap catalog should contain dockerhub server")
5050
assert.Contains(t, bootstrapContent, catalog.DockerCLIServerName, "bootstrap catalog should contain docker server")
51-
51+
5252
// Parse the YAML to ensure it's valid
5353
var registry map[string]interface{}
5454
err = yaml.Unmarshal(content, &registry)
5555
require.NoError(t, err, "bootstrap catalog should be valid YAML")
56-
56+
5757
// Verify structure
5858
registryMap, ok := registry["registry"].(map[string]interface{})
5959
require.True(t, ok, "bootstrap catalog should have registry map")
60-
60+
6161
// Check that we have exactly the Docker servers
6262
assert.Len(t, registryMap, 2, "bootstrap catalog should contain exactly 2 servers")
6363
assert.Contains(t, registryMap, catalog.DockerHubServerName, "should contain dockerhub server")
@@ -77,18 +77,18 @@ func TestBootstrapExistingFile(t *testing.T) {
7777

7878
// Create an existing file
7979
outputFile := filepath.Join(tempHome, "existing-catalog.yaml")
80-
err := os.WriteFile(outputFile, []byte("existing content"), 0644)
80+
err := os.WriteFile(outputFile, []byte("existing content"), 0o644)
8181
require.NoError(t, err)
82-
82+
8383
// Test bootstrapping over existing file should fail
8484
cmd := bootstrapCatalogCommand()
8585
cmd.SetArgs([]string{outputFile})
8686
cmd.SetContext(ctx)
87-
87+
8888
err = cmd.Execute()
8989
require.Error(t, err, "bootstrapping over existing file should fail")
9090
assert.Contains(t, err.Error(), "already exists", "error should mention file already exists")
91-
91+
9292
// Verify original content is preserved
9393
content, err := os.ReadFile(outputFile)
9494
require.NoError(t, err)
@@ -105,20 +105,20 @@ func TestBootstrapInvalidPath(t *testing.T) {
105105

106106
// Setup Docker catalog for testing
107107
setupTestDockerCatalog(t, tempHome)
108-
108+
109109
// Test bootstrapping to invalid path (use a file as directory path)
110110
// Create a file that will conflict with the directory creation
111111
conflictFile := filepath.Join(tempHome, "conflict-file")
112112
err := os.WriteFile(conflictFile, []byte("test"), 0644)
113113
require.NoError(t, err)
114-
114+
115115
// Try to bootstrap to a path that treats the file as a directory
116116
outputFile := filepath.Join(conflictFile, "catalog.yaml")
117-
117+
118118
cmd := bootstrapCatalogCommand()
119119
cmd.SetArgs([]string{outputFile})
120120
cmd.SetContext(ctx)
121-
121+
122122
err = cmd.Execute()
123123
require.Error(t, err, "bootstrapping to invalid path should fail")
124124
assert.Contains(t, err.Error(), "not a directory", "error should indicate directory issue")
@@ -137,29 +137,29 @@ func TestBootstrapDockerEntriesExtraction(t *testing.T) {
137137

138138
ctx := context.Background()
139139
outputFile := filepath.Join(tempHome, "detailed-bootstrap.yaml")
140-
140+
141141
// Create and execute bootstrap command
142142
cmd := bootstrapCatalogCommand()
143143
cmd.SetArgs([]string{outputFile})
144144
cmd.SetContext(ctx)
145-
145+
146146
err := cmd.Execute()
147147
require.NoError(t, err, "bootstrap command should succeed")
148-
148+
149149
// Read the bootstrap content
150150
content, err := os.ReadFile(outputFile)
151151
require.NoError(t, err)
152-
152+
153153
bootstrapContent := string(content)
154-
154+
155155
// Verify detailed Docker Hub server content is preserved
156156
assert.Contains(t, bootstrapContent, "Docker Hub official MCP server", "should preserve dockerhub description")
157157
assert.Contains(t, bootstrapContent, "mcp/dockerhub", "should preserve dockerhub image")
158-
158+
159159
// Verify detailed Docker CLI server content is preserved
160160
assert.Contains(t, bootstrapContent, "Use the Docker CLI", "should preserve docker description")
161161
assert.Contains(t, bootstrapContent, "docker@sha256:", "should preserve docker image")
162-
162+
163163
// Verify other servers are NOT included
164164
assert.NotContains(t, bootstrapContent, "github", "should not contain other servers like github")
165165
assert.NotContains(t, bootstrapContent, "elasticsearch", "should not contain other servers like elasticsearch")
@@ -168,7 +168,7 @@ func TestBootstrapDockerEntriesExtraction(t *testing.T) {
168168
// Helper function to set up basic test Docker catalog
169169
func setupTestDockerCatalog(t *testing.T, homeDir string) {
170170
t.Helper()
171-
171+
172172
// Create .docker/mcp directory structure
173173
mcpDir := filepath.Join(homeDir, ".docker", "mcp")
174174
catalogsDir := filepath.Join(mcpDir, "catalogs")
@@ -211,7 +211,7 @@ func setupTestDockerCatalog(t *testing.T, homeDir string) {
211211
// Helper function to set up detailed test Docker catalog with more servers
212212
func setupDetailedTestDockerCatalog(t *testing.T, homeDir string) {
213213
t.Helper()
214-
214+
215215
// Create .docker/mcp directory structure
216216
mcpDir := filepath.Join(homeDir, ".docker", "mcp")
217217
catalogsDir := filepath.Join(mcpDir, "catalogs")
@@ -293,4 +293,4 @@ func setupDetailedTestDockerCatalog(t *testing.T, homeDir string) {
293293
- name: "search"`
294294
err = os.WriteFile(filepath.Join(catalogsDir, "docker-mcp.yaml"), []byte(dockerCatalog), 0644)
295295
require.NoError(t, err)
296-
}
296+
}

0 commit comments

Comments
 (0)