Skip to content

Commit 317c4d0

Browse files
committed
fix lint
1 parent b5f9ef5 commit 317c4d0

29 files changed

+42
-121
lines changed

pkg/mcp/builders/config.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ package builders
1919

2020
import (
2121
"fmt"
22-
"os"
2322
"time"
24-
25-
"gopkg.in/yaml.v3"
2623
)
2724

2825
// ToolsConfig represents the structure of the tools configuration file
@@ -38,35 +35,6 @@ type ToolConfig struct {
3835
Options map[string]interface{} `yaml:"options,omitempty"`
3936
}
4037

41-
// LoadToolsConfig loads tool configuration from a file
42-
func LoadToolsConfig(filename string) (*ToolsConfig, error) {
43-
data, err := os.ReadFile(filename)
44-
if err != nil {
45-
return nil, fmt.Errorf("failed to read config file %s: %w", filename, err)
46-
}
47-
48-
var config ToolsConfig
49-
if err := yaml.Unmarshal(data, &config); err != nil {
50-
return nil, fmt.Errorf("failed to parse config file %s: %w", filename, err)
51-
}
52-
53-
return &config, nil
54-
}
55-
56-
// SaveToolsConfig saves tool configuration to a file
57-
func SaveToolsConfig(config *ToolsConfig, filename string) error {
58-
data, err := yaml.Marshal(config)
59-
if err != nil {
60-
return fmt.Errorf("failed to marshal config: %w", err)
61-
}
62-
63-
if err := os.WriteFile(filename, data, 0644); err != nil {
64-
return fmt.Errorf("failed to write config file %s: %w", filename, err)
65-
}
66-
67-
return nil
68-
}
69-
7038
// ToToolBuildConfigs converts tool configuration to build configurations
7139
func (tc *ToolsConfig) ToToolBuildConfigs() map[string]ToolBuildConfig {
7240
configs := make(map[string]ToolBuildConfig)

pkg/mcp/builders/config_test.go

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
package builders
1919

2020
import (
21-
"os"
22-
"path/filepath"
2321
"testing"
2422
"time"
2523

@@ -170,61 +168,6 @@ func TestToolConfig(t *testing.T) {
170168
})
171169
}
172170

