Add support for file editor
This commit is contained in:
@@ -83,11 +83,11 @@ func (d *DinD) InstanceNew(session *types.Session, conf types.InstanceConfig) (*
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := dockerClient.CreateContainer(opts); err != nil {
|
||||
if err := dockerClient.ContainerCreate(opts); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ips, err := dockerClient.GetContainerIPs(containerName)
|
||||
ips, err := dockerClient.ContainerIPs(containerName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -131,7 +131,7 @@ func (d *DinD) InstanceDelete(session *types.Session, instance *types.Instance)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = dockerClient.DeleteContainer(instance.Name)
|
||||
err = dockerClient.ContainerDelete(instance.Name)
|
||||
if err != nil && !strings.Contains(err.Error(), "No such container") {
|
||||
return err
|
||||
}
|
||||
@@ -150,6 +150,40 @@ func (d *DinD) InstanceExec(instance *types.Instance, cmd []string) (int, error)
|
||||
return dockerClient.Exec(instance.Name, cmd)
|
||||
}
|
||||
|
||||
func (d *DinD) InstanceFSTree(instance *types.Instance) (io.Reader, error) {
|
||||
session, err := d.getSession(instance.SessionId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dockerClient, err := d.factory.GetForSession(session)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b := bytes.NewBuffer([]byte{})
|
||||
|
||||
if c, err := dockerClient.ExecAttach(instance.Name, []string{"bash", "-c", `tree --noreport -J $HOME`}, b); c > 0 {
|
||||
log.Println(b.String())
|
||||
return nil, fmt.Errorf("Error %d trying list directories", c)
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func (d *DinD) InstanceFile(instance *types.Instance, filePath string) (io.Reader, error) {
|
||||
session, err := d.getSession(instance.SessionId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dockerClient, err := d.factory.GetForSession(session)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dockerClient.CopyFromContainer(instance.Name, filePath)
|
||||
}
|
||||
|
||||
func (d *DinD) InstanceResizeTerminal(instance *types.Instance, rows, cols uint) error {
|
||||
session, err := d.getSession(instance.SessionId)
|
||||
if err != nil {
|
||||
|
||||
@@ -27,7 +27,7 @@ func (p *overlaySessionProvisioner) SessionNew(ctx context.Context, s *types.Ses
|
||||
// We assume we are out of capacity
|
||||
return fmt.Errorf("Out of capacity")
|
||||
}
|
||||
u, _ := url.Parse(dockerClient.GetDaemonHost())
|
||||
u, _ := url.Parse(dockerClient.DaemonHost())
|
||||
if u.Host == "" {
|
||||
s.Host = "localhost"
|
||||
} else {
|
||||
@@ -36,13 +36,13 @@ func (p *overlaySessionProvisioner) SessionNew(ctx context.Context, s *types.Ses
|
||||
}
|
||||
|
||||
opts := dtypes.NetworkCreate{Driver: "overlay", Attachable: true}
|
||||
if err := dockerClient.CreateNetwork(s.Id, opts); err != nil {
|
||||
if err := dockerClient.NetworkCreate(s.Id, opts); err != nil {
|
||||
log.Println("ERROR NETWORKING", err)
|
||||
return err
|
||||
}
|
||||
log.Printf("Network [%s] created for session [%s]\n", s.Id, s.Id)
|
||||
|
||||
ip, err := dockerClient.ConnectNetwork(config.L2ContainerName, s.Id, s.PwdIpAddress)
|
||||
ip, err := dockerClient.NetworkConnect(config.L2ContainerName, s.Id, s.PwdIpAddress)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return err
|
||||
@@ -58,14 +58,14 @@ func (p *overlaySessionProvisioner) SessionClose(s *types.Session) error {
|
||||
log.Println(err)
|
||||
return err
|
||||
}
|
||||
if err := dockerClient.DisconnectNetwork(config.L2ContainerName, s.Id); err != nil {
|
||||
if err := dockerClient.NetworkDisconnect(config.L2ContainerName, s.Id); err != nil {
|
||||
if !strings.Contains(err.Error(), "is not connected to the network") {
|
||||
log.Println("ERROR NETWORKING", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
log.Printf("Disconnected l2 from network [%s]\n", s.Id)
|
||||
if err := dockerClient.DeleteNetwork(s.Id); err != nil {
|
||||
if err := dockerClient.NetworkDelete(s.Id); err != nil {
|
||||
if !strings.Contains(err.Error(), "not found") {
|
||||
log.Println(err)
|
||||
return err
|
||||
|
||||
@@ -19,6 +19,8 @@ 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)
|
||||
|
||||
@@ -155,6 +155,15 @@ func (d *windows) InstanceExec(instance *types.Instance, cmd []string) (int, err
|
||||
return ex.ExitCode, nil
|
||||
}
|
||||
|
||||
func (d *windows) InstanceFSTree(instance *types.Instance) (io.Reader, error) {
|
||||
//TODO implement
|
||||
return nil, nil
|
||||
}
|
||||
func (d *windows) InstanceFile(instance *types.Instance, filePath string) (io.Reader, error) {
|
||||
//TODO implement
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (d *windows) releaseInstance(instanceId string) error {
|
||||
return d.storage.WindowsInstanceDelete(instanceId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user