Skip to content

Commit 792d2f5

Browse files
authored
chore(lint): fix linting issues (#344)
* chore(lint): fix linting issues Signed-off-by: Marc Nuri <[email protected]> * feat(ci): add linting to build and build-all-platforms target Signed-off-by: Marc Nuri <[email protected]> --------- Signed-off-by: Marc Nuri <[email protected]>
1 parent c69e90c commit 792d2f5

File tree

6 files changed

+12
-14
lines changed

6 files changed

+12
-14
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ clean: ## Clean up all build artifacts
4747
rm -rf $(CLEAN_TARGETS)
4848

4949
.PHONY: build
50-
build: clean tidy format ## Build the project
50+
build: clean tidy format lint ## Build the project
5151
go build $(COMMON_BUILD_ARGS) -o $(BINARY_NAME) ./cmd/kubernetes-mcp-server
5252

5353

5454
.PHONY: build-all-platforms
55-
build-all-platforms: clean tidy format ## Build the project for all platforms
55+
build-all-platforms: clean tidy format lint ## Build the project for all platforms
5656
$(foreach os,$(OSES),$(foreach arch,$(ARCHS), \
5757
GOOS=$(os) GOARCH=$(arch) go build $(COMMON_BUILD_ARGS) -o $(BINARY_NAME)-$(os)-$(arch)$(if $(findstring windows,$(os)),.exe,) ./cmd/kubernetes-mcp-server; \
5858
))

pkg/mcp/common_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ func (s *BaseMcpSuite) SetupTest() {
436436

437437
func (s *BaseMcpSuite) TearDownTest() {
438438
if s.McpClient != nil {
439-
s.McpClient.Close()
439+
s.Close()
440440
}
441441
if s.mcpServer != nil {
442442
s.mcpServer.Close()

pkg/mcp/mcp.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ func (c *Configuration) ListOutput() output.Output {
4848
}
4949

5050
func (c *Configuration) isToolApplicable(tool api.ServerTool) bool {
51-
if c.StaticConfig.ReadOnly && !ptr.Deref(tool.Tool.Annotations.ReadOnlyHint, false) {
51+
if c.ReadOnly && !ptr.Deref(tool.Tool.Annotations.ReadOnlyHint, false) {
5252
return false
5353
}
54-
if c.StaticConfig.DisableDestructive && ptr.Deref(tool.Tool.Annotations.DestructiveHint, false) {
54+
if c.DisableDestructive && ptr.Deref(tool.Tool.Annotations.DestructiveHint, false) {
5555
return false
5656
}
57-
if c.StaticConfig.EnabledTools != nil && !slices.Contains(c.StaticConfig.EnabledTools, tool.Tool.Name) {
57+
if c.EnabledTools != nil && !slices.Contains(c.EnabledTools, tool.Tool.Name) {
5858
return false
5959
}
60-
if c.StaticConfig.DisabledTools != nil && slices.Contains(c.StaticConfig.DisabledTools, tool.Tool.Name) {
60+
if c.DisabledTools != nil && slices.Contains(c.DisabledTools, tool.Tool.Name) {
6161
return false
6262
}
6363
return true
@@ -79,7 +79,7 @@ func NewServer(configuration Configuration) (*Server, error) {
7979
server.WithLogging(),
8080
server.WithToolHandlerMiddleware(toolCallLoggingMiddleware),
8181
)
82-
if configuration.StaticConfig.RequireOAuth && false { // TODO: Disabled scope auth validation for now
82+
if configuration.RequireOAuth && false { // TODO: Disabled scope auth validation for now
8383
serverOptions = append(serverOptions, server.WithToolHandlerMiddleware(toolScopedAuthorizationMiddleware))
8484
}
8585

pkg/mcp/toolsets_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (s *ToolsetsSuite) SetupTest() {
2929
s.originalToolsets = toolsets.Toolsets()
3030
s.MockServer = test.NewMockServer()
3131
s.Cfg = configuration.Default()
32-
s.Cfg.KubeConfig = s.MockServer.KubeconfigFile(s.T())
32+
s.Cfg.KubeConfig = s.KubeconfigFile(s.T())
3333
}
3434

3535
func (s *ToolsetsSuite) TearDownTest() {

pkg/toolsets/core/namespaces.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"k8s.io/utils/ptr"
99

1010
"github.com/containers/kubernetes-mcp-server/pkg/api"
11-
"github.com/containers/kubernetes-mcp-server/pkg/kubernetes"
1211
internalk8s "github.com/containers/kubernetes-mcp-server/pkg/kubernetes"
1312
)
1413

@@ -52,15 +51,15 @@ func initNamespaces(o internalk8s.Openshift) []api.ServerTool {
5251
}
5352

5453
func namespacesList(params api.ToolHandlerParams) (*api.ToolCallResult, error) {
55-
ret, err := params.NamespacesList(params, kubernetes.ResourceListOptions{AsTable: params.ListOutput.AsTable()})
54+
ret, err := params.NamespacesList(params, internalk8s.ResourceListOptions{AsTable: params.ListOutput.AsTable()})
5655
if err != nil {
5756
return api.NewToolCallResult("", fmt.Errorf("failed to list namespaces: %v", err)), nil
5857
}
5958
return api.NewToolCallResult(params.ListOutput.PrintObj(ret)), nil
6059
}
6160

6261
func projectsList(params api.ToolHandlerParams) (*api.ToolCallResult, error) {
63-
ret, err := params.ProjectsList(params, kubernetes.ResourceListOptions{AsTable: params.ListOutput.AsTable()})
62+
ret, err := params.ProjectsList(params, internalk8s.ResourceListOptions{AsTable: params.ListOutput.AsTable()})
6463
if err != nil {
6564
return api.NewToolCallResult("", fmt.Errorf("failed to list projects: %v", err)), nil
6665
}

pkg/toolsets/core/resources.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"k8s.io/utils/ptr"
1111

1212
"github.com/containers/kubernetes-mcp-server/pkg/api"
13-
"github.com/containers/kubernetes-mcp-server/pkg/kubernetes"
1413
internalk8s "github.com/containers/kubernetes-mcp-server/pkg/kubernetes"
1514
"github.com/containers/kubernetes-mcp-server/pkg/output"
1615
)
@@ -152,7 +151,7 @@ func resourcesList(params api.ToolHandlerParams) (*api.ToolCallResult, error) {
152151
namespace = ""
153152
}
154153
labelSelector := params.GetArguments()["labelSelector"]
155-
resourceListOptions := kubernetes.ResourceListOptions{
154+
resourceListOptions := internalk8s.ResourceListOptions{
156155
AsTable: params.ListOutput.AsTable(),
157156
}
158157

0 commit comments

Comments
 (0)