Skip to content

enable the servers group #1233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/thv/app/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func NewRootCmd(enableUpdates bool) *cobra.Command {
rootCmd.AddCommand(newSecretCommand())
rootCmd.AddCommand(inspectorCommand())
rootCmd.AddCommand(newMCPCommand())
// rootCmd.AddCommand(groupCmd) // TODO: add back in once we have a working group command, and update the docs
rootCmd.AddCommand(groupCmd)

// Silence printing the usage on error
rootCmd.SilenceUsage = true
Expand Down
5 changes: 3 additions & 2 deletions cmd/thv/app/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/stacklok/toolhive/pkg/config"
"github.com/stacklok/toolhive/pkg/secrets"
"github.com/stacklok/toolhive/pkg/validation"
"github.com/stacklok/toolhive/pkg/workloads"
)

Expand Down Expand Up @@ -147,7 +148,7 @@ func completeLogsArgs(cmd *cobra.Command, args []string, _ string) ([]string, co

// ValidateGroupFlag returns a cobra PreRunE-compatible function
// that validates the --group flag *if provided*.
/*func validateGroupFlag() func(cmd *cobra.Command, args []string) error {
func validateGroupFlag() func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, _ []string) error {
groupName, err := cmd.Flags().GetString("group")
if err != nil {
Expand All @@ -166,4 +167,4 @@ func completeLogsArgs(cmd *cobra.Command, args []string, _ string) ([]string, co

return nil
}
}*/
}
5 changes: 2 additions & 3 deletions cmd/thv/app/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ func init() {
listCmd.Flags().BoolVarP(&listAll, "all", "a", false, "Show all workloads (default shows just running)")
listCmd.Flags().StringVar(&listFormat, "format", FormatText, "Output format (json, text, or mcpservers)")
listCmd.Flags().StringArrayVarP(&listLabelFilter, "label", "l", []string{}, "Filter workloads by labels (format: key=value)")
// TODO: Re-enable when group functionality is complete
// listCmd.Flags().StringVar(&listGroupFilter, "group", "", "Filter workloads by group")
listCmd.Flags().StringVar(&listGroupFilter, "group", "", "Filter workloads by group")

// listCmd.PreRunE = validateGroupFlag()
listCmd.PreRunE = validateGroupFlag()
}

func listCmdFunc(cmd *cobra.Command, _ []string) error {
Expand Down
11 changes: 5 additions & 6 deletions cmd/thv/app/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ var restartCmd = &cobra.Command{

func init() {
restartCmd.Flags().BoolVarP(&restartAll, "all", "a", false, "Restart all MCP servers")
// TODO: Uncomment when groups are fully supported
//restartCmd.Flags().StringVarP(&restartGroup, "group", "g", "", "Restart all MCP servers in a specific group")
//
//// Mark the flags as mutually exclusive
//restartCmd.MarkFlagsMutuallyExclusive("all", "group")
restartCmd.Flags().StringVarP(&restartGroup, "group", "g", "", "Restart all MCP servers in a specific group")

// restartCmd.PreRunE = validateGroupFlag()
// Mark the flags as mutually exclusive
restartCmd.MarkFlagsMutuallyExclusive("all", "group")

restartCmd.PreRunE = validateGroupFlag()
}

func restartCmdFunc(cmd *cobra.Command, args []string) error {
Expand Down
5 changes: 2 additions & 3 deletions cmd/thv/app/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ var rmCmd = &cobra.Command{
}

func init() {
// TODO: Re-enable when group functionality is complete
// rmCmd.Flags().String("group", "", "Delete all workloads in the specified group")
rmCmd.Flags().String("group", "", "Delete all workloads in the specified group")

// rmCmd.PreRunE = validateGroupFlag()
rmCmd.PreRunE = validateGroupFlag()
}

//nolint:gocyclo // This function is complex but manageable
Expand Down
5 changes: 2 additions & 3 deletions cmd/thv/app/run_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ func AddRunFlags(cmd *cobra.Command, config *RunFlags) {
cmd.Flags().StringVar(&config.Transport, "transport", "", "Transport mode (sse, streamable-http or stdio)")
cmd.Flags().StringVar(&config.ProxyMode, "proxy-mode", "sse", "Proxy mode for stdio transport (sse or streamable-http)")
cmd.Flags().StringVar(&config.Name, "name", "", "Name of the MCP server (auto-generated from image if not provided)")
// TODO: Re-enable when group functionality is complete
// cmd.Flags().StringVar(&config.Group, "group", "default",
// "Name of the group this workload belongs to (defaults to 'default' if not specified)")
cmd.Flags().StringVar(&config.Group, "group", "default",
"Name of the group this workload belongs to (defaults to 'default' if not specified)")
cmd.Flags().StringVar(&config.Host, "host", transport.LocalhostIPv4, "Host for the HTTP proxy to listen on (IP or hostname)")
cmd.Flags().IntVar(&config.ProxyPort, "proxy-port", 0, "Port for the HTTP proxy to listen on (host port)")
cmd.Flags().IntVar(&config.TargetPort, "target-port", 0,
Expand Down
4 changes: 2 additions & 2 deletions cmd/thv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/stacklok/toolhive/cmd/thv/app"
"github.com/stacklok/toolhive/pkg/client"
"github.com/stacklok/toolhive/pkg/container/runtime"
"github.com/stacklok/toolhive/pkg/groups"
"github.com/stacklok/toolhive/pkg/logger"
)

Expand All @@ -20,8 +21,7 @@ func main() {

// Check and perform default group migration if needed
// Migrates existing workloads to the default group, only executes once
// TODO: Re-enable when group functionality is complete
// groups.CheckAndPerformDefaultGroupMigration()
groups.CheckAndPerformDefaultGroupMigration()

// Skip update check for completion command or if we are running in kubernetes
if err := app.NewRootCmd(!app.IsCompletionCommand(os.Args) && !runtime.IsKubernetesRuntime()).Execute(); err != nil {
Expand Down
1 change: 1 addition & 0 deletions docs/cli/thv.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions docs/cli/thv_group.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions docs/cli/thv_group_create.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions docs/cli/thv_group_list.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions docs/cli/thv_group_rm.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/cli/thv_list.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions docs/cli/thv_restart.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion docs/cli/thv_rm.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/cli/thv_run.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package e2e_test
package e2e

import (
"testing"
Expand Down
Loading
Loading