refactor: explicit initialization and dependency injection
Docker Build and Push / build-and-push-tags (push) Has been skipped
Docker Build and Push / build-and-push-branches (push) Successful in 10m2s

- Replace init() with config.Load() function when loading env variables
- Inject portRegistry into session, server, and lifecycle structs
- Inject sessionRegistry directly into interaction and lifecycle
- Remove SetSessionRegistry function and global port variables
This commit is contained in:
2026-01-18 20:42:10 +07:00
parent 2b9bca65d5
commit 317ab2dbe4
7 changed files with 81 additions and 76 deletions
+2 -7
View File
@@ -30,7 +30,6 @@ type Interaction interface {
Mode() types.Mode
SetChannel(channel ssh.Channel)
SetLifecycle(lifecycle Lifecycle)
SetSessionRegistry(registry SessionRegistry)
SetMode(m types.Mode)
SetWH(w, h int)
Start()
@@ -80,24 +79,20 @@ func (i *interaction) SetWH(w, h int) {
}
}
func New(slug slug.Slug, forwarder Forwarder) Interaction {
func New(slug slug.Slug, forwarder Forwarder, sessionRegistry SessionRegistry) Interaction {
ctx, cancel := context.WithCancel(context.Background())
return &interaction{
channel: nil,
slug: slug,
forwarder: forwarder,
lifecycle: nil,
sessionRegistry: nil,
sessionRegistry: sessionRegistry,
program: nil,
ctx: ctx,
cancel: cancel,
}
}
func (i *interaction) SetSessionRegistry(registry SessionRegistry) {
i.sessionRegistry = registry
}
func (i *interaction) SetLifecycle(lifecycle Lifecycle) {
i.lifecycle = lifecycle
}