From a16bb72c7aefaaf790844de469039c74946fc760 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 21 Jan 2026 16:45:02 +0100 Subject: [PATCH 01/25] feat: add wake-up command to manage on-demand workspaces and integrate tests --- .github/workflows/integration-test.yml | 2 +- cli/cmd/root.go | 1 + cli/cmd/wakeup.go | 134 +++++++++++++++++++++ cli/cmd/wakeup_test.go | 84 +++++++++++++ int/integration_test.go | 157 +++++++++++++++++++++++++ 5 files changed, 377 insertions(+), 1 deletion(-) create mode 100644 cli/cmd/wakeup.go create mode 100644 cli/cmd/wakeup_test.go diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index f0f2a2e..731d919 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -38,7 +38,7 @@ jobs: run: | echo "Cleaning up any orphaned test workspaces..." # List all workspaces and delete any with test name prefixes - ./cs list workspaces -t $CS_TEAM_ID | grep -E "cli-(test|git-test|pipeline-test|log-test|sync-test|open-test|setenv-test|edge-test)-" | awk '{print $2}' | while read ws_id; do + ./cs list workspaces -t $CS_TEAM_ID | grep -E "cli-(test|git-test|pipeline-test|log-test|sync-test|open-test|setenv-test|edge-test|wakeup-test)-" | awk '{print $2}' | while read ws_id; do if [ ! -z "$ws_id" ]; then echo "Deleting orphaned workspace: $ws_id" ./cs delete workspace -w $ws_id --yes || true diff --git a/cli/cmd/root.go b/cli/cmd/root.go index 71e6d86..47dda2a 100644 --- a/cli/cmd/root.go +++ b/cli/cmd/root.go @@ -92,6 +92,7 @@ func GetRootCmd() *cobra.Command { AddSyncCmd(rootCmd, &opts) AddUpdateCmd(rootCmd) AddGoCmd(rootCmd) + AddWakeUpCmd(rootCmd, opts) return rootCmd } diff --git a/cli/cmd/wakeup.go b/cli/cmd/wakeup.go new file mode 100644 index 0000000..8a445b6 --- /dev/null +++ b/cli/cmd/wakeup.go @@ -0,0 +1,134 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + +package cmd + +import ( + "context" + "crypto/tls" + "fmt" + "net/http" + "time" + + "github.com/codesphere-cloud/cs-go/pkg/io" + "github.com/spf13/cobra" +) + +type WakeUpCmd struct { + cmd *cobra.Command + Opts GlobalOptions + Timeout *time.Duration + Insecure bool +} + +func (c *WakeUpCmd) RunE(_ *cobra.Command, args []string) error { + client, err := NewClient(c.Opts) + if err != nil { + return fmt.Errorf("failed to create Codesphere client: %w", err) + } + + wsId, err := c.Opts.GetWorkspaceId() + if err != nil { + return fmt.Errorf("failed to get workspace ID: %w", err) + } + + token, err := c.Opts.Env.GetApiToken() + if err != nil { + return fmt.Errorf("failed to get API token: %w", err) + } + + return c.WakeUpWorkspace(client, wsId, token) +} + +func AddWakeUpCmd(rootCmd *cobra.Command, opts GlobalOptions) { + wakeup := WakeUpCmd{ + cmd: &cobra.Command{ + Use: "wake-up", + Short: "Wake up an on-demand workspace", + Long: `Wake up an on-demand workspace by making an authenticated request to its services domain.`, + Example: io.FormatExampleCommands("wake-up", []io.Example{ + {Cmd: "-w 1234", Desc: "wake up workspace 1234"}, + {Cmd: "", Desc: "wake up workspace set by environment variable CS_WORKSPACE_ID"}, + {Cmd: "-w 1234 --timeout 60s", Desc: "wake up workspace with 60 second timeout"}, + }), + }, + Opts: opts, + } + wakeup.Timeout = wakeup.cmd.Flags().DurationP("timeout", "", 120*time.Second, "Timeout for waking up the workspace") + wakeup.cmd.Flags().BoolVar(&wakeup.Insecure, "insecure", false, "skip TLS certificate verification (for testing only)") + rootCmd.AddCommand(wakeup.cmd) + wakeup.cmd.RunE = wakeup.RunE +} + +func (c *WakeUpCmd) WakeUpWorkspace(client Client, wsId int, token string) error { + workspace, err := client.GetWorkspace(wsId) + if err != nil { + return fmt.Errorf("failed to get workspace: %w", err) + } + + if workspace.DevDomain == nil { + return fmt.Errorf("workspace %d does not have a development domain configured", wsId) + } + + // Construct the services domain: ${WORKSPACE_ID}-3000.${DEV_DOMAIN} + servicesDomain := fmt.Sprintf("https://%d-3000.%s", wsId, *workspace.DevDomain) + + fmt.Printf("Waking up workspace %d (%s)...\n", wsId, workspace.Name) + timeout := 120 * time.Second + if c.Timeout != nil { + timeout = *c.Timeout + } + + ctx, cancel := context.WithTimeout(context.Background(), timeout) + defer cancel() + + err = makeWakeUpRequest(ctx, servicesDomain, token, c.Insecure) + if err != nil { + if ctx.Err() == context.DeadlineExceeded { + return fmt.Errorf("timeout exceeded while waking up workspace %d", wsId) + } + return fmt.Errorf("failed to wake up workspace: %w", err) + } + + fmt.Printf("Successfully woke up workspace %d\n", wsId) + return nil +} + +func makeWakeUpRequest(ctx context.Context, servicesDomain string, token string, insecure bool) error { + req, err := http.NewRequestWithContext(ctx, "GET", servicesDomain, nil) + if err != nil { + return fmt.Errorf("failed to create request: %w", err) + } + + req.Header.Set("x-forward-security", token) + + transport := &http.Transport{} + if insecure { + transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + } + + client := &http.Client{ + Timeout: 30 * time.Second, + Transport: transport, + CheckRedirect: func(req *http.Request, via []*http.Request) error { + if len(via) >= 10 { + return fmt.Errorf("too many redirects") + } + req.Header.Set("x-forward-security", token) + return nil + }, + } + + resp, err := client.Do(req) + if err != nil { + return fmt.Errorf("failed to make request: %w", err) + } + defer resp.Body.Close() + + // 4xx errors are considered failures + if resp.StatusCode >= 400 && resp.StatusCode < 500 { + return fmt.Errorf("received error response: %s", resp.Status) + } + + return nil +} diff --git a/cli/cmd/wakeup_test.go b/cli/cmd/wakeup_test.go new file mode 100644 index 0000000..130b0d3 --- /dev/null +++ b/cli/cmd/wakeup_test.go @@ -0,0 +1,84 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + +package cmd_test + +import ( + "fmt" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + "github.com/codesphere-cloud/cs-go/api" + "github.com/codesphere-cloud/cs-go/cli/cmd" +) + +var _ = Describe("WakeUp", func() { + var ( + mockEnv *cmd.MockEnv + mockClient *cmd.MockClient + c *cmd.WakeUpCmd + wsId int + teamId int + token string + ) + + JustBeforeEach(func() { + mockClient = cmd.NewMockClient(GinkgoT()) + mockEnv = cmd.NewMockEnv(GinkgoT()) + wsId = 42 + teamId = 21 + token = "test-api-token" + c = &cmd.WakeUpCmd{ + Opts: cmd.GlobalOptions{ + Env: mockEnv, + WorkspaceId: &wsId, + }, + } + }) + + Context("WakeUpWorkspace", func() { + It("should construct the correct services domain and wake up the workspace", func() { + devDomain := "team-slug.codesphere.com" + workspace := api.Workspace{ + Id: wsId, + TeamId: teamId, + Name: "test-workspace", + DevDomain: &devDomain, + } + + mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) + + err := c.WakeUpWorkspace(mockClient, wsId, token) + + // This will fail because we're making a real HTTP request + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("failed to wake up workspace")) + }) + + It("should return error if workspace has no dev domain", func() { + workspace := api.Workspace{ + Id: wsId, + TeamId: teamId, + Name: "test-workspace", + DevDomain: nil, + } + + mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) + + err := c.WakeUpWorkspace(mockClient, wsId, token) + + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("does not have a development domain configured")) + }) + + It("should return error if GetWorkspace fails", func() { + mockClient.EXPECT().GetWorkspace(wsId).Return(api.Workspace{}, fmt.Errorf("api error")) + + err := c.WakeUpWorkspace(mockClient, wsId, token) + + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("failed to get workspace")) + }) + }) +}) diff --git a/int/integration_test.go b/int/integration_test.go index 43ae670..726b277 100644 --- a/int/integration_test.go +++ b/int/integration_test.go @@ -822,6 +822,7 @@ var _ = Describe("Command Error Handling Tests", func() { {"start pipeline", []string{"start", "pipeline", "-w", "99999999"}}, {"git pull", []string{"git", "pull", "-w", "99999999"}}, {"set-env", []string{"set-env", "-w", "99999999", "TEST_VAR=test"}}, + {"wake-up", []string{"wake-up", "-w", "99999999"}}, } for _, tc := range testCases { @@ -975,6 +976,162 @@ var _ = Describe("Git Pull Integration Tests", func() { }) }) +var _ = Describe("Wake Up Workspace Integration Tests", func() { + var ( + teamId string + workspaceName string + workspaceId string + ) + + BeforeEach(func() { + teamId, _ = intutil.SkipIfMissingEnvVars() + workspaceName = fmt.Sprintf("cli-wakeup-test-%d", time.Now().Unix()) + }) + + AfterEach(func() { + if workspaceId != "" { + By(fmt.Sprintf("Cleaning up: deleting workspace %s (ID: %s)", workspaceName, workspaceId)) + intutil.CleanupWorkspace(workspaceId) + workspaceId = "" + } + }) + + Context("Wake Up Command", func() { + BeforeEach(func() { + By("Creating a workspace for wake-up testing") + output := intutil.RunCommand( + "create", "workspace", workspaceName, + "-t", teamId, + "-p", "8", + "--timeout", "15m", + ) + fmt.Printf("Create workspace output: %s\n", output) + + Expect(output).To(ContainSubstring("Workspace created")) + workspaceId = intutil.ExtractWorkspaceId(output) + Expect(workspaceId).NotTo(BeEmpty()) + + By("Waiting for workspace to be fully provisioned") + time.Sleep(5 * time.Second) + }) + + It("should wake up workspace successfully", func() { + By("Waking up the workspace") + output := intutil.RunCommand( + "wake-up", + "-w", workspaceId, + ) + fmt.Printf("Wake up workspace output: %s\n", output) + + Expect(output).To(ContainSubstring("Waking up workspace")) + Expect(output).To(ContainSubstring(workspaceId)) + }) + + It("should respect custom timeout", func() { + By("Waking up workspace with custom timeout") + output, exitCode := intutil.RunCommandWithExitCode( + "wake-up", + "-w", workspaceId, + "--timeout", "5s", + ) + fmt.Printf("Wake up with timeout output: %s (exit code: %d)\n", output, exitCode) + + Expect(output).To(ContainSubstring("Waking up workspace")) + }) + + It("should work with workspace ID from environment variable", func() { + By("Setting CS_WORKSPACE_ID environment variable") + originalWsId := os.Getenv("CS_WORKSPACE_ID") + _ = os.Setenv("CS_WORKSPACE_ID", workspaceId) + defer func() { _ = os.Setenv("CS_WORKSPACE_ID", originalWsId) }() + + By("Waking up workspace using environment variable") + output := intutil.RunCommand("wake-up") + fmt.Printf("Wake up with env var output: %s\n", output) + + Expect(output).To(ContainSubstring("Waking up workspace")) + Expect(output).To(ContainSubstring(workspaceId)) + }) + }) + + Context("Wake Up Error Handling", func() { + It("should fail when workspace ID is missing", func() { + By("Attempting to wake up workspace without ID") + originalWsId := os.Getenv("CS_WORKSPACE_ID") + _ = os.Unsetenv("CS_WORKSPACE_ID") + defer func() { _ = os.Setenv("CS_WORKSPACE_ID", originalWsId) }() + + output, exitCode := intutil.RunCommandWithExitCode("wake-up") + fmt.Printf("Wake up without workspace ID output: %s (exit code: %d)\n", output, exitCode) + + Expect(exitCode).NotTo(Equal(0)) + Expect(output).To(Or( + ContainSubstring("workspace"), + ContainSubstring("required"), + ContainSubstring("not set"), + )) + }) + + It("should fail gracefully with non-existent workspace", func() { + By("Attempting to wake up non-existent workspace") + output, exitCode := intutil.RunCommandWithExitCode( + "wake-up", + "-w", "99999999", + ) + fmt.Printf("Wake up non-existent workspace output: %s (exit code: %d)\n", output, exitCode) + + Expect(exitCode).NotTo(Equal(0)) + Expect(output).To(Or( + ContainSubstring("failed to get workspace"), + ContainSubstring("not found"), + ContainSubstring("404"), + )) + }) + + It("should handle workspace without dev domain gracefully", func() { + By("Creating a workspace (which might not have dev domain configured)") + output := intutil.RunCommand( + "create", "workspace", workspaceName, + "-t", teamId, + "-p", "8", + "--timeout", "15m", + ) + fmt.Printf("Create workspace output: %s\n", output) + + Expect(output).To(ContainSubstring("Workspace created")) + workspaceId = intutil.ExtractWorkspaceId(output) + Expect(workspaceId).NotTo(BeEmpty()) + + By("Attempting to wake up the workspace") + wakeupOutput, wakeupExitCode := intutil.RunCommandWithExitCode( + "wake-up", + "-w", workspaceId, + ) + fmt.Printf("Wake up workspace output: %s (exit code: %d)\n", wakeupOutput, wakeupExitCode) + + if wakeupExitCode != 0 { + Expect(wakeupOutput).To(Or( + ContainSubstring("development domain"), + ContainSubstring("dev domain"), + ContainSubstring("failed to wake up"), + )) + } + }) + }) + + Context("Wake Up Command Help", func() { + It("should display help information", func() { + By("Running wake-up --help") + output := intutil.RunCommand("wake-up", "--help") + fmt.Printf("Wake up help output: %s\n", output) + + Expect(output).To(ContainSubstring("Wake up an on-demand workspace")) + Expect(output).To(ContainSubstring("--timeout")) + Expect(output).To(ContainSubstring("-w, --workspace")) + }) + }) +}) + var _ = Describe("Command Error Handling Tests", func() { It("should fail gracefully with non-existent workspace for all commands", func() { testCases := []struct { From 38522d17824589ff7088abb8b2ffa35393192466 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 21 Jan 2026 15:47:35 +0000 Subject: [PATCH 02/25] chore(docs): Auto-update docs and licenses Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> --- NOTICE | 6 ------ docs/README.md | 1 + docs/cs.md | 1 + docs/cs_wake-up.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 docs/cs_wake-up.md diff --git a/NOTICE b/NOTICE index d0e20ce..b1ae0f8 100644 --- a/NOTICE +++ b/NOTICE @@ -351,12 +351,6 @@ Version: v0.3.3 License: Apache-2.0 License URL: https://github.com/xanzy/ssh-agent/blob/v0.3.3/LICENSE ----------- -Module: github.com/yaml/go-yaml -Version: v2.1.0 -License: Apache-2.0 -License URL: https://github.com/yaml/go-yaml/blob/v2.1.0/LICENSE - ---------- Module: go.yaml.in/yaml/v2 Version: v2.4.3 diff --git a/docs/README.md b/docs/README.md index 550ed80..787e443 100644 --- a/docs/README.md +++ b/docs/README.md @@ -33,4 +33,5 @@ Manage and debug resources deployed in Codesphere via command line. * [cs sync](cs_sync.md) - Sync Codesphere resources * [cs update](cs_update.md) - Update Codesphere CLI * [cs version](cs_version.md) - Print version +* [cs wake-up](cs_wake-up.md) - Wake up an on-demand workspace diff --git a/docs/cs.md b/docs/cs.md index 550ed80..787e443 100644 --- a/docs/cs.md +++ b/docs/cs.md @@ -33,4 +33,5 @@ Manage and debug resources deployed in Codesphere via command line. * [cs sync](cs_sync.md) - Sync Codesphere resources * [cs update](cs_update.md) - Update Codesphere CLI * [cs version](cs_version.md) - Print version +* [cs wake-up](cs_wake-up.md) - Wake up an on-demand workspace diff --git a/docs/cs_wake-up.md b/docs/cs_wake-up.md new file mode 100644 index 0000000..a68ca55 --- /dev/null +++ b/docs/cs_wake-up.md @@ -0,0 +1,46 @@ +## cs wake-up + +Wake up an on-demand workspace + +### Synopsis + +Wake up an on-demand workspace by making an authenticated request to its services domain. + +``` +cs wake-up [flags] +``` + +### Examples + +``` +# wake up workspace 1234 +$ cs wake-up -w 1234 + +# wake up workspace set by environment variable CS_WORKSPACE_ID +$ cs wake-up + +# wake up workspace with 60 second timeout +$ cs wake-up -w 1234 --timeout 60s +``` + +### Options + +``` + -h, --help help for wake-up + --insecure skip TLS certificate verification (for testing only) + --timeout duration Timeout for waking up the workspace (default 2m0s) +``` + +### Options inherited from parent commands + +``` + -a, --api string URL of Codesphere API (can also be CS_API) + -t, --team int Team ID (relevant for some commands, can also be CS_TEAM_ID) (default -1) + -v, --verbose Verbose output + -w, --workspace int Workspace ID (relevant for some commands, can also be CS_WORKSPACE_ID) (default -1) +``` + +### SEE ALSO + +* [cs](cs.md) - The Codesphere CLI + From 3b9e8a20035a82c477c27cff2d85fc8c42018e4d Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 21 Jan 2026 15:48:27 +0000 Subject: [PATCH 03/25] chore(docs): Auto-update docs and licenses Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> --- pkg/tmpl/NOTICE | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pkg/tmpl/NOTICE b/pkg/tmpl/NOTICE index d0e20ce..b1ae0f8 100644 --- a/pkg/tmpl/NOTICE +++ b/pkg/tmpl/NOTICE @@ -351,12 +351,6 @@ Version: v0.3.3 License: Apache-2.0 License URL: https://github.com/xanzy/ssh-agent/blob/v0.3.3/LICENSE ----------- -Module: github.com/yaml/go-yaml -Version: v2.1.0 -License: Apache-2.0 -License URL: https://github.com/yaml/go-yaml/blob/v2.1.0/LICENSE - ---------- Module: go.yaml.in/yaml/v2 Version: v2.4.3 From 2eaf8ce82ad354a276b6f1fdaec920ce47c8af9c Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 21 Jan 2026 16:53:29 +0100 Subject: [PATCH 04/25] fix: logging and lint error --- cli/cmd/wakeup.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cli/cmd/wakeup.go b/cli/cmd/wakeup.go index 8a445b6..9142b02 100644 --- a/cli/cmd/wakeup.go +++ b/cli/cmd/wakeup.go @@ -7,6 +7,7 @@ import ( "context" "crypto/tls" "fmt" + "log" "net/http" "time" @@ -73,7 +74,7 @@ func (c *WakeUpCmd) WakeUpWorkspace(client Client, wsId int, token string) error // Construct the services domain: ${WORKSPACE_ID}-3000.${DEV_DOMAIN} servicesDomain := fmt.Sprintf("https://%d-3000.%s", wsId, *workspace.DevDomain) - fmt.Printf("Waking up workspace %d (%s)...\n", wsId, workspace.Name) + log.Printf("Waking up workspace %d (%s)...\n", wsId, workspace.Name) timeout := 120 * time.Second if c.Timeout != nil { timeout = *c.Timeout @@ -90,7 +91,7 @@ func (c *WakeUpCmd) WakeUpWorkspace(client Client, wsId int, token string) error return fmt.Errorf("failed to wake up workspace: %w", err) } - fmt.Printf("Successfully woke up workspace %d\n", wsId) + log.Printf("Successfully woke up workspace %d\n", wsId) return nil } @@ -123,7 +124,9 @@ func makeWakeUpRequest(ctx context.Context, servicesDomain string, token string, if err != nil { return fmt.Errorf("failed to make request: %w", err) } - defer resp.Body.Close() + defer func() { + _ = resp.Body.Close() + }() // 4xx errors are considered failures if resp.StatusCode >= 400 && resp.StatusCode < 500 { From 34e7c70f8b4dcd6fe69151a7028093bf37cf2169 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 21 Jan 2026 17:26:08 +0100 Subject: [PATCH 05/25] fix: tests --- int/integration_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/int/integration_test.go b/int/integration_test.go index 726b277..2c035ac 100644 --- a/int/integration_test.go +++ b/int/integration_test.go @@ -1020,6 +1020,7 @@ var _ = Describe("Wake Up Workspace Integration Tests", func() { output := intutil.RunCommand( "wake-up", "-w", workspaceId, + "--insecure", ) fmt.Printf("Wake up workspace output: %s\n", output) @@ -1033,6 +1034,7 @@ var _ = Describe("Wake Up Workspace Integration Tests", func() { "wake-up", "-w", workspaceId, "--timeout", "5s", + "--insecure", ) fmt.Printf("Wake up with timeout output: %s (exit code: %d)\n", output, exitCode) @@ -1046,7 +1048,7 @@ var _ = Describe("Wake Up Workspace Integration Tests", func() { defer func() { _ = os.Setenv("CS_WORKSPACE_ID", originalWsId) }() By("Waking up workspace using environment variable") - output := intutil.RunCommand("wake-up") + output := intutil.RunCommand("wake-up", "--insecure") fmt.Printf("Wake up with env var output: %s\n", output) Expect(output).To(ContainSubstring("Waking up workspace")) From 35a0e8f392d78b83693096c84192449160bae590 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 21 Jan 2026 16:27:50 +0000 Subject: [PATCH 06/25] chore(docs): Auto-update docs and licenses Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> --- NOTICE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NOTICE b/NOTICE index b1ae0f8..1a5d05f 100644 --- a/NOTICE +++ b/NOTICE @@ -7,7 +7,7 @@ This project includes code licensed under the following terms: Module: dario.cat/mergo Version: v1.0.2 License: BSD-3-Clause -License URL: https://github.com/imdario/mergo/blob/v1.0.2/LICENSE +License URL: Unknown ---------- Module: github.com/Masterminds/semver/v3 From acc7015c821f8c8f34ae02ce8660a8987bc8516f Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 21 Jan 2026 16:28:50 +0000 Subject: [PATCH 07/25] chore(docs): Auto-update docs and licenses Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> --- NOTICE | 2 +- pkg/tmpl/NOTICE | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NOTICE b/NOTICE index 1a5d05f..b1ae0f8 100644 --- a/NOTICE +++ b/NOTICE @@ -7,7 +7,7 @@ This project includes code licensed under the following terms: Module: dario.cat/mergo Version: v1.0.2 License: BSD-3-Clause -License URL: Unknown +License URL: https://github.com/imdario/mergo/blob/v1.0.2/LICENSE ---------- Module: github.com/Masterminds/semver/v3 diff --git a/pkg/tmpl/NOTICE b/pkg/tmpl/NOTICE index b1ae0f8..1a5d05f 100644 --- a/pkg/tmpl/NOTICE +++ b/pkg/tmpl/NOTICE @@ -7,7 +7,7 @@ This project includes code licensed under the following terms: Module: dario.cat/mergo Version: v1.0.2 License: BSD-3-Clause -License URL: https://github.com/imdario/mergo/blob/v1.0.2/LICENSE +License URL: Unknown ---------- Module: github.com/Masterminds/semver/v3 From e704b923d4bf17cec3a5dfb2406b05dd93c22467 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 21 Jan 2026 16:30:21 +0000 Subject: [PATCH 08/25] chore(docs): Auto-update docs and licenses Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> --- NOTICE | 2 +- pkg/tmpl/NOTICE | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NOTICE b/NOTICE index b1ae0f8..1a5d05f 100644 --- a/NOTICE +++ b/NOTICE @@ -7,7 +7,7 @@ This project includes code licensed under the following terms: Module: dario.cat/mergo Version: v1.0.2 License: BSD-3-Clause -License URL: https://github.com/imdario/mergo/blob/v1.0.2/LICENSE +License URL: Unknown ---------- Module: github.com/Masterminds/semver/v3 diff --git a/pkg/tmpl/NOTICE b/pkg/tmpl/NOTICE index 1a5d05f..b1ae0f8 100644 --- a/pkg/tmpl/NOTICE +++ b/pkg/tmpl/NOTICE @@ -7,7 +7,7 @@ This project includes code licensed under the following terms: Module: dario.cat/mergo Version: v1.0.2 License: BSD-3-Clause -License URL: Unknown +License URL: https://github.com/imdario/mergo/blob/v1.0.2/LICENSE ---------- Module: github.com/Masterminds/semver/v3 From 18bee678b77cb3c25c3599d63830fa8205e0cce0 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 21 Jan 2026 16:31:28 +0000 Subject: [PATCH 09/25] chore(docs): Auto-update docs and licenses Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> --- NOTICE | 2 +- pkg/tmpl/NOTICE | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NOTICE b/NOTICE index 1a5d05f..b1ae0f8 100644 --- a/NOTICE +++ b/NOTICE @@ -7,7 +7,7 @@ This project includes code licensed under the following terms: Module: dario.cat/mergo Version: v1.0.2 License: BSD-3-Clause -License URL: Unknown +License URL: https://github.com/imdario/mergo/blob/v1.0.2/LICENSE ---------- Module: github.com/Masterminds/semver/v3 diff --git a/pkg/tmpl/NOTICE b/pkg/tmpl/NOTICE index b1ae0f8..1a5d05f 100644 --- a/pkg/tmpl/NOTICE +++ b/pkg/tmpl/NOTICE @@ -7,7 +7,7 @@ This project includes code licensed under the following terms: Module: dario.cat/mergo Version: v1.0.2 License: BSD-3-Clause -License URL: https://github.com/imdario/mergo/blob/v1.0.2/LICENSE +License URL: Unknown ---------- Module: github.com/Masterminds/semver/v3 From 7f96b0413cc9045e7c2fce9fc2ff55ad5ae1e118 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 21 Jan 2026 16:32:16 +0000 Subject: [PATCH 10/25] chore(docs): Auto-update docs and licenses Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> --- pkg/tmpl/NOTICE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/tmpl/NOTICE b/pkg/tmpl/NOTICE index 1a5d05f..b1ae0f8 100644 --- a/pkg/tmpl/NOTICE +++ b/pkg/tmpl/NOTICE @@ -7,7 +7,7 @@ This project includes code licensed under the following terms: Module: dario.cat/mergo Version: v1.0.2 License: BSD-3-Clause -License URL: Unknown +License URL: https://github.com/imdario/mergo/blob/v1.0.2/LICENSE ---------- Module: github.com/Masterminds/semver/v3 From 165d31be4d5772c9acc3887e113216b0bcff6227 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Thu, 22 Jan 2026 09:51:50 +0100 Subject: [PATCH 11/25] fix: Improve error handling in WaitForWorkspaceRunning function --- api/workspace.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/workspace.go b/api/workspace.go index ee68c38..338ada9 100644 --- a/api/workspace.go +++ b/api/workspace.go @@ -119,8 +119,12 @@ func (client *Client) WaitForWorkspaceRunning(workspace *Workspace, timeout time status, err := client.WorkspaceStatus(workspace.Id) if err != nil { - // TODO: log error and retry until timeout is reached. - return errors.FormatAPIError(err) + // Retry on error (e.g., 404 if workspace not yet registered) until timeout + if client.time.Now().After(maxWaitTime) { + return errors.FormatAPIError(err) + } + client.time.Sleep(delay) + continue } if status.IsRunning { return nil From 647ec6c99d29c6628712f7b5d581993bd3af1e68 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Thu, 22 Jan 2026 11:24:52 +0100 Subject: [PATCH 12/25] fix: list workspace example --- cli/cmd/list_workspaces.go | 2 +- docs/cs_list_workspaces.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/cmd/list_workspaces.go b/cli/cmd/list_workspaces.go index 679df0a..dfc73b7 100644 --- a/cli/cmd/list_workspaces.go +++ b/cli/cmd/list_workspaces.go @@ -25,7 +25,7 @@ func addListWorkspacesCmd(p *cobra.Command, opts GlobalOptions) { Short: "List workspaces", Long: `List workspaces available in Codesphere`, Example: io.FormatExampleCommands("list workspaces", []io.Example{ - {Cmd: "--team-id ", Desc: "List all workspaces"}, + {Cmd: "-t ", Desc: "List all workspaces"}, }), }, Opts: opts, diff --git a/docs/cs_list_workspaces.md b/docs/cs_list_workspaces.md index b0c8201..3327f01 100644 --- a/docs/cs_list_workspaces.md +++ b/docs/cs_list_workspaces.md @@ -14,7 +14,7 @@ cs list workspaces [flags] ``` # List all workspaces -$ cs list workspaces --team-id +$ cs list workspaces -t ``` ### Options From 99ea55376fada484c3cbf92a6309a69d7cea555a Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Thu, 22 Jan 2026 15:02:02 +0100 Subject: [PATCH 13/25] feat: add curl command --- .github/workflows/integration-test.yml | 2 +- cli/cmd/curl.go | 136 ++++++++++++++++++++ cli/cmd/curl_test.go | 103 ++++++++++++++++ cli/cmd/root.go | 1 + cli/cmd/wakeup.go | 9 +- cli/cmd/workspace_url.go | 21 ++++ cli/cmd/workspace_url_test.go | 67 ++++++++++ int/integration_test.go | 164 +++++++++++++++++++++++++ 8 files changed, 497 insertions(+), 6 deletions(-) create mode 100644 cli/cmd/curl.go create mode 100644 cli/cmd/curl_test.go create mode 100644 cli/cmd/workspace_url.go create mode 100644 cli/cmd/workspace_url_test.go diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 731d919..f23aade 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -38,7 +38,7 @@ jobs: run: | echo "Cleaning up any orphaned test workspaces..." # List all workspaces and delete any with test name prefixes - ./cs list workspaces -t $CS_TEAM_ID | grep -E "cli-(test|git-test|pipeline-test|log-test|sync-test|open-test|setenv-test|edge-test|wakeup-test)-" | awk '{print $2}' | while read ws_id; do + ./cs list workspaces -t $CS_TEAM_ID | grep -E "cli-(test|git-test|pipeline-test|log-test|sync-test|open-test|setenv-test|edge-test|wakeup-test|curl-test)-" | awk '{print $2}' | while read ws_id; do if [ ! -z "$ws_id" ]; then echo "Deleting orphaned workspace: $ws_id" ./cs delete workspace -w $ws_id --yes || true diff --git a/cli/cmd/curl.go b/cli/cmd/curl.go new file mode 100644 index 0000000..4574f0b --- /dev/null +++ b/cli/cmd/curl.go @@ -0,0 +1,136 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + +package cmd + +import ( + "context" + "fmt" + "log" + "os" + "os/exec" + "time" + + "github.com/codesphere-cloud/cs-go/pkg/io" + "github.com/spf13/cobra" +) + +type CurlCmd struct { + cmd *cobra.Command + Opts GlobalOptions + Port *int + Timeout *time.Duration + Insecure bool +} + +func (c *CurlCmd) RunE(_ *cobra.Command, args []string) error { + client, err := NewClient(c.Opts) + if err != nil { + return fmt.Errorf("failed to create Codesphere client: %w", err) + } + + wsId, err := c.Opts.GetWorkspaceId() + if err != nil { + return fmt.Errorf("failed to get workspace ID: %w", err) + } + + token, err := c.Opts.Env.GetApiToken() + if err != nil { + return fmt.Errorf("failed to get API token: %w", err) + } + + if len(args) == 0 { + return fmt.Errorf("path is required (e.g., / or /api/endpoint)") + } + + path := args[0] + curlArgs := args[1:] + + return c.CurlWorkspace(client, wsId, token, path, curlArgs) +} + +func AddCurlCmd(rootCmd *cobra.Command, opts GlobalOptions) { + curl := CurlCmd{ + cmd: &cobra.Command{ + Use: "curl [path] [-- curl-args...]", + Short: "Send authenticated HTTP requests to workspace dev domain", + Long: `Send authenticated HTTP requests to a workspace's development domain using curl-like syntax.`, + Example: io.FormatExampleCommands("curl", []io.Example{ + {Cmd: "/ -w 1234", Desc: "GET request to workspace root"}, + {Cmd: "/api/health -w 1234 -p 3001", Desc: "GET request to port 3001"}, + {Cmd: "/api/data -w 1234 -- -XPOST -d '{\"key\":\"value\"}'", Desc: "POST request with data"}, + {Cmd: "/api/endpoint -w 1234 -- -v", Desc: "verbose output"}, + {Cmd: "/ -- -I", Desc: "HEAD request using workspace from env var"}, + }), + Args: cobra.MinimumNArgs(1), + }, + Opts: opts, + } + curl.Port = curl.cmd.Flags().IntP("port", "p", 3000, "Port to connect to") + curl.Timeout = curl.cmd.Flags().DurationP("timeout", "", 30*time.Second, "Timeout for the request") + curl.cmd.Flags().BoolVar(&curl.Insecure, "insecure", false, "skip TLS certificate verification (for testing only)") + rootCmd.AddCommand(curl.cmd) + curl.cmd.RunE = curl.RunE +} + +func (c *CurlCmd) CurlWorkspace(client Client, wsId int, token string, path string, curlArgs []string) error { + workspace, err := client.GetWorkspace(wsId) + if err != nil { + return fmt.Errorf("failed to get workspace: %w", err) + } + + port := 3000 + if c.Port != nil { + port = *c.Port + } + + url, err := ConstructWorkspaceServiceURL(workspace, port, path) + if err != nil { + return err + } + + log.Printf("Sending request to workspace %d (%s) at %s\n", wsId, workspace.Name, url) + + timeout := 30 * time.Second + if c.Timeout != nil { + timeout = *c.Timeout + } + + ctx, cancel := context.WithTimeout(context.Background(), timeout) + defer cancel() + + // Build curl command + cmdArgs := []string{"curl"} + + // Add authentication header + cmdArgs = append(cmdArgs, "-H", fmt.Sprintf("x-forward-security: %s", token)) + + // Add insecure flag if specified + if c.Insecure { + cmdArgs = append(cmdArgs, "-k") + } + + // Add user's curl arguments + cmdArgs = append(cmdArgs, curlArgs...) + + // Add URL as the last argument + cmdArgs = append(cmdArgs, url) + + // Execute curl command + cmd := exec.CommandContext(ctx, cmdArgs[0], cmdArgs[1:]...) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + err = cmd.Run() + if err != nil { + if ctx.Err() == context.DeadlineExceeded { + return fmt.Errorf("timeout exceeded while requesting workspace %d", wsId) + } + if exitErr, ok := err.(*exec.ExitError); ok { + os.Exit(exitErr.ExitCode()) + } + return fmt.Errorf("failed to execute curl: %w", err) + } + + return nil +} diff --git a/cli/cmd/curl_test.go b/cli/cmd/curl_test.go new file mode 100644 index 0000000..df12130 --- /dev/null +++ b/cli/cmd/curl_test.go @@ -0,0 +1,103 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + +package cmd_test + +import ( + "fmt" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + "github.com/codesphere-cloud/cs-go/api" + "github.com/codesphere-cloud/cs-go/cli/cmd" +) + +var _ = Describe("Curl", func() { + var ( + mockEnv *cmd.MockEnv + mockClient *cmd.MockClient + c *cmd.CurlCmd + wsId int + teamId int + token string + port int + ) + + JustBeforeEach(func() { + mockClient = cmd.NewMockClient(GinkgoT()) + mockEnv = cmd.NewMockEnv(GinkgoT()) + wsId = 42 + teamId = 21 + token = "test-api-token" + port = 3000 + c = &cmd.CurlCmd{ + Opts: cmd.GlobalOptions{ + Env: mockEnv, + WorkspaceId: &wsId, + }, + Port: &port, + } + }) + + Context("CurlWorkspace", func() { + It("should construct the correct URL with default port", func() { + devDomain := "team-slug.codesphere.com" + workspace := api.Workspace{ + Id: wsId, + TeamId: teamId, + Name: "test-workspace", + DevDomain: &devDomain, + } + + mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) + + err := c.CurlWorkspace(mockClient, wsId, token, "/api/health", []string{"-I"}) + + Expect(err).To(HaveOccurred()) + }) + + It("should construct the correct URL with custom port", func() { + customPort := 3001 + c.Port = &customPort + devDomain := "team-slug.codesphere.com" + workspace := api.Workspace{ + Id: wsId, + TeamId: teamId, + Name: "test-workspace", + DevDomain: &devDomain, + } + + mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) + + err := c.CurlWorkspace(mockClient, wsId, token, "/custom/path", []string{}) + + Expect(err).To(HaveOccurred()) + }) + + It("should return error if workspace has no dev domain", func() { + workspace := api.Workspace{ + Id: wsId, + TeamId: teamId, + Name: "test-workspace", + DevDomain: nil, + } + + mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) + + err := c.CurlWorkspace(mockClient, wsId, token, "/", []string{}) + + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("does not have a development domain configured")) + }) + + It("should return error if GetWorkspace fails", func() { + mockClient.EXPECT().GetWorkspace(wsId).Return(api.Workspace{}, fmt.Errorf("api error")) + + err := c.CurlWorkspace(mockClient, wsId, token, "/", []string{}) + + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("failed to get workspace")) + }) + }) +}) diff --git a/cli/cmd/root.go b/cli/cmd/root.go index 47dda2a..64559f7 100644 --- a/cli/cmd/root.go +++ b/cli/cmd/root.go @@ -93,6 +93,7 @@ func GetRootCmd() *cobra.Command { AddUpdateCmd(rootCmd) AddGoCmd(rootCmd) AddWakeUpCmd(rootCmd, opts) + AddCurlCmd(rootCmd, opts) return rootCmd } diff --git a/cli/cmd/wakeup.go b/cli/cmd/wakeup.go index 9142b02..cd91e23 100644 --- a/cli/cmd/wakeup.go +++ b/cli/cmd/wakeup.go @@ -67,12 +67,11 @@ func (c *WakeUpCmd) WakeUpWorkspace(client Client, wsId int, token string) error return fmt.Errorf("failed to get workspace: %w", err) } - if workspace.DevDomain == nil { - return fmt.Errorf("workspace %d does not have a development domain configured", wsId) - } - // Construct the services domain: ${WORKSPACE_ID}-3000.${DEV_DOMAIN} - servicesDomain := fmt.Sprintf("https://%d-3000.%s", wsId, *workspace.DevDomain) + servicesDomain, err := ConstructWorkspaceServiceURL(workspace, 3000, "") + if err != nil { + return err + } log.Printf("Waking up workspace %d (%s)...\n", wsId, workspace.Name) timeout := 120 * time.Second diff --git a/cli/cmd/workspace_url.go b/cli/cmd/workspace_url.go new file mode 100644 index 0000000..bf57c8a --- /dev/null +++ b/cli/cmd/workspace_url.go @@ -0,0 +1,21 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + +package cmd + +import ( + "fmt" + + "github.com/codesphere-cloud/cs-go/api" +) + +// ConstructWorkspaceServiceURL constructs a URL for accessing a workspace service +// Format: https://${WORKSPACE_ID}-${PORT}.${DEV_DOMAIN}${PATH} +func ConstructWorkspaceServiceURL(workspace api.Workspace, port int, path string) (string, error) { + if workspace.DevDomain == nil { + return "", fmt.Errorf("workspace %d does not have a development domain configured", workspace.Id) + } + + url := fmt.Sprintf("https://%d-%d.%s%s", workspace.Id, port, *workspace.DevDomain, path) + return url, nil +} diff --git a/cli/cmd/workspace_url_test.go b/cli/cmd/workspace_url_test.go new file mode 100644 index 0000000..3d6642b --- /dev/null +++ b/cli/cmd/workspace_url_test.go @@ -0,0 +1,67 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + +package cmd_test + +import ( + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + "github.com/codesphere-cloud/cs-go/api" + "github.com/codesphere-cloud/cs-go/cli/cmd" +) + +var _ = Describe("WorkspaceURL", func() { + Context("ConstructWorkspaceServiceURL", func() { + It("should construct URL correctly with all parameters", func() { + devDomain := "team-slug.codesphere.com" + workspace := api.Workspace{ + Id: 1234, + DevDomain: &devDomain, + } + + url, err := cmd.ConstructWorkspaceServiceURL(workspace, 3000, "/api/health") + + Expect(err).NotTo(HaveOccurred()) + Expect(url).To(Equal("https://1234-3000.team-slug.codesphere.com/api/health")) + }) + + It("should construct URL correctly with root path", func() { + devDomain := "team-slug.codesphere.com" + workspace := api.Workspace{ + Id: 5678, + DevDomain: &devDomain, + } + + url, err := cmd.ConstructWorkspaceServiceURL(workspace, 8080, "/") + + Expect(err).NotTo(HaveOccurred()) + Expect(url).To(Equal("https://5678-8080.team-slug.codesphere.com/")) + }) + + It("should construct URL correctly with empty path", func() { + devDomain := "dev.example.com" + workspace := api.Workspace{ + Id: 999, + DevDomain: &devDomain, + } + + url, err := cmd.ConstructWorkspaceServiceURL(workspace, 3001, "") + + Expect(err).NotTo(HaveOccurred()) + Expect(url).To(Equal("https://999-3001.dev.example.com")) + }) + + It("should return error when dev domain is nil", func() { + workspace := api.Workspace{ + Id: 1234, + DevDomain: nil, + } + + _, err := cmd.ConstructWorkspaceServiceURL(workspace, 3000, "/") + + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("does not have a development domain configured")) + }) + }) +}) diff --git a/int/integration_test.go b/int/integration_test.go index 2c035ac..9f1c4ac 100644 --- a/int/integration_test.go +++ b/int/integration_test.go @@ -823,6 +823,7 @@ var _ = Describe("Command Error Handling Tests", func() { {"git pull", []string{"git", "pull", "-w", "99999999"}}, {"set-env", []string{"set-env", "-w", "99999999", "TEST_VAR=test"}}, {"wake-up", []string{"wake-up", "-w", "99999999"}}, + {"curl", []string{"curl", "/", "-w", "99999999"}}, } for _, tc := range testCases { @@ -1134,6 +1135,169 @@ var _ = Describe("Wake Up Workspace Integration Tests", func() { }) }) +var _ = Describe("Curl Workspace Integration Tests", func() { + var ( + teamId string + workspaceName string + workspaceId string + ) + + BeforeEach(func() { + teamId, _ = intutil.SkipIfMissingEnvVars() + workspaceName = fmt.Sprintf("cli-curl-test-%d", time.Now().Unix()) + }) + + AfterEach(func() { + if workspaceId != "" { + By(fmt.Sprintf("Cleaning up: deleting workspace %s (ID: %s)", workspaceName, workspaceId)) + intutil.CleanupWorkspace(workspaceId) + workspaceId = "" + } + }) + + Context("Curl Command", func() { + BeforeEach(func() { + By("Creating a workspace for curl testing") + output := intutil.RunCommand( + "create", "workspace", workspaceName, + "-t", teamId, + "-p", "8", + "--timeout", "15m", + ) + fmt.Printf("Create workspace output: %s\n", output) + + Expect(output).To(ContainSubstring("Workspace created")) + workspaceId = intutil.ExtractWorkspaceId(output) + Expect(workspaceId).NotTo(BeEmpty()) + + By("Waiting for workspace to be fully provisioned") + time.Sleep(5 * time.Second) + }) + + It("should send authenticated request to workspace", func() { + By("Sending curl request to workspace root") + output := intutil.RunCommand( + "curl", "/", + "-w", workspaceId, + "--insecure", + "--", "-s", "-o", "/dev/null", "-w", "%{http_code}", + ) + fmt.Printf("Curl workspace output: %s\n", output) + + Expect(output).To(ContainSubstring("Sending request to workspace")) + Expect(output).To(ContainSubstring(workspaceId)) + }) + + It("should support custom port", func() { + By("Sending curl request to custom port") + output, exitCode := intutil.RunCommandWithExitCode( + "curl", "/", + "-w", workspaceId, + "-p", "3001", + "--insecure", + "--", "-s", "-o", "/dev/null", "-w", "%{http_code}", + ) + fmt.Printf("Curl with custom port output: %s (exit code: %d)\n", output, exitCode) + + Expect(output).To(ContainSubstring("Sending request to workspace")) + }) + + It("should pass through curl arguments", func() { + By("Sending HEAD request using curl -I flag") + output := intutil.RunCommand( + "curl", "/", + "-w", workspaceId, + "--insecure", + "--", "-I", + ) + fmt.Printf("Curl with -I flag output: %s\n", output) + + Expect(output).To(ContainSubstring("Sending request to workspace")) + }) + + It("should work with workspace ID from environment variable", func() { + By("Setting CS_WORKSPACE_ID environment variable") + originalWsId := os.Getenv("CS_WORKSPACE_ID") + _ = os.Setenv("CS_WORKSPACE_ID", workspaceId) + defer func() { _ = os.Setenv("CS_WORKSPACE_ID", originalWsId) }() + + By("Sending curl request using environment variable") + output := intutil.RunCommand( + "curl", "/", + "--insecure", + "--", "-s", "-o", "/dev/null", "-w", "%{http_code}", + ) + fmt.Printf("Curl with env var output: %s\n", output) + + Expect(output).To(ContainSubstring("Sending request to workspace")) + Expect(output).To(ContainSubstring(workspaceId)) + }) + }) + + Context("Curl Error Handling", func() { + It("should fail when workspace ID is missing", func() { + By("Attempting to curl without workspace ID") + originalWsId := os.Getenv("CS_WORKSPACE_ID") + _ = os.Unsetenv("CS_WORKSPACE_ID") + defer func() { _ = os.Setenv("CS_WORKSPACE_ID", originalWsId) }() + + output, exitCode := intutil.RunCommandWithExitCode("curl", "/") + fmt.Printf("Curl without workspace ID output: %s (exit code: %d)\n", output, exitCode) + + Expect(exitCode).NotTo(Equal(0)) + Expect(output).To(Or( + ContainSubstring("workspace"), + ContainSubstring("required"), + ContainSubstring("not set"), + )) + }) + + It("should fail gracefully with non-existent workspace", func() { + By("Attempting to curl non-existent workspace") + output, exitCode := intutil.RunCommandWithExitCode( + "curl", "/", + "-w", "99999999", + ) + fmt.Printf("Curl non-existent workspace output: %s (exit code: %d)\n", output, exitCode) + + Expect(exitCode).NotTo(Equal(0)) + Expect(output).To(Or( + ContainSubstring("failed to get workspace"), + ContainSubstring("not found"), + ContainSubstring("404"), + )) + }) + + It("should require path argument", func() { + By("Attempting to curl without path") + output, exitCode := intutil.RunCommandWithExitCode( + "curl", + "-w", "1234", + ) + fmt.Printf("Curl without path output: %s (exit code: %d)\n", output, exitCode) + + Expect(exitCode).NotTo(Equal(0)) + Expect(output).To(Or( + ContainSubstring("path"), + ContainSubstring("required"), + ContainSubstring("argument"), + )) + }) + }) + + Context("Curl Command Help", func() { + It("should display help information", func() { + By("Running curl --help") + output := intutil.RunCommand("curl", "--help") + fmt.Printf("Curl help output: %s\n", output) + + Expect(output).To(ContainSubstring("Send authenticated HTTP requests")) + Expect(output).To(ContainSubstring("--port")) + Expect(output).To(ContainSubstring("-w, --workspace")) + }) + }) +}) + var _ = Describe("Command Error Handling Tests", func() { It("should fail gracefully with non-existent workspace for all commands", func() { testCases := []struct { From b06abdaac60b320644dca820ea1f6cca16241fc9 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Thu, 22 Jan 2026 14:02:48 +0000 Subject: [PATCH 14/25] chore(docs): Auto-update docs and licenses Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> --- docs/README.md | 1 + docs/cs.md | 1 + docs/cs_curl.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 docs/cs_curl.md diff --git a/docs/README.md b/docs/README.md index 787e443..890b480 100644 --- a/docs/README.md +++ b/docs/README.md @@ -19,6 +19,7 @@ Manage and debug resources deployed in Codesphere via command line. ### SEE ALSO * [cs create](cs_create.md) - Create codesphere resource +* [cs curl](cs_curl.md) - Send authenticated HTTP requests to workspace dev domain * [cs delete](cs_delete.md) - Delete Codesphere resources * [cs exec](cs_exec.md) - Run a command in Codesphere workspace * [cs generate](cs_generate.md) - Generate codesphere artifacts diff --git a/docs/cs.md b/docs/cs.md index 787e443..890b480 100644 --- a/docs/cs.md +++ b/docs/cs.md @@ -19,6 +19,7 @@ Manage and debug resources deployed in Codesphere via command line. ### SEE ALSO * [cs create](cs_create.md) - Create codesphere resource +* [cs curl](cs_curl.md) - Send authenticated HTTP requests to workspace dev domain * [cs delete](cs_delete.md) - Delete Codesphere resources * [cs exec](cs_exec.md) - Run a command in Codesphere workspace * [cs generate](cs_generate.md) - Generate codesphere artifacts diff --git a/docs/cs_curl.md b/docs/cs_curl.md new file mode 100644 index 0000000..4ace46e --- /dev/null +++ b/docs/cs_curl.md @@ -0,0 +1,53 @@ +## cs curl + +Send authenticated HTTP requests to workspace dev domain + +### Synopsis + +Send authenticated HTTP requests to a workspace's development domain using curl-like syntax. + +``` +cs curl [path] [-- curl-args...] [flags] +``` + +### Examples + +``` +# GET request to workspace root +$ cs curl / -w 1234 + +# GET request to port 3001 +$ cs curl /api/health -w 1234 -p 3001 + +# POST request with data +$ cs curl /api/data -w 1234 -- -XPOST -d '{"key":"value"}' + +# verbose output +$ cs curl /api/endpoint -w 1234 -- -v + +# HEAD request using workspace from env var +$ cs curl / -- -I +``` + +### Options + +``` + -h, --help help for curl + --insecure skip TLS certificate verification (for testing only) + -p, --port int Port to connect to (default 3000) + --timeout duration Timeout for the request (default 30s) +``` + +### Options inherited from parent commands + +``` + -a, --api string URL of Codesphere API (can also be CS_API) + -t, --team int Team ID (relevant for some commands, can also be CS_TEAM_ID) (default -1) + -v, --verbose Verbose output + -w, --workspace int Workspace ID (relevant for some commands, can also be CS_WORKSPACE_ID) (default -1) +``` + +### SEE ALSO + +* [cs](cs.md) - The Codesphere CLI + From 51b37b597eb3480e8255440a2304e46f6b631f13 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Mon, 26 Jan 2026 15:34:54 +0100 Subject: [PATCH 15/25] fix: enhance URL construction by stripping workspace-port prefix from devDomain --- cli/cmd/workspace_url.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/cli/cmd/workspace_url.go b/cli/cmd/workspace_url.go index bf57c8a..6d6b6d5 100644 --- a/cli/cmd/workspace_url.go +++ b/cli/cmd/workspace_url.go @@ -5,6 +5,8 @@ package cmd import ( "fmt" + "strconv" + "strings" "github.com/codesphere-cloud/cs-go/api" ) @@ -16,6 +18,22 @@ func ConstructWorkspaceServiceURL(workspace api.Workspace, port int, path string return "", fmt.Errorf("workspace %d does not have a development domain configured", workspace.Id) } - url := fmt.Sprintf("https://%d-%d.%s%s", workspace.Id, port, *workspace.DevDomain, path) + devDomain := *workspace.DevDomain + + // extract just the base domain (e.g., "dev.codesphere.com") + if strings.Contains(devDomain, ".") { + parts := strings.SplitN(devDomain, ".", 2) + if len(parts) == 2 { + // Check if the first part starts with workspace ID followed by a hyphen + prefix := parts[0] + wsIdStr := strconv.Itoa(workspace.Id) + if strings.HasPrefix(prefix, wsIdStr+"-") { + // Strip the workspace-port prefix and use the base domain + devDomain = parts[1] + } + } + } + + url := fmt.Sprintf("https://%d-%d.%s%s", workspace.Id, port, devDomain, path) return url, nil } From 5e41b59e58ff049f1edea1b8dd3bb90db7536bf5 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 28 Jan 2026 11:32:56 +0100 Subject: [PATCH 16/25] feat: enhance workspace management by adding team retrieval and service URL construction --- cli/cmd/client.go | 4 + cli/cmd/curl.go | 17 ++-- cli/cmd/curl_test.go | 40 +++++--- cli/cmd/mocks.go | 182 ++++++++++++++++++++++++++++++++++ cli/cmd/wakeup.go | 30 ++++-- cli/cmd/wakeup_test.go | 26 +++-- cli/cmd/workspace_url.go | 39 -------- cli/cmd/workspace_url_test.go | 67 ------------- int/integration_test.go | 21 +++- 9 files changed, 271 insertions(+), 155 deletions(-) delete mode 100644 cli/cmd/workspace_url.go delete mode 100644 cli/cmd/workspace_url_test.go diff --git a/cli/cmd/client.go b/cli/cmd/client.go index 88b4b2b..52a1f26 100644 --- a/cli/cmd/client.go +++ b/cli/cmd/client.go @@ -9,15 +9,19 @@ import ( "context" "fmt" "net/url" + "time" "github.com/codesphere-cloud/cs-go/api" ) type Client interface { ListTeams() ([]api.Team, error) + GetTeam(teamId int) (*api.Team, error) ListWorkspaces(teamId int) ([]api.Workspace, error) ListBaseimages() ([]api.Baseimage, error) GetWorkspace(workspaceId int) (api.Workspace, error) + WorkspaceStatus(workspaceId int) (*api.WorkspaceStatus, error) + WaitForWorkspaceRunning(workspace *api.Workspace, timeout time.Duration) error SetEnvVarOnWorkspace(workspaceId int, vars map[string]string) error ExecCommand(workspaceId int, command string, workdir string, env map[string]string) (string, string, error) ListWorkspacePlans() ([]api.WorkspacePlan, error) diff --git a/cli/cmd/curl.go b/cli/cmd/curl.go index 4574f0b..c7011af 100644 --- a/cli/cmd/curl.go +++ b/cli/cmd/curl.go @@ -79,15 +79,19 @@ func (c *CurlCmd) CurlWorkspace(client Client, wsId int, token string, path stri return fmt.Errorf("failed to get workspace: %w", err) } + // Get team to obtain datacenter ID + team, err := client.GetTeam(workspace.TeamId) + if err != nil { + return fmt.Errorf("failed to get team: %w", err) + } + port := 3000 if c.Port != nil { port = *c.Port } - url, err := ConstructWorkspaceServiceURL(workspace, port, path) - if err != nil { - return err - } + // Construct URL using datacenter format: ${WORKSPACE_ID}-${PORT}.${DATACENTER_ID}.codesphere.com + url := fmt.Sprintf("https://%d-%d.%d.codesphere.com%s", wsId, port, team.DefaultDataCenterId, path) log.Printf("Sending request to workspace %d (%s) at %s\n", wsId, workspace.Name, url) @@ -126,10 +130,7 @@ func (c *CurlCmd) CurlWorkspace(client Client, wsId int, token string, path stri if ctx.Err() == context.DeadlineExceeded { return fmt.Errorf("timeout exceeded while requesting workspace %d", wsId) } - if exitErr, ok := err.(*exec.ExitError); ok { - os.Exit(exitErr.ExitCode()) - } - return fmt.Errorf("failed to execute curl: %w", err) + return fmt.Errorf("curl command failed: %w", err) } return nil diff --git a/cli/cmd/curl_test.go b/cli/cmd/curl_test.go index df12130..9810570 100644 --- a/cli/cmd/curl_test.go +++ b/cli/cmd/curl_test.go @@ -42,15 +42,19 @@ var _ = Describe("Curl", func() { Context("CurlWorkspace", func() { It("should construct the correct URL with default port", func() { - devDomain := "team-slug.codesphere.com" workspace := api.Workspace{ - Id: wsId, - TeamId: teamId, - Name: "test-workspace", - DevDomain: &devDomain, + Id: wsId, + TeamId: teamId, + Name: "test-workspace", + } + team := api.Team{ + Id: teamId, + DefaultDataCenterId: 5, + Name: "test-team", } mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) + mockClient.EXPECT().GetTeam(teamId).Return(&team, nil) err := c.CurlWorkspace(mockClient, wsId, token, "/api/health", []string{"-I"}) @@ -60,35 +64,39 @@ var _ = Describe("Curl", func() { It("should construct the correct URL with custom port", func() { customPort := 3001 c.Port = &customPort - devDomain := "team-slug.codesphere.com" workspace := api.Workspace{ - Id: wsId, - TeamId: teamId, - Name: "test-workspace", - DevDomain: &devDomain, + Id: wsId, + TeamId: teamId, + Name: "test-workspace", + } + team := api.Team{ + Id: teamId, + DefaultDataCenterId: 5, + Name: "test-team", } mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) + mockClient.EXPECT().GetTeam(teamId).Return(&team, nil) err := c.CurlWorkspace(mockClient, wsId, token, "/custom/path", []string{}) Expect(err).To(HaveOccurred()) }) - It("should return error if workspace has no dev domain", func() { + It("should return error if GetTeam fails", func() { workspace := api.Workspace{ - Id: wsId, - TeamId: teamId, - Name: "test-workspace", - DevDomain: nil, + Id: wsId, + TeamId: teamId, + Name: "test-workspace", } mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) + mockClient.EXPECT().GetTeam(teamId).Return(nil, fmt.Errorf("team not found")) err := c.CurlWorkspace(mockClient, wsId, token, "/", []string{}) Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("does not have a development domain configured")) + Expect(err.Error()).To(ContainSubstring("failed to get team")) }) It("should return error if GetWorkspace fails", func() { diff --git a/cli/cmd/mocks.go b/cli/cmd/mocks.go index f9d274f..a8c318d 100644 --- a/cli/cmd/mocks.go +++ b/cli/cmd/mocks.go @@ -7,6 +7,7 @@ package cmd import ( "github.com/codesphere-cloud/cs-go/api" mock "github.com/stretchr/testify/mock" + "time" ) // NewMockClient creates a new instance of MockClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. @@ -358,6 +359,68 @@ func (_c *MockClient_GetPipelineState_Call) RunAndReturn(run func(wsId int, stag return _c } +// GetTeam provides a mock function for the type MockClient +func (_mock *MockClient) GetTeam(teamId int) (*api.Team, error) { + ret := _mock.Called(teamId) + + if len(ret) == 0 { + panic("no return value specified for GetTeam") + } + + var r0 *api.Team + var r1 error + if returnFunc, ok := ret.Get(0).(func(int) (*api.Team, error)); ok { + return returnFunc(teamId) + } + if returnFunc, ok := ret.Get(0).(func(int) *api.Team); ok { + r0 = returnFunc(teamId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*api.Team) + } + } + if returnFunc, ok := ret.Get(1).(func(int) error); ok { + r1 = returnFunc(teamId) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockClient_GetTeam_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTeam' +type MockClient_GetTeam_Call struct { + *mock.Call +} + +// GetTeam is a helper method to define mock.On call +// - teamId int +func (_e *MockClient_Expecter) GetTeam(teamId interface{}) *MockClient_GetTeam_Call { + return &MockClient_GetTeam_Call{Call: _e.mock.On("GetTeam", teamId)} +} + +func (_c *MockClient_GetTeam_Call) Run(run func(teamId int)) *MockClient_GetTeam_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + run( + arg0, + ) + }) + return _c +} + +func (_c *MockClient_GetTeam_Call) Return(v *api.Team, err error) *MockClient_GetTeam_Call { + _c.Call.Return(v, err) + return _c +} + +func (_c *MockClient_GetTeam_Call) RunAndReturn(run func(teamId int) (*api.Team, error)) *MockClient_GetTeam_Call { + _c.Call.Return(run) + return _c +} + // GetWorkspace provides a mock function for the type MockClient func (_mock *MockClient) GetWorkspace(workspaceId int) (api.Workspace, error) { ret := _mock.Called(workspaceId) @@ -828,6 +891,125 @@ func (_c *MockClient_StartPipelineStage_Call) RunAndReturn(run func(wsId int, pr return _c } +// WaitForWorkspaceRunning provides a mock function for the type MockClient +func (_mock *MockClient) WaitForWorkspaceRunning(workspace *api.Workspace, timeout time.Duration) error { + ret := _mock.Called(workspace, timeout) + + if len(ret) == 0 { + panic("no return value specified for WaitForWorkspaceRunning") + } + + var r0 error + if returnFunc, ok := ret.Get(0).(func(*api.Workspace, time.Duration) error); ok { + r0 = returnFunc(workspace, timeout) + } else { + r0 = ret.Error(0) + } + return r0 +} + +// MockClient_WaitForWorkspaceRunning_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WaitForWorkspaceRunning' +type MockClient_WaitForWorkspaceRunning_Call struct { + *mock.Call +} + +// WaitForWorkspaceRunning is a helper method to define mock.On call +// - workspace *api.Workspace +// - timeout time.Duration +func (_e *MockClient_Expecter) WaitForWorkspaceRunning(workspace interface{}, timeout interface{}) *MockClient_WaitForWorkspaceRunning_Call { + return &MockClient_WaitForWorkspaceRunning_Call{Call: _e.mock.On("WaitForWorkspaceRunning", workspace, timeout)} +} + +func (_c *MockClient_WaitForWorkspaceRunning_Call) Run(run func(workspace *api.Workspace, timeout time.Duration)) *MockClient_WaitForWorkspaceRunning_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 *api.Workspace + if args[0] != nil { + arg0 = args[0].(*api.Workspace) + } + var arg1 time.Duration + if args[1] != nil { + arg1 = args[1].(time.Duration) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockClient_WaitForWorkspaceRunning_Call) Return(err error) *MockClient_WaitForWorkspaceRunning_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockClient_WaitForWorkspaceRunning_Call) RunAndReturn(run func(workspace *api.Workspace, timeout time.Duration) error) *MockClient_WaitForWorkspaceRunning_Call { + _c.Call.Return(run) + return _c +} + +// WorkspaceStatus provides a mock function for the type MockClient +func (_mock *MockClient) WorkspaceStatus(workspaceId int) (*api.WorkspaceStatus, error) { + ret := _mock.Called(workspaceId) + + if len(ret) == 0 { + panic("no return value specified for WorkspaceStatus") + } + + var r0 *api.WorkspaceStatus + var r1 error + if returnFunc, ok := ret.Get(0).(func(int) (*api.WorkspaceStatus, error)); ok { + return returnFunc(workspaceId) + } + if returnFunc, ok := ret.Get(0).(func(int) *api.WorkspaceStatus); ok { + r0 = returnFunc(workspaceId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*api.WorkspaceStatus) + } + } + if returnFunc, ok := ret.Get(1).(func(int) error); ok { + r1 = returnFunc(workspaceId) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockClient_WorkspaceStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WorkspaceStatus' +type MockClient_WorkspaceStatus_Call struct { + *mock.Call +} + +// WorkspaceStatus is a helper method to define mock.On call +// - workspaceId int +func (_e *MockClient_Expecter) WorkspaceStatus(workspaceId interface{}) *MockClient_WorkspaceStatus_Call { + return &MockClient_WorkspaceStatus_Call{Call: _e.mock.On("WorkspaceStatus", workspaceId)} +} + +func (_c *MockClient_WorkspaceStatus_Call) Run(run func(workspaceId int)) *MockClient_WorkspaceStatus_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + run( + arg0, + ) + }) + return _c +} + +func (_c *MockClient_WorkspaceStatus_Call) Return(v *api.WorkspaceStatus, err error) *MockClient_WorkspaceStatus_Call { + _c.Call.Return(v, err) + return _c +} + +func (_c *MockClient_WorkspaceStatus_Call) RunAndReturn(run func(workspaceId int) (*api.WorkspaceStatus, error)) *MockClient_WorkspaceStatus_Call { + _c.Call.Return(run) + return _c +} + // NewMockPrompt creates a new instance of MockPrompt. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewMockPrompt(t interface { diff --git a/cli/cmd/wakeup.go b/cli/cmd/wakeup.go index cd91e23..b8f5de2 100644 --- a/cli/cmd/wakeup.go +++ b/cli/cmd/wakeup.go @@ -67,13 +67,16 @@ func (c *WakeUpCmd) WakeUpWorkspace(client Client, wsId int, token string) error return fmt.Errorf("failed to get workspace: %w", err) } - // Construct the services domain: ${WORKSPACE_ID}-3000.${DEV_DOMAIN} - servicesDomain, err := ConstructWorkspaceServiceURL(workspace, 3000, "") + // Get team to obtain datacenter ID + team, err := client.GetTeam(workspace.TeamId) if err != nil { - return err + return fmt.Errorf("failed to get team: %w", err) } - log.Printf("Waking up workspace %d (%s)...\n", wsId, workspace.Name) + // Construct the services domain using datacenter format: ${WORKSPACE_ID}-3000.${DATACENTER_ID}.codesphere.com + servicesDomain := fmt.Sprintf("https://%d-3000.%d.codesphere.com", wsId, team.DefaultDataCenterId) + + log.Printf("Waking up workspace %d (%s) at URL: %s\n", wsId, workspace.Name, servicesDomain) timeout := 120 * time.Second if c.Timeout != nil { timeout = *c.Timeout @@ -90,6 +93,12 @@ func (c *WakeUpCmd) WakeUpWorkspace(client Client, wsId int, token string) error return fmt.Errorf("failed to wake up workspace: %w", err) } + log.Printf("Waiting for workspace %d to be running...\n", wsId) + err = client.WaitForWorkspaceRunning(&workspace, timeout) + if err != nil { + return fmt.Errorf("workspace did not become running: %w", err) + } + log.Printf("Successfully woke up workspace %d\n", wsId) return nil } @@ -111,11 +120,7 @@ func makeWakeUpRequest(ctx context.Context, servicesDomain string, token string, Timeout: 30 * time.Second, Transport: transport, CheckRedirect: func(req *http.Request, via []*http.Request) error { - if len(via) >= 10 { - return fmt.Errorf("too many redirects") - } - req.Header.Set("x-forward-security", token) - return nil + return http.ErrUseLastResponse }, } @@ -127,9 +132,12 @@ func makeWakeUpRequest(ctx context.Context, servicesDomain string, token string, _ = resp.Body.Close() }() - // 4xx errors are considered failures + log.Printf("Wake-up request received status: %d %s\n", resp.StatusCode, resp.Status) + + // Accept 2xx, 3xx, and 5xx responses (5xx is expected when workspace is starting) + // 4xx errors indicate authentication issues if resp.StatusCode >= 400 && resp.StatusCode < 500 { - return fmt.Errorf("received error response: %s", resp.Status) + return fmt.Errorf("authentication failed: %s", resp.Status) } return nil diff --git a/cli/cmd/wakeup_test.go b/cli/cmd/wakeup_test.go index 130b0d3..c8de5de 100644 --- a/cli/cmd/wakeup_test.go +++ b/cli/cmd/wakeup_test.go @@ -39,15 +39,19 @@ var _ = Describe("WakeUp", func() { Context("WakeUpWorkspace", func() { It("should construct the correct services domain and wake up the workspace", func() { - devDomain := "team-slug.codesphere.com" workspace := api.Workspace{ - Id: wsId, - TeamId: teamId, - Name: "test-workspace", - DevDomain: &devDomain, + Id: wsId, + TeamId: teamId, + Name: "test-workspace", + } + team := api.Team{ + Id: teamId, + DefaultDataCenterId: 5, + Name: "test-team", } mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) + mockClient.EXPECT().GetTeam(teamId).Return(&team, nil) err := c.WakeUpWorkspace(mockClient, wsId, token) @@ -56,20 +60,20 @@ var _ = Describe("WakeUp", func() { Expect(err.Error()).To(ContainSubstring("failed to wake up workspace")) }) - It("should return error if workspace has no dev domain", func() { + It("should return error if GetTeam fails", func() { workspace := api.Workspace{ - Id: wsId, - TeamId: teamId, - Name: "test-workspace", - DevDomain: nil, + Id: wsId, + TeamId: teamId, + Name: "test-workspace", } mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) + mockClient.EXPECT().GetTeam(teamId).Return(nil, fmt.Errorf("team not found")) err := c.WakeUpWorkspace(mockClient, wsId, token) Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("does not have a development domain configured")) + Expect(err.Error()).To(ContainSubstring("failed to get team")) }) It("should return error if GetWorkspace fails", func() { diff --git a/cli/cmd/workspace_url.go b/cli/cmd/workspace_url.go deleted file mode 100644 index 6d6b6d5..0000000 --- a/cli/cmd/workspace_url.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Codesphere Inc. -// SPDX-License-Identifier: Apache-2.0 - -package cmd - -import ( - "fmt" - "strconv" - "strings" - - "github.com/codesphere-cloud/cs-go/api" -) - -// ConstructWorkspaceServiceURL constructs a URL for accessing a workspace service -// Format: https://${WORKSPACE_ID}-${PORT}.${DEV_DOMAIN}${PATH} -func ConstructWorkspaceServiceURL(workspace api.Workspace, port int, path string) (string, error) { - if workspace.DevDomain == nil { - return "", fmt.Errorf("workspace %d does not have a development domain configured", workspace.Id) - } - - devDomain := *workspace.DevDomain - - // extract just the base domain (e.g., "dev.codesphere.com") - if strings.Contains(devDomain, ".") { - parts := strings.SplitN(devDomain, ".", 2) - if len(parts) == 2 { - // Check if the first part starts with workspace ID followed by a hyphen - prefix := parts[0] - wsIdStr := strconv.Itoa(workspace.Id) - if strings.HasPrefix(prefix, wsIdStr+"-") { - // Strip the workspace-port prefix and use the base domain - devDomain = parts[1] - } - } - } - - url := fmt.Sprintf("https://%d-%d.%s%s", workspace.Id, port, devDomain, path) - return url, nil -} diff --git a/cli/cmd/workspace_url_test.go b/cli/cmd/workspace_url_test.go deleted file mode 100644 index 3d6642b..0000000 --- a/cli/cmd/workspace_url_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) Codesphere Inc. -// SPDX-License-Identifier: Apache-2.0 - -package cmd_test - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "github.com/codesphere-cloud/cs-go/api" - "github.com/codesphere-cloud/cs-go/cli/cmd" -) - -var _ = Describe("WorkspaceURL", func() { - Context("ConstructWorkspaceServiceURL", func() { - It("should construct URL correctly with all parameters", func() { - devDomain := "team-slug.codesphere.com" - workspace := api.Workspace{ - Id: 1234, - DevDomain: &devDomain, - } - - url, err := cmd.ConstructWorkspaceServiceURL(workspace, 3000, "/api/health") - - Expect(err).NotTo(HaveOccurred()) - Expect(url).To(Equal("https://1234-3000.team-slug.codesphere.com/api/health")) - }) - - It("should construct URL correctly with root path", func() { - devDomain := "team-slug.codesphere.com" - workspace := api.Workspace{ - Id: 5678, - DevDomain: &devDomain, - } - - url, err := cmd.ConstructWorkspaceServiceURL(workspace, 8080, "/") - - Expect(err).NotTo(HaveOccurred()) - Expect(url).To(Equal("https://5678-8080.team-slug.codesphere.com/")) - }) - - It("should construct URL correctly with empty path", func() { - devDomain := "dev.example.com" - workspace := api.Workspace{ - Id: 999, - DevDomain: &devDomain, - } - - url, err := cmd.ConstructWorkspaceServiceURL(workspace, 3001, "") - - Expect(err).NotTo(HaveOccurred()) - Expect(url).To(Equal("https://999-3001.dev.example.com")) - }) - - It("should return error when dev domain is nil", func() { - workspace := api.Workspace{ - Id: 1234, - DevDomain: nil, - } - - _, err := cmd.ConstructWorkspaceServiceURL(workspace, 3000, "/") - - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("does not have a development domain configured")) - }) - }) -}) diff --git a/int/integration_test.go b/int/integration_test.go index 9f1c4ac..afc0305 100644 --- a/int/integration_test.go +++ b/int/integration_test.go @@ -401,8 +401,13 @@ var _ = Describe("Open Workspace Integration Tests", func() { It("should fail when workspace ID is missing", func() { By("Attempting to open workspace without ID") originalWsId := os.Getenv("CS_WORKSPACE_ID") + originalWsIdFallback := os.Getenv("WORKSPACE_ID") _ = os.Unsetenv("CS_WORKSPACE_ID") - defer func() { _ = os.Setenv("CS_WORKSPACE_ID", originalWsId) }() + _ = os.Unsetenv("WORKSPACE_ID") + defer func() { + _ = os.Setenv("CS_WORKSPACE_ID", originalWsId) + _ = os.Setenv("WORKSPACE_ID", originalWsIdFallback) + }() output, exitCode := intutil.RunCommandWithExitCode( "open", "workspace", @@ -1061,8 +1066,13 @@ var _ = Describe("Wake Up Workspace Integration Tests", func() { It("should fail when workspace ID is missing", func() { By("Attempting to wake up workspace without ID") originalWsId := os.Getenv("CS_WORKSPACE_ID") + originalWsIdFallback := os.Getenv("WORKSPACE_ID") _ = os.Unsetenv("CS_WORKSPACE_ID") - defer func() { _ = os.Setenv("CS_WORKSPACE_ID", originalWsId) }() + _ = os.Unsetenv("WORKSPACE_ID") + defer func() { + _ = os.Setenv("CS_WORKSPACE_ID", originalWsId) + _ = os.Setenv("WORKSPACE_ID", originalWsIdFallback) + }() output, exitCode := intutil.RunCommandWithExitCode("wake-up") fmt.Printf("Wake up without workspace ID output: %s (exit code: %d)\n", output, exitCode) @@ -1238,8 +1248,13 @@ var _ = Describe("Curl Workspace Integration Tests", func() { It("should fail when workspace ID is missing", func() { By("Attempting to curl without workspace ID") originalWsId := os.Getenv("CS_WORKSPACE_ID") + originalWsIdFallback := os.Getenv("WORKSPACE_ID") _ = os.Unsetenv("CS_WORKSPACE_ID") - defer func() { _ = os.Setenv("CS_WORKSPACE_ID", originalWsId) }() + _ = os.Unsetenv("WORKSPACE_ID") + defer func() { + _ = os.Setenv("CS_WORKSPACE_ID", originalWsId) + _ = os.Setenv("WORKSPACE_ID", originalWsIdFallback) + }() output, exitCode := intutil.RunCommandWithExitCode("curl", "/") fmt.Printf("Curl without workspace ID output: %s (exit code: %d)\n", output, exitCode) From 5dc44be3987753b32d9ca167e4b6ca0efa262ee5 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 28 Jan 2026 12:50:21 +0100 Subject: [PATCH 17/25] fix: wake up and curl --- api/workspace.go | 11 +++++ cli/cmd/client.go | 1 + cli/cmd/curl.go | 23 ++++++---- cli/cmd/curl_test.go | 46 ++++++++----------- cli/cmd/mocks.go | 57 +++++++++++++++++++++++ cli/cmd/wakeup.go | 101 +++++++++++------------------------------ cli/cmd/wakeup_test.go | 51 +++++++++++++-------- 7 files changed, 163 insertions(+), 127 deletions(-) diff --git a/api/workspace.go b/api/workspace.go index 338ada9..69b2607 100644 --- a/api/workspace.go +++ b/api/workspace.go @@ -108,6 +108,17 @@ func (c *Client) GetPipelineState(wsId int, stage string) ([]PipelineStatus, err return res, errors.FormatAPIError(err) } +// ScaleWorkspace sets the number of replicas for a workspace. +// For on-demand workspaces, setting replicas to 1 wakes up the workspace, +func (c *Client) ScaleWorkspace(wsId int, replicas int) error { + req := c.api.WorkspacesAPI.WorkspacesUpdateWorkspace(c.ctx, float32(wsId)). + WorkspacesUpdateWorkspaceRequest(openapi_client.WorkspacesUpdateWorkspaceRequest{ + Replicas: &replicas, + }) + _, err := req.Execute() + return errors.FormatAPIError(err) +} + // Waits for a given workspace to be running. // // Returns [TimedOut] error if the workspace does not become running in time. diff --git a/cli/cmd/client.go b/cli/cmd/client.go index 52a1f26..9705343 100644 --- a/cli/cmd/client.go +++ b/cli/cmd/client.go @@ -22,6 +22,7 @@ type Client interface { GetWorkspace(workspaceId int) (api.Workspace, error) WorkspaceStatus(workspaceId int) (*api.WorkspaceStatus, error) WaitForWorkspaceRunning(workspace *api.Workspace, timeout time.Duration) error + ScaleWorkspace(wsId int, replicas int) error SetEnvVarOnWorkspace(workspaceId int, vars map[string]string) error ExecCommand(workspaceId int, command string, workdir string, env map[string]string) (string, string, error) ListWorkspacePlans() ([]api.WorkspacePlan, error) diff --git a/cli/cmd/curl.go b/cli/cmd/curl.go index c7011af..4c64c7b 100644 --- a/cli/cmd/curl.go +++ b/cli/cmd/curl.go @@ -6,9 +6,9 @@ package cmd import ( "context" "fmt" - "log" "os" "os/exec" + "strings" "time" "github.com/codesphere-cloud/cs-go/pkg/io" @@ -79,10 +79,9 @@ func (c *CurlCmd) CurlWorkspace(client Client, wsId int, token string, path stri return fmt.Errorf("failed to get workspace: %w", err) } - // Get team to obtain datacenter ID - team, err := client.GetTeam(workspace.TeamId) - if err != nil { - return fmt.Errorf("failed to get team: %w", err) + // Get the dev domain from the workspace + if workspace.DevDomain == nil || *workspace.DevDomain == "" { + return fmt.Errorf("workspace %d does not have a dev domain configured", wsId) } port := 3000 @@ -90,10 +89,18 @@ func (c *CurlCmd) CurlWorkspace(client Client, wsId int, token string, path stri port = *c.Port } - // Construct URL using datacenter format: ${WORKSPACE_ID}-${PORT}.${DATACENTER_ID}.codesphere.com - url := fmt.Sprintf("https://%d-%d.%d.codesphere.com%s", wsId, port, team.DefaultDataCenterId, path) + // Use the workspace's dev domain and replace the port if needed + // DevDomain format is: {workspace_id}-{port}.{domain} + devDomain := *workspace.DevDomain + var url string + if port != 3000 { + // Replace the default port (3000) with the custom port in the dev domain + url = fmt.Sprintf("https://%d-%d.%s%s", wsId, port, devDomain[strings.Index(devDomain, ".")+1:], path) + } else { + url = fmt.Sprintf("https://%s%s", devDomain, path) + } - log.Printf("Sending request to workspace %d (%s) at %s\n", wsId, workspace.Name, url) + fmt.Fprintf(os.Stderr, "Sending request to workspace %d (%s) at %s\n", wsId, workspace.Name, url) timeout := 30 * time.Second if c.Timeout != nil { diff --git a/cli/cmd/curl_test.go b/cli/cmd/curl_test.go index 9810570..448dfa9 100644 --- a/cli/cmd/curl_test.go +++ b/cli/cmd/curl_test.go @@ -42,61 +42,55 @@ var _ = Describe("Curl", func() { Context("CurlWorkspace", func() { It("should construct the correct URL with default port", func() { + devDomain := "42-3000.dev.5.codesphere.com" workspace := api.Workspace{ - Id: wsId, - TeamId: teamId, - Name: "test-workspace", - } - team := api.Team{ - Id: teamId, - DefaultDataCenterId: 5, - Name: "test-team", + Id: wsId, + TeamId: teamId, + Name: "test-workspace", + DevDomain: &devDomain, } mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) - mockClient.EXPECT().GetTeam(teamId).Return(&team, nil) err := c.CurlWorkspace(mockClient, wsId, token, "/api/health", []string{"-I"}) - Expect(err).To(HaveOccurred()) + // Should succeed since curl can make the request + Expect(err).ToNot(HaveOccurred()) }) It("should construct the correct URL with custom port", func() { customPort := 3001 c.Port = &customPort + devDomain := "42-3000.dev.5.codesphere.com" workspace := api.Workspace{ - Id: wsId, - TeamId: teamId, - Name: "test-workspace", - } - team := api.Team{ - Id: teamId, - DefaultDataCenterId: 5, - Name: "test-team", + Id: wsId, + TeamId: teamId, + Name: "test-workspace", + DevDomain: &devDomain, } mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) - mockClient.EXPECT().GetTeam(teamId).Return(&team, nil) err := c.CurlWorkspace(mockClient, wsId, token, "/custom/path", []string{}) - Expect(err).To(HaveOccurred()) + // Should succeed since curl can make the request + Expect(err).ToNot(HaveOccurred()) }) - It("should return error if GetTeam fails", func() { + It("should return error if workspace has no dev domain", func() { workspace := api.Workspace{ - Id: wsId, - TeamId: teamId, - Name: "test-workspace", + Id: wsId, + TeamId: teamId, + Name: "test-workspace", + DevDomain: nil, } mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) - mockClient.EXPECT().GetTeam(teamId).Return(nil, fmt.Errorf("team not found")) err := c.CurlWorkspace(mockClient, wsId, token, "/", []string{}) Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("failed to get team")) + Expect(err.Error()).To(ContainSubstring("does not have a dev domain configured")) }) It("should return error if GetWorkspace fails", func() { diff --git a/cli/cmd/mocks.go b/cli/cmd/mocks.go index a8c318d..eb1d4d8 100644 --- a/cli/cmd/mocks.go +++ b/cli/cmd/mocks.go @@ -771,6 +771,63 @@ func (_c *MockClient_ListWorkspaces_Call) RunAndReturn(run func(teamId int) ([]a return _c } +// ScaleWorkspace provides a mock function for the type MockClient +func (_mock *MockClient) ScaleWorkspace(wsId int, replicas int) error { + ret := _mock.Called(wsId, replicas) + + if len(ret) == 0 { + panic("no return value specified for ScaleWorkspace") + } + + var r0 error + if returnFunc, ok := ret.Get(0).(func(int, int) error); ok { + r0 = returnFunc(wsId, replicas) + } else { + r0 = ret.Error(0) + } + return r0 +} + +// MockClient_ScaleWorkspace_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ScaleWorkspace' +type MockClient_ScaleWorkspace_Call struct { + *mock.Call +} + +// ScaleWorkspace is a helper method to define mock.On call +// - wsId int +// - replicas int +func (_e *MockClient_Expecter) ScaleWorkspace(wsId interface{}, replicas interface{}) *MockClient_ScaleWorkspace_Call { + return &MockClient_ScaleWorkspace_Call{Call: _e.mock.On("ScaleWorkspace", wsId, replicas)} +} + +func (_c *MockClient_ScaleWorkspace_Call) Run(run func(wsId int, replicas int)) *MockClient_ScaleWorkspace_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 int + if args[1] != nil { + arg1 = args[1].(int) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockClient_ScaleWorkspace_Call) Return(err error) *MockClient_ScaleWorkspace_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockClient_ScaleWorkspace_Call) RunAndReturn(run func(wsId int, replicas int) error) *MockClient_ScaleWorkspace_Call { + _c.Call.Return(run) + return _c +} + // SetEnvVarOnWorkspace provides a mock function for the type MockClient func (_mock *MockClient) SetEnvVarOnWorkspace(workspaceId int, vars map[string]string) error { ret := _mock.Called(workspaceId, vars) diff --git a/cli/cmd/wakeup.go b/cli/cmd/wakeup.go index b8f5de2..c5cde3a 100644 --- a/cli/cmd/wakeup.go +++ b/cli/cmd/wakeup.go @@ -4,11 +4,7 @@ package cmd import ( - "context" - "crypto/tls" "fmt" - "log" - "net/http" "time" "github.com/codesphere-cloud/cs-go/pkg/io" @@ -16,10 +12,9 @@ import ( ) type WakeUpCmd struct { - cmd *cobra.Command - Opts GlobalOptions - Timeout *time.Duration - Insecure bool + cmd *cobra.Command + Opts GlobalOptions + Timeout *time.Duration } func (c *WakeUpCmd) RunE(_ *cobra.Command, args []string) error { @@ -33,12 +28,7 @@ func (c *WakeUpCmd) RunE(_ *cobra.Command, args []string) error { return fmt.Errorf("failed to get workspace ID: %w", err) } - token, err := c.Opts.Env.GetApiToken() - if err != nil { - return fmt.Errorf("failed to get API token: %w", err) - } - - return c.WakeUpWorkspace(client, wsId, token) + return c.WakeUpWorkspace(client, wsId) } func AddWakeUpCmd(rootCmd *cobra.Command, opts GlobalOptions) { @@ -46,7 +36,7 @@ func AddWakeUpCmd(rootCmd *cobra.Command, opts GlobalOptions) { cmd: &cobra.Command{ Use: "wake-up", Short: "Wake up an on-demand workspace", - Long: `Wake up an on-demand workspace by making an authenticated request to its services domain.`, + Long: `Wake up an on-demand workspace by scaling it to 1 replica via the API.`, Example: io.FormatExampleCommands("wake-up", []io.Example{ {Cmd: "-w 1234", Desc: "wake up workspace 1234"}, {Cmd: "", Desc: "wake up workspace set by environment variable CS_WORKSPACE_ID"}, @@ -56,89 +46,52 @@ func AddWakeUpCmd(rootCmd *cobra.Command, opts GlobalOptions) { Opts: opts, } wakeup.Timeout = wakeup.cmd.Flags().DurationP("timeout", "", 120*time.Second, "Timeout for waking up the workspace") - wakeup.cmd.Flags().BoolVar(&wakeup.Insecure, "insecure", false, "skip TLS certificate verification (for testing only)") rootCmd.AddCommand(wakeup.cmd) wakeup.cmd.RunE = wakeup.RunE } -func (c *WakeUpCmd) WakeUpWorkspace(client Client, wsId int, token string) error { +func (c *WakeUpCmd) WakeUpWorkspace(client Client, wsId int) error { workspace, err := client.GetWorkspace(wsId) if err != nil { return fmt.Errorf("failed to get workspace: %w", err) } - // Get team to obtain datacenter ID - team, err := client.GetTeam(workspace.TeamId) + // Check if workspace is already running + status, err := client.WorkspaceStatus(wsId) if err != nil { - return fmt.Errorf("failed to get team: %w", err) + return fmt.Errorf("failed to get workspace status: %w", err) } - // Construct the services domain using datacenter format: ${WORKSPACE_ID}-3000.${DATACENTER_ID}.codesphere.com - servicesDomain := fmt.Sprintf("https://%d-3000.%d.codesphere.com", wsId, team.DefaultDataCenterId) - - log.Printf("Waking up workspace %d (%s) at URL: %s\n", wsId, workspace.Name, servicesDomain) - timeout := 120 * time.Second - if c.Timeout != nil { - timeout = *c.Timeout + if status.IsRunning { + fmt.Printf("Workspace %d (%s) is already running\n", wsId, workspace.Name) + return nil } - ctx, cancel := context.WithTimeout(context.Background(), timeout) - defer cancel() + fmt.Printf("Waking up workspace %d (%s)...\n", wsId, workspace.Name) - err = makeWakeUpRequest(ctx, servicesDomain, token, c.Insecure) - if err != nil { - if ctx.Err() == context.DeadlineExceeded { - return fmt.Errorf("timeout exceeded while waking up workspace %d", wsId) - } - return fmt.Errorf("failed to wake up workspace: %w", err) + // Scale workspace to at least 1 replica to wake it up + // If workspace already has replicas configured (but not running), preserve that count + targetReplicas := 1 + if workspace.Replicas > 1 { + targetReplicas = workspace.Replicas } - log.Printf("Waiting for workspace %d to be running...\n", wsId) - err = client.WaitForWorkspaceRunning(&workspace, timeout) - if err != nil { - return fmt.Errorf("workspace did not become running: %w", err) - } - - log.Printf("Successfully woke up workspace %d\n", wsId) - return nil -} - -func makeWakeUpRequest(ctx context.Context, servicesDomain string, token string, insecure bool) error { - req, err := http.NewRequestWithContext(ctx, "GET", servicesDomain, nil) + err = client.ScaleWorkspace(wsId, targetReplicas) if err != nil { - return fmt.Errorf("failed to create request: %w", err) + return fmt.Errorf("failed to scale workspace: %w", err) } - req.Header.Set("x-forward-security", token) - - transport := &http.Transport{} - if insecure { - transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} - } - - client := &http.Client{ - Timeout: 30 * time.Second, - Transport: transport, - CheckRedirect: func(req *http.Request, via []*http.Request) error { - return http.ErrUseLastResponse - }, + timeout := 120 * time.Second + if c.Timeout != nil { + timeout = *c.Timeout } - resp, err := client.Do(req) + fmt.Printf("Waiting for workspace %d to be running...\n", wsId) + err = client.WaitForWorkspaceRunning(&workspace, timeout) if err != nil { - return fmt.Errorf("failed to make request: %w", err) - } - defer func() { - _ = resp.Body.Close() - }() - - log.Printf("Wake-up request received status: %d %s\n", resp.StatusCode, resp.Status) - - // Accept 2xx, 3xx, and 5xx responses (5xx is expected when workspace is starting) - // 4xx errors indicate authentication issues - if resp.StatusCode >= 400 && resp.StatusCode < 500 { - return fmt.Errorf("authentication failed: %s", resp.Status) + return fmt.Errorf("workspace did not become running: %w", err) } + fmt.Printf("Workspace %d is now running\n", wsId) return nil } diff --git a/cli/cmd/wakeup_test.go b/cli/cmd/wakeup_test.go index c8de5de..3ce9d7e 100644 --- a/cli/cmd/wakeup_test.go +++ b/cli/cmd/wakeup_test.go @@ -5,9 +5,11 @@ package cmd_test import ( "fmt" + "time" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/stretchr/testify/mock" "github.com/codesphere-cloud/cs-go/api" "github.com/codesphere-cloud/cs-go/cli/cmd" @@ -20,7 +22,6 @@ var _ = Describe("WakeUp", func() { c *cmd.WakeUpCmd wsId int teamId int - token string ) JustBeforeEach(func() { @@ -28,7 +29,6 @@ var _ = Describe("WakeUp", func() { mockEnv = cmd.NewMockEnv(GinkgoT()) wsId = 42 teamId = 21 - token = "test-api-token" c = &cmd.WakeUpCmd{ Opts: cmd.GlobalOptions{ Env: mockEnv, @@ -38,29 +38,26 @@ var _ = Describe("WakeUp", func() { }) Context("WakeUpWorkspace", func() { - It("should construct the correct services domain and wake up the workspace", func() { + It("should wake up the workspace by scaling to 1 replica", func() { workspace := api.Workspace{ Id: wsId, TeamId: teamId, Name: "test-workspace", } - team := api.Team{ - Id: teamId, - DefaultDataCenterId: 5, - Name: "test-team", - } + timeout := 120 * time.Second + c.Timeout = &timeout mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) - mockClient.EXPECT().GetTeam(teamId).Return(&team, nil) + mockClient.EXPECT().WorkspaceStatus(wsId).Return(&api.WorkspaceStatus{IsRunning: false}, nil) + mockClient.EXPECT().ScaleWorkspace(wsId, 1).Return(nil) + mockClient.EXPECT().WaitForWorkspaceRunning(mock.Anything, mock.Anything).Return(nil) - err := c.WakeUpWorkspace(mockClient, wsId, token) + err := c.WakeUpWorkspace(mockClient, wsId) - // This will fail because we're making a real HTTP request - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("failed to wake up workspace")) + Expect(err).ToNot(HaveOccurred()) }) - It("should return error if GetTeam fails", func() { + It("should return early if workspace is already running", func() { workspace := api.Workspace{ Id: wsId, TeamId: teamId, @@ -68,21 +65,37 @@ var _ = Describe("WakeUp", func() { } mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) - mockClient.EXPECT().GetTeam(teamId).Return(nil, fmt.Errorf("team not found")) + mockClient.EXPECT().WorkspaceStatus(wsId).Return(&api.WorkspaceStatus{IsRunning: true}, nil) - err := c.WakeUpWorkspace(mockClient, wsId, token) + err := c.WakeUpWorkspace(mockClient, wsId) - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("failed to get team")) + Expect(err).ToNot(HaveOccurred()) }) It("should return error if GetWorkspace fails", func() { mockClient.EXPECT().GetWorkspace(wsId).Return(api.Workspace{}, fmt.Errorf("api error")) - err := c.WakeUpWorkspace(mockClient, wsId, token) + err := c.WakeUpWorkspace(mockClient, wsId) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("failed to get workspace")) }) + + It("should return error if ScaleWorkspace fails", func() { + workspace := api.Workspace{ + Id: wsId, + TeamId: teamId, + Name: "test-workspace", + } + + mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) + mockClient.EXPECT().WorkspaceStatus(wsId).Return(&api.WorkspaceStatus{IsRunning: false}, nil) + mockClient.EXPECT().ScaleWorkspace(wsId, 1).Return(fmt.Errorf("scale error")) + + err := c.WakeUpWorkspace(mockClient, wsId) + + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("failed to scale workspace")) + }) }) }) From 98a1b935d8a9eedbd4ec2c3953811d20cc2e4075 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 28 Jan 2026 11:51:26 +0000 Subject: [PATCH 18/25] chore(docs): Auto-update docs and licenses Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> --- docs/cs_wake-up.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/cs_wake-up.md b/docs/cs_wake-up.md index a68ca55..fa746d5 100644 --- a/docs/cs_wake-up.md +++ b/docs/cs_wake-up.md @@ -4,7 +4,7 @@ Wake up an on-demand workspace ### Synopsis -Wake up an on-demand workspace by making an authenticated request to its services domain. +Wake up an on-demand workspace by scaling it to 1 replica via the API. ``` cs wake-up [flags] @@ -27,7 +27,6 @@ $ cs wake-up -w 1234 --timeout 60s ``` -h, --help help for wake-up - --insecure skip TLS certificate verification (for testing only) --timeout duration Timeout for waking up the workspace (default 2m0s) ``` From e8741535410cefbe1c358edb72f3b9f56c30ca04 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 28 Jan 2026 13:33:01 +0100 Subject: [PATCH 19/25] ref: cleanup --- .mockery.yml | 1 - api/mocks.go | 10 +- api/openapi_client/mocks.go | 1219 +++++++---------------------------- api/workspace.go | 1 - cli/cmd/client.go | 1 - cli/cmd/curl.go | 4 - cli/cmd/mocks.go | 296 ++------- int/integration_test.go | 4 +- pkg/exporter/mocks.go | 79 +-- pkg/git/mocks.go | 31 +- pkg/io/mocks.go | 99 +-- 11 files changed, 301 insertions(+), 1444 deletions(-) diff --git a/.mockery.yml b/.mockery.yml index 17a686d..c1fe4a6 100644 --- a/.mockery.yml +++ b/.mockery.yml @@ -25,7 +25,6 @@ packages: github.com/codesphere-cloud/cs-go/api/openapi_client: config: all: true - include-auto-generated: true interfaces: github.com/codesphere-cloud/cs-go/api: config: diff --git a/api/mocks.go b/api/mocks.go index 05a287a..5e2084e 100644 --- a/api/mocks.go +++ b/api/mocks.go @@ -92,20 +92,14 @@ type MockTime_Sleep_Call struct { } // Sleep is a helper method to define mock.On call -// - duration time.Duration +// - duration func (_e *MockTime_Expecter) Sleep(duration interface{}) *MockTime_Sleep_Call { return &MockTime_Sleep_Call{Call: _e.mock.On("Sleep", duration)} } func (_c *MockTime_Sleep_Call) Run(run func(duration time.Duration)) *MockTime_Sleep_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 time.Duration - if args[0] != nil { - arg0 = args[0].(time.Duration) - } - run( - arg0, - ) + run(args[0].(time.Duration)) }) return _c } diff --git a/api/openapi_client/mocks.go b/api/openapi_client/mocks.go index 9b0a61b..8e1cd3b 100644 --- a/api/openapi_client/mocks.go +++ b/api/openapi_client/mocks.go @@ -60,32 +60,16 @@ type MockDomainsAPI_DomainsCreateDomain_Call struct { } // DomainsCreateDomain is a helper method to define mock.On call -// - ctx context.Context -// - teamId float32 -// - domainName string +// - ctx +// - teamId +// - domainName func (_e *MockDomainsAPI_Expecter) DomainsCreateDomain(ctx interface{}, teamId interface{}, domainName interface{}) *MockDomainsAPI_DomainsCreateDomain_Call { return &MockDomainsAPI_DomainsCreateDomain_Call{Call: _e.mock.On("DomainsCreateDomain", ctx, teamId, domainName)} } func (_c *MockDomainsAPI_DomainsCreateDomain_Call) Run(run func(ctx context.Context, teamId float32, domainName string)) *MockDomainsAPI_DomainsCreateDomain_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(string)) }) return _c } @@ -142,20 +126,14 @@ type MockDomainsAPI_DomainsCreateDomainExecute_Call struct { } // DomainsCreateDomainExecute is a helper method to define mock.On call -// - r ApiDomainsCreateDomainRequest +// - r func (_e *MockDomainsAPI_Expecter) DomainsCreateDomainExecute(r interface{}) *MockDomainsAPI_DomainsCreateDomainExecute_Call { return &MockDomainsAPI_DomainsCreateDomainExecute_Call{Call: _e.mock.On("DomainsCreateDomainExecute", r)} } func (_c *MockDomainsAPI_DomainsCreateDomainExecute_Call) Run(run func(r ApiDomainsCreateDomainRequest)) *MockDomainsAPI_DomainsCreateDomainExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiDomainsCreateDomainRequest - if args[0] != nil { - arg0 = args[0].(ApiDomainsCreateDomainRequest) - } - run( - arg0, - ) + run(args[0].(ApiDomainsCreateDomainRequest)) }) return _c } @@ -193,32 +171,16 @@ type MockDomainsAPI_DomainsDeleteDomain_Call struct { } // DomainsDeleteDomain is a helper method to define mock.On call -// - ctx context.Context -// - teamId float32 -// - domainName string +// - ctx +// - teamId +// - domainName func (_e *MockDomainsAPI_Expecter) DomainsDeleteDomain(ctx interface{}, teamId interface{}, domainName interface{}) *MockDomainsAPI_DomainsDeleteDomain_Call { return &MockDomainsAPI_DomainsDeleteDomain_Call{Call: _e.mock.On("DomainsDeleteDomain", ctx, teamId, domainName)} } func (_c *MockDomainsAPI_DomainsDeleteDomain_Call) Run(run func(ctx context.Context, teamId float32, domainName string)) *MockDomainsAPI_DomainsDeleteDomain_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(string)) }) return _c } @@ -267,20 +229,14 @@ type MockDomainsAPI_DomainsDeleteDomainExecute_Call struct { } // DomainsDeleteDomainExecute is a helper method to define mock.On call -// - r ApiDomainsDeleteDomainRequest +// - r func (_e *MockDomainsAPI_Expecter) DomainsDeleteDomainExecute(r interface{}) *MockDomainsAPI_DomainsDeleteDomainExecute_Call { return &MockDomainsAPI_DomainsDeleteDomainExecute_Call{Call: _e.mock.On("DomainsDeleteDomainExecute", r)} } func (_c *MockDomainsAPI_DomainsDeleteDomainExecute_Call) Run(run func(r ApiDomainsDeleteDomainRequest)) *MockDomainsAPI_DomainsDeleteDomainExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiDomainsDeleteDomainRequest - if args[0] != nil { - arg0 = args[0].(ApiDomainsDeleteDomainRequest) - } - run( - arg0, - ) + run(args[0].(ApiDomainsDeleteDomainRequest)) }) return _c } @@ -318,32 +274,16 @@ type MockDomainsAPI_DomainsGetDomain_Call struct { } // DomainsGetDomain is a helper method to define mock.On call -// - ctx context.Context -// - teamId float32 -// - domainName string +// - ctx +// - teamId +// - domainName func (_e *MockDomainsAPI_Expecter) DomainsGetDomain(ctx interface{}, teamId interface{}, domainName interface{}) *MockDomainsAPI_DomainsGetDomain_Call { return &MockDomainsAPI_DomainsGetDomain_Call{Call: _e.mock.On("DomainsGetDomain", ctx, teamId, domainName)} } func (_c *MockDomainsAPI_DomainsGetDomain_Call) Run(run func(ctx context.Context, teamId float32, domainName string)) *MockDomainsAPI_DomainsGetDomain_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(string)) }) return _c } @@ -400,20 +340,14 @@ type MockDomainsAPI_DomainsGetDomainExecute_Call struct { } // DomainsGetDomainExecute is a helper method to define mock.On call -// - r ApiDomainsGetDomainRequest +// - r func (_e *MockDomainsAPI_Expecter) DomainsGetDomainExecute(r interface{}) *MockDomainsAPI_DomainsGetDomainExecute_Call { return &MockDomainsAPI_DomainsGetDomainExecute_Call{Call: _e.mock.On("DomainsGetDomainExecute", r)} } func (_c *MockDomainsAPI_DomainsGetDomainExecute_Call) Run(run func(r ApiDomainsGetDomainRequest)) *MockDomainsAPI_DomainsGetDomainExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiDomainsGetDomainRequest - if args[0] != nil { - arg0 = args[0].(ApiDomainsGetDomainRequest) - } - run( - arg0, - ) + run(args[0].(ApiDomainsGetDomainRequest)) }) return _c } @@ -451,26 +385,15 @@ type MockDomainsAPI_DomainsListDomains_Call struct { } // DomainsListDomains is a helper method to define mock.On call -// - ctx context.Context -// - teamId float32 +// - ctx +// - teamId func (_e *MockDomainsAPI_Expecter) DomainsListDomains(ctx interface{}, teamId interface{}) *MockDomainsAPI_DomainsListDomains_Call { return &MockDomainsAPI_DomainsListDomains_Call{Call: _e.mock.On("DomainsListDomains", ctx, teamId)} } func (_c *MockDomainsAPI_DomainsListDomains_Call) Run(run func(ctx context.Context, teamId float32)) *MockDomainsAPI_DomainsListDomains_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -527,20 +450,14 @@ type MockDomainsAPI_DomainsListDomainsExecute_Call struct { } // DomainsListDomainsExecute is a helper method to define mock.On call -// - r ApiDomainsListDomainsRequest +// - r func (_e *MockDomainsAPI_Expecter) DomainsListDomainsExecute(r interface{}) *MockDomainsAPI_DomainsListDomainsExecute_Call { return &MockDomainsAPI_DomainsListDomainsExecute_Call{Call: _e.mock.On("DomainsListDomainsExecute", r)} } func (_c *MockDomainsAPI_DomainsListDomainsExecute_Call) Run(run func(r ApiDomainsListDomainsRequest)) *MockDomainsAPI_DomainsListDomainsExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiDomainsListDomainsRequest - if args[0] != nil { - arg0 = args[0].(ApiDomainsListDomainsRequest) - } - run( - arg0, - ) + run(args[0].(ApiDomainsListDomainsRequest)) }) return _c } @@ -578,32 +495,16 @@ type MockDomainsAPI_DomainsUpdateDomain_Call struct { } // DomainsUpdateDomain is a helper method to define mock.On call -// - ctx context.Context -// - teamId float32 -// - domainName string +// - ctx +// - teamId +// - domainName func (_e *MockDomainsAPI_Expecter) DomainsUpdateDomain(ctx interface{}, teamId interface{}, domainName interface{}) *MockDomainsAPI_DomainsUpdateDomain_Call { return &MockDomainsAPI_DomainsUpdateDomain_Call{Call: _e.mock.On("DomainsUpdateDomain", ctx, teamId, domainName)} } func (_c *MockDomainsAPI_DomainsUpdateDomain_Call) Run(run func(ctx context.Context, teamId float32, domainName string)) *MockDomainsAPI_DomainsUpdateDomain_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(string)) }) return _c } @@ -660,20 +561,14 @@ type MockDomainsAPI_DomainsUpdateDomainExecute_Call struct { } // DomainsUpdateDomainExecute is a helper method to define mock.On call -// - r ApiDomainsUpdateDomainRequest +// - r func (_e *MockDomainsAPI_Expecter) DomainsUpdateDomainExecute(r interface{}) *MockDomainsAPI_DomainsUpdateDomainExecute_Call { return &MockDomainsAPI_DomainsUpdateDomainExecute_Call{Call: _e.mock.On("DomainsUpdateDomainExecute", r)} } func (_c *MockDomainsAPI_DomainsUpdateDomainExecute_Call) Run(run func(r ApiDomainsUpdateDomainRequest)) *MockDomainsAPI_DomainsUpdateDomainExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiDomainsUpdateDomainRequest - if args[0] != nil { - arg0 = args[0].(ApiDomainsUpdateDomainRequest) - } - run( - arg0, - ) + run(args[0].(ApiDomainsUpdateDomainRequest)) }) return _c } @@ -711,32 +606,16 @@ type MockDomainsAPI_DomainsUpdateWorkspaceConnections_Call struct { } // DomainsUpdateWorkspaceConnections is a helper method to define mock.On call -// - ctx context.Context -// - teamId float32 -// - domainName string +// - ctx +// - teamId +// - domainName func (_e *MockDomainsAPI_Expecter) DomainsUpdateWorkspaceConnections(ctx interface{}, teamId interface{}, domainName interface{}) *MockDomainsAPI_DomainsUpdateWorkspaceConnections_Call { return &MockDomainsAPI_DomainsUpdateWorkspaceConnections_Call{Call: _e.mock.On("DomainsUpdateWorkspaceConnections", ctx, teamId, domainName)} } func (_c *MockDomainsAPI_DomainsUpdateWorkspaceConnections_Call) Run(run func(ctx context.Context, teamId float32, domainName string)) *MockDomainsAPI_DomainsUpdateWorkspaceConnections_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(string)) }) return _c } @@ -793,20 +672,14 @@ type MockDomainsAPI_DomainsUpdateWorkspaceConnectionsExecute_Call struct { } // DomainsUpdateWorkspaceConnectionsExecute is a helper method to define mock.On call -// - r ApiDomainsUpdateWorkspaceConnectionsRequest +// - r func (_e *MockDomainsAPI_Expecter) DomainsUpdateWorkspaceConnectionsExecute(r interface{}) *MockDomainsAPI_DomainsUpdateWorkspaceConnectionsExecute_Call { return &MockDomainsAPI_DomainsUpdateWorkspaceConnectionsExecute_Call{Call: _e.mock.On("DomainsUpdateWorkspaceConnectionsExecute", r)} } func (_c *MockDomainsAPI_DomainsUpdateWorkspaceConnectionsExecute_Call) Run(run func(r ApiDomainsUpdateWorkspaceConnectionsRequest)) *MockDomainsAPI_DomainsUpdateWorkspaceConnectionsExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiDomainsUpdateWorkspaceConnectionsRequest - if args[0] != nil { - arg0 = args[0].(ApiDomainsUpdateWorkspaceConnectionsRequest) - } - run( - arg0, - ) + run(args[0].(ApiDomainsUpdateWorkspaceConnectionsRequest)) }) return _c } @@ -844,32 +717,16 @@ type MockDomainsAPI_DomainsVerifyDomain_Call struct { } // DomainsVerifyDomain is a helper method to define mock.On call -// - ctx context.Context -// - teamId float32 -// - domainName string +// - ctx +// - teamId +// - domainName func (_e *MockDomainsAPI_Expecter) DomainsVerifyDomain(ctx interface{}, teamId interface{}, domainName interface{}) *MockDomainsAPI_DomainsVerifyDomain_Call { return &MockDomainsAPI_DomainsVerifyDomain_Call{Call: _e.mock.On("DomainsVerifyDomain", ctx, teamId, domainName)} } func (_c *MockDomainsAPI_DomainsVerifyDomain_Call) Run(run func(ctx context.Context, teamId float32, domainName string)) *MockDomainsAPI_DomainsVerifyDomain_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(string)) }) return _c } @@ -926,20 +783,14 @@ type MockDomainsAPI_DomainsVerifyDomainExecute_Call struct { } // DomainsVerifyDomainExecute is a helper method to define mock.On call -// - r ApiDomainsVerifyDomainRequest +// - r func (_e *MockDomainsAPI_Expecter) DomainsVerifyDomainExecute(r interface{}) *MockDomainsAPI_DomainsVerifyDomainExecute_Call { return &MockDomainsAPI_DomainsVerifyDomainExecute_Call{Call: _e.mock.On("DomainsVerifyDomainExecute", r)} } func (_c *MockDomainsAPI_DomainsVerifyDomainExecute_Call) Run(run func(r ApiDomainsVerifyDomainRequest)) *MockDomainsAPI_DomainsVerifyDomainExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiDomainsVerifyDomainRequest - if args[0] != nil { - arg0 = args[0].(ApiDomainsVerifyDomainRequest) - } - run( - arg0, - ) + run(args[0].(ApiDomainsVerifyDomainRequest)) }) return _c } @@ -1004,20 +855,14 @@ type MockMetadataAPI_MetadataGetDatacenters_Call struct { } // MetadataGetDatacenters is a helper method to define mock.On call -// - ctx context.Context +// - ctx func (_e *MockMetadataAPI_Expecter) MetadataGetDatacenters(ctx interface{}) *MockMetadataAPI_MetadataGetDatacenters_Call { return &MockMetadataAPI_MetadataGetDatacenters_Call{Call: _e.mock.On("MetadataGetDatacenters", ctx)} } func (_c *MockMetadataAPI_MetadataGetDatacenters_Call) Run(run func(ctx context.Context)) *MockMetadataAPI_MetadataGetDatacenters_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - run( - arg0, - ) + run(args[0].(context.Context)) }) return _c } @@ -1074,20 +919,14 @@ type MockMetadataAPI_MetadataGetDatacentersExecute_Call struct { } // MetadataGetDatacentersExecute is a helper method to define mock.On call -// - r ApiMetadataGetDatacentersRequest +// - r func (_e *MockMetadataAPI_Expecter) MetadataGetDatacentersExecute(r interface{}) *MockMetadataAPI_MetadataGetDatacentersExecute_Call { return &MockMetadataAPI_MetadataGetDatacentersExecute_Call{Call: _e.mock.On("MetadataGetDatacentersExecute", r)} } func (_c *MockMetadataAPI_MetadataGetDatacentersExecute_Call) Run(run func(r ApiMetadataGetDatacentersRequest)) *MockMetadataAPI_MetadataGetDatacentersExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiMetadataGetDatacentersRequest - if args[0] != nil { - arg0 = args[0].(ApiMetadataGetDatacentersRequest) - } - run( - arg0, - ) + run(args[0].(ApiMetadataGetDatacentersRequest)) }) return _c } @@ -1125,20 +964,14 @@ type MockMetadataAPI_MetadataGetWorkspaceBaseImages_Call struct { } // MetadataGetWorkspaceBaseImages is a helper method to define mock.On call -// - ctx context.Context +// - ctx func (_e *MockMetadataAPI_Expecter) MetadataGetWorkspaceBaseImages(ctx interface{}) *MockMetadataAPI_MetadataGetWorkspaceBaseImages_Call { return &MockMetadataAPI_MetadataGetWorkspaceBaseImages_Call{Call: _e.mock.On("MetadataGetWorkspaceBaseImages", ctx)} } func (_c *MockMetadataAPI_MetadataGetWorkspaceBaseImages_Call) Run(run func(ctx context.Context)) *MockMetadataAPI_MetadataGetWorkspaceBaseImages_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - run( - arg0, - ) + run(args[0].(context.Context)) }) return _c } @@ -1195,20 +1028,14 @@ type MockMetadataAPI_MetadataGetWorkspaceBaseImagesExecute_Call struct { } // MetadataGetWorkspaceBaseImagesExecute is a helper method to define mock.On call -// - r ApiMetadataGetWorkspaceBaseImagesRequest +// - r func (_e *MockMetadataAPI_Expecter) MetadataGetWorkspaceBaseImagesExecute(r interface{}) *MockMetadataAPI_MetadataGetWorkspaceBaseImagesExecute_Call { return &MockMetadataAPI_MetadataGetWorkspaceBaseImagesExecute_Call{Call: _e.mock.On("MetadataGetWorkspaceBaseImagesExecute", r)} } func (_c *MockMetadataAPI_MetadataGetWorkspaceBaseImagesExecute_Call) Run(run func(r ApiMetadataGetWorkspaceBaseImagesRequest)) *MockMetadataAPI_MetadataGetWorkspaceBaseImagesExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiMetadataGetWorkspaceBaseImagesRequest - if args[0] != nil { - arg0 = args[0].(ApiMetadataGetWorkspaceBaseImagesRequest) - } - run( - arg0, - ) + run(args[0].(ApiMetadataGetWorkspaceBaseImagesRequest)) }) return _c } @@ -1246,20 +1073,14 @@ type MockMetadataAPI_MetadataGetWorkspacePlans_Call struct { } // MetadataGetWorkspacePlans is a helper method to define mock.On call -// - ctx context.Context +// - ctx func (_e *MockMetadataAPI_Expecter) MetadataGetWorkspacePlans(ctx interface{}) *MockMetadataAPI_MetadataGetWorkspacePlans_Call { return &MockMetadataAPI_MetadataGetWorkspacePlans_Call{Call: _e.mock.On("MetadataGetWorkspacePlans", ctx)} } func (_c *MockMetadataAPI_MetadataGetWorkspacePlans_Call) Run(run func(ctx context.Context)) *MockMetadataAPI_MetadataGetWorkspacePlans_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - run( - arg0, - ) + run(args[0].(context.Context)) }) return _c } @@ -1316,20 +1137,14 @@ type MockMetadataAPI_MetadataGetWorkspacePlansExecute_Call struct { } // MetadataGetWorkspacePlansExecute is a helper method to define mock.On call -// - r ApiMetadataGetWorkspacePlansRequest +// - r func (_e *MockMetadataAPI_Expecter) MetadataGetWorkspacePlansExecute(r interface{}) *MockMetadataAPI_MetadataGetWorkspacePlansExecute_Call { return &MockMetadataAPI_MetadataGetWorkspacePlansExecute_Call{Call: _e.mock.On("MetadataGetWorkspacePlansExecute", r)} } func (_c *MockMetadataAPI_MetadataGetWorkspacePlansExecute_Call) Run(run func(r ApiMetadataGetWorkspacePlansRequest)) *MockMetadataAPI_MetadataGetWorkspacePlansExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiMetadataGetWorkspacePlansRequest - if args[0] != nil { - arg0 = args[0].(ApiMetadataGetWorkspacePlansRequest) - } - run( - arg0, - ) + run(args[0].(ApiMetadataGetWorkspacePlansRequest)) }) return _c } @@ -1394,20 +1209,14 @@ type MockTeamsAPI_TeamsCreateTeam_Call struct { } // TeamsCreateTeam is a helper method to define mock.On call -// - ctx context.Context +// - ctx func (_e *MockTeamsAPI_Expecter) TeamsCreateTeam(ctx interface{}) *MockTeamsAPI_TeamsCreateTeam_Call { return &MockTeamsAPI_TeamsCreateTeam_Call{Call: _e.mock.On("TeamsCreateTeam", ctx)} } func (_c *MockTeamsAPI_TeamsCreateTeam_Call) Run(run func(ctx context.Context)) *MockTeamsAPI_TeamsCreateTeam_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - run( - arg0, - ) + run(args[0].(context.Context)) }) return _c } @@ -1464,20 +1273,14 @@ type MockTeamsAPI_TeamsCreateTeamExecute_Call struct { } // TeamsCreateTeamExecute is a helper method to define mock.On call -// - r ApiTeamsCreateTeamRequest +// - r func (_e *MockTeamsAPI_Expecter) TeamsCreateTeamExecute(r interface{}) *MockTeamsAPI_TeamsCreateTeamExecute_Call { return &MockTeamsAPI_TeamsCreateTeamExecute_Call{Call: _e.mock.On("TeamsCreateTeamExecute", r)} } func (_c *MockTeamsAPI_TeamsCreateTeamExecute_Call) Run(run func(r ApiTeamsCreateTeamRequest)) *MockTeamsAPI_TeamsCreateTeamExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiTeamsCreateTeamRequest - if args[0] != nil { - arg0 = args[0].(ApiTeamsCreateTeamRequest) - } - run( - arg0, - ) + run(args[0].(ApiTeamsCreateTeamRequest)) }) return _c } @@ -1515,26 +1318,15 @@ type MockTeamsAPI_TeamsDeleteTeam_Call struct { } // TeamsDeleteTeam is a helper method to define mock.On call -// - ctx context.Context -// - teamId float32 +// - ctx +// - teamId func (_e *MockTeamsAPI_Expecter) TeamsDeleteTeam(ctx interface{}, teamId interface{}) *MockTeamsAPI_TeamsDeleteTeam_Call { return &MockTeamsAPI_TeamsDeleteTeam_Call{Call: _e.mock.On("TeamsDeleteTeam", ctx, teamId)} } func (_c *MockTeamsAPI_TeamsDeleteTeam_Call) Run(run func(ctx context.Context, teamId float32)) *MockTeamsAPI_TeamsDeleteTeam_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -1583,20 +1375,14 @@ type MockTeamsAPI_TeamsDeleteTeamExecute_Call struct { } // TeamsDeleteTeamExecute is a helper method to define mock.On call -// - r ApiTeamsDeleteTeamRequest +// - r func (_e *MockTeamsAPI_Expecter) TeamsDeleteTeamExecute(r interface{}) *MockTeamsAPI_TeamsDeleteTeamExecute_Call { return &MockTeamsAPI_TeamsDeleteTeamExecute_Call{Call: _e.mock.On("TeamsDeleteTeamExecute", r)} } func (_c *MockTeamsAPI_TeamsDeleteTeamExecute_Call) Run(run func(r ApiTeamsDeleteTeamRequest)) *MockTeamsAPI_TeamsDeleteTeamExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiTeamsDeleteTeamRequest - if args[0] != nil { - arg0 = args[0].(ApiTeamsDeleteTeamRequest) - } - run( - arg0, - ) + run(args[0].(ApiTeamsDeleteTeamRequest)) }) return _c } @@ -1634,26 +1420,15 @@ type MockTeamsAPI_TeamsGetTeam_Call struct { } // TeamsGetTeam is a helper method to define mock.On call -// - ctx context.Context -// - teamId float32 +// - ctx +// - teamId func (_e *MockTeamsAPI_Expecter) TeamsGetTeam(ctx interface{}, teamId interface{}) *MockTeamsAPI_TeamsGetTeam_Call { return &MockTeamsAPI_TeamsGetTeam_Call{Call: _e.mock.On("TeamsGetTeam", ctx, teamId)} } func (_c *MockTeamsAPI_TeamsGetTeam_Call) Run(run func(ctx context.Context, teamId float32)) *MockTeamsAPI_TeamsGetTeam_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -1710,20 +1485,14 @@ type MockTeamsAPI_TeamsGetTeamExecute_Call struct { } // TeamsGetTeamExecute is a helper method to define mock.On call -// - r ApiTeamsGetTeamRequest +// - r func (_e *MockTeamsAPI_Expecter) TeamsGetTeamExecute(r interface{}) *MockTeamsAPI_TeamsGetTeamExecute_Call { return &MockTeamsAPI_TeamsGetTeamExecute_Call{Call: _e.mock.On("TeamsGetTeamExecute", r)} } func (_c *MockTeamsAPI_TeamsGetTeamExecute_Call) Run(run func(r ApiTeamsGetTeamRequest)) *MockTeamsAPI_TeamsGetTeamExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiTeamsGetTeamRequest - if args[0] != nil { - arg0 = args[0].(ApiTeamsGetTeamRequest) - } - run( - arg0, - ) + run(args[0].(ApiTeamsGetTeamRequest)) }) return _c } @@ -1761,20 +1530,14 @@ type MockTeamsAPI_TeamsListTeams_Call struct { } // TeamsListTeams is a helper method to define mock.On call -// - ctx context.Context +// - ctx func (_e *MockTeamsAPI_Expecter) TeamsListTeams(ctx interface{}) *MockTeamsAPI_TeamsListTeams_Call { return &MockTeamsAPI_TeamsListTeams_Call{Call: _e.mock.On("TeamsListTeams", ctx)} } func (_c *MockTeamsAPI_TeamsListTeams_Call) Run(run func(ctx context.Context)) *MockTeamsAPI_TeamsListTeams_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - run( - arg0, - ) + run(args[0].(context.Context)) }) return _c } @@ -1831,20 +1594,14 @@ type MockTeamsAPI_TeamsListTeamsExecute_Call struct { } // TeamsListTeamsExecute is a helper method to define mock.On call -// - r ApiTeamsListTeamsRequest +// - r func (_e *MockTeamsAPI_Expecter) TeamsListTeamsExecute(r interface{}) *MockTeamsAPI_TeamsListTeamsExecute_Call { return &MockTeamsAPI_TeamsListTeamsExecute_Call{Call: _e.mock.On("TeamsListTeamsExecute", r)} } func (_c *MockTeamsAPI_TeamsListTeamsExecute_Call) Run(run func(r ApiTeamsListTeamsRequest)) *MockTeamsAPI_TeamsListTeamsExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiTeamsListTeamsRequest - if args[0] != nil { - arg0 = args[0].(ApiTeamsListTeamsRequest) - } - run( - arg0, - ) + run(args[0].(ApiTeamsListTeamsRequest)) }) return _c } @@ -1909,32 +1666,16 @@ type MockUsageAPI_UsageGetLandscapeServiceEvents_Call struct { } // UsageGetLandscapeServiceEvents is a helper method to define mock.On call -// - ctx context.Context -// - teamId float32 -// - resourceId string +// - ctx +// - teamId +// - resourceId func (_e *MockUsageAPI_Expecter) UsageGetLandscapeServiceEvents(ctx interface{}, teamId interface{}, resourceId interface{}) *MockUsageAPI_UsageGetLandscapeServiceEvents_Call { return &MockUsageAPI_UsageGetLandscapeServiceEvents_Call{Call: _e.mock.On("UsageGetLandscapeServiceEvents", ctx, teamId, resourceId)} } func (_c *MockUsageAPI_UsageGetLandscapeServiceEvents_Call) Run(run func(ctx context.Context, teamId float32, resourceId string)) *MockUsageAPI_UsageGetLandscapeServiceEvents_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(string)) }) return _c } @@ -1991,20 +1732,14 @@ type MockUsageAPI_UsageGetLandscapeServiceEventsExecute_Call struct { } // UsageGetLandscapeServiceEventsExecute is a helper method to define mock.On call -// - r ApiUsageGetLandscapeServiceEventsRequest +// - r func (_e *MockUsageAPI_Expecter) UsageGetLandscapeServiceEventsExecute(r interface{}) *MockUsageAPI_UsageGetLandscapeServiceEventsExecute_Call { return &MockUsageAPI_UsageGetLandscapeServiceEventsExecute_Call{Call: _e.mock.On("UsageGetLandscapeServiceEventsExecute", r)} } func (_c *MockUsageAPI_UsageGetLandscapeServiceEventsExecute_Call) Run(run func(r ApiUsageGetLandscapeServiceEventsRequest)) *MockUsageAPI_UsageGetLandscapeServiceEventsExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiUsageGetLandscapeServiceEventsRequest - if args[0] != nil { - arg0 = args[0].(ApiUsageGetLandscapeServiceEventsRequest) - } - run( - arg0, - ) + run(args[0].(ApiUsageGetLandscapeServiceEventsRequest)) }) return _c } @@ -2042,26 +1777,15 @@ type MockUsageAPI_UsageGetUsageSummaryLandscape_Call struct { } // UsageGetUsageSummaryLandscape is a helper method to define mock.On call -// - ctx context.Context -// - teamId float32 +// - ctx +// - teamId func (_e *MockUsageAPI_Expecter) UsageGetUsageSummaryLandscape(ctx interface{}, teamId interface{}) *MockUsageAPI_UsageGetUsageSummaryLandscape_Call { return &MockUsageAPI_UsageGetUsageSummaryLandscape_Call{Call: _e.mock.On("UsageGetUsageSummaryLandscape", ctx, teamId)} } func (_c *MockUsageAPI_UsageGetUsageSummaryLandscape_Call) Run(run func(ctx context.Context, teamId float32)) *MockUsageAPI_UsageGetUsageSummaryLandscape_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -2118,20 +1842,14 @@ type MockUsageAPI_UsageGetUsageSummaryLandscapeExecute_Call struct { } // UsageGetUsageSummaryLandscapeExecute is a helper method to define mock.On call -// - r ApiUsageGetUsageSummaryLandscapeRequest +// - r func (_e *MockUsageAPI_Expecter) UsageGetUsageSummaryLandscapeExecute(r interface{}) *MockUsageAPI_UsageGetUsageSummaryLandscapeExecute_Call { return &MockUsageAPI_UsageGetUsageSummaryLandscapeExecute_Call{Call: _e.mock.On("UsageGetUsageSummaryLandscapeExecute", r)} } func (_c *MockUsageAPI_UsageGetUsageSummaryLandscapeExecute_Call) Run(run func(r ApiUsageGetUsageSummaryLandscapeRequest)) *MockUsageAPI_UsageGetUsageSummaryLandscapeExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiUsageGetUsageSummaryLandscapeRequest - if args[0] != nil { - arg0 = args[0].(ApiUsageGetUsageSummaryLandscapeRequest) - } - run( - arg0, - ) + run(args[0].(ApiUsageGetUsageSummaryLandscapeRequest)) }) return _c } @@ -2196,20 +1914,14 @@ type MockWorkspacesAPI_WorkspacesCreateWorkspace_Call struct { } // WorkspacesCreateWorkspace is a helper method to define mock.On call -// - ctx context.Context +// - ctx func (_e *MockWorkspacesAPI_Expecter) WorkspacesCreateWorkspace(ctx interface{}) *MockWorkspacesAPI_WorkspacesCreateWorkspace_Call { return &MockWorkspacesAPI_WorkspacesCreateWorkspace_Call{Call: _e.mock.On("WorkspacesCreateWorkspace", ctx)} } func (_c *MockWorkspacesAPI_WorkspacesCreateWorkspace_Call) Run(run func(ctx context.Context)) *MockWorkspacesAPI_WorkspacesCreateWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - run( - arg0, - ) + run(args[0].(context.Context)) }) return _c } @@ -2266,20 +1978,14 @@ type MockWorkspacesAPI_WorkspacesCreateWorkspaceExecute_Call struct { } // WorkspacesCreateWorkspaceExecute is a helper method to define mock.On call -// - r ApiWorkspacesCreateWorkspaceRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesCreateWorkspaceExecute(r interface{}) *MockWorkspacesAPI_WorkspacesCreateWorkspaceExecute_Call { return &MockWorkspacesAPI_WorkspacesCreateWorkspaceExecute_Call{Call: _e.mock.On("WorkspacesCreateWorkspaceExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesCreateWorkspaceExecute_Call) Run(run func(r ApiWorkspacesCreateWorkspaceRequest)) *MockWorkspacesAPI_WorkspacesCreateWorkspaceExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesCreateWorkspaceRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesCreateWorkspaceRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesCreateWorkspaceRequest)) }) return _c } @@ -2317,26 +2023,15 @@ type MockWorkspacesAPI_WorkspacesDeleteEnvVar_Call struct { } // WorkspacesDeleteEnvVar is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 +// - ctx +// - workspaceId func (_e *MockWorkspacesAPI_Expecter) WorkspacesDeleteEnvVar(ctx interface{}, workspaceId interface{}) *MockWorkspacesAPI_WorkspacesDeleteEnvVar_Call { return &MockWorkspacesAPI_WorkspacesDeleteEnvVar_Call{Call: _e.mock.On("WorkspacesDeleteEnvVar", ctx, workspaceId)} } func (_c *MockWorkspacesAPI_WorkspacesDeleteEnvVar_Call) Run(run func(ctx context.Context, workspaceId float32)) *MockWorkspacesAPI_WorkspacesDeleteEnvVar_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -2385,20 +2080,14 @@ type MockWorkspacesAPI_WorkspacesDeleteEnvVarExecute_Call struct { } // WorkspacesDeleteEnvVarExecute is a helper method to define mock.On call -// - r ApiWorkspacesDeleteEnvVarRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesDeleteEnvVarExecute(r interface{}) *MockWorkspacesAPI_WorkspacesDeleteEnvVarExecute_Call { return &MockWorkspacesAPI_WorkspacesDeleteEnvVarExecute_Call{Call: _e.mock.On("WorkspacesDeleteEnvVarExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesDeleteEnvVarExecute_Call) Run(run func(r ApiWorkspacesDeleteEnvVarRequest)) *MockWorkspacesAPI_WorkspacesDeleteEnvVarExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesDeleteEnvVarRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesDeleteEnvVarRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesDeleteEnvVarRequest)) }) return _c } @@ -2436,26 +2125,15 @@ type MockWorkspacesAPI_WorkspacesDeleteWorkspace_Call struct { } // WorkspacesDeleteWorkspace is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 +// - ctx +// - workspaceId func (_e *MockWorkspacesAPI_Expecter) WorkspacesDeleteWorkspace(ctx interface{}, workspaceId interface{}) *MockWorkspacesAPI_WorkspacesDeleteWorkspace_Call { return &MockWorkspacesAPI_WorkspacesDeleteWorkspace_Call{Call: _e.mock.On("WorkspacesDeleteWorkspace", ctx, workspaceId)} } func (_c *MockWorkspacesAPI_WorkspacesDeleteWorkspace_Call) Run(run func(ctx context.Context, workspaceId float32)) *MockWorkspacesAPI_WorkspacesDeleteWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -2504,20 +2182,14 @@ type MockWorkspacesAPI_WorkspacesDeleteWorkspaceExecute_Call struct { } // WorkspacesDeleteWorkspaceExecute is a helper method to define mock.On call -// - r ApiWorkspacesDeleteWorkspaceRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesDeleteWorkspaceExecute(r interface{}) *MockWorkspacesAPI_WorkspacesDeleteWorkspaceExecute_Call { return &MockWorkspacesAPI_WorkspacesDeleteWorkspaceExecute_Call{Call: _e.mock.On("WorkspacesDeleteWorkspaceExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesDeleteWorkspaceExecute_Call) Run(run func(r ApiWorkspacesDeleteWorkspaceRequest)) *MockWorkspacesAPI_WorkspacesDeleteWorkspaceExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesDeleteWorkspaceRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesDeleteWorkspaceRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesDeleteWorkspaceRequest)) }) return _c } @@ -2555,26 +2227,15 @@ type MockWorkspacesAPI_WorkspacesDeployLandscape_Call struct { } // WorkspacesDeployLandscape is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 +// - ctx +// - workspaceId func (_e *MockWorkspacesAPI_Expecter) WorkspacesDeployLandscape(ctx interface{}, workspaceId interface{}) *MockWorkspacesAPI_WorkspacesDeployLandscape_Call { return &MockWorkspacesAPI_WorkspacesDeployLandscape_Call{Call: _e.mock.On("WorkspacesDeployLandscape", ctx, workspaceId)} } func (_c *MockWorkspacesAPI_WorkspacesDeployLandscape_Call) Run(run func(ctx context.Context, workspaceId float32)) *MockWorkspacesAPI_WorkspacesDeployLandscape_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -2612,32 +2273,16 @@ type MockWorkspacesAPI_WorkspacesDeployLandscape1_Call struct { } // WorkspacesDeployLandscape1 is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 -// - profile string +// - ctx +// - workspaceId +// - profile func (_e *MockWorkspacesAPI_Expecter) WorkspacesDeployLandscape1(ctx interface{}, workspaceId interface{}, profile interface{}) *MockWorkspacesAPI_WorkspacesDeployLandscape1_Call { return &MockWorkspacesAPI_WorkspacesDeployLandscape1_Call{Call: _e.mock.On("WorkspacesDeployLandscape1", ctx, workspaceId, profile)} } func (_c *MockWorkspacesAPI_WorkspacesDeployLandscape1_Call) Run(run func(ctx context.Context, workspaceId float32, profile string)) *MockWorkspacesAPI_WorkspacesDeployLandscape1_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(string)) }) return _c } @@ -2686,20 +2331,14 @@ type MockWorkspacesAPI_WorkspacesDeployLandscape1Execute_Call struct { } // WorkspacesDeployLandscape1Execute is a helper method to define mock.On call -// - r ApiWorkspacesDeployLandscape1Request +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesDeployLandscape1Execute(r interface{}) *MockWorkspacesAPI_WorkspacesDeployLandscape1Execute_Call { return &MockWorkspacesAPI_WorkspacesDeployLandscape1Execute_Call{Call: _e.mock.On("WorkspacesDeployLandscape1Execute", r)} } func (_c *MockWorkspacesAPI_WorkspacesDeployLandscape1Execute_Call) Run(run func(r ApiWorkspacesDeployLandscape1Request)) *MockWorkspacesAPI_WorkspacesDeployLandscape1Execute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesDeployLandscape1Request - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesDeployLandscape1Request) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesDeployLandscape1Request)) }) return _c } @@ -2748,20 +2387,14 @@ type MockWorkspacesAPI_WorkspacesDeployLandscapeExecute_Call struct { } // WorkspacesDeployLandscapeExecute is a helper method to define mock.On call -// - r ApiWorkspacesDeployLandscapeRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesDeployLandscapeExecute(r interface{}) *MockWorkspacesAPI_WorkspacesDeployLandscapeExecute_Call { return &MockWorkspacesAPI_WorkspacesDeployLandscapeExecute_Call{Call: _e.mock.On("WorkspacesDeployLandscapeExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesDeployLandscapeExecute_Call) Run(run func(r ApiWorkspacesDeployLandscapeRequest)) *MockWorkspacesAPI_WorkspacesDeployLandscapeExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesDeployLandscapeRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesDeployLandscapeRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesDeployLandscapeRequest)) }) return _c } @@ -2799,26 +2432,15 @@ type MockWorkspacesAPI_WorkspacesExecuteCommand_Call struct { } // WorkspacesExecuteCommand is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 +// - ctx +// - workspaceId func (_e *MockWorkspacesAPI_Expecter) WorkspacesExecuteCommand(ctx interface{}, workspaceId interface{}) *MockWorkspacesAPI_WorkspacesExecuteCommand_Call { return &MockWorkspacesAPI_WorkspacesExecuteCommand_Call{Call: _e.mock.On("WorkspacesExecuteCommand", ctx, workspaceId)} } func (_c *MockWorkspacesAPI_WorkspacesExecuteCommand_Call) Run(run func(ctx context.Context, workspaceId float32)) *MockWorkspacesAPI_WorkspacesExecuteCommand_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -2875,20 +2497,14 @@ type MockWorkspacesAPI_WorkspacesExecuteCommandExecute_Call struct { } // WorkspacesExecuteCommandExecute is a helper method to define mock.On call -// - r ApiWorkspacesExecuteCommandRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesExecuteCommandExecute(r interface{}) *MockWorkspacesAPI_WorkspacesExecuteCommandExecute_Call { return &MockWorkspacesAPI_WorkspacesExecuteCommandExecute_Call{Call: _e.mock.On("WorkspacesExecuteCommandExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesExecuteCommandExecute_Call) Run(run func(r ApiWorkspacesExecuteCommandRequest)) *MockWorkspacesAPI_WorkspacesExecuteCommandExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesExecuteCommandRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesExecuteCommandRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesExecuteCommandRequest)) }) return _c } @@ -2926,26 +2542,15 @@ type MockWorkspacesAPI_WorkspacesGetWorkspace_Call struct { } // WorkspacesGetWorkspace is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 +// - ctx +// - workspaceId func (_e *MockWorkspacesAPI_Expecter) WorkspacesGetWorkspace(ctx interface{}, workspaceId interface{}) *MockWorkspacesAPI_WorkspacesGetWorkspace_Call { return &MockWorkspacesAPI_WorkspacesGetWorkspace_Call{Call: _e.mock.On("WorkspacesGetWorkspace", ctx, workspaceId)} } func (_c *MockWorkspacesAPI_WorkspacesGetWorkspace_Call) Run(run func(ctx context.Context, workspaceId float32)) *MockWorkspacesAPI_WorkspacesGetWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -3002,20 +2607,14 @@ type MockWorkspacesAPI_WorkspacesGetWorkspaceExecute_Call struct { } // WorkspacesGetWorkspaceExecute is a helper method to define mock.On call -// - r ApiWorkspacesGetWorkspaceRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesGetWorkspaceExecute(r interface{}) *MockWorkspacesAPI_WorkspacesGetWorkspaceExecute_Call { return &MockWorkspacesAPI_WorkspacesGetWorkspaceExecute_Call{Call: _e.mock.On("WorkspacesGetWorkspaceExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesGetWorkspaceExecute_Call) Run(run func(r ApiWorkspacesGetWorkspaceRequest)) *MockWorkspacesAPI_WorkspacesGetWorkspaceExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesGetWorkspaceRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesGetWorkspaceRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesGetWorkspaceRequest)) }) return _c } @@ -3053,26 +2652,15 @@ type MockWorkspacesAPI_WorkspacesGetWorkspaceStatus_Call struct { } // WorkspacesGetWorkspaceStatus is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 +// - ctx +// - workspaceId func (_e *MockWorkspacesAPI_Expecter) WorkspacesGetWorkspaceStatus(ctx interface{}, workspaceId interface{}) *MockWorkspacesAPI_WorkspacesGetWorkspaceStatus_Call { return &MockWorkspacesAPI_WorkspacesGetWorkspaceStatus_Call{Call: _e.mock.On("WorkspacesGetWorkspaceStatus", ctx, workspaceId)} } func (_c *MockWorkspacesAPI_WorkspacesGetWorkspaceStatus_Call) Run(run func(ctx context.Context, workspaceId float32)) *MockWorkspacesAPI_WorkspacesGetWorkspaceStatus_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -3129,20 +2717,14 @@ type MockWorkspacesAPI_WorkspacesGetWorkspaceStatusExecute_Call struct { } // WorkspacesGetWorkspaceStatusExecute is a helper method to define mock.On call -// - r ApiWorkspacesGetWorkspaceStatusRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesGetWorkspaceStatusExecute(r interface{}) *MockWorkspacesAPI_WorkspacesGetWorkspaceStatusExecute_Call { return &MockWorkspacesAPI_WorkspacesGetWorkspaceStatusExecute_Call{Call: _e.mock.On("WorkspacesGetWorkspaceStatusExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesGetWorkspaceStatusExecute_Call) Run(run func(r ApiWorkspacesGetWorkspaceStatusRequest)) *MockWorkspacesAPI_WorkspacesGetWorkspaceStatusExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesGetWorkspaceStatusRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesGetWorkspaceStatusRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesGetWorkspaceStatusRequest)) }) return _c } @@ -3180,26 +2762,15 @@ type MockWorkspacesAPI_WorkspacesGitHead_Call struct { } // WorkspacesGitHead is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 +// - ctx +// - workspaceId func (_e *MockWorkspacesAPI_Expecter) WorkspacesGitHead(ctx interface{}, workspaceId interface{}) *MockWorkspacesAPI_WorkspacesGitHead_Call { return &MockWorkspacesAPI_WorkspacesGitHead_Call{Call: _e.mock.On("WorkspacesGitHead", ctx, workspaceId)} } func (_c *MockWorkspacesAPI_WorkspacesGitHead_Call) Run(run func(ctx context.Context, workspaceId float32)) *MockWorkspacesAPI_WorkspacesGitHead_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -3256,20 +2827,14 @@ type MockWorkspacesAPI_WorkspacesGitHeadExecute_Call struct { } // WorkspacesGitHeadExecute is a helper method to define mock.On call -// - r ApiWorkspacesGitHeadRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesGitHeadExecute(r interface{}) *MockWorkspacesAPI_WorkspacesGitHeadExecute_Call { return &MockWorkspacesAPI_WorkspacesGitHeadExecute_Call{Call: _e.mock.On("WorkspacesGitHeadExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesGitHeadExecute_Call) Run(run func(r ApiWorkspacesGitHeadRequest)) *MockWorkspacesAPI_WorkspacesGitHeadExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesGitHeadRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesGitHeadRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesGitHeadRequest)) }) return _c } @@ -3307,26 +2872,15 @@ type MockWorkspacesAPI_WorkspacesGitPull_Call struct { } // WorkspacesGitPull is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 +// - ctx +// - workspaceId func (_e *MockWorkspacesAPI_Expecter) WorkspacesGitPull(ctx interface{}, workspaceId interface{}) *MockWorkspacesAPI_WorkspacesGitPull_Call { return &MockWorkspacesAPI_WorkspacesGitPull_Call{Call: _e.mock.On("WorkspacesGitPull", ctx, workspaceId)} } func (_c *MockWorkspacesAPI_WorkspacesGitPull_Call) Run(run func(ctx context.Context, workspaceId float32)) *MockWorkspacesAPI_WorkspacesGitPull_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -3364,32 +2918,16 @@ type MockWorkspacesAPI_WorkspacesGitPull1_Call struct { } // WorkspacesGitPull1 is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 -// - remote string +// - ctx +// - workspaceId +// - remote func (_e *MockWorkspacesAPI_Expecter) WorkspacesGitPull1(ctx interface{}, workspaceId interface{}, remote interface{}) *MockWorkspacesAPI_WorkspacesGitPull1_Call { return &MockWorkspacesAPI_WorkspacesGitPull1_Call{Call: _e.mock.On("WorkspacesGitPull1", ctx, workspaceId, remote)} } func (_c *MockWorkspacesAPI_WorkspacesGitPull1_Call) Run(run func(ctx context.Context, workspaceId float32, remote string)) *MockWorkspacesAPI_WorkspacesGitPull1_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(string)) }) return _c } @@ -3438,20 +2976,14 @@ type MockWorkspacesAPI_WorkspacesGitPull1Execute_Call struct { } // WorkspacesGitPull1Execute is a helper method to define mock.On call -// - r ApiWorkspacesGitPull1Request +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesGitPull1Execute(r interface{}) *MockWorkspacesAPI_WorkspacesGitPull1Execute_Call { return &MockWorkspacesAPI_WorkspacesGitPull1Execute_Call{Call: _e.mock.On("WorkspacesGitPull1Execute", r)} } func (_c *MockWorkspacesAPI_WorkspacesGitPull1Execute_Call) Run(run func(r ApiWorkspacesGitPull1Request)) *MockWorkspacesAPI_WorkspacesGitPull1Execute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesGitPull1Request - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesGitPull1Request) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesGitPull1Request)) }) return _c } @@ -3489,38 +3021,17 @@ type MockWorkspacesAPI_WorkspacesGitPull2_Call struct { } // WorkspacesGitPull2 is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 -// - remote string -// - branch string +// - ctx +// - workspaceId +// - remote +// - branch func (_e *MockWorkspacesAPI_Expecter) WorkspacesGitPull2(ctx interface{}, workspaceId interface{}, remote interface{}, branch interface{}) *MockWorkspacesAPI_WorkspacesGitPull2_Call { return &MockWorkspacesAPI_WorkspacesGitPull2_Call{Call: _e.mock.On("WorkspacesGitPull2", ctx, workspaceId, remote, branch)} } func (_c *MockWorkspacesAPI_WorkspacesGitPull2_Call) Run(run func(ctx context.Context, workspaceId float32, remote string, branch string)) *MockWorkspacesAPI_WorkspacesGitPull2_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - run( - arg0, - arg1, - arg2, - arg3, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(string), args[3].(string)) }) return _c } @@ -3569,20 +3080,14 @@ type MockWorkspacesAPI_WorkspacesGitPull2Execute_Call struct { } // WorkspacesGitPull2Execute is a helper method to define mock.On call -// - r ApiWorkspacesGitPull2Request +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesGitPull2Execute(r interface{}) *MockWorkspacesAPI_WorkspacesGitPull2Execute_Call { return &MockWorkspacesAPI_WorkspacesGitPull2Execute_Call{Call: _e.mock.On("WorkspacesGitPull2Execute", r)} } func (_c *MockWorkspacesAPI_WorkspacesGitPull2Execute_Call) Run(run func(r ApiWorkspacesGitPull2Request)) *MockWorkspacesAPI_WorkspacesGitPull2Execute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesGitPull2Request - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesGitPull2Request) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesGitPull2Request)) }) return _c } @@ -3631,20 +3136,14 @@ type MockWorkspacesAPI_WorkspacesGitPullExecute_Call struct { } // WorkspacesGitPullExecute is a helper method to define mock.On call -// - r ApiWorkspacesGitPullRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesGitPullExecute(r interface{}) *MockWorkspacesAPI_WorkspacesGitPullExecute_Call { return &MockWorkspacesAPI_WorkspacesGitPullExecute_Call{Call: _e.mock.On("WorkspacesGitPullExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesGitPullExecute_Call) Run(run func(r ApiWorkspacesGitPullRequest)) *MockWorkspacesAPI_WorkspacesGitPullExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesGitPullRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesGitPullRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesGitPullRequest)) }) return _c } @@ -3682,26 +3181,15 @@ type MockWorkspacesAPI_WorkspacesListEnvVars_Call struct { } // WorkspacesListEnvVars is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 +// - ctx +// - workspaceId func (_e *MockWorkspacesAPI_Expecter) WorkspacesListEnvVars(ctx interface{}, workspaceId interface{}) *MockWorkspacesAPI_WorkspacesListEnvVars_Call { return &MockWorkspacesAPI_WorkspacesListEnvVars_Call{Call: _e.mock.On("WorkspacesListEnvVars", ctx, workspaceId)} } func (_c *MockWorkspacesAPI_WorkspacesListEnvVars_Call) Run(run func(ctx context.Context, workspaceId float32)) *MockWorkspacesAPI_WorkspacesListEnvVars_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -3758,20 +3246,14 @@ type MockWorkspacesAPI_WorkspacesListEnvVarsExecute_Call struct { } // WorkspacesListEnvVarsExecute is a helper method to define mock.On call -// - r ApiWorkspacesListEnvVarsRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesListEnvVarsExecute(r interface{}) *MockWorkspacesAPI_WorkspacesListEnvVarsExecute_Call { return &MockWorkspacesAPI_WorkspacesListEnvVarsExecute_Call{Call: _e.mock.On("WorkspacesListEnvVarsExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesListEnvVarsExecute_Call) Run(run func(r ApiWorkspacesListEnvVarsRequest)) *MockWorkspacesAPI_WorkspacesListEnvVarsExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesListEnvVarsRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesListEnvVarsRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesListEnvVarsRequest)) }) return _c } @@ -3809,26 +3291,15 @@ type MockWorkspacesAPI_WorkspacesListWorkspaces_Call struct { } // WorkspacesListWorkspaces is a helper method to define mock.On call -// - ctx context.Context -// - teamId float32 +// - ctx +// - teamId func (_e *MockWorkspacesAPI_Expecter) WorkspacesListWorkspaces(ctx interface{}, teamId interface{}) *MockWorkspacesAPI_WorkspacesListWorkspaces_Call { return &MockWorkspacesAPI_WorkspacesListWorkspaces_Call{Call: _e.mock.On("WorkspacesListWorkspaces", ctx, teamId)} } func (_c *MockWorkspacesAPI_WorkspacesListWorkspaces_Call) Run(run func(ctx context.Context, teamId float32)) *MockWorkspacesAPI_WorkspacesListWorkspaces_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -3885,20 +3356,14 @@ type MockWorkspacesAPI_WorkspacesListWorkspacesExecute_Call struct { } // WorkspacesListWorkspacesExecute is a helper method to define mock.On call -// - r ApiWorkspacesListWorkspacesRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesListWorkspacesExecute(r interface{}) *MockWorkspacesAPI_WorkspacesListWorkspacesExecute_Call { return &MockWorkspacesAPI_WorkspacesListWorkspacesExecute_Call{Call: _e.mock.On("WorkspacesListWorkspacesExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesListWorkspacesExecute_Call) Run(run func(r ApiWorkspacesListWorkspacesRequest)) *MockWorkspacesAPI_WorkspacesListWorkspacesExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesListWorkspacesRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesListWorkspacesRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesListWorkspacesRequest)) }) return _c } @@ -3936,38 +3401,17 @@ type MockWorkspacesAPI_WorkspacesLogs_Call struct { } // WorkspacesLogs is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 -// - stage string -// - step float32 +// - ctx +// - workspaceId +// - stage +// - step func (_e *MockWorkspacesAPI_Expecter) WorkspacesLogs(ctx interface{}, workspaceId interface{}, stage interface{}, step interface{}) *MockWorkspacesAPI_WorkspacesLogs_Call { return &MockWorkspacesAPI_WorkspacesLogs_Call{Call: _e.mock.On("WorkspacesLogs", ctx, workspaceId, stage, step)} } func (_c *MockWorkspacesAPI_WorkspacesLogs_Call) Run(run func(ctx context.Context, workspaceId float32, stage string, step float32)) *MockWorkspacesAPI_WorkspacesLogs_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 float32 - if args[3] != nil { - arg3 = args[3].(float32) - } - run( - arg0, - arg1, - arg2, - arg3, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(string), args[3].(float32)) }) return _c } @@ -4024,20 +3468,14 @@ type MockWorkspacesAPI_WorkspacesLogsExecute_Call struct { } // WorkspacesLogsExecute is a helper method to define mock.On call -// - r ApiWorkspacesLogsRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesLogsExecute(r interface{}) *MockWorkspacesAPI_WorkspacesLogsExecute_Call { return &MockWorkspacesAPI_WorkspacesLogsExecute_Call{Call: _e.mock.On("WorkspacesLogsExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesLogsExecute_Call) Run(run func(r ApiWorkspacesLogsRequest)) *MockWorkspacesAPI_WorkspacesLogsExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesLogsRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesLogsRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesLogsRequest)) }) return _c } @@ -4075,32 +3513,16 @@ type MockWorkspacesAPI_WorkspacesPipelineStatus_Call struct { } // WorkspacesPipelineStatus is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 -// - stage string +// - ctx +// - workspaceId +// - stage func (_e *MockWorkspacesAPI_Expecter) WorkspacesPipelineStatus(ctx interface{}, workspaceId interface{}, stage interface{}) *MockWorkspacesAPI_WorkspacesPipelineStatus_Call { return &MockWorkspacesAPI_WorkspacesPipelineStatus_Call{Call: _e.mock.On("WorkspacesPipelineStatus", ctx, workspaceId, stage)} } func (_c *MockWorkspacesAPI_WorkspacesPipelineStatus_Call) Run(run func(ctx context.Context, workspaceId float32, stage string)) *MockWorkspacesAPI_WorkspacesPipelineStatus_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(string)) }) return _c } @@ -4157,20 +3579,14 @@ type MockWorkspacesAPI_WorkspacesPipelineStatusExecute_Call struct { } // WorkspacesPipelineStatusExecute is a helper method to define mock.On call -// - r ApiWorkspacesPipelineStatusRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesPipelineStatusExecute(r interface{}) *MockWorkspacesAPI_WorkspacesPipelineStatusExecute_Call { return &MockWorkspacesAPI_WorkspacesPipelineStatusExecute_Call{Call: _e.mock.On("WorkspacesPipelineStatusExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesPipelineStatusExecute_Call) Run(run func(r ApiWorkspacesPipelineStatusRequest)) *MockWorkspacesAPI_WorkspacesPipelineStatusExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesPipelineStatusRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesPipelineStatusRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesPipelineStatusRequest)) }) return _c } @@ -4208,38 +3624,17 @@ type MockWorkspacesAPI_WorkspacesReplicaLogs_Call struct { } // WorkspacesReplicaLogs is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 -// - step float32 -// - replica string +// - ctx +// - workspaceId +// - step +// - replica func (_e *MockWorkspacesAPI_Expecter) WorkspacesReplicaLogs(ctx interface{}, workspaceId interface{}, step interface{}, replica interface{}) *MockWorkspacesAPI_WorkspacesReplicaLogs_Call { return &MockWorkspacesAPI_WorkspacesReplicaLogs_Call{Call: _e.mock.On("WorkspacesReplicaLogs", ctx, workspaceId, step, replica)} } func (_c *MockWorkspacesAPI_WorkspacesReplicaLogs_Call) Run(run func(ctx context.Context, workspaceId float32, step float32, replica string)) *MockWorkspacesAPI_WorkspacesReplicaLogs_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 float32 - if args[2] != nil { - arg2 = args[2].(float32) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - run( - arg0, - arg1, - arg2, - arg3, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(float32), args[3].(string)) }) return _c } @@ -4296,20 +3691,14 @@ type MockWorkspacesAPI_WorkspacesReplicaLogsExecute_Call struct { } // WorkspacesReplicaLogsExecute is a helper method to define mock.On call -// - r ApiWorkspacesReplicaLogsRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesReplicaLogsExecute(r interface{}) *MockWorkspacesAPI_WorkspacesReplicaLogsExecute_Call { return &MockWorkspacesAPI_WorkspacesReplicaLogsExecute_Call{Call: _e.mock.On("WorkspacesReplicaLogsExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesReplicaLogsExecute_Call) Run(run func(r ApiWorkspacesReplicaLogsRequest)) *MockWorkspacesAPI_WorkspacesReplicaLogsExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesReplicaLogsRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesReplicaLogsRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesReplicaLogsRequest)) }) return _c } @@ -4347,26 +3736,15 @@ type MockWorkspacesAPI_WorkspacesScaleLandscapeServices_Call struct { } // WorkspacesScaleLandscapeServices is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 +// - ctx +// - workspaceId func (_e *MockWorkspacesAPI_Expecter) WorkspacesScaleLandscapeServices(ctx interface{}, workspaceId interface{}) *MockWorkspacesAPI_WorkspacesScaleLandscapeServices_Call { return &MockWorkspacesAPI_WorkspacesScaleLandscapeServices_Call{Call: _e.mock.On("WorkspacesScaleLandscapeServices", ctx, workspaceId)} } func (_c *MockWorkspacesAPI_WorkspacesScaleLandscapeServices_Call) Run(run func(ctx context.Context, workspaceId float32)) *MockWorkspacesAPI_WorkspacesScaleLandscapeServices_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -4415,20 +3793,14 @@ type MockWorkspacesAPI_WorkspacesScaleLandscapeServicesExecute_Call struct { } // WorkspacesScaleLandscapeServicesExecute is a helper method to define mock.On call -// - r ApiWorkspacesScaleLandscapeServicesRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesScaleLandscapeServicesExecute(r interface{}) *MockWorkspacesAPI_WorkspacesScaleLandscapeServicesExecute_Call { return &MockWorkspacesAPI_WorkspacesScaleLandscapeServicesExecute_Call{Call: _e.mock.On("WorkspacesScaleLandscapeServicesExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesScaleLandscapeServicesExecute_Call) Run(run func(r ApiWorkspacesScaleLandscapeServicesRequest)) *MockWorkspacesAPI_WorkspacesScaleLandscapeServicesExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesScaleLandscapeServicesRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesScaleLandscapeServicesRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesScaleLandscapeServicesRequest)) }) return _c } @@ -4466,38 +3838,17 @@ type MockWorkspacesAPI_WorkspacesServerLogs_Call struct { } // WorkspacesServerLogs is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 -// - step float32 -// - server string +// - ctx +// - workspaceId +// - step +// - server func (_e *MockWorkspacesAPI_Expecter) WorkspacesServerLogs(ctx interface{}, workspaceId interface{}, step interface{}, server interface{}) *MockWorkspacesAPI_WorkspacesServerLogs_Call { return &MockWorkspacesAPI_WorkspacesServerLogs_Call{Call: _e.mock.On("WorkspacesServerLogs", ctx, workspaceId, step, server)} } func (_c *MockWorkspacesAPI_WorkspacesServerLogs_Call) Run(run func(ctx context.Context, workspaceId float32, step float32, server string)) *MockWorkspacesAPI_WorkspacesServerLogs_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 float32 - if args[2] != nil { - arg2 = args[2].(float32) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - run( - arg0, - arg1, - arg2, - arg3, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(float32), args[3].(string)) }) return _c } @@ -4554,20 +3905,14 @@ type MockWorkspacesAPI_WorkspacesServerLogsExecute_Call struct { } // WorkspacesServerLogsExecute is a helper method to define mock.On call -// - r ApiWorkspacesServerLogsRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesServerLogsExecute(r interface{}) *MockWorkspacesAPI_WorkspacesServerLogsExecute_Call { return &MockWorkspacesAPI_WorkspacesServerLogsExecute_Call{Call: _e.mock.On("WorkspacesServerLogsExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesServerLogsExecute_Call) Run(run func(r ApiWorkspacesServerLogsRequest)) *MockWorkspacesAPI_WorkspacesServerLogsExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesServerLogsRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesServerLogsRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesServerLogsRequest)) }) return _c } @@ -4605,26 +3950,15 @@ type MockWorkspacesAPI_WorkspacesSetEnvVar_Call struct { } // WorkspacesSetEnvVar is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 +// - ctx +// - workspaceId func (_e *MockWorkspacesAPI_Expecter) WorkspacesSetEnvVar(ctx interface{}, workspaceId interface{}) *MockWorkspacesAPI_WorkspacesSetEnvVar_Call { return &MockWorkspacesAPI_WorkspacesSetEnvVar_Call{Call: _e.mock.On("WorkspacesSetEnvVar", ctx, workspaceId)} } func (_c *MockWorkspacesAPI_WorkspacesSetEnvVar_Call) Run(run func(ctx context.Context, workspaceId float32)) *MockWorkspacesAPI_WorkspacesSetEnvVar_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -4673,20 +4007,14 @@ type MockWorkspacesAPI_WorkspacesSetEnvVarExecute_Call struct { } // WorkspacesSetEnvVarExecute is a helper method to define mock.On call -// - r ApiWorkspacesSetEnvVarRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesSetEnvVarExecute(r interface{}) *MockWorkspacesAPI_WorkspacesSetEnvVarExecute_Call { return &MockWorkspacesAPI_WorkspacesSetEnvVarExecute_Call{Call: _e.mock.On("WorkspacesSetEnvVarExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesSetEnvVarExecute_Call) Run(run func(r ApiWorkspacesSetEnvVarRequest)) *MockWorkspacesAPI_WorkspacesSetEnvVarExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesSetEnvVarRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesSetEnvVarRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesSetEnvVarRequest)) }) return _c } @@ -4724,32 +4052,16 @@ type MockWorkspacesAPI_WorkspacesStartPipelineStage_Call struct { } // WorkspacesStartPipelineStage is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 -// - stage string +// - ctx +// - workspaceId +// - stage func (_e *MockWorkspacesAPI_Expecter) WorkspacesStartPipelineStage(ctx interface{}, workspaceId interface{}, stage interface{}) *MockWorkspacesAPI_WorkspacesStartPipelineStage_Call { return &MockWorkspacesAPI_WorkspacesStartPipelineStage_Call{Call: _e.mock.On("WorkspacesStartPipelineStage", ctx, workspaceId, stage)} } func (_c *MockWorkspacesAPI_WorkspacesStartPipelineStage_Call) Run(run func(ctx context.Context, workspaceId float32, stage string)) *MockWorkspacesAPI_WorkspacesStartPipelineStage_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(string)) }) return _c } @@ -4787,38 +4099,17 @@ type MockWorkspacesAPI_WorkspacesStartPipelineStage1_Call struct { } // WorkspacesStartPipelineStage1 is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 -// - stage string -// - profile string +// - ctx +// - workspaceId +// - stage +// - profile func (_e *MockWorkspacesAPI_Expecter) WorkspacesStartPipelineStage1(ctx interface{}, workspaceId interface{}, stage interface{}, profile interface{}) *MockWorkspacesAPI_WorkspacesStartPipelineStage1_Call { return &MockWorkspacesAPI_WorkspacesStartPipelineStage1_Call{Call: _e.mock.On("WorkspacesStartPipelineStage1", ctx, workspaceId, stage, profile)} } func (_c *MockWorkspacesAPI_WorkspacesStartPipelineStage1_Call) Run(run func(ctx context.Context, workspaceId float32, stage string, profile string)) *MockWorkspacesAPI_WorkspacesStartPipelineStage1_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - run( - arg0, - arg1, - arg2, - arg3, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(string), args[3].(string)) }) return _c } @@ -4867,20 +4158,14 @@ type MockWorkspacesAPI_WorkspacesStartPipelineStage1Execute_Call struct { } // WorkspacesStartPipelineStage1Execute is a helper method to define mock.On call -// - r ApiWorkspacesStartPipelineStage1Request +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesStartPipelineStage1Execute(r interface{}) *MockWorkspacesAPI_WorkspacesStartPipelineStage1Execute_Call { return &MockWorkspacesAPI_WorkspacesStartPipelineStage1Execute_Call{Call: _e.mock.On("WorkspacesStartPipelineStage1Execute", r)} } func (_c *MockWorkspacesAPI_WorkspacesStartPipelineStage1Execute_Call) Run(run func(r ApiWorkspacesStartPipelineStage1Request)) *MockWorkspacesAPI_WorkspacesStartPipelineStage1Execute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesStartPipelineStage1Request - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesStartPipelineStage1Request) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesStartPipelineStage1Request)) }) return _c } @@ -4929,20 +4214,14 @@ type MockWorkspacesAPI_WorkspacesStartPipelineStageExecute_Call struct { } // WorkspacesStartPipelineStageExecute is a helper method to define mock.On call -// - r ApiWorkspacesStartPipelineStageRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesStartPipelineStageExecute(r interface{}) *MockWorkspacesAPI_WorkspacesStartPipelineStageExecute_Call { return &MockWorkspacesAPI_WorkspacesStartPipelineStageExecute_Call{Call: _e.mock.On("WorkspacesStartPipelineStageExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesStartPipelineStageExecute_Call) Run(run func(r ApiWorkspacesStartPipelineStageRequest)) *MockWorkspacesAPI_WorkspacesStartPipelineStageExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesStartPipelineStageRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesStartPipelineStageRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesStartPipelineStageRequest)) }) return _c } @@ -4980,32 +4259,16 @@ type MockWorkspacesAPI_WorkspacesStopPipelineStage_Call struct { } // WorkspacesStopPipelineStage is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 -// - stage string +// - ctx +// - workspaceId +// - stage func (_e *MockWorkspacesAPI_Expecter) WorkspacesStopPipelineStage(ctx interface{}, workspaceId interface{}, stage interface{}) *MockWorkspacesAPI_WorkspacesStopPipelineStage_Call { return &MockWorkspacesAPI_WorkspacesStopPipelineStage_Call{Call: _e.mock.On("WorkspacesStopPipelineStage", ctx, workspaceId, stage)} } func (_c *MockWorkspacesAPI_WorkspacesStopPipelineStage_Call) Run(run func(ctx context.Context, workspaceId float32, stage string)) *MockWorkspacesAPI_WorkspacesStopPipelineStage_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(context.Context), args[1].(float32), args[2].(string)) }) return _c } @@ -5054,20 +4317,14 @@ type MockWorkspacesAPI_WorkspacesStopPipelineStageExecute_Call struct { } // WorkspacesStopPipelineStageExecute is a helper method to define mock.On call -// - r ApiWorkspacesStopPipelineStageRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesStopPipelineStageExecute(r interface{}) *MockWorkspacesAPI_WorkspacesStopPipelineStageExecute_Call { return &MockWorkspacesAPI_WorkspacesStopPipelineStageExecute_Call{Call: _e.mock.On("WorkspacesStopPipelineStageExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesStopPipelineStageExecute_Call) Run(run func(r ApiWorkspacesStopPipelineStageRequest)) *MockWorkspacesAPI_WorkspacesStopPipelineStageExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesStopPipelineStageRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesStopPipelineStageRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesStopPipelineStageRequest)) }) return _c } @@ -5105,26 +4362,15 @@ type MockWorkspacesAPI_WorkspacesTeardownLandscape_Call struct { } // WorkspacesTeardownLandscape is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 +// - ctx +// - workspaceId func (_e *MockWorkspacesAPI_Expecter) WorkspacesTeardownLandscape(ctx interface{}, workspaceId interface{}) *MockWorkspacesAPI_WorkspacesTeardownLandscape_Call { return &MockWorkspacesAPI_WorkspacesTeardownLandscape_Call{Call: _e.mock.On("WorkspacesTeardownLandscape", ctx, workspaceId)} } func (_c *MockWorkspacesAPI_WorkspacesTeardownLandscape_Call) Run(run func(ctx context.Context, workspaceId float32)) *MockWorkspacesAPI_WorkspacesTeardownLandscape_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -5173,20 +4419,14 @@ type MockWorkspacesAPI_WorkspacesTeardownLandscapeExecute_Call struct { } // WorkspacesTeardownLandscapeExecute is a helper method to define mock.On call -// - r ApiWorkspacesTeardownLandscapeRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesTeardownLandscapeExecute(r interface{}) *MockWorkspacesAPI_WorkspacesTeardownLandscapeExecute_Call { return &MockWorkspacesAPI_WorkspacesTeardownLandscapeExecute_Call{Call: _e.mock.On("WorkspacesTeardownLandscapeExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesTeardownLandscapeExecute_Call) Run(run func(r ApiWorkspacesTeardownLandscapeRequest)) *MockWorkspacesAPI_WorkspacesTeardownLandscapeExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesTeardownLandscapeRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesTeardownLandscapeRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesTeardownLandscapeRequest)) }) return _c } @@ -5224,26 +4464,15 @@ type MockWorkspacesAPI_WorkspacesUpdateWorkspace_Call struct { } // WorkspacesUpdateWorkspace is a helper method to define mock.On call -// - ctx context.Context -// - workspaceId float32 +// - ctx +// - workspaceId func (_e *MockWorkspacesAPI_Expecter) WorkspacesUpdateWorkspace(ctx interface{}, workspaceId interface{}) *MockWorkspacesAPI_WorkspacesUpdateWorkspace_Call { return &MockWorkspacesAPI_WorkspacesUpdateWorkspace_Call{Call: _e.mock.On("WorkspacesUpdateWorkspace", ctx, workspaceId)} } func (_c *MockWorkspacesAPI_WorkspacesUpdateWorkspace_Call) Run(run func(ctx context.Context, workspaceId float32)) *MockWorkspacesAPI_WorkspacesUpdateWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 float32 - if args[1] != nil { - arg1 = args[1].(float32) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].(float32)) }) return _c } @@ -5292,20 +4521,14 @@ type MockWorkspacesAPI_WorkspacesUpdateWorkspaceExecute_Call struct { } // WorkspacesUpdateWorkspaceExecute is a helper method to define mock.On call -// - r ApiWorkspacesUpdateWorkspaceRequest +// - r func (_e *MockWorkspacesAPI_Expecter) WorkspacesUpdateWorkspaceExecute(r interface{}) *MockWorkspacesAPI_WorkspacesUpdateWorkspaceExecute_Call { return &MockWorkspacesAPI_WorkspacesUpdateWorkspaceExecute_Call{Call: _e.mock.On("WorkspacesUpdateWorkspaceExecute", r)} } func (_c *MockWorkspacesAPI_WorkspacesUpdateWorkspaceExecute_Call) Run(run func(r ApiWorkspacesUpdateWorkspaceRequest)) *MockWorkspacesAPI_WorkspacesUpdateWorkspaceExecute_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 ApiWorkspacesUpdateWorkspaceRequest - if args[0] != nil { - arg0 = args[0].(ApiWorkspacesUpdateWorkspaceRequest) - } - run( - arg0, - ) + run(args[0].(ApiWorkspacesUpdateWorkspaceRequest)) }) return _c } diff --git a/api/workspace.go b/api/workspace.go index 69b2607..64880f1 100644 --- a/api/workspace.go +++ b/api/workspace.go @@ -130,7 +130,6 @@ func (client *Client) WaitForWorkspaceRunning(workspace *Workspace, timeout time status, err := client.WorkspaceStatus(workspace.Id) if err != nil { - // Retry on error (e.g., 404 if workspace not yet registered) until timeout if client.time.Now().After(maxWaitTime) { return errors.FormatAPIError(err) } diff --git a/cli/cmd/client.go b/cli/cmd/client.go index 9705343..bf8ae3a 100644 --- a/cli/cmd/client.go +++ b/cli/cmd/client.go @@ -16,7 +16,6 @@ import ( type Client interface { ListTeams() ([]api.Team, error) - GetTeam(teamId int) (*api.Team, error) ListWorkspaces(teamId int) ([]api.Workspace, error) ListBaseimages() ([]api.Baseimage, error) GetWorkspace(workspaceId int) (api.Workspace, error) diff --git a/cli/cmd/curl.go b/cli/cmd/curl.go index 4c64c7b..29117ad 100644 --- a/cli/cmd/curl.go +++ b/cli/cmd/curl.go @@ -39,10 +39,6 @@ func (c *CurlCmd) RunE(_ *cobra.Command, args []string) error { return fmt.Errorf("failed to get API token: %w", err) } - if len(args) == 0 { - return fmt.Errorf("path is required (e.g., / or /api/endpoint)") - } - path := args[0] curlArgs := args[1:] diff --git a/cli/cmd/mocks.go b/cli/cmd/mocks.go index eb1d4d8..98d3359 100644 --- a/cli/cmd/mocks.go +++ b/cli/cmd/mocks.go @@ -60,20 +60,14 @@ type MockClient_DeleteWorkspace_Call struct { } // DeleteWorkspace is a helper method to define mock.On call -// - wsId int +// - wsId func (_e *MockClient_Expecter) DeleteWorkspace(wsId interface{}) *MockClient_DeleteWorkspace_Call { return &MockClient_DeleteWorkspace_Call{Call: _e.mock.On("DeleteWorkspace", wsId)} } func (_c *MockClient_DeleteWorkspace_Call) Run(run func(wsId int)) *MockClient_DeleteWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - run( - arg0, - ) + run(args[0].(int)) }) return _c } @@ -111,26 +105,15 @@ type MockClient_DeployLandscape_Call struct { } // DeployLandscape is a helper method to define mock.On call -// - wsId int -// - profile string +// - wsId +// - profile func (_e *MockClient_Expecter) DeployLandscape(wsId interface{}, profile interface{}) *MockClient_DeployLandscape_Call { return &MockClient_DeployLandscape_Call{Call: _e.mock.On("DeployLandscape", wsId, profile)} } func (_c *MockClient_DeployLandscape_Call) Run(run func(wsId int, profile string)) *MockClient_DeployLandscape_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) + run(args[0].(int), args[1].(string)) }) return _c } @@ -179,20 +162,14 @@ type MockClient_DeployWorkspace_Call struct { } // DeployWorkspace is a helper method to define mock.On call -// - args api.DeployWorkspaceArgs +// - args func (_e *MockClient_Expecter) DeployWorkspace(args interface{}) *MockClient_DeployWorkspace_Call { return &MockClient_DeployWorkspace_Call{Call: _e.mock.On("DeployWorkspace", args)} } func (_c *MockClient_DeployWorkspace_Call) Run(run func(args api.DeployWorkspaceArgs)) *MockClient_DeployWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 api.DeployWorkspaceArgs - if args[0] != nil { - arg0 = args[0].(api.DeployWorkspaceArgs) - } - run( - arg0, - ) + run(args[0].(api.DeployWorkspaceArgs)) }) return _c } @@ -245,38 +222,17 @@ type MockClient_ExecCommand_Call struct { } // ExecCommand is a helper method to define mock.On call -// - workspaceId int -// - command string -// - workdir string -// - env map[string]string +// - workspaceId +// - command +// - workdir +// - env func (_e *MockClient_Expecter) ExecCommand(workspaceId interface{}, command interface{}, workdir interface{}, env interface{}) *MockClient_ExecCommand_Call { return &MockClient_ExecCommand_Call{Call: _e.mock.On("ExecCommand", workspaceId, command, workdir, env)} } func (_c *MockClient_ExecCommand_Call) Run(run func(workspaceId int, command string, workdir string, env map[string]string)) *MockClient_ExecCommand_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 map[string]string - if args[3] != nil { - arg3 = args[3].(map[string]string) - } - run( - arg0, - arg1, - arg2, - arg3, - ) + run(args[0].(int), args[1].(string), args[2].(string), args[3].(map[string]string)) }) return _c } @@ -325,26 +281,15 @@ type MockClient_GetPipelineState_Call struct { } // GetPipelineState is a helper method to define mock.On call -// - wsId int -// - stage string +// - wsId +// - stage func (_e *MockClient_Expecter) GetPipelineState(wsId interface{}, stage interface{}) *MockClient_GetPipelineState_Call { return &MockClient_GetPipelineState_Call{Call: _e.mock.On("GetPipelineState", wsId, stage)} } func (_c *MockClient_GetPipelineState_Call) Run(run func(wsId int, stage string)) *MockClient_GetPipelineState_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) + run(args[0].(int), args[1].(string)) }) return _c } @@ -359,68 +304,6 @@ func (_c *MockClient_GetPipelineState_Call) RunAndReturn(run func(wsId int, stag return _c } -// GetTeam provides a mock function for the type MockClient -func (_mock *MockClient) GetTeam(teamId int) (*api.Team, error) { - ret := _mock.Called(teamId) - - if len(ret) == 0 { - panic("no return value specified for GetTeam") - } - - var r0 *api.Team - var r1 error - if returnFunc, ok := ret.Get(0).(func(int) (*api.Team, error)); ok { - return returnFunc(teamId) - } - if returnFunc, ok := ret.Get(0).(func(int) *api.Team); ok { - r0 = returnFunc(teamId) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*api.Team) - } - } - if returnFunc, ok := ret.Get(1).(func(int) error); ok { - r1 = returnFunc(teamId) - } else { - r1 = ret.Error(1) - } - return r0, r1 -} - -// MockClient_GetTeam_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTeam' -type MockClient_GetTeam_Call struct { - *mock.Call -} - -// GetTeam is a helper method to define mock.On call -// - teamId int -func (_e *MockClient_Expecter) GetTeam(teamId interface{}) *MockClient_GetTeam_Call { - return &MockClient_GetTeam_Call{Call: _e.mock.On("GetTeam", teamId)} -} - -func (_c *MockClient_GetTeam_Call) Run(run func(teamId int)) *MockClient_GetTeam_Call { - _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - run( - arg0, - ) - }) - return _c -} - -func (_c *MockClient_GetTeam_Call) Return(v *api.Team, err error) *MockClient_GetTeam_Call { - _c.Call.Return(v, err) - return _c -} - -func (_c *MockClient_GetTeam_Call) RunAndReturn(run func(teamId int) (*api.Team, error)) *MockClient_GetTeam_Call { - _c.Call.Return(run) - return _c -} - // GetWorkspace provides a mock function for the type MockClient func (_mock *MockClient) GetWorkspace(workspaceId int) (api.Workspace, error) { ret := _mock.Called(workspaceId) @@ -453,20 +336,14 @@ type MockClient_GetWorkspace_Call struct { } // GetWorkspace is a helper method to define mock.On call -// - workspaceId int +// - workspaceId func (_e *MockClient_Expecter) GetWorkspace(workspaceId interface{}) *MockClient_GetWorkspace_Call { return &MockClient_GetWorkspace_Call{Call: _e.mock.On("GetWorkspace", workspaceId)} } func (_c *MockClient_GetWorkspace_Call) Run(run func(workspaceId int)) *MockClient_GetWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - run( - arg0, - ) + run(args[0].(int)) }) return _c } @@ -504,32 +381,16 @@ type MockClient_GitPull_Call struct { } // GitPull is a helper method to define mock.On call -// - wsId int -// - remote string -// - branch string +// - wsId +// - remote +// - branch func (_e *MockClient_Expecter) GitPull(wsId interface{}, remote interface{}, branch interface{}) *MockClient_GitPull_Call { return &MockClient_GitPull_Call{Call: _e.mock.On("GitPull", wsId, remote, branch)} } func (_c *MockClient_GitPull_Call) Run(run func(wsId int, remote string, branch string)) *MockClient_GitPull_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(int), args[1].(string), args[2].(string)) }) return _c } @@ -743,20 +604,14 @@ type MockClient_ListWorkspaces_Call struct { } // ListWorkspaces is a helper method to define mock.On call -// - teamId int +// - teamId func (_e *MockClient_Expecter) ListWorkspaces(teamId interface{}) *MockClient_ListWorkspaces_Call { return &MockClient_ListWorkspaces_Call{Call: _e.mock.On("ListWorkspaces", teamId)} } func (_c *MockClient_ListWorkspaces_Call) Run(run func(teamId int)) *MockClient_ListWorkspaces_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - run( - arg0, - ) + run(args[0].(int)) }) return _c } @@ -794,26 +649,15 @@ type MockClient_ScaleWorkspace_Call struct { } // ScaleWorkspace is a helper method to define mock.On call -// - wsId int -// - replicas int +// - wsId +// - replicas func (_e *MockClient_Expecter) ScaleWorkspace(wsId interface{}, replicas interface{}) *MockClient_ScaleWorkspace_Call { return &MockClient_ScaleWorkspace_Call{Call: _e.mock.On("ScaleWorkspace", wsId, replicas)} } func (_c *MockClient_ScaleWorkspace_Call) Run(run func(wsId int, replicas int)) *MockClient_ScaleWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - var arg1 int - if args[1] != nil { - arg1 = args[1].(int) - } - run( - arg0, - arg1, - ) + run(args[0].(int), args[1].(int)) }) return _c } @@ -851,26 +695,15 @@ type MockClient_SetEnvVarOnWorkspace_Call struct { } // SetEnvVarOnWorkspace is a helper method to define mock.On call -// - workspaceId int -// - vars map[string]string +// - workspaceId +// - vars func (_e *MockClient_Expecter) SetEnvVarOnWorkspace(workspaceId interface{}, vars interface{}) *MockClient_SetEnvVarOnWorkspace_Call { return &MockClient_SetEnvVarOnWorkspace_Call{Call: _e.mock.On("SetEnvVarOnWorkspace", workspaceId, vars)} } func (_c *MockClient_SetEnvVarOnWorkspace_Call) Run(run func(workspaceId int, vars map[string]string)) *MockClient_SetEnvVarOnWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - var arg1 map[string]string - if args[1] != nil { - arg1 = args[1].(map[string]string) - } - run( - arg0, - arg1, - ) + run(args[0].(int), args[1].(map[string]string)) }) return _c } @@ -908,32 +741,16 @@ type MockClient_StartPipelineStage_Call struct { } // StartPipelineStage is a helper method to define mock.On call -// - wsId int -// - profile string -// - stage string +// - wsId +// - profile +// - stage func (_e *MockClient_Expecter) StartPipelineStage(wsId interface{}, profile interface{}, stage interface{}) *MockClient_StartPipelineStage_Call { return &MockClient_StartPipelineStage_Call{Call: _e.mock.On("StartPipelineStage", wsId, profile, stage)} } func (_c *MockClient_StartPipelineStage_Call) Run(run func(wsId int, profile string, stage string)) *MockClient_StartPipelineStage_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(int), args[1].(string), args[2].(string)) }) return _c } @@ -971,26 +788,15 @@ type MockClient_WaitForWorkspaceRunning_Call struct { } // WaitForWorkspaceRunning is a helper method to define mock.On call -// - workspace *api.Workspace -// - timeout time.Duration +// - workspace +// - timeout func (_e *MockClient_Expecter) WaitForWorkspaceRunning(workspace interface{}, timeout interface{}) *MockClient_WaitForWorkspaceRunning_Call { return &MockClient_WaitForWorkspaceRunning_Call{Call: _e.mock.On("WaitForWorkspaceRunning", workspace, timeout)} } func (_c *MockClient_WaitForWorkspaceRunning_Call) Run(run func(workspace *api.Workspace, timeout time.Duration)) *MockClient_WaitForWorkspaceRunning_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 *api.Workspace - if args[0] != nil { - arg0 = args[0].(*api.Workspace) - } - var arg1 time.Duration - if args[1] != nil { - arg1 = args[1].(time.Duration) - } - run( - arg0, - arg1, - ) + run(args[0].(*api.Workspace), args[1].(time.Duration)) }) return _c } @@ -1039,20 +845,14 @@ type MockClient_WorkspaceStatus_Call struct { } // WorkspaceStatus is a helper method to define mock.On call -// - workspaceId int +// - workspaceId func (_e *MockClient_Expecter) WorkspaceStatus(workspaceId interface{}) *MockClient_WorkspaceStatus_Call { return &MockClient_WorkspaceStatus_Call{Call: _e.mock.On("WorkspaceStatus", workspaceId)} } func (_c *MockClient_WorkspaceStatus_Call) Run(run func(workspaceId int)) *MockClient_WorkspaceStatus_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - run( - arg0, - ) + run(args[0].(int)) }) return _c } @@ -1117,20 +917,14 @@ type MockPrompt_InputPrompt_Call struct { } // InputPrompt is a helper method to define mock.On call -// - prompt string +// - prompt func (_e *MockPrompt_Expecter) InputPrompt(prompt interface{}) *MockPrompt_InputPrompt_Call { return &MockPrompt_InputPrompt_Call{Call: _e.mock.On("InputPrompt", prompt)} } func (_c *MockPrompt_InputPrompt_Call) Run(run func(prompt string)) *MockPrompt_InputPrompt_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) + run(args[0].(string)) }) return _c } @@ -1195,20 +989,14 @@ type MockBrowser_OpenIde_Call struct { } // OpenIde is a helper method to define mock.On call -// - path string +// - path func (_e *MockBrowser_Expecter) OpenIde(path interface{}) *MockBrowser_OpenIde_Call { return &MockBrowser_OpenIde_Call{Call: _e.mock.On("OpenIde", path)} } func (_c *MockBrowser_OpenIde_Call) Run(run func(path string)) *MockBrowser_OpenIde_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) + run(args[0].(string)) }) return _c } diff --git a/int/integration_test.go b/int/integration_test.go index afc0305..06dd65d 100644 --- a/int/integration_test.go +++ b/int/integration_test.go @@ -1026,7 +1026,6 @@ var _ = Describe("Wake Up Workspace Integration Tests", func() { output := intutil.RunCommand( "wake-up", "-w", workspaceId, - "--insecure", ) fmt.Printf("Wake up workspace output: %s\n", output) @@ -1040,7 +1039,6 @@ var _ = Describe("Wake Up Workspace Integration Tests", func() { "wake-up", "-w", workspaceId, "--timeout", "5s", - "--insecure", ) fmt.Printf("Wake up with timeout output: %s (exit code: %d)\n", output, exitCode) @@ -1054,7 +1052,7 @@ var _ = Describe("Wake Up Workspace Integration Tests", func() { defer func() { _ = os.Setenv("CS_WORKSPACE_ID", originalWsId) }() By("Waking up workspace using environment variable") - output := intutil.RunCommand("wake-up", "--insecure") + output := intutil.RunCommand("wake-up") fmt.Printf("Wake up with env var output: %s\n", output) Expect(output).To(ContainSubstring("Waking up workspace")) diff --git a/pkg/exporter/mocks.go b/pkg/exporter/mocks.go index a2febe4..67c0262 100644 --- a/pkg/exporter/mocks.go +++ b/pkg/exporter/mocks.go @@ -104,32 +104,16 @@ type MockExporter_ExportImages_Call struct { } // ExportImages is a helper method to define mock.On call -// - ctx context.Context -// - registry string -// - imagePrefix string +// - ctx +// - registry +// - imagePrefix func (_e *MockExporter_Expecter) ExportImages(ctx interface{}, registry interface{}, imagePrefix interface{}) *MockExporter_ExportImages_Call { return &MockExporter_ExportImages_Call{Call: _e.mock.On("ExportImages", ctx, registry, imagePrefix)} } func (_c *MockExporter_ExportImages_Call) Run(run func(ctx context.Context, registry string, imagePrefix string)) *MockExporter_ExportImages_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(context.Context), args[1].(string), args[2].(string)) }) return _c } @@ -167,50 +151,19 @@ type MockExporter_ExportKubernetesArtifacts_Call struct { } // ExportKubernetesArtifacts is a helper method to define mock.On call -// - registry string -// - image string -// - namespace string -// - pullSecret string -// - hostname string -// - ingressClass string +// - registry +// - image +// - namespace +// - pullSecret +// - hostname +// - ingressClass func (_e *MockExporter_Expecter) ExportKubernetesArtifacts(registry interface{}, image interface{}, namespace interface{}, pullSecret interface{}, hostname interface{}, ingressClass interface{}) *MockExporter_ExportKubernetesArtifacts_Call { return &MockExporter_ExportKubernetesArtifacts_Call{Call: _e.mock.On("ExportKubernetesArtifacts", registry, image, namespace, pullSecret, hostname, ingressClass)} } func (_c *MockExporter_ExportKubernetesArtifacts_Call) Run(run func(registry string, image string, namespace string, pullSecret string, hostname string, ingressClass string)) *MockExporter_ExportKubernetesArtifacts_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - var arg4 string - if args[4] != nil { - arg4 = args[4].(string) - } - var arg5 string - if args[5] != nil { - arg5 = args[5].(string) - } - run( - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - ) + run(args[0].(string), args[1].(string), args[2].(string), args[3].(string), args[4].(string), args[5].(string)) }) return _c } @@ -259,20 +212,14 @@ type MockExporter_ReadYmlFile_Call struct { } // ReadYmlFile is a helper method to define mock.On call -// - path string +// - path func (_e *MockExporter_Expecter) ReadYmlFile(path interface{}) *MockExporter_ReadYmlFile_Call { return &MockExporter_ReadYmlFile_Call{Call: _e.mock.On("ReadYmlFile", path)} } func (_c *MockExporter_ReadYmlFile_Call) Run(run func(path string)) *MockExporter_ReadYmlFile_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) + run(args[0].(string)) }) return _c } diff --git a/pkg/git/mocks.go b/pkg/git/mocks.go index fa2afdb..a3f3c0f 100644 --- a/pkg/git/mocks.go +++ b/pkg/git/mocks.go @@ -71,38 +71,17 @@ type MockGit_CloneRepository_Call struct { } // CloneRepository is a helper method to define mock.On call -// - fs *cs.FileSystem -// - url string -// - branch string -// - path string +// - fs +// - url +// - branch +// - path func (_e *MockGit_Expecter) CloneRepository(fs interface{}, url interface{}, branch interface{}, path interface{}) *MockGit_CloneRepository_Call { return &MockGit_CloneRepository_Call{Call: _e.mock.On("CloneRepository", fs, url, branch, path)} } func (_c *MockGit_CloneRepository_Call) Run(run func(fs *cs.FileSystem, url string, branch string, path string)) *MockGit_CloneRepository_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 *cs.FileSystem - if args[0] != nil { - arg0 = args[0].(*cs.FileSystem) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - run( - arg0, - arg1, - arg2, - arg3, - ) + run(args[0].(*cs.FileSystem), args[1].(string), args[2].(string), args[3].(string)) }) return _c } diff --git a/pkg/io/mocks.go b/pkg/io/mocks.go index 92c93f6..8e26b84 100644 --- a/pkg/io/mocks.go +++ b/pkg/io/mocks.go @@ -69,26 +69,15 @@ type MockExec_ExecuteCommand_Call struct { } // ExecuteCommand is a helper method to define mock.On call -// - ctx context.Context -// - cmdArgs []string +// - ctx +// - cmdArgs func (_e *MockExec_Expecter) ExecuteCommand(ctx interface{}, cmdArgs interface{}) *MockExec_ExecuteCommand_Call { return &MockExec_ExecuteCommand_Call{Call: _e.mock.On("ExecuteCommand", ctx, cmdArgs)} } func (_c *MockExec_ExecuteCommand_Call) Run(run func(ctx context.Context, cmdArgs []string)) *MockExec_ExecuteCommand_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 []string - if args[1] != nil { - arg1 = args[1].([]string) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].([]string)) }) return _c } @@ -142,26 +131,15 @@ type MockHttpServer_Handle_Call struct { } // Handle is a helper method to define mock.On call -// - pattern string -// - handler http.Handler +// - pattern +// - handler func (_e *MockHttpServer_Expecter) Handle(pattern interface{}, handler interface{}) *MockHttpServer_Handle_Call { return &MockHttpServer_Handle_Call{Call: _e.mock.On("Handle", pattern, handler)} } func (_c *MockHttpServer_Handle_Call) Run(run func(pattern string, handler http.Handler)) *MockHttpServer_Handle_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 http.Handler - if args[1] != nil { - arg1 = args[1].(http.Handler) - } - run( - arg0, - arg1, - ) + run(args[0].(string), args[1].(http.Handler)) }) return _c } @@ -188,26 +166,15 @@ type MockHttpServer_HandleFunc_Call struct { } // HandleFunc is a helper method to define mock.On call -// - pattern string -// - handler func(http.ResponseWriter, *http.Request) +// - pattern +// - handler func (_e *MockHttpServer_Expecter) HandleFunc(pattern interface{}, handler interface{}) *MockHttpServer_HandleFunc_Call { return &MockHttpServer_HandleFunc_Call{Call: _e.mock.On("HandleFunc", pattern, handler)} } func (_c *MockHttpServer_HandleFunc_Call) Run(run func(pattern string, handler func(http.ResponseWriter, *http.Request))) *MockHttpServer_HandleFunc_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 func(http.ResponseWriter, *http.Request) - if args[1] != nil { - arg1 = args[1].(func(http.ResponseWriter, *http.Request)) - } - run( - arg0, - arg1, - ) + run(args[0].(string), args[1].(func(http.ResponseWriter, *http.Request))) }) return _c } @@ -245,26 +212,15 @@ type MockHttpServer_ListenAndServe_Call struct { } // ListenAndServe is a helper method to define mock.On call -// - addr string -// - handler http.Handler +// - addr +// - handler func (_e *MockHttpServer_Expecter) ListenAndServe(addr interface{}, handler interface{}) *MockHttpServer_ListenAndServe_Call { return &MockHttpServer_ListenAndServe_Call{Call: _e.mock.On("ListenAndServe", addr, handler)} } func (_c *MockHttpServer_ListenAndServe_Call) Run(run func(addr string, handler http.Handler)) *MockHttpServer_ListenAndServe_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 http.Handler - if args[1] != nil { - arg1 = args[1].(http.Handler) - } - run( - arg0, - arg1, - ) + run(args[0].(string), args[1].(http.Handler)) }) return _c } @@ -291,38 +247,17 @@ type MockHttpServer_Redirect_Call struct { } // Redirect is a helper method to define mock.On call -// - w http.ResponseWriter -// - r *http.Request -// - url string -// - code int +// - w +// - r +// - url +// - code func (_e *MockHttpServer_Expecter) Redirect(w interface{}, r interface{}, url interface{}, code interface{}) *MockHttpServer_Redirect_Call { return &MockHttpServer_Redirect_Call{Call: _e.mock.On("Redirect", w, r, url, code)} } func (_c *MockHttpServer_Redirect_Call) Run(run func(w http.ResponseWriter, r *http.Request, url string, code int)) *MockHttpServer_Redirect_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 http.ResponseWriter - if args[0] != nil { - arg0 = args[0].(http.ResponseWriter) - } - var arg1 *http.Request - if args[1] != nil { - arg1 = args[1].(*http.Request) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 int - if args[3] != nil { - arg3 = args[3].(int) - } - run( - arg0, - arg1, - arg2, - arg3, - ) + run(args[0].(http.ResponseWriter), args[1].(*http.Request), args[2].(string), args[3].(int)) }) return _c } From d03ba6853348a2405c09b25e9f905bc6f073d2c4 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 28 Jan 2026 12:34:09 +0000 Subject: [PATCH 20/25] chore(docs): Auto-update docs and licenses Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> --- api/mocks.go | 10 +- cli/cmd/mocks.go | 234 ++++++++++++++++++++++++++++++++++-------- pkg/exporter/mocks.go | 79 +++++++++++--- pkg/git/mocks.go | 31 +++++- pkg/io/mocks.go | 99 +++++++++++++++--- 5 files changed, 374 insertions(+), 79 deletions(-) diff --git a/api/mocks.go b/api/mocks.go index 5e2084e..05a287a 100644 --- a/api/mocks.go +++ b/api/mocks.go @@ -92,14 +92,20 @@ type MockTime_Sleep_Call struct { } // Sleep is a helper method to define mock.On call -// - duration +// - duration time.Duration func (_e *MockTime_Expecter) Sleep(duration interface{}) *MockTime_Sleep_Call { return &MockTime_Sleep_Call{Call: _e.mock.On("Sleep", duration)} } func (_c *MockTime_Sleep_Call) Run(run func(duration time.Duration)) *MockTime_Sleep_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(time.Duration)) + var arg0 time.Duration + if args[0] != nil { + arg0 = args[0].(time.Duration) + } + run( + arg0, + ) }) return _c } diff --git a/cli/cmd/mocks.go b/cli/cmd/mocks.go index 98d3359..e7ea3bb 100644 --- a/cli/cmd/mocks.go +++ b/cli/cmd/mocks.go @@ -60,14 +60,20 @@ type MockClient_DeleteWorkspace_Call struct { } // DeleteWorkspace is a helper method to define mock.On call -// - wsId +// - wsId int func (_e *MockClient_Expecter) DeleteWorkspace(wsId interface{}) *MockClient_DeleteWorkspace_Call { return &MockClient_DeleteWorkspace_Call{Call: _e.mock.On("DeleteWorkspace", wsId)} } func (_c *MockClient_DeleteWorkspace_Call) Run(run func(wsId int)) *MockClient_DeleteWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + run( + arg0, + ) }) return _c } @@ -105,15 +111,26 @@ type MockClient_DeployLandscape_Call struct { } // DeployLandscape is a helper method to define mock.On call -// - wsId -// - profile +// - wsId int +// - profile string func (_e *MockClient_Expecter) DeployLandscape(wsId interface{}, profile interface{}) *MockClient_DeployLandscape_Call { return &MockClient_DeployLandscape_Call{Call: _e.mock.On("DeployLandscape", wsId, profile)} } func (_c *MockClient_DeployLandscape_Call) Run(run func(wsId int, profile string)) *MockClient_DeployLandscape_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(string)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + run( + arg0, + arg1, + ) }) return _c } @@ -162,14 +179,20 @@ type MockClient_DeployWorkspace_Call struct { } // DeployWorkspace is a helper method to define mock.On call -// - args +// - args api.DeployWorkspaceArgs func (_e *MockClient_Expecter) DeployWorkspace(args interface{}) *MockClient_DeployWorkspace_Call { return &MockClient_DeployWorkspace_Call{Call: _e.mock.On("DeployWorkspace", args)} } func (_c *MockClient_DeployWorkspace_Call) Run(run func(args api.DeployWorkspaceArgs)) *MockClient_DeployWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(api.DeployWorkspaceArgs)) + var arg0 api.DeployWorkspaceArgs + if args[0] != nil { + arg0 = args[0].(api.DeployWorkspaceArgs) + } + run( + arg0, + ) }) return _c } @@ -222,17 +245,38 @@ type MockClient_ExecCommand_Call struct { } // ExecCommand is a helper method to define mock.On call -// - workspaceId -// - command -// - workdir -// - env +// - workspaceId int +// - command string +// - workdir string +// - env map[string]string func (_e *MockClient_Expecter) ExecCommand(workspaceId interface{}, command interface{}, workdir interface{}, env interface{}) *MockClient_ExecCommand_Call { return &MockClient_ExecCommand_Call{Call: _e.mock.On("ExecCommand", workspaceId, command, workdir, env)} } func (_c *MockClient_ExecCommand_Call) Run(run func(workspaceId int, command string, workdir string, env map[string]string)) *MockClient_ExecCommand_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(string), args[2].(string), args[3].(map[string]string)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + var arg3 map[string]string + if args[3] != nil { + arg3 = args[3].(map[string]string) + } + run( + arg0, + arg1, + arg2, + arg3, + ) }) return _c } @@ -281,15 +325,26 @@ type MockClient_GetPipelineState_Call struct { } // GetPipelineState is a helper method to define mock.On call -// - wsId -// - stage +// - wsId int +// - stage string func (_e *MockClient_Expecter) GetPipelineState(wsId interface{}, stage interface{}) *MockClient_GetPipelineState_Call { return &MockClient_GetPipelineState_Call{Call: _e.mock.On("GetPipelineState", wsId, stage)} } func (_c *MockClient_GetPipelineState_Call) Run(run func(wsId int, stage string)) *MockClient_GetPipelineState_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(string)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + run( + arg0, + arg1, + ) }) return _c } @@ -336,14 +391,20 @@ type MockClient_GetWorkspace_Call struct { } // GetWorkspace is a helper method to define mock.On call -// - workspaceId +// - workspaceId int func (_e *MockClient_Expecter) GetWorkspace(workspaceId interface{}) *MockClient_GetWorkspace_Call { return &MockClient_GetWorkspace_Call{Call: _e.mock.On("GetWorkspace", workspaceId)} } func (_c *MockClient_GetWorkspace_Call) Run(run func(workspaceId int)) *MockClient_GetWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + run( + arg0, + ) }) return _c } @@ -381,16 +442,32 @@ type MockClient_GitPull_Call struct { } // GitPull is a helper method to define mock.On call -// - wsId -// - remote -// - branch +// - wsId int +// - remote string +// - branch string func (_e *MockClient_Expecter) GitPull(wsId interface{}, remote interface{}, branch interface{}) *MockClient_GitPull_Call { return &MockClient_GitPull_Call{Call: _e.mock.On("GitPull", wsId, remote, branch)} } func (_c *MockClient_GitPull_Call) Run(run func(wsId int, remote string, branch string)) *MockClient_GitPull_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(string), args[2].(string)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + run( + arg0, + arg1, + arg2, + ) }) return _c } @@ -604,14 +681,20 @@ type MockClient_ListWorkspaces_Call struct { } // ListWorkspaces is a helper method to define mock.On call -// - teamId +// - teamId int func (_e *MockClient_Expecter) ListWorkspaces(teamId interface{}) *MockClient_ListWorkspaces_Call { return &MockClient_ListWorkspaces_Call{Call: _e.mock.On("ListWorkspaces", teamId)} } func (_c *MockClient_ListWorkspaces_Call) Run(run func(teamId int)) *MockClient_ListWorkspaces_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + run( + arg0, + ) }) return _c } @@ -649,15 +732,26 @@ type MockClient_ScaleWorkspace_Call struct { } // ScaleWorkspace is a helper method to define mock.On call -// - wsId -// - replicas +// - wsId int +// - replicas int func (_e *MockClient_Expecter) ScaleWorkspace(wsId interface{}, replicas interface{}) *MockClient_ScaleWorkspace_Call { return &MockClient_ScaleWorkspace_Call{Call: _e.mock.On("ScaleWorkspace", wsId, replicas)} } func (_c *MockClient_ScaleWorkspace_Call) Run(run func(wsId int, replicas int)) *MockClient_ScaleWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(int)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 int + if args[1] != nil { + arg1 = args[1].(int) + } + run( + arg0, + arg1, + ) }) return _c } @@ -695,15 +789,26 @@ type MockClient_SetEnvVarOnWorkspace_Call struct { } // SetEnvVarOnWorkspace is a helper method to define mock.On call -// - workspaceId -// - vars +// - workspaceId int +// - vars map[string]string func (_e *MockClient_Expecter) SetEnvVarOnWorkspace(workspaceId interface{}, vars interface{}) *MockClient_SetEnvVarOnWorkspace_Call { return &MockClient_SetEnvVarOnWorkspace_Call{Call: _e.mock.On("SetEnvVarOnWorkspace", workspaceId, vars)} } func (_c *MockClient_SetEnvVarOnWorkspace_Call) Run(run func(workspaceId int, vars map[string]string)) *MockClient_SetEnvVarOnWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(map[string]string)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 map[string]string + if args[1] != nil { + arg1 = args[1].(map[string]string) + } + run( + arg0, + arg1, + ) }) return _c } @@ -741,16 +846,32 @@ type MockClient_StartPipelineStage_Call struct { } // StartPipelineStage is a helper method to define mock.On call -// - wsId -// - profile -// - stage +// - wsId int +// - profile string +// - stage string func (_e *MockClient_Expecter) StartPipelineStage(wsId interface{}, profile interface{}, stage interface{}) *MockClient_StartPipelineStage_Call { return &MockClient_StartPipelineStage_Call{Call: _e.mock.On("StartPipelineStage", wsId, profile, stage)} } func (_c *MockClient_StartPipelineStage_Call) Run(run func(wsId int, profile string, stage string)) *MockClient_StartPipelineStage_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(string), args[2].(string)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + run( + arg0, + arg1, + arg2, + ) }) return _c } @@ -788,15 +909,26 @@ type MockClient_WaitForWorkspaceRunning_Call struct { } // WaitForWorkspaceRunning is a helper method to define mock.On call -// - workspace -// - timeout +// - workspace *api.Workspace +// - timeout time.Duration func (_e *MockClient_Expecter) WaitForWorkspaceRunning(workspace interface{}, timeout interface{}) *MockClient_WaitForWorkspaceRunning_Call { return &MockClient_WaitForWorkspaceRunning_Call{Call: _e.mock.On("WaitForWorkspaceRunning", workspace, timeout)} } func (_c *MockClient_WaitForWorkspaceRunning_Call) Run(run func(workspace *api.Workspace, timeout time.Duration)) *MockClient_WaitForWorkspaceRunning_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*api.Workspace), args[1].(time.Duration)) + var arg0 *api.Workspace + if args[0] != nil { + arg0 = args[0].(*api.Workspace) + } + var arg1 time.Duration + if args[1] != nil { + arg1 = args[1].(time.Duration) + } + run( + arg0, + arg1, + ) }) return _c } @@ -845,14 +977,20 @@ type MockClient_WorkspaceStatus_Call struct { } // WorkspaceStatus is a helper method to define mock.On call -// - workspaceId +// - workspaceId int func (_e *MockClient_Expecter) WorkspaceStatus(workspaceId interface{}) *MockClient_WorkspaceStatus_Call { return &MockClient_WorkspaceStatus_Call{Call: _e.mock.On("WorkspaceStatus", workspaceId)} } func (_c *MockClient_WorkspaceStatus_Call) Run(run func(workspaceId int)) *MockClient_WorkspaceStatus_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + run( + arg0, + ) }) return _c } @@ -917,14 +1055,20 @@ type MockPrompt_InputPrompt_Call struct { } // InputPrompt is a helper method to define mock.On call -// - prompt +// - prompt string func (_e *MockPrompt_Expecter) InputPrompt(prompt interface{}) *MockPrompt_InputPrompt_Call { return &MockPrompt_InputPrompt_Call{Call: _e.mock.On("InputPrompt", prompt)} } func (_c *MockPrompt_InputPrompt_Call) Run(run func(prompt string)) *MockPrompt_InputPrompt_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + var arg0 string + if args[0] != nil { + arg0 = args[0].(string) + } + run( + arg0, + ) }) return _c } @@ -989,14 +1133,20 @@ type MockBrowser_OpenIde_Call struct { } // OpenIde is a helper method to define mock.On call -// - path +// - path string func (_e *MockBrowser_Expecter) OpenIde(path interface{}) *MockBrowser_OpenIde_Call { return &MockBrowser_OpenIde_Call{Call: _e.mock.On("OpenIde", path)} } func (_c *MockBrowser_OpenIde_Call) Run(run func(path string)) *MockBrowser_OpenIde_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + var arg0 string + if args[0] != nil { + arg0 = args[0].(string) + } + run( + arg0, + ) }) return _c } diff --git a/pkg/exporter/mocks.go b/pkg/exporter/mocks.go index 67c0262..a2febe4 100644 --- a/pkg/exporter/mocks.go +++ b/pkg/exporter/mocks.go @@ -104,16 +104,32 @@ type MockExporter_ExportImages_Call struct { } // ExportImages is a helper method to define mock.On call -// - ctx -// - registry -// - imagePrefix +// - ctx context.Context +// - registry string +// - imagePrefix string func (_e *MockExporter_Expecter) ExportImages(ctx interface{}, registry interface{}, imagePrefix interface{}) *MockExporter_ExportImages_Call { return &MockExporter_ExportImages_Call{Call: _e.mock.On("ExportImages", ctx, registry, imagePrefix)} } func (_c *MockExporter_ExportImages_Call) Run(run func(ctx context.Context, registry string, imagePrefix string)) *MockExporter_ExportImages_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string)) + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + run( + arg0, + arg1, + arg2, + ) }) return _c } @@ -151,19 +167,50 @@ type MockExporter_ExportKubernetesArtifacts_Call struct { } // ExportKubernetesArtifacts is a helper method to define mock.On call -// - registry -// - image -// - namespace -// - pullSecret -// - hostname -// - ingressClass +// - registry string +// - image string +// - namespace string +// - pullSecret string +// - hostname string +// - ingressClass string func (_e *MockExporter_Expecter) ExportKubernetesArtifacts(registry interface{}, image interface{}, namespace interface{}, pullSecret interface{}, hostname interface{}, ingressClass interface{}) *MockExporter_ExportKubernetesArtifacts_Call { return &MockExporter_ExportKubernetesArtifacts_Call{Call: _e.mock.On("ExportKubernetesArtifacts", registry, image, namespace, pullSecret, hostname, ingressClass)} } func (_c *MockExporter_ExportKubernetesArtifacts_Call) Run(run func(registry string, image string, namespace string, pullSecret string, hostname string, ingressClass string)) *MockExporter_ExportKubernetesArtifacts_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(string), args[2].(string), args[3].(string), args[4].(string), args[5].(string)) + var arg0 string + if args[0] != nil { + arg0 = args[0].(string) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + var arg3 string + if args[3] != nil { + arg3 = args[3].(string) + } + var arg4 string + if args[4] != nil { + arg4 = args[4].(string) + } + var arg5 string + if args[5] != nil { + arg5 = args[5].(string) + } + run( + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + ) }) return _c } @@ -212,14 +259,20 @@ type MockExporter_ReadYmlFile_Call struct { } // ReadYmlFile is a helper method to define mock.On call -// - path +// - path string func (_e *MockExporter_Expecter) ReadYmlFile(path interface{}) *MockExporter_ReadYmlFile_Call { return &MockExporter_ReadYmlFile_Call{Call: _e.mock.On("ReadYmlFile", path)} } func (_c *MockExporter_ReadYmlFile_Call) Run(run func(path string)) *MockExporter_ReadYmlFile_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + var arg0 string + if args[0] != nil { + arg0 = args[0].(string) + } + run( + arg0, + ) }) return _c } diff --git a/pkg/git/mocks.go b/pkg/git/mocks.go index a3f3c0f..fa2afdb 100644 --- a/pkg/git/mocks.go +++ b/pkg/git/mocks.go @@ -71,17 +71,38 @@ type MockGit_CloneRepository_Call struct { } // CloneRepository is a helper method to define mock.On call -// - fs -// - url -// - branch -// - path +// - fs *cs.FileSystem +// - url string +// - branch string +// - path string func (_e *MockGit_Expecter) CloneRepository(fs interface{}, url interface{}, branch interface{}, path interface{}) *MockGit_CloneRepository_Call { return &MockGit_CloneRepository_Call{Call: _e.mock.On("CloneRepository", fs, url, branch, path)} } func (_c *MockGit_CloneRepository_Call) Run(run func(fs *cs.FileSystem, url string, branch string, path string)) *MockGit_CloneRepository_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*cs.FileSystem), args[1].(string), args[2].(string), args[3].(string)) + var arg0 *cs.FileSystem + if args[0] != nil { + arg0 = args[0].(*cs.FileSystem) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + var arg3 string + if args[3] != nil { + arg3 = args[3].(string) + } + run( + arg0, + arg1, + arg2, + arg3, + ) }) return _c } diff --git a/pkg/io/mocks.go b/pkg/io/mocks.go index 8e26b84..92c93f6 100644 --- a/pkg/io/mocks.go +++ b/pkg/io/mocks.go @@ -69,15 +69,26 @@ type MockExec_ExecuteCommand_Call struct { } // ExecuteCommand is a helper method to define mock.On call -// - ctx -// - cmdArgs +// - ctx context.Context +// - cmdArgs []string func (_e *MockExec_Expecter) ExecuteCommand(ctx interface{}, cmdArgs interface{}) *MockExec_ExecuteCommand_Call { return &MockExec_ExecuteCommand_Call{Call: _e.mock.On("ExecuteCommand", ctx, cmdArgs)} } func (_c *MockExec_ExecuteCommand_Call) Run(run func(ctx context.Context, cmdArgs []string)) *MockExec_ExecuteCommand_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].([]string)) + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 []string + if args[1] != nil { + arg1 = args[1].([]string) + } + run( + arg0, + arg1, + ) }) return _c } @@ -131,15 +142,26 @@ type MockHttpServer_Handle_Call struct { } // Handle is a helper method to define mock.On call -// - pattern -// - handler +// - pattern string +// - handler http.Handler func (_e *MockHttpServer_Expecter) Handle(pattern interface{}, handler interface{}) *MockHttpServer_Handle_Call { return &MockHttpServer_Handle_Call{Call: _e.mock.On("Handle", pattern, handler)} } func (_c *MockHttpServer_Handle_Call) Run(run func(pattern string, handler http.Handler)) *MockHttpServer_Handle_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(http.Handler)) + var arg0 string + if args[0] != nil { + arg0 = args[0].(string) + } + var arg1 http.Handler + if args[1] != nil { + arg1 = args[1].(http.Handler) + } + run( + arg0, + arg1, + ) }) return _c } @@ -166,15 +188,26 @@ type MockHttpServer_HandleFunc_Call struct { } // HandleFunc is a helper method to define mock.On call -// - pattern -// - handler +// - pattern string +// - handler func(http.ResponseWriter, *http.Request) func (_e *MockHttpServer_Expecter) HandleFunc(pattern interface{}, handler interface{}) *MockHttpServer_HandleFunc_Call { return &MockHttpServer_HandleFunc_Call{Call: _e.mock.On("HandleFunc", pattern, handler)} } func (_c *MockHttpServer_HandleFunc_Call) Run(run func(pattern string, handler func(http.ResponseWriter, *http.Request))) *MockHttpServer_HandleFunc_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(func(http.ResponseWriter, *http.Request))) + var arg0 string + if args[0] != nil { + arg0 = args[0].(string) + } + var arg1 func(http.ResponseWriter, *http.Request) + if args[1] != nil { + arg1 = args[1].(func(http.ResponseWriter, *http.Request)) + } + run( + arg0, + arg1, + ) }) return _c } @@ -212,15 +245,26 @@ type MockHttpServer_ListenAndServe_Call struct { } // ListenAndServe is a helper method to define mock.On call -// - addr -// - handler +// - addr string +// - handler http.Handler func (_e *MockHttpServer_Expecter) ListenAndServe(addr interface{}, handler interface{}) *MockHttpServer_ListenAndServe_Call { return &MockHttpServer_ListenAndServe_Call{Call: _e.mock.On("ListenAndServe", addr, handler)} } func (_c *MockHttpServer_ListenAndServe_Call) Run(run func(addr string, handler http.Handler)) *MockHttpServer_ListenAndServe_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(http.Handler)) + var arg0 string + if args[0] != nil { + arg0 = args[0].(string) + } + var arg1 http.Handler + if args[1] != nil { + arg1 = args[1].(http.Handler) + } + run( + arg0, + arg1, + ) }) return _c } @@ -247,17 +291,38 @@ type MockHttpServer_Redirect_Call struct { } // Redirect is a helper method to define mock.On call -// - w -// - r -// - url -// - code +// - w http.ResponseWriter +// - r *http.Request +// - url string +// - code int func (_e *MockHttpServer_Expecter) Redirect(w interface{}, r interface{}, url interface{}, code interface{}) *MockHttpServer_Redirect_Call { return &MockHttpServer_Redirect_Call{Call: _e.mock.On("Redirect", w, r, url, code)} } func (_c *MockHttpServer_Redirect_Call) Run(run func(w http.ResponseWriter, r *http.Request, url string, code int)) *MockHttpServer_Redirect_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(http.ResponseWriter), args[1].(*http.Request), args[2].(string), args[3].(int)) + var arg0 http.ResponseWriter + if args[0] != nil { + arg0 = args[0].(http.ResponseWriter) + } + var arg1 *http.Request + if args[1] != nil { + arg1 = args[1].(*http.Request) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + var arg3 int + if args[3] != nil { + arg3 = args[3].(int) + } + run( + arg0, + arg1, + arg2, + arg3, + ) }) return _c } From 12bdf290234b2182288bb720e02e69dae0f60b97 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 28 Jan 2026 14:07:59 +0100 Subject: [PATCH 21/25] fix: integration test --- int/integration_test.go | 19 ++++++++++++++++--- int/util/workspace.go | 4 ++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/int/integration_test.go b/int/integration_test.go index 06dd65d..9e62703 100644 --- a/int/integration_test.go +++ b/int/integration_test.go @@ -1029,7 +1029,11 @@ var _ = Describe("Wake Up Workspace Integration Tests", func() { ) fmt.Printf("Wake up workspace output: %s\n", output) - Expect(output).To(ContainSubstring("Waking up workspace")) + Expect(output).To(Or( + ContainSubstring("Waking up workspace"), + // The workspace might already be running + ContainSubstring("is already running"), + )) Expect(output).To(ContainSubstring(workspaceId)) }) @@ -1042,7 +1046,12 @@ var _ = Describe("Wake Up Workspace Integration Tests", func() { ) fmt.Printf("Wake up with timeout output: %s (exit code: %d)\n", output, exitCode) - Expect(output).To(ContainSubstring("Waking up workspace")) + Expect(output).To(Or( + ContainSubstring("Waking up workspace"), + // The workspace might already be running + ContainSubstring("is already running"), + )) + Expect(exitCode).To(Equal(0)) }) It("should work with workspace ID from environment variable", func() { @@ -1055,7 +1064,11 @@ var _ = Describe("Wake Up Workspace Integration Tests", func() { output := intutil.RunCommand("wake-up") fmt.Printf("Wake up with env var output: %s\n", output) - Expect(output).To(ContainSubstring("Waking up workspace")) + Expect(output).To(Or( + ContainSubstring("Waking up workspace"), + // The workspace might already be running + ContainSubstring("is already running"), + )) Expect(output).To(ContainSubstring(workspaceId)) }) }) diff --git a/int/util/workspace.go b/int/util/workspace.go index 2877271..ca27880 100644 --- a/int/util/workspace.go +++ b/int/util/workspace.go @@ -92,6 +92,10 @@ func WaitForWorkspaceRunning(client *api.Client, workspaceId int, timeout time.D return client.WaitForWorkspaceRunning(&api.Workspace{Id: workspaceId}, timeout) } +func ScaleWorkspace(client *api.Client, workspaceId int, replicas int) error { + return client.ScaleWorkspace(workspaceId, replicas) +} + func VerifyWorkspaceExists(workspaceId, teamId string) bool { output := RunCommand("list", "workspaces", "-t", teamId) return strings.Contains(output, workspaceId) From 401eb633a31e70b71256074f7ec189f0f55a064b Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 28 Jan 2026 14:44:33 +0100 Subject: [PATCH 22/25] Update api/workspace.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- api/workspace.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/workspace.go b/api/workspace.go index 64880f1..2ec8ef1 100644 --- a/api/workspace.go +++ b/api/workspace.go @@ -109,7 +109,7 @@ func (c *Client) GetPipelineState(wsId int, stage string) ([]PipelineStatus, err } // ScaleWorkspace sets the number of replicas for a workspace. -// For on-demand workspaces, setting replicas to 1 wakes up the workspace, +// For on-demand workspaces, setting replicas to 1 wakes up the workspace. func (c *Client) ScaleWorkspace(wsId int, replicas int) error { req := c.api.WorkspacesAPI.WorkspacesUpdateWorkspace(c.ctx, float32(wsId)). WorkspacesUpdateWorkspaceRequest(openapi_client.WorkspacesUpdateWorkspaceRequest{ From ca57a7cb5ff58a4385a91fccdec6cb26757bcd20 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 28 Jan 2026 14:52:17 +0100 Subject: [PATCH 23/25] ref: curl tests --- api/mocks.go | 10 +- cli/cmd/client.go | 6 + cli/cmd/curl.go | 25 ++-- cli/cmd/curl_test.go | 131 ++++++++++++++++-- cli/cmd/mocks.go | 312 ++++++++++++++++-------------------------- pkg/exporter/mocks.go | 79 ++--------- pkg/git/mocks.go | 31 +---- pkg/io/mocks.go | 99 +++----------- 8 files changed, 301 insertions(+), 392 deletions(-) diff --git a/api/mocks.go b/api/mocks.go index 05a287a..5e2084e 100644 --- a/api/mocks.go +++ b/api/mocks.go @@ -92,20 +92,14 @@ type MockTime_Sleep_Call struct { } // Sleep is a helper method to define mock.On call -// - duration time.Duration +// - duration func (_e *MockTime_Expecter) Sleep(duration interface{}) *MockTime_Sleep_Call { return &MockTime_Sleep_Call{Call: _e.mock.On("Sleep", duration)} } func (_c *MockTime_Sleep_Call) Run(run func(duration time.Duration)) *MockTime_Sleep_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 time.Duration - if args[0] != nil { - arg0 = args[0].(time.Duration) - } - run( - arg0, - ) + run(args[0].(time.Duration)) }) return _c } diff --git a/cli/cmd/client.go b/cli/cmd/client.go index bf8ae3a..4c33402 100644 --- a/cli/cmd/client.go +++ b/cli/cmd/client.go @@ -8,6 +8,7 @@ package cmd import ( "context" "fmt" + "io" "net/url" "time" @@ -33,6 +34,11 @@ type Client interface { DeployLandscape(wsId int, profile string) error } +// CommandExecutor abstracts command execution for testing +type CommandExecutor interface { + Execute(ctx context.Context, name string, args []string, stdout, stderr io.Writer) error +} + func NewClient(opts GlobalOptions) (Client, error) { token, err := opts.Env.GetApiToken() if err != nil { diff --git a/cli/cmd/curl.go b/cli/cmd/curl.go index 29117ad..72c3318 100644 --- a/cli/cmd/curl.go +++ b/cli/cmd/curl.go @@ -6,21 +6,33 @@ package cmd import ( "context" "fmt" + "io" "os" "os/exec" "strings" "time" - "github.com/codesphere-cloud/cs-go/pkg/io" + io_pkg "github.com/codesphere-cloud/cs-go/pkg/io" "github.com/spf13/cobra" ) +// DefaultCommandExecutor uses os/exec to run commands +type DefaultCommandExecutor struct{} + +func (e *DefaultCommandExecutor) Execute(ctx context.Context, name string, args []string, stdout, stderr io.Writer) error { + cmd := exec.CommandContext(ctx, name, args...) + cmd.Stdout = stdout + cmd.Stderr = stderr + return cmd.Run() +} + type CurlCmd struct { cmd *cobra.Command Opts GlobalOptions Port *int Timeout *time.Duration Insecure bool + Executor CommandExecutor // Injectable for testing } func (c *CurlCmd) RunE(_ *cobra.Command, args []string) error { @@ -51,7 +63,7 @@ func AddCurlCmd(rootCmd *cobra.Command, opts GlobalOptions) { Use: "curl [path] [-- curl-args...]", Short: "Send authenticated HTTP requests to workspace dev domain", Long: `Send authenticated HTTP requests to a workspace's development domain using curl-like syntax.`, - Example: io.FormatExampleCommands("curl", []io.Example{ + Example: io_pkg.FormatExampleCommands("curl", []io_pkg.Example{ {Cmd: "/ -w 1234", Desc: "GET request to workspace root"}, {Cmd: "/api/health -w 1234 -p 3001", Desc: "GET request to port 3001"}, {Cmd: "/api/data -w 1234 -- -XPOST -d '{\"key\":\"value\"}'", Desc: "POST request with data"}, @@ -60,7 +72,8 @@ func AddCurlCmd(rootCmd *cobra.Command, opts GlobalOptions) { }), Args: cobra.MinimumNArgs(1), }, - Opts: opts, + Opts: opts, + Executor: &DefaultCommandExecutor{}, } curl.Port = curl.cmd.Flags().IntP("port", "p", 3000, "Port to connect to") curl.Timeout = curl.cmd.Flags().DurationP("timeout", "", 30*time.Second, "Timeout for the request") @@ -124,11 +137,7 @@ func (c *CurlCmd) CurlWorkspace(client Client, wsId int, token string, path stri cmdArgs = append(cmdArgs, url) // Execute curl command - cmd := exec.CommandContext(ctx, cmdArgs[0], cmdArgs[1:]...) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - err = cmd.Run() + err = c.Executor.Execute(ctx, cmdArgs[0], cmdArgs[1:], os.Stdout, os.Stderr) if err != nil { if ctx.Err() == context.DeadlineExceeded { return fmt.Errorf("timeout exceeded while requesting workspace %d", wsId) diff --git a/cli/cmd/curl_test.go b/cli/cmd/curl_test.go index 448dfa9..b7af8a4 100644 --- a/cli/cmd/curl_test.go +++ b/cli/cmd/curl_test.go @@ -8,6 +8,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/stretchr/testify/mock" "github.com/codesphere-cloud/cs-go/api" "github.com/codesphere-cloud/cs-go/cli/cmd" @@ -15,18 +16,20 @@ import ( var _ = Describe("Curl", func() { var ( - mockEnv *cmd.MockEnv - mockClient *cmd.MockClient - c *cmd.CurlCmd - wsId int - teamId int - token string - port int + mockEnv *cmd.MockEnv + mockClient *cmd.MockClient + mockExecutor *cmd.MockCommandExecutor + c *cmd.CurlCmd + wsId int + teamId int + token string + port int ) JustBeforeEach(func() { mockClient = cmd.NewMockClient(GinkgoT()) mockEnv = cmd.NewMockEnv(GinkgoT()) + mockExecutor = cmd.NewMockCommandExecutor(GinkgoT()) wsId = 42 teamId = 21 token = "test-api-token" @@ -36,7 +39,8 @@ var _ = Describe("Curl", func() { Env: mockEnv, WorkspaceId: &wsId, }, - Port: &port, + Port: &port, + Executor: mockExecutor, } }) @@ -51,10 +55,33 @@ var _ = Describe("Curl", func() { } mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) + mockExecutor.EXPECT().Execute( + mock.Anything, + "curl", + mock.MatchedBy(func(args []string) bool { + // Verify the args contain the expected header, flag, and URL + hasHeader := false + hasFlag := false + hasURL := false + for i, arg := range args { + if arg == "-H" && i+1 < len(args) && args[i+1] == fmt.Sprintf("x-forward-security: %s", token) { + hasHeader = true + } + if arg == "-I" { + hasFlag = true + } + if arg == "https://42-3000.dev.5.codesphere.com/api/health" { + hasURL = true + } + } + return hasHeader && hasFlag && hasURL + }), + mock.Anything, + mock.Anything, + ).Return(nil) err := c.CurlWorkspace(mockClient, wsId, token, "/api/health", []string{"-I"}) - // Should succeed since curl can make the request Expect(err).ToNot(HaveOccurred()) }) @@ -70,10 +97,70 @@ var _ = Describe("Curl", func() { } mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) + mockExecutor.EXPECT().Execute( + mock.Anything, + "curl", + mock.MatchedBy(func(args []string) bool { + // Verify the URL contains the custom port + hasHeader := false + hasURL := false + for i, arg := range args { + if arg == "-H" && i+1 < len(args) && args[i+1] == fmt.Sprintf("x-forward-security: %s", token) { + hasHeader = true + } + if arg == "https://42-3001.dev.5.codesphere.com/custom/path" { + hasURL = true + } + } + return hasHeader && hasURL + }), + mock.Anything, + mock.Anything, + ).Return(nil) err := c.CurlWorkspace(mockClient, wsId, token, "/custom/path", []string{}) - // Should succeed since curl can make the request + Expect(err).ToNot(HaveOccurred()) + }) + + It("should pass insecure flag when specified", func() { + c.Insecure = true + devDomain := "42-3000.dev.5.codesphere.com" + workspace := api.Workspace{ + Id: wsId, + TeamId: teamId, + Name: "test-workspace", + DevDomain: &devDomain, + } + + mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) + mockExecutor.EXPECT().Execute( + mock.Anything, + "curl", + mock.MatchedBy(func(args []string) bool { + // Verify the insecure flag is present + hasInsecure := false + hasHeader := false + hasURL := false + for i, arg := range args { + if arg == "-k" { + hasInsecure = true + } + if arg == "-H" && i+1 < len(args) && args[i+1] == fmt.Sprintf("x-forward-security: %s", token) { + hasHeader = true + } + if arg == "https://42-3000.dev.5.codesphere.com/" { + hasURL = true + } + } + return hasInsecure && hasHeader && hasURL + }), + mock.Anything, + mock.Anything, + ).Return(nil) + + err := c.CurlWorkspace(mockClient, wsId, token, "/", []string{}) + Expect(err).ToNot(HaveOccurred()) }) @@ -101,5 +188,29 @@ var _ = Describe("Curl", func() { Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("failed to get workspace")) }) + + It("should return error if command execution fails", func() { + devDomain := "42-3000.dev.5.codesphere.com" + workspace := api.Workspace{ + Id: wsId, + TeamId: teamId, + Name: "test-workspace", + DevDomain: &devDomain, + } + + mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) + mockExecutor.EXPECT().Execute( + mock.Anything, + mock.Anything, + mock.Anything, + mock.Anything, + mock.Anything, + ).Return(fmt.Errorf("command failed")) + + err := c.CurlWorkspace(mockClient, wsId, token, "/", []string{}) + + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("curl command failed")) + }) }) }) diff --git a/cli/cmd/mocks.go b/cli/cmd/mocks.go index e7ea3bb..83945b2 100644 --- a/cli/cmd/mocks.go +++ b/cli/cmd/mocks.go @@ -5,8 +5,10 @@ package cmd import ( + "context" "github.com/codesphere-cloud/cs-go/api" mock "github.com/stretchr/testify/mock" + "io" "time" ) @@ -60,20 +62,14 @@ type MockClient_DeleteWorkspace_Call struct { } // DeleteWorkspace is a helper method to define mock.On call -// - wsId int +// - wsId func (_e *MockClient_Expecter) DeleteWorkspace(wsId interface{}) *MockClient_DeleteWorkspace_Call { return &MockClient_DeleteWorkspace_Call{Call: _e.mock.On("DeleteWorkspace", wsId)} } func (_c *MockClient_DeleteWorkspace_Call) Run(run func(wsId int)) *MockClient_DeleteWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - run( - arg0, - ) + run(args[0].(int)) }) return _c } @@ -111,26 +107,15 @@ type MockClient_DeployLandscape_Call struct { } // DeployLandscape is a helper method to define mock.On call -// - wsId int -// - profile string +// - wsId +// - profile func (_e *MockClient_Expecter) DeployLandscape(wsId interface{}, profile interface{}) *MockClient_DeployLandscape_Call { return &MockClient_DeployLandscape_Call{Call: _e.mock.On("DeployLandscape", wsId, profile)} } func (_c *MockClient_DeployLandscape_Call) Run(run func(wsId int, profile string)) *MockClient_DeployLandscape_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) + run(args[0].(int), args[1].(string)) }) return _c } @@ -179,20 +164,14 @@ type MockClient_DeployWorkspace_Call struct { } // DeployWorkspace is a helper method to define mock.On call -// - args api.DeployWorkspaceArgs +// - args func (_e *MockClient_Expecter) DeployWorkspace(args interface{}) *MockClient_DeployWorkspace_Call { return &MockClient_DeployWorkspace_Call{Call: _e.mock.On("DeployWorkspace", args)} } func (_c *MockClient_DeployWorkspace_Call) Run(run func(args api.DeployWorkspaceArgs)) *MockClient_DeployWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 api.DeployWorkspaceArgs - if args[0] != nil { - arg0 = args[0].(api.DeployWorkspaceArgs) - } - run( - arg0, - ) + run(args[0].(api.DeployWorkspaceArgs)) }) return _c } @@ -245,38 +224,17 @@ type MockClient_ExecCommand_Call struct { } // ExecCommand is a helper method to define mock.On call -// - workspaceId int -// - command string -// - workdir string -// - env map[string]string +// - workspaceId +// - command +// - workdir +// - env func (_e *MockClient_Expecter) ExecCommand(workspaceId interface{}, command interface{}, workdir interface{}, env interface{}) *MockClient_ExecCommand_Call { return &MockClient_ExecCommand_Call{Call: _e.mock.On("ExecCommand", workspaceId, command, workdir, env)} } func (_c *MockClient_ExecCommand_Call) Run(run func(workspaceId int, command string, workdir string, env map[string]string)) *MockClient_ExecCommand_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 map[string]string - if args[3] != nil { - arg3 = args[3].(map[string]string) - } - run( - arg0, - arg1, - arg2, - arg3, - ) + run(args[0].(int), args[1].(string), args[2].(string), args[3].(map[string]string)) }) return _c } @@ -325,26 +283,15 @@ type MockClient_GetPipelineState_Call struct { } // GetPipelineState is a helper method to define mock.On call -// - wsId int -// - stage string +// - wsId +// - stage func (_e *MockClient_Expecter) GetPipelineState(wsId interface{}, stage interface{}) *MockClient_GetPipelineState_Call { return &MockClient_GetPipelineState_Call{Call: _e.mock.On("GetPipelineState", wsId, stage)} } func (_c *MockClient_GetPipelineState_Call) Run(run func(wsId int, stage string)) *MockClient_GetPipelineState_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - run( - arg0, - arg1, - ) + run(args[0].(int), args[1].(string)) }) return _c } @@ -391,20 +338,14 @@ type MockClient_GetWorkspace_Call struct { } // GetWorkspace is a helper method to define mock.On call -// - workspaceId int +// - workspaceId func (_e *MockClient_Expecter) GetWorkspace(workspaceId interface{}) *MockClient_GetWorkspace_Call { return &MockClient_GetWorkspace_Call{Call: _e.mock.On("GetWorkspace", workspaceId)} } func (_c *MockClient_GetWorkspace_Call) Run(run func(workspaceId int)) *MockClient_GetWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - run( - arg0, - ) + run(args[0].(int)) }) return _c } @@ -442,32 +383,16 @@ type MockClient_GitPull_Call struct { } // GitPull is a helper method to define mock.On call -// - wsId int -// - remote string -// - branch string +// - wsId +// - remote +// - branch func (_e *MockClient_Expecter) GitPull(wsId interface{}, remote interface{}, branch interface{}) *MockClient_GitPull_Call { return &MockClient_GitPull_Call{Call: _e.mock.On("GitPull", wsId, remote, branch)} } func (_c *MockClient_GitPull_Call) Run(run func(wsId int, remote string, branch string)) *MockClient_GitPull_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(int), args[1].(string), args[2].(string)) }) return _c } @@ -681,20 +606,14 @@ type MockClient_ListWorkspaces_Call struct { } // ListWorkspaces is a helper method to define mock.On call -// - teamId int +// - teamId func (_e *MockClient_Expecter) ListWorkspaces(teamId interface{}) *MockClient_ListWorkspaces_Call { return &MockClient_ListWorkspaces_Call{Call: _e.mock.On("ListWorkspaces", teamId)} } func (_c *MockClient_ListWorkspaces_Call) Run(run func(teamId int)) *MockClient_ListWorkspaces_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - run( - arg0, - ) + run(args[0].(int)) }) return _c } @@ -732,26 +651,15 @@ type MockClient_ScaleWorkspace_Call struct { } // ScaleWorkspace is a helper method to define mock.On call -// - wsId int -// - replicas int +// - wsId +// - replicas func (_e *MockClient_Expecter) ScaleWorkspace(wsId interface{}, replicas interface{}) *MockClient_ScaleWorkspace_Call { return &MockClient_ScaleWorkspace_Call{Call: _e.mock.On("ScaleWorkspace", wsId, replicas)} } func (_c *MockClient_ScaleWorkspace_Call) Run(run func(wsId int, replicas int)) *MockClient_ScaleWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - var arg1 int - if args[1] != nil { - arg1 = args[1].(int) - } - run( - arg0, - arg1, - ) + run(args[0].(int), args[1].(int)) }) return _c } @@ -789,26 +697,15 @@ type MockClient_SetEnvVarOnWorkspace_Call struct { } // SetEnvVarOnWorkspace is a helper method to define mock.On call -// - workspaceId int -// - vars map[string]string +// - workspaceId +// - vars func (_e *MockClient_Expecter) SetEnvVarOnWorkspace(workspaceId interface{}, vars interface{}) *MockClient_SetEnvVarOnWorkspace_Call { return &MockClient_SetEnvVarOnWorkspace_Call{Call: _e.mock.On("SetEnvVarOnWorkspace", workspaceId, vars)} } func (_c *MockClient_SetEnvVarOnWorkspace_Call) Run(run func(workspaceId int, vars map[string]string)) *MockClient_SetEnvVarOnWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - var arg1 map[string]string - if args[1] != nil { - arg1 = args[1].(map[string]string) - } - run( - arg0, - arg1, - ) + run(args[0].(int), args[1].(map[string]string)) }) return _c } @@ -846,32 +743,16 @@ type MockClient_StartPipelineStage_Call struct { } // StartPipelineStage is a helper method to define mock.On call -// - wsId int -// - profile string -// - stage string +// - wsId +// - profile +// - stage func (_e *MockClient_Expecter) StartPipelineStage(wsId interface{}, profile interface{}, stage interface{}) *MockClient_StartPipelineStage_Call { return &MockClient_StartPipelineStage_Call{Call: _e.mock.On("StartPipelineStage", wsId, profile, stage)} } func (_c *MockClient_StartPipelineStage_Call) Run(run func(wsId int, profile string, stage string)) *MockClient_StartPipelineStage_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(int), args[1].(string), args[2].(string)) }) return _c } @@ -909,26 +790,15 @@ type MockClient_WaitForWorkspaceRunning_Call struct { } // WaitForWorkspaceRunning is a helper method to define mock.On call -// - workspace *api.Workspace -// - timeout time.Duration +// - workspace +// - timeout func (_e *MockClient_Expecter) WaitForWorkspaceRunning(workspace interface{}, timeout interface{}) *MockClient_WaitForWorkspaceRunning_Call { return &MockClient_WaitForWorkspaceRunning_Call{Call: _e.mock.On("WaitForWorkspaceRunning", workspace, timeout)} } func (_c *MockClient_WaitForWorkspaceRunning_Call) Run(run func(workspace *api.Workspace, timeout time.Duration)) *MockClient_WaitForWorkspaceRunning_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 *api.Workspace - if args[0] != nil { - arg0 = args[0].(*api.Workspace) - } - var arg1 time.Duration - if args[1] != nil { - arg1 = args[1].(time.Duration) - } - run( - arg0, - arg1, - ) + run(args[0].(*api.Workspace), args[1].(time.Duration)) }) return _c } @@ -977,20 +847,14 @@ type MockClient_WorkspaceStatus_Call struct { } // WorkspaceStatus is a helper method to define mock.On call -// - workspaceId int +// - workspaceId func (_e *MockClient_Expecter) WorkspaceStatus(workspaceId interface{}) *MockClient_WorkspaceStatus_Call { return &MockClient_WorkspaceStatus_Call{Call: _e.mock.On("WorkspaceStatus", workspaceId)} } func (_c *MockClient_WorkspaceStatus_Call) Run(run func(workspaceId int)) *MockClient_WorkspaceStatus_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 int - if args[0] != nil { - arg0 = args[0].(int) - } - run( - arg0, - ) + run(args[0].(int)) }) return _c } @@ -1005,6 +869,82 @@ func (_c *MockClient_WorkspaceStatus_Call) RunAndReturn(run func(workspaceId int return _c } +// NewMockCommandExecutor creates a new instance of MockCommandExecutor. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockCommandExecutor(t interface { + mock.TestingT + Cleanup(func()) +}) *MockCommandExecutor { + mock := &MockCommandExecutor{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} + +// MockCommandExecutor is an autogenerated mock type for the CommandExecutor type +type MockCommandExecutor struct { + mock.Mock +} + +type MockCommandExecutor_Expecter struct { + mock *mock.Mock +} + +func (_m *MockCommandExecutor) EXPECT() *MockCommandExecutor_Expecter { + return &MockCommandExecutor_Expecter{mock: &_m.Mock} +} + +// Execute provides a mock function for the type MockCommandExecutor +func (_mock *MockCommandExecutor) Execute(ctx context.Context, name string, args []string, stdout io.Writer, stderr io.Writer) error { + ret := _mock.Called(ctx, name, args, stdout, stderr) + + if len(ret) == 0 { + panic("no return value specified for Execute") + } + + var r0 error + if returnFunc, ok := ret.Get(0).(func(context.Context, string, []string, io.Writer, io.Writer) error); ok { + r0 = returnFunc(ctx, name, args, stdout, stderr) + } else { + r0 = ret.Error(0) + } + return r0 +} + +// MockCommandExecutor_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' +type MockCommandExecutor_Execute_Call struct { + *mock.Call +} + +// Execute is a helper method to define mock.On call +// - ctx +// - name +// - args +// - stdout +// - stderr +func (_e *MockCommandExecutor_Expecter) Execute(ctx interface{}, name interface{}, args interface{}, stdout interface{}, stderr interface{}) *MockCommandExecutor_Execute_Call { + return &MockCommandExecutor_Execute_Call{Call: _e.mock.On("Execute", ctx, name, args, stdout, stderr)} +} + +func (_c *MockCommandExecutor_Execute_Call) Run(run func(ctx context.Context, name string, args []string, stdout io.Writer, stderr io.Writer)) *MockCommandExecutor_Execute_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].([]string), args[3].(io.Writer), args[4].(io.Writer)) + }) + return _c +} + +func (_c *MockCommandExecutor_Execute_Call) Return(err error) *MockCommandExecutor_Execute_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockCommandExecutor_Execute_Call) RunAndReturn(run func(ctx context.Context, name string, args []string, stdout io.Writer, stderr io.Writer) error) *MockCommandExecutor_Execute_Call { + _c.Call.Return(run) + return _c +} + // NewMockPrompt creates a new instance of MockPrompt. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewMockPrompt(t interface { @@ -1055,20 +995,14 @@ type MockPrompt_InputPrompt_Call struct { } // InputPrompt is a helper method to define mock.On call -// - prompt string +// - prompt func (_e *MockPrompt_Expecter) InputPrompt(prompt interface{}) *MockPrompt_InputPrompt_Call { return &MockPrompt_InputPrompt_Call{Call: _e.mock.On("InputPrompt", prompt)} } func (_c *MockPrompt_InputPrompt_Call) Run(run func(prompt string)) *MockPrompt_InputPrompt_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) + run(args[0].(string)) }) return _c } @@ -1133,20 +1067,14 @@ type MockBrowser_OpenIde_Call struct { } // OpenIde is a helper method to define mock.On call -// - path string +// - path func (_e *MockBrowser_Expecter) OpenIde(path interface{}) *MockBrowser_OpenIde_Call { return &MockBrowser_OpenIde_Call{Call: _e.mock.On("OpenIde", path)} } func (_c *MockBrowser_OpenIde_Call) Run(run func(path string)) *MockBrowser_OpenIde_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) + run(args[0].(string)) }) return _c } diff --git a/pkg/exporter/mocks.go b/pkg/exporter/mocks.go index a2febe4..67c0262 100644 --- a/pkg/exporter/mocks.go +++ b/pkg/exporter/mocks.go @@ -104,32 +104,16 @@ type MockExporter_ExportImages_Call struct { } // ExportImages is a helper method to define mock.On call -// - ctx context.Context -// - registry string -// - imagePrefix string +// - ctx +// - registry +// - imagePrefix func (_e *MockExporter_Expecter) ExportImages(ctx interface{}, registry interface{}, imagePrefix interface{}) *MockExporter_ExportImages_Call { return &MockExporter_ExportImages_Call{Call: _e.mock.On("ExportImages", ctx, registry, imagePrefix)} } func (_c *MockExporter_ExportImages_Call) Run(run func(ctx context.Context, registry string, imagePrefix string)) *MockExporter_ExportImages_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - run( - arg0, - arg1, - arg2, - ) + run(args[0].(context.Context), args[1].(string), args[2].(string)) }) return _c } @@ -167,50 +151,19 @@ type MockExporter_ExportKubernetesArtifacts_Call struct { } // ExportKubernetesArtifacts is a helper method to define mock.On call -// - registry string -// - image string -// - namespace string -// - pullSecret string -// - hostname string -// - ingressClass string +// - registry +// - image +// - namespace +// - pullSecret +// - hostname +// - ingressClass func (_e *MockExporter_Expecter) ExportKubernetesArtifacts(registry interface{}, image interface{}, namespace interface{}, pullSecret interface{}, hostname interface{}, ingressClass interface{}) *MockExporter_ExportKubernetesArtifacts_Call { return &MockExporter_ExportKubernetesArtifacts_Call{Call: _e.mock.On("ExportKubernetesArtifacts", registry, image, namespace, pullSecret, hostname, ingressClass)} } func (_c *MockExporter_ExportKubernetesArtifacts_Call) Run(run func(registry string, image string, namespace string, pullSecret string, hostname string, ingressClass string)) *MockExporter_ExportKubernetesArtifacts_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - var arg4 string - if args[4] != nil { - arg4 = args[4].(string) - } - var arg5 string - if args[5] != nil { - arg5 = args[5].(string) - } - run( - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - ) + run(args[0].(string), args[1].(string), args[2].(string), args[3].(string), args[4].(string), args[5].(string)) }) return _c } @@ -259,20 +212,14 @@ type MockExporter_ReadYmlFile_Call struct { } // ReadYmlFile is a helper method to define mock.On call -// - path string +// - path func (_e *MockExporter_Expecter) ReadYmlFile(path interface{}) *MockExporter_ReadYmlFile_Call { return &MockExporter_ReadYmlFile_Call{Call: _e.mock.On("ReadYmlFile", path)} } func (_c *MockExporter_ReadYmlFile_Call) Run(run func(path string)) *MockExporter_ReadYmlFile_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - run( - arg0, - ) + run(args[0].(string)) }) return _c } diff --git a/pkg/git/mocks.go b/pkg/git/mocks.go index fa2afdb..a3f3c0f 100644 --- a/pkg/git/mocks.go +++ b/pkg/git/mocks.go @@ -71,38 +71,17 @@ type MockGit_CloneRepository_Call struct { } // CloneRepository is a helper method to define mock.On call -// - fs *cs.FileSystem -// - url string -// - branch string -// - path string +// - fs +// - url +// - branch +// - path func (_e *MockGit_Expecter) CloneRepository(fs interface{}, url interface{}, branch interface{}, path interface{}) *MockGit_CloneRepository_Call { return &MockGit_CloneRepository_Call{Call: _e.mock.On("CloneRepository", fs, url, branch, path)} } func (_c *MockGit_CloneRepository_Call) Run(run func(fs *cs.FileSystem, url string, branch string, path string)) *MockGit_CloneRepository_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 *cs.FileSystem - if args[0] != nil { - arg0 = args[0].(*cs.FileSystem) - } - var arg1 string - if args[1] != nil { - arg1 = args[1].(string) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 string - if args[3] != nil { - arg3 = args[3].(string) - } - run( - arg0, - arg1, - arg2, - arg3, - ) + run(args[0].(*cs.FileSystem), args[1].(string), args[2].(string), args[3].(string)) }) return _c } diff --git a/pkg/io/mocks.go b/pkg/io/mocks.go index 92c93f6..8e26b84 100644 --- a/pkg/io/mocks.go +++ b/pkg/io/mocks.go @@ -69,26 +69,15 @@ type MockExec_ExecuteCommand_Call struct { } // ExecuteCommand is a helper method to define mock.On call -// - ctx context.Context -// - cmdArgs []string +// - ctx +// - cmdArgs func (_e *MockExec_Expecter) ExecuteCommand(ctx interface{}, cmdArgs interface{}) *MockExec_ExecuteCommand_Call { return &MockExec_ExecuteCommand_Call{Call: _e.mock.On("ExecuteCommand", ctx, cmdArgs)} } func (_c *MockExec_ExecuteCommand_Call) Run(run func(ctx context.Context, cmdArgs []string)) *MockExec_ExecuteCommand_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 context.Context - if args[0] != nil { - arg0 = args[0].(context.Context) - } - var arg1 []string - if args[1] != nil { - arg1 = args[1].([]string) - } - run( - arg0, - arg1, - ) + run(args[0].(context.Context), args[1].([]string)) }) return _c } @@ -142,26 +131,15 @@ type MockHttpServer_Handle_Call struct { } // Handle is a helper method to define mock.On call -// - pattern string -// - handler http.Handler +// - pattern +// - handler func (_e *MockHttpServer_Expecter) Handle(pattern interface{}, handler interface{}) *MockHttpServer_Handle_Call { return &MockHttpServer_Handle_Call{Call: _e.mock.On("Handle", pattern, handler)} } func (_c *MockHttpServer_Handle_Call) Run(run func(pattern string, handler http.Handler)) *MockHttpServer_Handle_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 http.Handler - if args[1] != nil { - arg1 = args[1].(http.Handler) - } - run( - arg0, - arg1, - ) + run(args[0].(string), args[1].(http.Handler)) }) return _c } @@ -188,26 +166,15 @@ type MockHttpServer_HandleFunc_Call struct { } // HandleFunc is a helper method to define mock.On call -// - pattern string -// - handler func(http.ResponseWriter, *http.Request) +// - pattern +// - handler func (_e *MockHttpServer_Expecter) HandleFunc(pattern interface{}, handler interface{}) *MockHttpServer_HandleFunc_Call { return &MockHttpServer_HandleFunc_Call{Call: _e.mock.On("HandleFunc", pattern, handler)} } func (_c *MockHttpServer_HandleFunc_Call) Run(run func(pattern string, handler func(http.ResponseWriter, *http.Request))) *MockHttpServer_HandleFunc_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 func(http.ResponseWriter, *http.Request) - if args[1] != nil { - arg1 = args[1].(func(http.ResponseWriter, *http.Request)) - } - run( - arg0, - arg1, - ) + run(args[0].(string), args[1].(func(http.ResponseWriter, *http.Request))) }) return _c } @@ -245,26 +212,15 @@ type MockHttpServer_ListenAndServe_Call struct { } // ListenAndServe is a helper method to define mock.On call -// - addr string -// - handler http.Handler +// - addr +// - handler func (_e *MockHttpServer_Expecter) ListenAndServe(addr interface{}, handler interface{}) *MockHttpServer_ListenAndServe_Call { return &MockHttpServer_ListenAndServe_Call{Call: _e.mock.On("ListenAndServe", addr, handler)} } func (_c *MockHttpServer_ListenAndServe_Call) Run(run func(addr string, handler http.Handler)) *MockHttpServer_ListenAndServe_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 string - if args[0] != nil { - arg0 = args[0].(string) - } - var arg1 http.Handler - if args[1] != nil { - arg1 = args[1].(http.Handler) - } - run( - arg0, - arg1, - ) + run(args[0].(string), args[1].(http.Handler)) }) return _c } @@ -291,38 +247,17 @@ type MockHttpServer_Redirect_Call struct { } // Redirect is a helper method to define mock.On call -// - w http.ResponseWriter -// - r *http.Request -// - url string -// - code int +// - w +// - r +// - url +// - code func (_e *MockHttpServer_Expecter) Redirect(w interface{}, r interface{}, url interface{}, code interface{}) *MockHttpServer_Redirect_Call { return &MockHttpServer_Redirect_Call{Call: _e.mock.On("Redirect", w, r, url, code)} } func (_c *MockHttpServer_Redirect_Call) Run(run func(w http.ResponseWriter, r *http.Request, url string, code int)) *MockHttpServer_Redirect_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 http.ResponseWriter - if args[0] != nil { - arg0 = args[0].(http.ResponseWriter) - } - var arg1 *http.Request - if args[1] != nil { - arg1 = args[1].(*http.Request) - } - var arg2 string - if args[2] != nil { - arg2 = args[2].(string) - } - var arg3 int - if args[3] != nil { - arg3 = args[3].(int) - } - run( - arg0, - arg1, - arg2, - arg3, - ) + run(args[0].(http.ResponseWriter), args[1].(*http.Request), args[2].(string), args[3].(int)) }) return _c } From d499ebfd1a0824251e5b27e96272ac3ea92fe7a1 Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Wed, 28 Jan 2026 13:53:26 +0000 Subject: [PATCH 24/25] chore(docs): Auto-update docs and licenses Signed-off-by: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> --- api/mocks.go | 10 +- cli/cmd/mocks.go | 272 ++++++++++++++++++++++++++++++++++-------- pkg/exporter/mocks.go | 79 ++++++++++-- pkg/git/mocks.go | 31 ++++- pkg/io/mocks.go | 99 ++++++++++++--- 5 files changed, 406 insertions(+), 85 deletions(-) diff --git a/api/mocks.go b/api/mocks.go index 5e2084e..05a287a 100644 --- a/api/mocks.go +++ b/api/mocks.go @@ -92,14 +92,20 @@ type MockTime_Sleep_Call struct { } // Sleep is a helper method to define mock.On call -// - duration +// - duration time.Duration func (_e *MockTime_Expecter) Sleep(duration interface{}) *MockTime_Sleep_Call { return &MockTime_Sleep_Call{Call: _e.mock.On("Sleep", duration)} } func (_c *MockTime_Sleep_Call) Run(run func(duration time.Duration)) *MockTime_Sleep_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(time.Duration)) + var arg0 time.Duration + if args[0] != nil { + arg0 = args[0].(time.Duration) + } + run( + arg0, + ) }) return _c } diff --git a/cli/cmd/mocks.go b/cli/cmd/mocks.go index 83945b2..5a6f9cf 100644 --- a/cli/cmd/mocks.go +++ b/cli/cmd/mocks.go @@ -62,14 +62,20 @@ type MockClient_DeleteWorkspace_Call struct { } // DeleteWorkspace is a helper method to define mock.On call -// - wsId +// - wsId int func (_e *MockClient_Expecter) DeleteWorkspace(wsId interface{}) *MockClient_DeleteWorkspace_Call { return &MockClient_DeleteWorkspace_Call{Call: _e.mock.On("DeleteWorkspace", wsId)} } func (_c *MockClient_DeleteWorkspace_Call) Run(run func(wsId int)) *MockClient_DeleteWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + run( + arg0, + ) }) return _c } @@ -107,15 +113,26 @@ type MockClient_DeployLandscape_Call struct { } // DeployLandscape is a helper method to define mock.On call -// - wsId -// - profile +// - wsId int +// - profile string func (_e *MockClient_Expecter) DeployLandscape(wsId interface{}, profile interface{}) *MockClient_DeployLandscape_Call { return &MockClient_DeployLandscape_Call{Call: _e.mock.On("DeployLandscape", wsId, profile)} } func (_c *MockClient_DeployLandscape_Call) Run(run func(wsId int, profile string)) *MockClient_DeployLandscape_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(string)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + run( + arg0, + arg1, + ) }) return _c } @@ -164,14 +181,20 @@ type MockClient_DeployWorkspace_Call struct { } // DeployWorkspace is a helper method to define mock.On call -// - args +// - args api.DeployWorkspaceArgs func (_e *MockClient_Expecter) DeployWorkspace(args interface{}) *MockClient_DeployWorkspace_Call { return &MockClient_DeployWorkspace_Call{Call: _e.mock.On("DeployWorkspace", args)} } func (_c *MockClient_DeployWorkspace_Call) Run(run func(args api.DeployWorkspaceArgs)) *MockClient_DeployWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(api.DeployWorkspaceArgs)) + var arg0 api.DeployWorkspaceArgs + if args[0] != nil { + arg0 = args[0].(api.DeployWorkspaceArgs) + } + run( + arg0, + ) }) return _c } @@ -224,17 +247,38 @@ type MockClient_ExecCommand_Call struct { } // ExecCommand is a helper method to define mock.On call -// - workspaceId -// - command -// - workdir -// - env +// - workspaceId int +// - command string +// - workdir string +// - env map[string]string func (_e *MockClient_Expecter) ExecCommand(workspaceId interface{}, command interface{}, workdir interface{}, env interface{}) *MockClient_ExecCommand_Call { return &MockClient_ExecCommand_Call{Call: _e.mock.On("ExecCommand", workspaceId, command, workdir, env)} } func (_c *MockClient_ExecCommand_Call) Run(run func(workspaceId int, command string, workdir string, env map[string]string)) *MockClient_ExecCommand_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(string), args[2].(string), args[3].(map[string]string)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + var arg3 map[string]string + if args[3] != nil { + arg3 = args[3].(map[string]string) + } + run( + arg0, + arg1, + arg2, + arg3, + ) }) return _c } @@ -283,15 +327,26 @@ type MockClient_GetPipelineState_Call struct { } // GetPipelineState is a helper method to define mock.On call -// - wsId -// - stage +// - wsId int +// - stage string func (_e *MockClient_Expecter) GetPipelineState(wsId interface{}, stage interface{}) *MockClient_GetPipelineState_Call { return &MockClient_GetPipelineState_Call{Call: _e.mock.On("GetPipelineState", wsId, stage)} } func (_c *MockClient_GetPipelineState_Call) Run(run func(wsId int, stage string)) *MockClient_GetPipelineState_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(string)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + run( + arg0, + arg1, + ) }) return _c } @@ -338,14 +393,20 @@ type MockClient_GetWorkspace_Call struct { } // GetWorkspace is a helper method to define mock.On call -// - workspaceId +// - workspaceId int func (_e *MockClient_Expecter) GetWorkspace(workspaceId interface{}) *MockClient_GetWorkspace_Call { return &MockClient_GetWorkspace_Call{Call: _e.mock.On("GetWorkspace", workspaceId)} } func (_c *MockClient_GetWorkspace_Call) Run(run func(workspaceId int)) *MockClient_GetWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + run( + arg0, + ) }) return _c } @@ -383,16 +444,32 @@ type MockClient_GitPull_Call struct { } // GitPull is a helper method to define mock.On call -// - wsId -// - remote -// - branch +// - wsId int +// - remote string +// - branch string func (_e *MockClient_Expecter) GitPull(wsId interface{}, remote interface{}, branch interface{}) *MockClient_GitPull_Call { return &MockClient_GitPull_Call{Call: _e.mock.On("GitPull", wsId, remote, branch)} } func (_c *MockClient_GitPull_Call) Run(run func(wsId int, remote string, branch string)) *MockClient_GitPull_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(string), args[2].(string)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + run( + arg0, + arg1, + arg2, + ) }) return _c } @@ -606,14 +683,20 @@ type MockClient_ListWorkspaces_Call struct { } // ListWorkspaces is a helper method to define mock.On call -// - teamId +// - teamId int func (_e *MockClient_Expecter) ListWorkspaces(teamId interface{}) *MockClient_ListWorkspaces_Call { return &MockClient_ListWorkspaces_Call{Call: _e.mock.On("ListWorkspaces", teamId)} } func (_c *MockClient_ListWorkspaces_Call) Run(run func(teamId int)) *MockClient_ListWorkspaces_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + run( + arg0, + ) }) return _c } @@ -651,15 +734,26 @@ type MockClient_ScaleWorkspace_Call struct { } // ScaleWorkspace is a helper method to define mock.On call -// - wsId -// - replicas +// - wsId int +// - replicas int func (_e *MockClient_Expecter) ScaleWorkspace(wsId interface{}, replicas interface{}) *MockClient_ScaleWorkspace_Call { return &MockClient_ScaleWorkspace_Call{Call: _e.mock.On("ScaleWorkspace", wsId, replicas)} } func (_c *MockClient_ScaleWorkspace_Call) Run(run func(wsId int, replicas int)) *MockClient_ScaleWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(int)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 int + if args[1] != nil { + arg1 = args[1].(int) + } + run( + arg0, + arg1, + ) }) return _c } @@ -697,15 +791,26 @@ type MockClient_SetEnvVarOnWorkspace_Call struct { } // SetEnvVarOnWorkspace is a helper method to define mock.On call -// - workspaceId -// - vars +// - workspaceId int +// - vars map[string]string func (_e *MockClient_Expecter) SetEnvVarOnWorkspace(workspaceId interface{}, vars interface{}) *MockClient_SetEnvVarOnWorkspace_Call { return &MockClient_SetEnvVarOnWorkspace_Call{Call: _e.mock.On("SetEnvVarOnWorkspace", workspaceId, vars)} } func (_c *MockClient_SetEnvVarOnWorkspace_Call) Run(run func(workspaceId int, vars map[string]string)) *MockClient_SetEnvVarOnWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(map[string]string)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 map[string]string + if args[1] != nil { + arg1 = args[1].(map[string]string) + } + run( + arg0, + arg1, + ) }) return _c } @@ -743,16 +848,32 @@ type MockClient_StartPipelineStage_Call struct { } // StartPipelineStage is a helper method to define mock.On call -// - wsId -// - profile -// - stage +// - wsId int +// - profile string +// - stage string func (_e *MockClient_Expecter) StartPipelineStage(wsId interface{}, profile interface{}, stage interface{}) *MockClient_StartPipelineStage_Call { return &MockClient_StartPipelineStage_Call{Call: _e.mock.On("StartPipelineStage", wsId, profile, stage)} } func (_c *MockClient_StartPipelineStage_Call) Run(run func(wsId int, profile string, stage string)) *MockClient_StartPipelineStage_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int), args[1].(string), args[2].(string)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + run( + arg0, + arg1, + arg2, + ) }) return _c } @@ -790,15 +911,26 @@ type MockClient_WaitForWorkspaceRunning_Call struct { } // WaitForWorkspaceRunning is a helper method to define mock.On call -// - workspace -// - timeout +// - workspace *api.Workspace +// - timeout time.Duration func (_e *MockClient_Expecter) WaitForWorkspaceRunning(workspace interface{}, timeout interface{}) *MockClient_WaitForWorkspaceRunning_Call { return &MockClient_WaitForWorkspaceRunning_Call{Call: _e.mock.On("WaitForWorkspaceRunning", workspace, timeout)} } func (_c *MockClient_WaitForWorkspaceRunning_Call) Run(run func(workspace *api.Workspace, timeout time.Duration)) *MockClient_WaitForWorkspaceRunning_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*api.Workspace), args[1].(time.Duration)) + var arg0 *api.Workspace + if args[0] != nil { + arg0 = args[0].(*api.Workspace) + } + var arg1 time.Duration + if args[1] != nil { + arg1 = args[1].(time.Duration) + } + run( + arg0, + arg1, + ) }) return _c } @@ -847,14 +979,20 @@ type MockClient_WorkspaceStatus_Call struct { } // WorkspaceStatus is a helper method to define mock.On call -// - workspaceId +// - workspaceId int func (_e *MockClient_Expecter) WorkspaceStatus(workspaceId interface{}) *MockClient_WorkspaceStatus_Call { return &MockClient_WorkspaceStatus_Call{Call: _e.mock.On("WorkspaceStatus", workspaceId)} } func (_c *MockClient_WorkspaceStatus_Call) Run(run func(workspaceId int)) *MockClient_WorkspaceStatus_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(int)) + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + run( + arg0, + ) }) return _c } @@ -919,18 +1057,44 @@ type MockCommandExecutor_Execute_Call struct { } // Execute is a helper method to define mock.On call -// - ctx -// - name -// - args -// - stdout -// - stderr +// - ctx context.Context +// - name string +// - args []string +// - stdout io.Writer +// - stderr io.Writer func (_e *MockCommandExecutor_Expecter) Execute(ctx interface{}, name interface{}, args interface{}, stdout interface{}, stderr interface{}) *MockCommandExecutor_Execute_Call { return &MockCommandExecutor_Execute_Call{Call: _e.mock.On("Execute", ctx, name, args, stdout, stderr)} } func (_c *MockCommandExecutor_Execute_Call) Run(run func(ctx context.Context, name string, args []string, stdout io.Writer, stderr io.Writer)) *MockCommandExecutor_Execute_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].([]string), args[3].(io.Writer), args[4].(io.Writer)) + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + var arg2 []string + if args[2] != nil { + arg2 = args[2].([]string) + } + var arg3 io.Writer + if args[3] != nil { + arg3 = args[3].(io.Writer) + } + var arg4 io.Writer + if args[4] != nil { + arg4 = args[4].(io.Writer) + } + run( + arg0, + arg1, + arg2, + arg3, + arg4, + ) }) return _c } @@ -995,14 +1159,20 @@ type MockPrompt_InputPrompt_Call struct { } // InputPrompt is a helper method to define mock.On call -// - prompt +// - prompt string func (_e *MockPrompt_Expecter) InputPrompt(prompt interface{}) *MockPrompt_InputPrompt_Call { return &MockPrompt_InputPrompt_Call{Call: _e.mock.On("InputPrompt", prompt)} } func (_c *MockPrompt_InputPrompt_Call) Run(run func(prompt string)) *MockPrompt_InputPrompt_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + var arg0 string + if args[0] != nil { + arg0 = args[0].(string) + } + run( + arg0, + ) }) return _c } @@ -1067,14 +1237,20 @@ type MockBrowser_OpenIde_Call struct { } // OpenIde is a helper method to define mock.On call -// - path +// - path string func (_e *MockBrowser_Expecter) OpenIde(path interface{}) *MockBrowser_OpenIde_Call { return &MockBrowser_OpenIde_Call{Call: _e.mock.On("OpenIde", path)} } func (_c *MockBrowser_OpenIde_Call) Run(run func(path string)) *MockBrowser_OpenIde_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + var arg0 string + if args[0] != nil { + arg0 = args[0].(string) + } + run( + arg0, + ) }) return _c } diff --git a/pkg/exporter/mocks.go b/pkg/exporter/mocks.go index 67c0262..a2febe4 100644 --- a/pkg/exporter/mocks.go +++ b/pkg/exporter/mocks.go @@ -104,16 +104,32 @@ type MockExporter_ExportImages_Call struct { } // ExportImages is a helper method to define mock.On call -// - ctx -// - registry -// - imagePrefix +// - ctx context.Context +// - registry string +// - imagePrefix string func (_e *MockExporter_Expecter) ExportImages(ctx interface{}, registry interface{}, imagePrefix interface{}) *MockExporter_ExportImages_Call { return &MockExporter_ExportImages_Call{Call: _e.mock.On("ExportImages", ctx, registry, imagePrefix)} } func (_c *MockExporter_ExportImages_Call) Run(run func(ctx context.Context, registry string, imagePrefix string)) *MockExporter_ExportImages_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string)) + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + run( + arg0, + arg1, + arg2, + ) }) return _c } @@ -151,19 +167,50 @@ type MockExporter_ExportKubernetesArtifacts_Call struct { } // ExportKubernetesArtifacts is a helper method to define mock.On call -// - registry -// - image -// - namespace -// - pullSecret -// - hostname -// - ingressClass +// - registry string +// - image string +// - namespace string +// - pullSecret string +// - hostname string +// - ingressClass string func (_e *MockExporter_Expecter) ExportKubernetesArtifacts(registry interface{}, image interface{}, namespace interface{}, pullSecret interface{}, hostname interface{}, ingressClass interface{}) *MockExporter_ExportKubernetesArtifacts_Call { return &MockExporter_ExportKubernetesArtifacts_Call{Call: _e.mock.On("ExportKubernetesArtifacts", registry, image, namespace, pullSecret, hostname, ingressClass)} } func (_c *MockExporter_ExportKubernetesArtifacts_Call) Run(run func(registry string, image string, namespace string, pullSecret string, hostname string, ingressClass string)) *MockExporter_ExportKubernetesArtifacts_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(string), args[2].(string), args[3].(string), args[4].(string), args[5].(string)) + var arg0 string + if args[0] != nil { + arg0 = args[0].(string) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + var arg3 string + if args[3] != nil { + arg3 = args[3].(string) + } + var arg4 string + if args[4] != nil { + arg4 = args[4].(string) + } + var arg5 string + if args[5] != nil { + arg5 = args[5].(string) + } + run( + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + ) }) return _c } @@ -212,14 +259,20 @@ type MockExporter_ReadYmlFile_Call struct { } // ReadYmlFile is a helper method to define mock.On call -// - path +// - path string func (_e *MockExporter_Expecter) ReadYmlFile(path interface{}) *MockExporter_ReadYmlFile_Call { return &MockExporter_ReadYmlFile_Call{Call: _e.mock.On("ReadYmlFile", path)} } func (_c *MockExporter_ReadYmlFile_Call) Run(run func(path string)) *MockExporter_ReadYmlFile_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + var arg0 string + if args[0] != nil { + arg0 = args[0].(string) + } + run( + arg0, + ) }) return _c } diff --git a/pkg/git/mocks.go b/pkg/git/mocks.go index a3f3c0f..fa2afdb 100644 --- a/pkg/git/mocks.go +++ b/pkg/git/mocks.go @@ -71,17 +71,38 @@ type MockGit_CloneRepository_Call struct { } // CloneRepository is a helper method to define mock.On call -// - fs -// - url -// - branch -// - path +// - fs *cs.FileSystem +// - url string +// - branch string +// - path string func (_e *MockGit_Expecter) CloneRepository(fs interface{}, url interface{}, branch interface{}, path interface{}) *MockGit_CloneRepository_Call { return &MockGit_CloneRepository_Call{Call: _e.mock.On("CloneRepository", fs, url, branch, path)} } func (_c *MockGit_CloneRepository_Call) Run(run func(fs *cs.FileSystem, url string, branch string, path string)) *MockGit_CloneRepository_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*cs.FileSystem), args[1].(string), args[2].(string), args[3].(string)) + var arg0 *cs.FileSystem + if args[0] != nil { + arg0 = args[0].(*cs.FileSystem) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + var arg3 string + if args[3] != nil { + arg3 = args[3].(string) + } + run( + arg0, + arg1, + arg2, + arg3, + ) }) return _c } diff --git a/pkg/io/mocks.go b/pkg/io/mocks.go index 8e26b84..92c93f6 100644 --- a/pkg/io/mocks.go +++ b/pkg/io/mocks.go @@ -69,15 +69,26 @@ type MockExec_ExecuteCommand_Call struct { } // ExecuteCommand is a helper method to define mock.On call -// - ctx -// - cmdArgs +// - ctx context.Context +// - cmdArgs []string func (_e *MockExec_Expecter) ExecuteCommand(ctx interface{}, cmdArgs interface{}) *MockExec_ExecuteCommand_Call { return &MockExec_ExecuteCommand_Call{Call: _e.mock.On("ExecuteCommand", ctx, cmdArgs)} } func (_c *MockExec_ExecuteCommand_Call) Run(run func(ctx context.Context, cmdArgs []string)) *MockExec_ExecuteCommand_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].([]string)) + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 []string + if args[1] != nil { + arg1 = args[1].([]string) + } + run( + arg0, + arg1, + ) }) return _c } @@ -131,15 +142,26 @@ type MockHttpServer_Handle_Call struct { } // Handle is a helper method to define mock.On call -// - pattern -// - handler +// - pattern string +// - handler http.Handler func (_e *MockHttpServer_Expecter) Handle(pattern interface{}, handler interface{}) *MockHttpServer_Handle_Call { return &MockHttpServer_Handle_Call{Call: _e.mock.On("Handle", pattern, handler)} } func (_c *MockHttpServer_Handle_Call) Run(run func(pattern string, handler http.Handler)) *MockHttpServer_Handle_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(http.Handler)) + var arg0 string + if args[0] != nil { + arg0 = args[0].(string) + } + var arg1 http.Handler + if args[1] != nil { + arg1 = args[1].(http.Handler) + } + run( + arg0, + arg1, + ) }) return _c } @@ -166,15 +188,26 @@ type MockHttpServer_HandleFunc_Call struct { } // HandleFunc is a helper method to define mock.On call -// - pattern -// - handler +// - pattern string +// - handler func(http.ResponseWriter, *http.Request) func (_e *MockHttpServer_Expecter) HandleFunc(pattern interface{}, handler interface{}) *MockHttpServer_HandleFunc_Call { return &MockHttpServer_HandleFunc_Call{Call: _e.mock.On("HandleFunc", pattern, handler)} } func (_c *MockHttpServer_HandleFunc_Call) Run(run func(pattern string, handler func(http.ResponseWriter, *http.Request))) *MockHttpServer_HandleFunc_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(func(http.ResponseWriter, *http.Request))) + var arg0 string + if args[0] != nil { + arg0 = args[0].(string) + } + var arg1 func(http.ResponseWriter, *http.Request) + if args[1] != nil { + arg1 = args[1].(func(http.ResponseWriter, *http.Request)) + } + run( + arg0, + arg1, + ) }) return _c } @@ -212,15 +245,26 @@ type MockHttpServer_ListenAndServe_Call struct { } // ListenAndServe is a helper method to define mock.On call -// - addr -// - handler +// - addr string +// - handler http.Handler func (_e *MockHttpServer_Expecter) ListenAndServe(addr interface{}, handler interface{}) *MockHttpServer_ListenAndServe_Call { return &MockHttpServer_ListenAndServe_Call{Call: _e.mock.On("ListenAndServe", addr, handler)} } func (_c *MockHttpServer_ListenAndServe_Call) Run(run func(addr string, handler http.Handler)) *MockHttpServer_ListenAndServe_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(http.Handler)) + var arg0 string + if args[0] != nil { + arg0 = args[0].(string) + } + var arg1 http.Handler + if args[1] != nil { + arg1 = args[1].(http.Handler) + } + run( + arg0, + arg1, + ) }) return _c } @@ -247,17 +291,38 @@ type MockHttpServer_Redirect_Call struct { } // Redirect is a helper method to define mock.On call -// - w -// - r -// - url -// - code +// - w http.ResponseWriter +// - r *http.Request +// - url string +// - code int func (_e *MockHttpServer_Expecter) Redirect(w interface{}, r interface{}, url interface{}, code interface{}) *MockHttpServer_Redirect_Call { return &MockHttpServer_Redirect_Call{Call: _e.mock.On("Redirect", w, r, url, code)} } func (_c *MockHttpServer_Redirect_Call) Run(run func(w http.ResponseWriter, r *http.Request, url string, code int)) *MockHttpServer_Redirect_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(http.ResponseWriter), args[1].(*http.Request), args[2].(string), args[3].(int)) + var arg0 http.ResponseWriter + if args[0] != nil { + arg0 = args[0].(http.ResponseWriter) + } + var arg1 *http.Request + if args[1] != nil { + arg1 = args[1].(*http.Request) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + var arg3 int + if args[3] != nil { + arg3 = args[3].(int) + } + run( + arg0, + arg1, + arg2, + arg3, + ) }) return _c } From 4215a9e1ce88e8cf211ffe316a984dc03ee5e27e Mon Sep 17 00:00:00 2001 From: OliverTrautvetter <66372584+OliverTrautvetter@users.noreply.github.com> Date: Mon, 2 Feb 2026 11:41:44 +0100 Subject: [PATCH 25/25] ref: simplify port and timeout handling in Curl and WakeUp commands --- cli/cmd/curl.go | 45 +++++++++++++----------------------------- cli/cmd/curl_test.go | 7 ++++--- cli/cmd/wakeup.go | 11 +++-------- cli/cmd/wakeup_test.go | 3 +-- 4 files changed, 22 insertions(+), 44 deletions(-) diff --git a/cli/cmd/curl.go b/cli/cmd/curl.go index 72c3318..2376e7e 100644 --- a/cli/cmd/curl.go +++ b/cli/cmd/curl.go @@ -7,6 +7,7 @@ import ( "context" "fmt" "io" + "log" "os" "os/exec" "strings" @@ -29,8 +30,8 @@ func (e *DefaultCommandExecutor) Execute(ctx context.Context, name string, args type CurlCmd struct { cmd *cobra.Command Opts GlobalOptions - Port *int - Timeout *time.Duration + Port int + Timeout time.Duration Insecure bool Executor CommandExecutor // Injectable for testing } @@ -75,8 +76,8 @@ func AddCurlCmd(rootCmd *cobra.Command, opts GlobalOptions) { Opts: opts, Executor: &DefaultCommandExecutor{}, } - curl.Port = curl.cmd.Flags().IntP("port", "p", 3000, "Port to connect to") - curl.Timeout = curl.cmd.Flags().DurationP("timeout", "", 30*time.Second, "Timeout for the request") + curl.cmd.Flags().IntVarP(&curl.Port, "port", "p", 3000, "Port to connect to") + curl.cmd.Flags().DurationVar(&curl.Timeout, "timeout", 30*time.Second, "Timeout for the request") curl.cmd.Flags().BoolVar(&curl.Insecure, "insecure", false, "skip TLS certificate verification (for testing only)") rootCmd.AddCommand(curl.cmd) curl.cmd.RunE = curl.RunE @@ -93,55 +94,37 @@ func (c *CurlCmd) CurlWorkspace(client Client, wsId int, token string, path stri return fmt.Errorf("workspace %d does not have a dev domain configured", wsId) } - port := 3000 - if c.Port != nil { - port = *c.Port - } - // Use the workspace's dev domain and replace the port if needed // DevDomain format is: {workspace_id}-{port}.{domain} devDomain := *workspace.DevDomain var url string - if port != 3000 { + if c.Port != 3000 { // Replace the default port (3000) with the custom port in the dev domain - url = fmt.Sprintf("https://%d-%d.%s%s", wsId, port, devDomain[strings.Index(devDomain, ".")+1:], path) + url = fmt.Sprintf("https://%d-%d.%s%s", wsId, c.Port, devDomain[strings.Index(devDomain, ".")+1:], path) } else { url = fmt.Sprintf("https://%s%s", devDomain, path) } - fmt.Fprintf(os.Stderr, "Sending request to workspace %d (%s) at %s\n", wsId, workspace.Name, url) - - timeout := 30 * time.Second - if c.Timeout != nil { - timeout = *c.Timeout - } + log.Printf("Sending request to workspace %d (%s) at %s\n", wsId, workspace.Name, url) - ctx, cancel := context.WithTimeout(context.Background(), timeout) + ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() - // Build curl command - cmdArgs := []string{"curl"} - - // Add authentication header - cmdArgs = append(cmdArgs, "-H", fmt.Sprintf("x-forward-security: %s", token)) + // Build curl command with authentication header + cmdArgs := []string{"curl", "-H", fmt.Sprintf("x-forward-security: %s", token)} // Add insecure flag if specified if c.Insecure { cmdArgs = append(cmdArgs, "-k") } - // Add user's curl arguments cmdArgs = append(cmdArgs, curlArgs...) - - // Add URL as the last argument cmdArgs = append(cmdArgs, url) - // Execute curl command err = c.Executor.Execute(ctx, cmdArgs[0], cmdArgs[1:], os.Stdout, os.Stderr) - if err != nil { - if ctx.Err() == context.DeadlineExceeded { - return fmt.Errorf("timeout exceeded while requesting workspace %d", wsId) - } + if err != nil && err == context.DeadlineExceeded { + return fmt.Errorf("timeout exceeded while requesting workspace %d", wsId) + } else if err != nil { return fmt.Errorf("curl command failed: %w", err) } diff --git a/cli/cmd/curl_test.go b/cli/cmd/curl_test.go index b7af8a4..69918e6 100644 --- a/cli/cmd/curl_test.go +++ b/cli/cmd/curl_test.go @@ -5,6 +5,7 @@ package cmd_test import ( "fmt" + "time" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -39,7 +40,8 @@ var _ = Describe("Curl", func() { Env: mockEnv, WorkspaceId: &wsId, }, - Port: &port, + Port: port, + Timeout: 30 * time.Second, Executor: mockExecutor, } }) @@ -86,8 +88,7 @@ var _ = Describe("Curl", func() { }) It("should construct the correct URL with custom port", func() { - customPort := 3001 - c.Port = &customPort + c.Port = 3001 devDomain := "42-3000.dev.5.codesphere.com" workspace := api.Workspace{ Id: wsId, diff --git a/cli/cmd/wakeup.go b/cli/cmd/wakeup.go index c5cde3a..a43a0b5 100644 --- a/cli/cmd/wakeup.go +++ b/cli/cmd/wakeup.go @@ -14,7 +14,7 @@ import ( type WakeUpCmd struct { cmd *cobra.Command Opts GlobalOptions - Timeout *time.Duration + Timeout time.Duration } func (c *WakeUpCmd) RunE(_ *cobra.Command, args []string) error { @@ -45,7 +45,7 @@ func AddWakeUpCmd(rootCmd *cobra.Command, opts GlobalOptions) { }, Opts: opts, } - wakeup.Timeout = wakeup.cmd.Flags().DurationP("timeout", "", 120*time.Second, "Timeout for waking up the workspace") + wakeup.cmd.Flags().DurationVar(&wakeup.Timeout, "timeout", 120*time.Second, "Timeout for waking up the workspace") rootCmd.AddCommand(wakeup.cmd) wakeup.cmd.RunE = wakeup.RunE } @@ -81,13 +81,8 @@ func (c *WakeUpCmd) WakeUpWorkspace(client Client, wsId int) error { return fmt.Errorf("failed to scale workspace: %w", err) } - timeout := 120 * time.Second - if c.Timeout != nil { - timeout = *c.Timeout - } - fmt.Printf("Waiting for workspace %d to be running...\n", wsId) - err = client.WaitForWorkspaceRunning(&workspace, timeout) + err = client.WaitForWorkspaceRunning(&workspace, c.Timeout) if err != nil { return fmt.Errorf("workspace did not become running: %w", err) } diff --git a/cli/cmd/wakeup_test.go b/cli/cmd/wakeup_test.go index 3ce9d7e..38a8683 100644 --- a/cli/cmd/wakeup_test.go +++ b/cli/cmd/wakeup_test.go @@ -44,8 +44,7 @@ var _ = Describe("WakeUp", func() { TeamId: teamId, Name: "test-workspace", } - timeout := 120 * time.Second - c.Timeout = &timeout + c.Timeout = 120 * time.Second mockClient.EXPECT().GetWorkspace(wsId).Return(workspace, nil) mockClient.EXPECT().WorkspaceStatus(wsId).Return(&api.WorkspaceStatus{IsRunning: false}, nil)