Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
1024bf5
refactor(cli): move cmd/agent under cmd/internal to mirror command tree
skevetter Jun 6, 2026
32719a3
refactor(cli): move cmd/helper under cmd/internal to mirror command tree
skevetter Jun 6, 2026
99bd001
refactor(cli): group helper ssh commands into ssh sub-package
skevetter Jun 6, 2026
fc153a9
refactor(cli): group helper workspace-info commands into workspaceinf…
skevetter Jun 6, 2026
5005934
refactor(cli): group helper provider commands into provider sub-package
skevetter Jun 6, 2026
07816b5
refactor(cli): group helper image commands into image sub-package
skevetter Jun 6, 2026
609a1d5
refactor(cli): fix stale cmd/agent path reference in comment
skevetter Jun 6, 2026
6740c31
refactor(cli): hoist agent/container to cmd/internal/agentcontainer
skevetter Jun 6, 2026
a430c4c
refactor(cli): hoist agent/workspace to cmd/internal/agentworkspace
skevetter Jun 6, 2026
da69c46
refactor(cli): hoist helper http/json/strings to prefixed sub-packages
skevetter Jun 6, 2026
123fc75
refactor(cli): hoist helper ssh/provider/image/workspaceinfo to prefi…
skevetter Jun 6, 2026
9b0eb69
refactor(cli): dissolve helper loose files into cmdinternal package
skevetter Jun 6, 2026
10454f2
refactor(cli): dissolve agent loose files into cmdinternal package
skevetter Jun 6, 2026
7ce4f05
refactor(cli): consolidate internal command-tree wiring into internal.go
skevetter Jun 6, 2026
b11fe7d
refactor(cli): promote internal helper subcommands to direct children
skevetter Jun 6, 2026
2b99adc
fix(lint): silence goconst on health.go agent-executed annotation
skevetter Jun 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 0 additions & 69 deletions cmd/agent/agent.go

This file was deleted.

59 changes: 0 additions & 59 deletions cmd/agent/git_ssh_signature_helper.go

This file was deleted.

41 changes: 0 additions & 41 deletions cmd/helper/helper.go

This file was deleted.

66 changes: 66 additions & 0 deletions cmd/internal/agent.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package cmdinternal

import (
"os"

"github.com/devsy-org/devsy/cmd/flags"
"github.com/devsy-org/devsy/cmd/internal/agentcontainer"
"github.com/devsy-org/devsy/cmd/internal/agentworkspace"
"github.com/devsy-org/devsy/pkg/config"
"github.com/devsy-org/devsy/pkg/envfile"
"github.com/devsy-org/devsy/pkg/log"
"github.com/spf13/cobra"
)

var AgentExecutedAnnotation = "devsy.sh/agent-executed"

// NewAgentCmd is the hidden parent for commands that run inside a workspace or
// container, invoked by the daemon over the agent tunnel.
func NewAgentCmd(globalFlags *flags.GlobalFlags) *cobra.Command {
agentCmd := &cobra.Command{
Use: "agent",
Short: "Devsy Agent",
PersistentPreRunE: agentPreRunE(globalFlags),
Hidden: true,
}

agentCmd.AddCommand(agentworkspace.NewWorkspaceCmd(globalFlags))
agentCmd.AddCommand(agentcontainer.NewContainerCmd(globalFlags))
agentCmd.AddCommand(NewDaemonCmd(globalFlags))
agentCmd.AddCommand(NewContainerTunnelCmd(globalFlags))
agentCmd.AddCommand(NewGitCredentialsCmd(globalFlags))
agentCmd.AddCommand(NewGitSSHSignatureCmd(globalFlags))
agentCmd.AddCommand(NewGitSSHSignatureHelperCmd(globalFlags))
agentCmd.AddCommand(NewDockerCredentialsCmd(globalFlags))
return agentCmd
}

// agentPreRunE builds the PersistentPreRunE shared by the agent command and the
// utility plumbing commands. Logging is forced to JSON because the agent
// subprocess uses stdout as a binary protocol channel, so log output must stay
// on stderr as single-line JSON captured by TunnelLogStreamer.lastLines.
func agentPreRunE(globalFlags *flags.GlobalFlags) func(*cobra.Command, []string) error {
return func(cobraCmd *cobra.Command, _ []string) error {
root := cobraCmd
for root.Parent() != nil {
root = root.Parent()
}
if root.Annotations == nil {
root.Annotations = map[string]string{}
}
root.Annotations[AgentExecutedAnnotation] = "true"

log.Init(log.Config{
Quiet: globalFlags.Quiet,
Debug: globalFlags.Debug,
Format: "json",
})

if globalFlags.DevsyHome != "" {
_ = os.Setenv(config.EnvHome, globalFlags.DevsyHome)
}

envfile.Apply()
return nil
}
}
2 changes: 1 addition & 1 deletion cmd/agent/daemon.go → cmd/internal/agent_daemon.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package agent
package cmdinternal

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package agent
package cmdinternal

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package container
package agentcontainer

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package container
package agentcontainer

import (
"github.com/devsy-org/devsy/cmd/flags"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package container
package agentcontainer

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package container
package agentcontainer

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build !windows

package container
package agentcontainer

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build windows

package container
package agentcontainer

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package container
package agentcontainer

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build !windows

package container
package agentcontainer

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build windows

package container
package agentcontainer

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build !windows

package container
package agentcontainer

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package container
package agentcontainer

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build !windows

package container
package agentcontainer

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build windows

package container
package agentcontainer

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package container
package agentcontainer

import (
"fmt"

"github.com/devsy-org/devsy/cmd/flags"
"github.com/devsy-org/devsy/pkg/log"
helperssh "github.com/devsy-org/devsy/pkg/ssh/server"
sshserver "github.com/devsy-org/devsy/pkg/ssh/server"
"github.com/devsy-org/devsy/pkg/ssh/server/port"
"github.com/spf13/cobra"
)
Expand All @@ -32,7 +32,7 @@ func NewSSHServerCmd(flags *flags.GlobalFlags) *cobra.Command {
}

sshCmd.Flags().
StringVar(&cmd.Address, "address", fmt.Sprintf("127.0.0.1:%d", helperssh.DefaultUserPort), "Address to listen to")
StringVar(&cmd.Address, "address", fmt.Sprintf("127.0.0.1:%d", sshserver.DefaultUserPort), "Address to listen to")
sshCmd.Flags().
StringVar(&cmd.RemoteUser, "remote-user", "", "The remote user for this workspace")
sshCmd.Flags().
Expand All @@ -42,7 +42,7 @@ func NewSSHServerCmd(flags *flags.GlobalFlags) *cobra.Command {

// Run runs the command logic.
func (cmd *SSHServerCmd) Run(_ *cobra.Command, _ []string) error {
server, err := helperssh.NewContainerServer(cmd.Address, cmd.Workdir)
server, err := sshserver.NewContainerServer(cmd.Address, cmd.Workdir)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package container
package agentcontainer

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package workspace
package agentworkspace

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package workspace
package agentworkspace

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package workspace
package agentworkspace

import (
"context"
Expand Down
Loading
Loading