mirror of
https://github.com/openshift/openshift-mcp-server.git
synced 2025-10-17 14:27:48 +03:00
chore(lint): fix linting issues (#344)
* chore(lint): fix linting issues Signed-off-by: Marc Nuri <marc@marcnuri.com> * feat(ci): add linting to build and build-all-platforms target Signed-off-by: Marc Nuri <marc@marcnuri.com> --------- Signed-off-by: Marc Nuri <marc@marcnuri.com>
This commit is contained in:
4
Makefile
4
Makefile
@@ -47,12 +47,12 @@ clean: ## Clean up all build artifacts
|
||||
rm -rf $(CLEAN_TARGETS)
|
||||
|
||||
.PHONY: build
|
||||
build: clean tidy format ## Build the project
|
||||
build: clean tidy format lint ## Build the project
|
||||
go build $(COMMON_BUILD_ARGS) -o $(BINARY_NAME) ./cmd/kubernetes-mcp-server
|
||||
|
||||
|
||||
.PHONY: build-all-platforms
|
||||
build-all-platforms: clean tidy format ## Build the project for all platforms
|
||||
build-all-platforms: clean tidy format lint ## Build the project for all platforms
|
||||
$(foreach os,$(OSES),$(foreach arch,$(ARCHS), \
|
||||
GOOS=$(os) GOARCH=$(arch) go build $(COMMON_BUILD_ARGS) -o $(BINARY_NAME)-$(os)-$(arch)$(if $(findstring windows,$(os)),.exe,) ./cmd/kubernetes-mcp-server; \
|
||||
))
|
||||
|
||||
@@ -436,7 +436,7 @@ func (s *BaseMcpSuite) SetupTest() {
|
||||
|
||||
func (s *BaseMcpSuite) TearDownTest() {
|
||||
if s.McpClient != nil {
|
||||
s.McpClient.Close()
|
||||
s.Close()
|
||||
}
|
||||
if s.mcpServer != nil {
|
||||
s.mcpServer.Close()
|
||||
|
||||
@@ -48,16 +48,16 @@ func (c *Configuration) ListOutput() output.Output {
|
||||
}
|
||||
|
||||
func (c *Configuration) isToolApplicable(tool api.ServerTool) bool {
|
||||
if c.StaticConfig.ReadOnly && !ptr.Deref(tool.Tool.Annotations.ReadOnlyHint, false) {
|
||||
if c.ReadOnly && !ptr.Deref(tool.Tool.Annotations.ReadOnlyHint, false) {
|
||||
return false
|
||||
}
|
||||
if c.StaticConfig.DisableDestructive && ptr.Deref(tool.Tool.Annotations.DestructiveHint, false) {
|
||||
if c.DisableDestructive && ptr.Deref(tool.Tool.Annotations.DestructiveHint, false) {
|
||||
return false
|
||||
}
|
||||
if c.StaticConfig.EnabledTools != nil && !slices.Contains(c.StaticConfig.EnabledTools, tool.Tool.Name) {
|
||||
if c.EnabledTools != nil && !slices.Contains(c.EnabledTools, tool.Tool.Name) {
|
||||
return false
|
||||
}
|
||||
if c.StaticConfig.DisabledTools != nil && slices.Contains(c.StaticConfig.DisabledTools, tool.Tool.Name) {
|
||||
if c.DisabledTools != nil && slices.Contains(c.DisabledTools, tool.Tool.Name) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -79,7 +79,7 @@ func NewServer(configuration Configuration) (*Server, error) {
|
||||
server.WithLogging(),
|
||||
server.WithToolHandlerMiddleware(toolCallLoggingMiddleware),
|
||||
)
|
||||
if configuration.StaticConfig.RequireOAuth && false { // TODO: Disabled scope auth validation for now
|
||||
if configuration.RequireOAuth && false { // TODO: Disabled scope auth validation for now
|
||||
serverOptions = append(serverOptions, server.WithToolHandlerMiddleware(toolScopedAuthorizationMiddleware))
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ func (s *ToolsetsSuite) SetupTest() {
|
||||
s.originalToolsets = toolsets.Toolsets()
|
||||
s.MockServer = test.NewMockServer()
|
||||
s.Cfg = configuration.Default()
|
||||
s.Cfg.KubeConfig = s.MockServer.KubeconfigFile(s.T())
|
||||
s.Cfg.KubeConfig = s.KubeconfigFile(s.T())
|
||||
}
|
||||
|
||||
func (s *ToolsetsSuite) TearDownTest() {
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/containers/kubernetes-mcp-server/pkg/api"
|
||||
"github.com/containers/kubernetes-mcp-server/pkg/kubernetes"
|
||||
internalk8s "github.com/containers/kubernetes-mcp-server/pkg/kubernetes"
|
||||
)
|
||||
|
||||
@@ -52,7 +51,7 @@ func initNamespaces(o internalk8s.Openshift) []api.ServerTool {
|
||||
}
|
||||
|
||||
func namespacesList(params api.ToolHandlerParams) (*api.ToolCallResult, error) {
|
||||
ret, err := params.NamespacesList(params, kubernetes.ResourceListOptions{AsTable: params.ListOutput.AsTable()})
|
||||
ret, err := params.NamespacesList(params, internalk8s.ResourceListOptions{AsTable: params.ListOutput.AsTable()})
|
||||
if err != nil {
|
||||
return api.NewToolCallResult("", fmt.Errorf("failed to list namespaces: %v", err)), nil
|
||||
}
|
||||
@@ -60,7 +59,7 @@ func namespacesList(params api.ToolHandlerParams) (*api.ToolCallResult, error) {
|
||||
}
|
||||
|
||||
func projectsList(params api.ToolHandlerParams) (*api.ToolCallResult, error) {
|
||||
ret, err := params.ProjectsList(params, kubernetes.ResourceListOptions{AsTable: params.ListOutput.AsTable()})
|
||||
ret, err := params.ProjectsList(params, internalk8s.ResourceListOptions{AsTable: params.ListOutput.AsTable()})
|
||||
if err != nil {
|
||||
return api.NewToolCallResult("", fmt.Errorf("failed to list projects: %v", err)), nil
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"github.com/containers/kubernetes-mcp-server/pkg/api"
|
||||
"github.com/containers/kubernetes-mcp-server/pkg/kubernetes"
|
||||
internalk8s "github.com/containers/kubernetes-mcp-server/pkg/kubernetes"
|
||||
"github.com/containers/kubernetes-mcp-server/pkg/output"
|
||||
)
|
||||
@@ -152,7 +151,7 @@ func resourcesList(params api.ToolHandlerParams) (*api.ToolCallResult, error) {
|
||||
namespace = ""
|
||||
}
|
||||
labelSelector := params.GetArguments()["labelSelector"]
|
||||
resourceListOptions := kubernetes.ResourceListOptions{
|
||||
resourceListOptions := internalk8s.ResourceListOptions{
|
||||
AsTable: params.ListOutput.AsTable(),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user