From 7dd7e080cb105fc595c31c57c63bf65c861c5112 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Tue, 12 Apr 2022 17:10:20 -0500 Subject: [PATCH 1/4] chore: Add alias `coder agent` --- cli/root.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/root.go b/cli/root.go index 08384b211af1d..29083d6d03e13 100644 --- a/cli/root.go +++ b/cli/root.go @@ -73,6 +73,7 @@ func Root() *cobra.Command { workspaceTunnel(), gitssh(), publickey(), + workspaceAgent(), ) cmd.PersistentFlags().String(varGlobalConfig, configdir.LocalConfig("coderv2"), "Path to the global `coder` config directory") From 8ad6bb1d66fc148365adef9f90feab54bed2c33c Mon Sep 17 00:00:00 2001 From: Garrett Date: Wed, 13 Apr 2022 19:14:45 +0000 Subject: [PATCH 2/4] move command --- cli/gitssh_test.go | 2 +- cli/workspaceagent_test.go | 4 ++-- cli/workspaces.go | 1 - provisionersdk/agent.go | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cli/gitssh_test.go b/cli/gitssh_test.go index 4ad6f6daea62b..b5105d3aa5011 100644 --- a/cli/gitssh_test.go +++ b/cli/gitssh_test.go @@ -65,7 +65,7 @@ func TestGitSSH(t *testing.T) { coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID) // start workspace agent - cmd, root := clitest.New(t, "workspaces", "agent", "--auth", "aws-instance-identity", "--url", client.URL.String()) + cmd, root := clitest.New(t, "agent", "--auth", "aws-instance-identity", "--url", client.URL.String()) agentClient := &*client clitest.SetupConfig(t, agentClient, root) ctx, cancelFunc := context.WithCancel(context.Background()) diff --git a/cli/workspaceagent_test.go b/cli/workspaceagent_test.go index c672c7bb7946c..c289a32968a81 100644 --- a/cli/workspaceagent_test.go +++ b/cli/workspaceagent_test.go @@ -47,7 +47,7 @@ func TestWorkspaceAgent(t *testing.T) { workspace := coderdtest.CreateWorkspace(t, client, codersdk.Me, template.ID) coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID) - cmd, _ := clitest.New(t, "workspaces", "agent", "--auth", "aws-instance-identity", "--url", client.URL.String()) + cmd, _ := clitest.New(t, "agent", "--auth", "aws-instance-identity", "--url", client.URL.String()) ctx, cancelFunc := context.WithCancel(context.Background()) defer cancelFunc() go func() { @@ -101,7 +101,7 @@ func TestWorkspaceAgent(t *testing.T) { workspace := coderdtest.CreateWorkspace(t, client, codersdk.Me, template.ID) coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID) - cmd, _ := clitest.New(t, "workspaces", "agent", "--auth", "google-instance-identity", "--url", client.URL.String()) + cmd, _ := clitest.New(t, "agent", "--auth", "google-instance-identity", "--url", client.URL.String()) ctx, cancelFunc := context.WithCancel(context.Background()) defer cancelFunc() go func() { diff --git a/cli/workspaces.go b/cli/workspaces.go index 8e350f31ee3e5..f6d740cd83ad8 100644 --- a/cli/workspaces.go +++ b/cli/workspaces.go @@ -13,7 +13,6 @@ func workspaces() *cobra.Command { Use: "workspaces", Aliases: []string{"ws"}, } - cmd.AddCommand(workspaceAgent()) cmd.AddCommand(workspaceCreate()) cmd.AddCommand(workspaceDelete()) cmd.AddCommand(workspaceList()) diff --git a/provisionersdk/agent.go b/provisionersdk/agent.go index cc372b3ce51d5..d50bd817982d7 100644 --- a/provisionersdk/agent.go +++ b/provisionersdk/agent.go @@ -16,7 +16,7 @@ $ProgressPreference = "SilentlyContinue" Invoke-WebRequest -Uri ${ACCESS_URL}bin/coder-windows-amd64.exe -OutFile $env:TEMP\sshd.exe $env:CODER_AUTH = "${AUTH_TYPE}" $env:CODER_URL = "${ACCESS_URL}" -Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "workspaces","agent" -PassThru +Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru `, }, "linux": { From 9c07236a6ce3debac75a9a4f71100572643e2166 Mon Sep 17 00:00:00 2001 From: Garrett Date: Wed, 13 Apr 2022 19:33:27 +0000 Subject: [PATCH 3/4] get last references --- provisionersdk/agent.go | 4 ++-- provisionersdk/agent_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/provisionersdk/agent.go b/provisionersdk/agent.go index d50bd817982d7..7c67699b5bcc3 100644 --- a/provisionersdk/agent.go +++ b/provisionersdk/agent.go @@ -28,7 +28,7 @@ curl -fsSL ${ACCESS_URL}bin/coder-linux-amd64 -o $BINARY_LOCATION chmod +x $BINARY_LOCATION export CODER_AUTH="${AUTH_TYPE}" export CODER_URL="${ACCESS_URL}" -exec $BINARY_LOCATION workspaces agent +exec $BINARY_LOCATION agent `, }, "darwin": { @@ -40,7 +40,7 @@ curl -fsSL ${ACCESS_URL}bin/coder-darwin-amd64 -o $BINARY_LOCATION chmod +x $BINARY_LOCATION export CODER_AUTH="${AUTH_TYPE}" export CODER_URL="${ACCESS_URL}" -exec $BINARY_LOCATION workspaces agent +exec $BINARY_LOCATION agent `, }, } diff --git a/provisionersdk/agent_test.go b/provisionersdk/agent_test.go index 3260494e9bb55..d9ebbb8d8936a 100644 --- a/provisionersdk/agent_test.go +++ b/provisionersdk/agent_test.go @@ -51,6 +51,6 @@ func TestAgentScript(t *testing.T) { require.NoError(t, err) // Because we use the "echo" binary, we should expect the arguments provided // as the response to executing our script. - require.Equal(t, "workspaces agent", strings.TrimSpace(string(output))) + require.Equal(t, "agent", strings.TrimSpace(string(output))) }) } From e1c5afb776eaf5cd2c18fa603b7ea9cf40758f95 Mon Sep 17 00:00:00 2001 From: Garrett Date: Wed, 13 Apr 2022 19:41:19 +0000 Subject: [PATCH 4/4] rename files --- cli/{workspaceagent.go => agent.go} | 0 cli/{workspaceagent_test.go => agent_test.go} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename cli/{workspaceagent.go => agent.go} (100%) rename cli/{workspaceagent_test.go => agent_test.go} (100%) diff --git a/cli/workspaceagent.go b/cli/agent.go similarity index 100% rename from cli/workspaceagent.go rename to cli/agent.go diff --git a/cli/workspaceagent_test.go b/cli/agent_test.go similarity index 100% rename from cli/workspaceagent_test.go rename to cli/agent_test.go