mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-05-27 12:52:27 +02:00
refactor: rename service_manager.go and remove unused CommandRunner interface
Rename service_manager.go to commands_service_manager.go to follow the established naming pattern with other command files. Remove the unused CommandRunner interface from commands.go since it's not being used anywhere in the codebase. Clean up unused imports. This improves consistency in file naming and removes dead code.
This commit is contained in:
committed by
Cuong Manh Le
parent
7677c2fbbe
commit
d5281d5df4
@@ -21,6 +21,17 @@ import (
|
|||||||
"github.com/Control-D-Inc/ctrld"
|
"github.com/Control-D-Inc/ctrld"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// filterEmptyStrings removes empty strings from a slice
|
||||||
|
func filterEmptyStrings(slice []string) []string {
|
||||||
|
var result []string
|
||||||
|
for _, s := range slice {
|
||||||
|
if s != "" {
|
||||||
|
result = append(result, s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
// ServiceCommand handles service-related operations
|
// ServiceCommand handles service-related operations
|
||||||
type ServiceCommand struct {
|
type ServiceCommand struct {
|
||||||
serviceManager *ServiceManager
|
serviceManager *ServiceManager
|
||||||
|
|||||||
@@ -5,22 +5,11 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/kardianos/service"
|
"github.com/kardianos/service"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// dialSocketControlServerTimeout is the default timeout to wait when ping control server.
|
// dialSocketControlServerTimeout is the default timeout to wait when ping control server.
|
||||||
const dialSocketControlServerTimeout = 30 * time.Second
|
const dialSocketControlServerTimeout = 30 * time.Second
|
||||||
|
|
||||||
// CommandRunner interface for dependency injection and testing
|
|
||||||
type CommandRunner interface {
|
|
||||||
RunServiceCommand(cmd *cobra.Command, args []string) error
|
|
||||||
RunLogCommand(cmd *cobra.Command, args []string) error
|
|
||||||
RunStatusCommand(cmd *cobra.Command, args []string) error
|
|
||||||
RunUpgradeCommand(cmd *cobra.Command, args []string) error
|
|
||||||
RunClientsCommand(cmd *cobra.Command, args []string) error
|
|
||||||
RunInterfacesCommand(cmd *cobra.Command, args []string) error
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServiceManager handles service operations
|
// ServiceManager handles service operations
|
||||||
type ServiceManager struct {
|
type ServiceManager struct {
|
||||||
prog *prog
|
prog *prog
|
||||||
@@ -50,17 +39,3 @@ func NewServiceManager() (*ServiceManager, error) {
|
|||||||
func (sm *ServiceManager) Status() (service.Status, error) {
|
func (sm *ServiceManager) Status() (service.Status, error) {
|
||||||
return sm.svc.Status()
|
return sm.svc.Status()
|
||||||
}
|
}
|
||||||
|
|
||||||
// initLogCmd is now implemented in commands_log.go as InitLogCmd
|
|
||||||
// initRunCmd is now implemented in commands_run.go as InitRunCmd
|
|
||||||
|
|
||||||
// filterEmptyStrings removes empty strings from a slice
|
|
||||||
func filterEmptyStrings(slice []string) []string {
|
|
||||||
var result []string
|
|
||||||
for _, s := range slice {
|
|
||||||
if s != "" {
|
|
||||||
result = append(result, s)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user