@@ -2,7 +2,7 @@ package runtime
22
33import (
44 "context"
5- "os "
5+ "fmt "
66 "path/filepath"
77
88 "github.com/pocketbase/pocketbase/core"
@@ -33,29 +33,6 @@ type Executor interface {
3333 Name () string
3434}
3535
36- type localExecutor struct {
37- app core.App
38- }
39-
40- func (e localExecutor ) PrepareWorkspace (projectDir string , compose string ) error {
41- if err := os .MkdirAll (projectDir , 0o755 ); err != nil {
42- return err
43- }
44- return os .WriteFile (filepath .Join (projectDir , "docker-compose.yml" ), []byte (compose ), 0o600 )
45- }
46-
47- func (e localExecutor ) DockerClient () (* docker.Client , error ) {
48- exec := docker .NewLocalExecutor ("" )
49- if os .Getuid () != 0 {
50- exec .SudoEnabled = true
51- }
52- return docker .New (exec ), nil
53- }
54-
55- func (e localExecutor ) Name () string {
56- return "local"
57- }
58-
5936type sshExecutor struct {
6037 app core.App
6138 serverID string
@@ -127,18 +104,25 @@ func (e sshExecutor) factory() sftpClientFactory {
127104 return defaultSFTPClientFactory
128105}
129106
130- func executorName ( serverID string ) string {
107+ func NewDeploymentExecutor ( app core. App , serverID string ) Executor {
131108 if serverID == "" || serverID == "local" {
132- return "local"
109+ return unsupportedExecutor {}
133110 }
134- return "ssh"
111+ return newSSHExecutor ( app , serverID )
135112}
136113
137- func NewDeploymentExecutor (app core.App , serverID string ) Executor {
138- if executorName (serverID ) == "local" {
139- return localExecutor {app : app }
140- }
141- return newSSHExecutor (app , serverID )
114+ type unsupportedExecutor struct {}
115+
116+ func (unsupportedExecutor ) PrepareWorkspace (string , string ) error {
117+ return fmt .Errorf ("managed server is required for deployment execution" )
118+ }
119+
120+ func (unsupportedExecutor ) DockerClient () (* docker.Client , error ) {
121+ return nil , fmt .Errorf ("managed server is required for deployment execution" )
122+ }
123+
124+ func (unsupportedExecutor ) Name () string {
125+ return "unsupported"
142126}
143127
144128func newSSHExecutor (app core.App , serverID string ) sshExecutor {
0 commit comments