Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix(cli): use proper timeouts for specific commands
Kyle Mendell267dd091a631
diff --git a/cli/internal/client/client.go b/cli/internal/client/client.goindex e8c8e0ed4..a6b135a6c 100644--- a/cli/internal/client/client.go+++ b/cli/internal/client/client.go@@ -38,7 +38,7 @@ import (const (headerAPIKey = "X-API-KEY" //nolint:gosec- defaultTimeout = 30 * time.Second+ defaultTimeout = 10 * time.MinutedefaultEnvID = "0")@@ -127,6 +127,11 @@ func (c *Client) SetEnvironment(envID string) {c.envID = envID}+// SetTimeout changes the timeout for subsequent requests.+func (c *Client) SetTimeout(timeout time.Duration) {+ c.httpClient.Timeout = timeout+}+// EnvID returns the current environment ID configured for this client.// The environment ID is used to scope API requests to a specific environment.func (c *Client) EnvID() string {diff --git a/cli/pkg/containers/cmd.go b/cli/pkg/containers/cmd.goindex 98c543cd0..5df0e6962 100644--- a/cli/pkg/containers/cmd.go+++ b/cli/pkg/containers/cmd.go@@ -4,6 +4,7 @@ import ("encoding/json""fmt""strings"+ "time""github.com/getarcaneapp/arcane/cli/internal/client""github.com/getarcaneapp/arcane/cli/internal/output"@@ -256,6 +257,9 @@ var containersUpdateCmd = &cobra.Command{return err}+ // Updating a container can take a long time as it pulls the image+ c.SetTimeout(30 * time.Minute)+path := types.Endpoints.ContainerUpdate(c.EnvID(), args[0])resp, err := c.Post(cmd.Context(), path, nil)if err != nil {diff --git a/cli/pkg/images/cmd.go b/cli/pkg/images/cmd.goindex 8497560bf..e3e3724ad 100644--- a/cli/pkg/images/cmd.go+++ b/cli/pkg/images/cmd.go@@ -334,6 +334,9 @@ var imagesPullCmd = &cobra.Command{return err}+ // Pulling large images can take a long time+ c.SetTimeout(30 * time.Minute)+imageName := args[0]path := types.Endpoints.ImagesPull(c.EnvID())@@ -610,6 +613,9 @@ var imagesUploadCmd = &cobra.Command{return err}+ // Uploading large images can take a long time+ c.SetTimeout(30 * time.Minute)+filePath := args[0]path := types.Endpoints.ImagesUpload(c.EnvID())diff --git a/cli/pkg/projects/cmd.go b/cli/pkg/projects/cmd.goindex 2835888b9..6dcb9e14f 100644--- a/cli/pkg/projects/cmd.go+++ b/cli/pkg/projects/cmd.go@@ -4,6 +4,7 @@ import ("encoding/json""fmt""strings"+ "time""github.com/getarcaneapp/arcane/cli/internal/client""github.com/getarcaneapp/arcane/cli/internal/output"@@ -235,6 +236,9 @@ var redeployCmd = &cobra.Command{return err}+ // Redeploying can take a long time as it pulls images and restarts containers+ c.SetTimeout(30 * time.Minute)+resp, err := c.Post(cmd.Context(), types.Endpoints.ProjectRedeploy(c.EnvID(), args[0]), nil)if err != nil {return fmt.Errorf("failed to redeploy project: %w", err)@@ -257,6 +261,9 @@ var pullCmd = &cobra.Command{return err}+ // Pulling images can take a long time+ c.SetTimeout(30 * time.Minute)+resp, err := c.Post(cmd.Context(), types.Endpoints.ProjectPull(c.EnvID(), args[0]), nil)if err != nil {return fmt.Errorf("failed to pull images: %w", err)diff --git a/cli/pkg/updater/cmd.go b/cli/pkg/updater/cmd.goindex 96886fc01..1bfd280c7 100644--- a/cli/pkg/updater/cmd.go+++ b/cli/pkg/updater/cmd.go@@ -3,6 +3,7 @@ package updaterimport ("encoding/json""fmt"+ "time""github.com/getarcaneapp/arcane/cli/internal/client""github.com/getarcaneapp/arcane/cli/internal/output"@@ -68,6 +69,9 @@ var runCmd = &cobra.Command{return err}+ // Updater run can take a long time as it pulls images and restarts containers+ c.SetTimeout(30 * time.Minute)+resp, err := c.Post(cmd.Context(), types.Endpoints.UpdaterRun(c.EnvID()), nil)if err != nil {return fmt.Errorf("failed to run updater: %w", err)