forked from play-with-docker/play-with-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provisioner.go
39 lines (30 loc) · 1.22 KB
/
provisioner.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package provisioner
import (
"context"
"errors"
"io"
"net"
"github.com/play-with-docker/play-with-docker/pwd/types"
)
var OutOfCapacityError = errors.New("OutOfCapacity")
func OutOfCapacity(e error) bool {
return e == OutOfCapacityError
}
type InstanceProvisionerApi interface {
InstanceNew(session *types.Session, conf types.InstanceConfig) (*types.Instance, error)
InstanceDelete(session *types.Session, instance *types.Instance) error
InstanceExec(instance *types.Instance, cmd []string) (int, error)
InstanceFSTree(instance *types.Instance) (io.Reader, error)
InstanceFile(instance *types.Instance, filePath string) (io.Reader, error)
InstanceResizeTerminal(instance *types.Instance, cols, rows uint) error
InstanceGetTerminal(instance *types.Instance) (net.Conn, error)
InstanceUploadFromUrl(instance *types.Instance, fileName, dest, url string) error
InstanceUploadFromReader(instance *types.Instance, fileName, dest string, reader io.Reader) error
}
type SessionProvisionerApi interface {
SessionNew(ctx context.Context, session *types.Session) error
SessionClose(session *types.Session) error
}
type InstanceProvisionerFactoryApi interface {
GetProvisioner(instanceType string) (InstanceProvisionerApi, error)
}