Skip to content
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

Removed unused composeFiles from client.go #275

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
25 changes: 10 additions & 15 deletions rocketpool-cli/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func serviceStatus(c *cli.Context) error {
}

// Print service status
return rp.PrintServiceStatus(getComposeFiles(c))
return rp.PrintServiceStatus()

}

Expand Down Expand Up @@ -447,7 +447,7 @@ func changeNetworks(c *cli.Context, rp *rocketpool.Client, apiContainerName stri

// Stop all of the containers
fmt.Print("Stopping containers... ")
err := rp.PauseService(getComposeFiles(c))
err := rp.PauseService()
if err != nil {
return fmt.Errorf("error stopping service: %w", err)
}
Expand Down Expand Up @@ -482,7 +482,7 @@ func changeNetworks(c *cli.Context, rp *rocketpool.Client, apiContainerName stri

// Terminate the current setup
fmt.Print("Removing old installation... ")
err = rp.StopService(getComposeFiles(c))
err = rp.StopService()
if err != nil {
return fmt.Errorf("error terminating old installation: %w", err)
}
Expand All @@ -497,7 +497,7 @@ func changeNetworks(c *cli.Context, rp *rocketpool.Client, apiContainerName stri

// Start the service
fmt.Print("Starting Rocket Pool... ")
err = rp.StartService(getComposeFiles(c))
err = rp.StartService()
if err != nil {
return fmt.Errorf("error starting service: %w", err)
}
Expand Down Expand Up @@ -655,7 +655,7 @@ func startService(c *cli.Context, ignoreConfigSuggestion bool) error {
}

// Start service
err = rp.StartService(getComposeFiles(c))
err = rp.StartService()
if err != nil {
return err
}
Expand Down Expand Up @@ -1073,7 +1073,7 @@ func pauseService(c *cli.Context) error {
}

// Pause service
return rp.PauseService(getComposeFiles(c))
return rp.PauseService()

}

Expand All @@ -1094,7 +1094,7 @@ func stopService(c *cli.Context) error {
defer rp.Close()

// Stop service
return rp.StopService(getComposeFiles(c))
return rp.StopService()

}

Expand All @@ -1109,7 +1109,7 @@ func serviceLogs(c *cli.Context, serviceNames ...string) error {
defer rp.Close()

// Print service logs
return rp.PrintServiceLogs(getComposeFiles(c), c.String("tail"), serviceNames...)
return rp.PrintServiceLogs(c.String("tail"), serviceNames...)

}

Expand All @@ -1124,7 +1124,7 @@ func serviceStats(c *cli.Context) error {
defer rp.Close()

// Print service stats
return rp.PrintServiceStats(getComposeFiles(c))
return rp.PrintServiceStats()

}

Expand All @@ -1139,7 +1139,7 @@ func serviceCompose(c *cli.Context) error {
defer rp.Close()

// Print service compose config
return rp.PrintServiceCompose(getComposeFiles(c))
return rp.PrintServiceCompose()

}

Expand Down Expand Up @@ -1255,11 +1255,6 @@ func serviceVersion(c *cli.Context) error {

}

// Get the compose file paths for a CLI context
func getComposeFiles(c *cli.Context) []string {
return c.Parent().StringSlice("compose-file")
}

// Destroy and resync the eth1 client from scratch
func resyncEth1(c *cli.Context) error {

Expand Down
32 changes: 16 additions & 16 deletions shared/services/rocketpool/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,10 +608,10 @@ func (c *Client) InstallUpdateTracker(verbose bool, version string) error {
}

// Start the Rocket Pool service
func (c *Client) StartService(composeFiles []string) error {
func (c *Client) StartService() error {

// Start the API container first
cmd, err := c.compose([]string{}, "up -d")
cmd, err := c.compose("up -d")
if err != nil {
return fmt.Errorf("error creating compose command for API container: %w", err)
}
Expand All @@ -621,58 +621,58 @@ func (c *Client) StartService(composeFiles []string) error {
}

// Start all of the containers
cmd, err = c.compose(composeFiles, "up -d --remove-orphans")
cmd, err = c.compose("up -d --remove-orphans")
if err != nil {
return err
}
return c.printOutput(cmd)
}

// Pause the Rocket Pool service
func (c *Client) PauseService(composeFiles []string) error {
cmd, err := c.compose(composeFiles, "stop")
func (c *Client) PauseService() error {
cmd, err := c.compose("stop")
if err != nil {
return err
}
return c.printOutput(cmd)
}

// Stop the Rocket Pool service
func (c *Client) StopService(composeFiles []string) error {
cmd, err := c.compose(composeFiles, "down -v")
func (c *Client) StopService() error {
cmd, err := c.compose("down -v")
if err != nil {
return err
}
return c.printOutput(cmd)
}

// Print the Rocket Pool service status
func (c *Client) PrintServiceStatus(composeFiles []string) error {
cmd, err := c.compose(composeFiles, "ps")
func (c *Client) PrintServiceStatus() error {
cmd, err := c.compose("ps")
if err != nil {
return err
}
return c.printOutput(cmd)
}

// Print the Rocket Pool service logs
func (c *Client) PrintServiceLogs(composeFiles []string, tail string, serviceNames ...string) error {
func (c *Client) PrintServiceLogs(tail string, serviceNames ...string) error {
sanitizedStrings := make([]string, len(serviceNames))
for i, serviceName := range serviceNames {
sanitizedStrings[i] = fmt.Sprintf("%s", shellescape.Quote(serviceName))
}
cmd, err := c.compose(composeFiles, fmt.Sprintf("logs -f --tail %s %s", shellescape.Quote(tail), strings.Join(sanitizedStrings, " ")))
cmd, err := c.compose(fmt.Sprintf("logs -f --tail %s %s", shellescape.Quote(tail), strings.Join(sanitizedStrings, " ")))
if err != nil {
return err
}
return c.printOutput(cmd)
}

// Print the Rocket Pool service stats
func (c *Client) PrintServiceStats(composeFiles []string) error {
func (c *Client) PrintServiceStats() error {

// Get service container IDs
cmd, err := c.compose(composeFiles, "ps -q")
cmd, err := c.compose("ps -q")
if err != nil {
return err
}
Expand All @@ -688,8 +688,8 @@ func (c *Client) PrintServiceStats(composeFiles []string) error {
}

// Print the Rocket Pool service compose config
func (c *Client) PrintServiceCompose(composeFiles []string) error {
cmd, err := c.compose(composeFiles, "config")
func (c *Client) PrintServiceCompose() error {
cmd, err := c.compose("config")
if err != nil {
return err
}
Expand Down Expand Up @@ -1139,7 +1139,7 @@ func convertUintParam(oldParam config.UserParam, newParam *cfgtypes.Parameter, n
}

// Build a docker compose command
func (c *Client) compose(composeFiles []string, args string) (string, error) {
func (c *Client) compose(args string) (string, error) {

// Cancel if running in non-docker mode
if c.daemonPath != "" {
Expand Down