Skip to content

Commit 1c9aa14

Browse files
committed
undo make target change, more lint fixes
1 parent 67f1d0c commit 1c9aa14

File tree

8 files changed

+43
-21
lines changed

8 files changed

+43
-21
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,13 @@ install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~
180180
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
181181
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
182182

183-
.PHONY: deploy-controller
184-
deploy-controller: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
183+
.PHONY: deploy
184+
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
185185
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
186186
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
187187

188-
.PHONY: undeploy-controller
189-
undeploy-controller: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
188+
.PHONY: undeploy
189+
undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
190190
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
191191

192192
##@ Dependencies

cmd/kmcp/cmd/add_tool.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,26 @@ func isValidPythonIdentifier(name string) bool {
115115
}
116116

117117
// First character must be letter or underscore
118-
if !((name[0] >= 'a' && name[0] <= 'z') || (name[0] >= 'A' && name[0] <= 'Z') || name[0] == '_') {
119-
return false
118+
firstChar := name[0]
119+
if firstChar < 'a' || firstChar > 'z' {
120+
if firstChar < 'A' || firstChar > 'Z' {
121+
if firstChar != '_' {
122+
return false
123+
}
124+
}
120125
}
121126

122127
// Remaining characters must be letters, digits, or underscores
123128
for i := 1; i < len(name); i++ {
124129
c := name[i]
125-
if !((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_') {
126-
return false
130+
if c < 'a' || c > 'z' {
131+
if c < 'A' || c > 'Z' {
132+
if c < '0' || c > '9' {
133+
if c != '_' {
134+
return false
135+
}
136+
}
137+
}
127138
}
128139
}
129140

cmd/kmcp/cmd/deploy.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,12 @@ func generateMCPServer(projectManifest *manifest.ProjectManifest, deploymentName
197197
// Determine transport type
198198
transportType := v1alpha1.TransportTypeStdio
199199
if deployTransport != "" {
200-
if deployTransport == transportHTTP {
200+
switch deployTransport {
201+
case transportHTTP:
201202
transportType = v1alpha1.TransportTypeHTTP
202-
} else if deployTransport == transportStdio {
203+
case transportStdio:
203204
transportType = v1alpha1.TransportTypeStdio
204-
} else {
205+
default:
205206
return nil, fmt.Errorf("invalid transport type: %s (must be 'stdio' or 'http')", deployTransport)
206207
}
207208
}
@@ -329,13 +330,14 @@ func applyToCluster(yamlContent, deploymentName string) error {
329330
if err != nil {
330331
return fmt.Errorf("failed to create temp file: %w", err)
331332
}
332-
defer os.Remove(tmpFile.Name())
333333

334334
// Write YAML content to temp file
335335
if _, err := tmpFile.Write([]byte(yamlContent)); err != nil {
336336
return fmt.Errorf("failed to write to temp file: %w", err)
337337
}
338-
tmpFile.Close()
338+
if err := tmpFile.Close(); err != nil {
339+
return fmt.Errorf("failed to close temp file: %w", err)
340+
}
339341

340342
// Apply using kubectl
341343
if err := runKubectl("apply", "-f", tmpFile.Name()); err != nil {
@@ -346,6 +348,9 @@ func applyToCluster(yamlContent, deploymentName string) error {
346348
fmt.Printf("💡 Check status with: kubectl get mcpserver %s -n %s\n", deploymentName, deployNamespace)
347349
fmt.Printf("💡 View logs with: kubectl logs -l app.kubernetes.io/name=%s -n %s\n", deploymentName, deployNamespace)
348350

351+
if err := os.Remove(tmpFile.Name()); err != nil {
352+
fmt.Printf("failed to remove temp file: %v\n", err)
353+
}
349354
return nil
350355
}
351356

internal/controller/mcpserver_controller_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package controller
1818

1919
import (
2020
"context"
21+
2122
"github.com/onsi/gomega"
2223

2324
ginkgo "github.com/onsi/ginkgo/v2"

internal/controller/suite_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ package controller
1818

1919
import (
2020
"context"
21-
"github.com/onsi/ginkgo/v2"
22-
"github.com/onsi/gomega"
2321
"os"
2422
"path/filepath"
2523
"testing"
2624

25+
"github.com/onsi/ginkgo/v2"
26+
"github.com/onsi/gomega"
27+
2728
"k8s.io/client-go/kubernetes/scheme"
2829
"k8s.io/client-go/rest"
2930
"sigs.k8s.io/controller-runtime/pkg/client"

pkg/build/build.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ func (b *Builder) buildDockerImage(opts Options, projectType string) error {
140140

141141
// Check if Docker is available
142142
if err := b.checkDockerAvailable(); err != nil {
143-
return fmt.Errorf("Docker not available: %w", err)
143+
return fmt.Errorf("docker not available: %w", err)
144144
}
145145

146146
// Check if Dockerfile exists
147147
dockerfilePath := filepath.Join(opts.ProjectDir, "Dockerfile")
148148
if !b.fileExists(dockerfilePath) {
149-
return fmt.Errorf("Dockerfile not found at %s", dockerfilePath)
149+
return fmt.Errorf("dockerfile not found at %s", dockerfilePath)
150150
}
151151

152152
// Generate image name if not provided
@@ -194,7 +194,7 @@ func (b *Builder) buildDockerImage(opts Options, projectType string) error {
194194
func (b *Builder) checkDockerAvailable() error {
195195
cmd := exec.Command("docker", "version", "--format", "{{.Server.Version}}")
196196
if err := cmd.Run(); err != nil {
197-
return fmt.Errorf("Docker is not available or not running. Please ensure Docker is installed and running")
197+
return fmt.Errorf("docker is not available or not running. Please ensure Docker is installed and running")
198198
}
199199
return nil
200200
}

pkg/tools/generator.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ func (g *Generator) GenerateToolFile(filePath, toolName string, config map[strin
5353
if err != nil {
5454
return fmt.Errorf("failed to create file: %w", err)
5555
}
56-
defer file.Close()
5756

5857
// Execute the template
5958
if err := tmpl.Execute(file, data); err != nil {
@@ -66,6 +65,10 @@ func (g *Generator) GenerateToolFile(filePath, toolName string, config map[strin
6665
return fmt.Errorf("failed to regenerate __init__.py: %w", err)
6766
}
6867

68+
if err := file.Close(); err != nil {
69+
return fmt.Errorf("failed to close file: %w", err)
70+
}
71+
6972
return nil
7073
}
7174

test/e2e/e2e_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ import (
2020
"context"
2121
"encoding/json"
2222
"fmt"
23-
"github.com/onsi/ginkgo/v2"
24-
"github.com/onsi/gomega"
2523
"net/http"
2624
"os"
2725
"os/exec"
2826
"path/filepath"
2927
"strings"
3028
"time"
3129

30+
"github.com/onsi/ginkgo/v2"
31+
"github.com/onsi/gomega"
32+
3233
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3334
"kagent.dev/kmcp/api/v1alpha1"
3435

0 commit comments

Comments
 (0)