173-
func TestConfigFileOperations(t *testing.T) {
174-
tempDir := t.TempDir()
175-
configFile := filepath.Join(tempDir, "test_config.yaml")
176-
177-
t.Run("SaveAndLoadConfig", func(t *testing.T) {
178-
originalConfig := &ToolsConfig{
179-
Tools: map[string]ToolConfig{
180-
"test_tool": {
181-
Enabled: true,
182-
ReadOnly: false,
183-
Features: []string{"feature1", "feature2"},
184-
Options: map[string]interface{}{
185-
"timeout": "30s",
186-
"maxRetries": 3,
187-
},
188-
},
189-
},
190-
}
191-
192-
// Save config
193-
err := SaveToolsConfig(originalConfig, configFile)
194-
require.NoError(t, err)
195-
196-
// Verify file exists
197-
_, err = os.Stat(configFile)
198-
assert.NoError(t, err)
199-
200-
// Load config
201-
loadedConfig, err := LoadToolsConfig(configFile)
202-
require.NoError(t, err)
203-
204-
// Verify content
205-
assert.Equal(t, originalConfig.Tools["test_tool"].Enabled, loadedConfig.Tools["test_tool"].Enabled)
206-
assert.Equal(t, originalConfig.Tools["test_tool"].ReadOnly, loadedConfig.Tools["test_tool"].ReadOnly)
207-
assert.Equal(t, originalConfig.Tools["test_tool"].Features, loadedConfig.Tools["test_tool"].Features)
208-
assert.Equal(t, originalConfig.Tools["test_tool"].Options, loadedConfig.Tools["test_tool"].Options)
209-
})
210-
211-
t.Run("LoadNonexistentFile", func(t *testing.T) {
212-
_, err := LoadToolsConfig("/nonexistent/config.yaml")
213-
assert.Error(t, err)
214-
assert.Contains(t, err.Error(), "failed to read config file")
215-
})
216-
217-
t.Run("LoadInvalidYAML", func(t *testing.T) {
218-
invalidFile := filepath.Join(tempDir, "invalid.yaml")
219-
err := os.WriteFile(invalidFile, []byte("invalid: yaml: content: ["), 0644)
220-
require.NoError(t, err)
221-
222-
_, err = LoadToolsConfig(invalidFile)
223-
assert.Error(t, err)
224-
assert.Contains(t, err.Error(), "failed to parse config file")
225-
})
226-
}
227-
228171
func TestConfigOptions(t *testing.T) {
229172
t.Run("WithReadOnly", func(t *testing.T) {
230173
config := NewToolBuildConfig(WithReadOnly(true))

pkg/mcp/builders/kafka/connect.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333

3434
// KafkaConnectToolBuilder implements the ToolBuilder interface for Kafka Connect
3535
// It provides functionality to build Kafka Connect administration tools
36+
// /nolint:revive
3637
type KafkaConnectToolBuilder struct {
3738
*builders.BaseToolBuilder
3839
}
@@ -296,20 +297,6 @@ func (b *KafkaConnectToolBuilder) marshalResponse(data interface{}) (*mcp.CallTo
296297
return mcp.NewToolResultText(string(jsonBytes)), nil
297298
}
298299

299-
// getKafkaConnectClient retrieves the Kafka Connect client from context
300-
func (b *KafkaConnectToolBuilder) getKafkaConnectClient(ctx context.Context) (kafka.Connect, error) {
301-
// Get Kafka session from context using the same key as in ctx.go
302-
// We define the key locally to avoid circular import
303-
type contextKey string
304-
const kafkaSessionContextKey contextKey = "kafka_session"
305-
306-
session, ok := ctx.Value(kafkaSessionContextKey).(*kafka.Session)
307-
if !ok || session == nil {
308-
return nil, fmt.Errorf("Kafka session not found in context")
309-
}
310-
return session.GetConnectClient()
311-
}
312-
313300
// Specific operation handler functions - migrated from original implementation
314301

315302
// handleKafkaConnectClusterGet handles retrieving Kafka Connect cluster information

pkg/mcp/builders/kafka/consume.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535

3636
// KafkaConsumeToolBuilder implements the ToolBuilder interface for Kafka client consume operations
3737
// It provides functionality to build Kafka consumer tools
38+
// /nolint:revive
3839
type KafkaConsumeToolBuilder struct {
3940
*builders.BaseToolBuilder
4041
logger *logrus.Logger

pkg/mcp/builders/kafka/groups.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
)
3232

3333
// KafkaGroupsToolBuilder implements the ToolBuilder interface for Kafka Consumer Groups
34+
// /nolint:revive
3435
type KafkaGroupsToolBuilder struct {
3536
*builders.BaseToolBuilder
3637
}

pkg/mcp/builders/kafka/partitions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
)
3232

3333
// KafkaPartitionsToolBuilder implements the ToolBuilder interface for Kafka Partitions
34+
// /nolint:revive
3435
type KafkaPartitionsToolBuilder struct {
3536
*builders.BaseToolBuilder
3637
}

pkg/mcp/builders/kafka/produce.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535

3636
// KafkaProduceToolBuilder implements the ToolBuilder interface for Kafka client produce operations
3737
// It provides functionality to build Kafka producer tools
38+
// /nolint:revive
3839
type KafkaProduceToolBuilder struct {
3940
*builders.BaseToolBuilder
4041
}
@@ -317,7 +318,7 @@ func (b *KafkaProduceToolBuilder) buildKafkaProduceHandler() func(context.Contex
317318
return b.handleError("produce message", results[0].Err), nil
318319
}
319320
} else {
320-
kafkaClient.Produce(timeoutCtx, record, func(_ *kgo.Record, err error) {
321+
kafkaClient.Produce(timeoutCtx, record, func(_ *kgo.Record, _ error) {
321322
// Log async errors but don't fail since we're async
322323
// In the future, this could be enhanced with proper async result handling
323324
})

pkg/mcp/builders/kafka/schema_registry.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
)
3333

3434
// KafkaSchemaRegistryToolBuilder implements the ToolBuilder interface for Kafka Schema Registry
35+
// /nolint:revive
3536
type KafkaSchemaRegistryToolBuilder struct {
3637
*builders.BaseToolBuilder
3738
}
@@ -494,7 +495,7 @@ func (b *KafkaSchemaRegistryToolBuilder) handleSchemaCompatibilitySet(ctx contex
494495
}
495496

496497
// handleSchemaTypesList handles listing supported schema types
497-
func (b *KafkaSchemaRegistryToolBuilder) handleSchemaTypesList(ctx context.Context, client *sr.Client, _ mcp.CallToolRequest) (*mcp.CallToolResult, error) {
498+
func (b *KafkaSchemaRegistryToolBuilder) handleSchemaTypesList(_ context.Context, client *sr.Client, _ mcp.CallToolRequest) (*mcp.CallToolResult, error) {
498499
types := []string{"AVRO", "JSON", "PROTOBUF"}
499500
return b.marshalResponse(types)
500501
}

pkg/mcp/builders/kafka/topics.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
)
3232

3333
// KafkaTopicsToolBuilder implements the ToolBuilder interface for Kafka Topics
34+
// /nolint:revive
3435
type KafkaTopicsToolBuilder struct {
3536
*builders.BaseToolBuilder
3637
}
@@ -306,6 +307,7 @@ func (b *KafkaTopicsToolBuilder) handleKafkaTopicCreate(ctx context.Context, adm
306307
return b.handleError("get replication factor", err), nil
307308
}
308309

310+
///nolint:gosec
309311
partitions := int32(partitionsNum)
310312
replicationFactor := int16(replicationFactorNum)
311313

pkg/mcp/builders/pulsar/brokers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
)
3131

3232
// PulsarAdminBrokersToolBuilder implements the ToolBuilder interface for Pulsar admin brokers
33+
// /nolint:revive
3334
type PulsarAdminBrokersToolBuilder struct {
3435
*builders.BaseToolBuilder
3536
}

0 commit comments

Comments
 (0)