More fixes
This commit is contained in:
@@ -111,7 +111,7 @@ func (p *pwd) InstanceGet(session *types.Session, name string) *types.Instance {
|
||||
|
||||
func (p *pwd) InstanceFind(sessionId, ip string) *types.Instance {
|
||||
defer observeAction("InstanceFind", time.Now())
|
||||
i, err := p.storage.InstanceFind(sessionId, ip)
|
||||
i, err := p.storage.InstanceFindByIP(sessionId, ip)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
@@ -211,7 +211,8 @@ func (p *pwd) InstanceNew(session *types.Session, conf InstanceConfig) (*types.I
|
||||
instance.ServerKey = conf.ServerKey
|
||||
instance.CACert = conf.CACert
|
||||
instance.Session = session
|
||||
instance.Proxy = router.EncodeHost(session.Id, ip, router.HostOpts{})
|
||||
instance.ProxyHost = router.EncodeHost(session.Id, ip, router.HostOpts{})
|
||||
instance.SessionHost = session.Host
|
||||
// For now this condition holds through. In the future we might need a more complex logic.
|
||||
instance.IsDockerHost = opts.Privileged
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ func TestInstanceNew(t *testing.T) {
|
||||
IsDockerHost: true,
|
||||
SessionId: session.Id,
|
||||
Session: session,
|
||||
Proxy: router.EncodeHost(session.Id, "10.0.0.1", router.HostOpts{}),
|
||||
ProxyHost: router.EncodeHost(session.Id, "10.0.0.1", router.HostOpts{}),
|
||||
}
|
||||
expectedContainerOpts := docker.CreateContainerOpts{
|
||||
Image: expectedInstance.Image,
|
||||
@@ -132,7 +132,7 @@ func TestInstanceNew_WithNotAllowedImage(t *testing.T) {
|
||||
SessionId: session.Id,
|
||||
IsDockerHost: false,
|
||||
Session: session,
|
||||
Proxy: router.EncodeHost(session.Id, "10.0.0.1", router.HostOpts{}),
|
||||
ProxyHost: router.EncodeHost(session.Id, "10.0.0.1", router.HostOpts{}),
|
||||
}
|
||||
expectedContainerOpts := docker.CreateContainerOpts{
|
||||
Image: expectedInstance.Image,
|
||||
@@ -193,7 +193,7 @@ func TestInstanceNew_WithCustomHostname(t *testing.T) {
|
||||
IsDockerHost: false,
|
||||
Session: session,
|
||||
SessionId: session.Id,
|
||||
Proxy: router.EncodeHost(session.Id, "10.0.0.1", router.HostOpts{}),
|
||||
ProxyHost: router.EncodeHost(session.Id, "10.0.0.1", router.HostOpts{}),
|
||||
}
|
||||
expectedContainerOpts := docker.CreateContainerOpts{
|
||||
Image: expectedInstance.Image,
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
)
|
||||
import "context"
|
||||
|
||||
type Instance struct {
|
||||
Image string `json:"image" bson:"image"`
|
||||
@@ -17,8 +14,8 @@ type Instance struct {
|
||||
Key []byte `json:"key" bson:"key"`
|
||||
IsDockerHost bool `json:"is_docker_host" bson:"is_docker_host"`
|
||||
SessionId string `json:"session_id" bson:"session_id"`
|
||||
Proxy string `json:"proxy" bson:"proxy"`
|
||||
ProxyHost string `json:"proxy_host" bson:"proxy_host"`
|
||||
SessionHost string `json:"session_host" bson:"session_host"`
|
||||
Session *Session `json:"-" bson:"-"`
|
||||
ctx context.Context `json:"-" bson:"-"`
|
||||
rw sync.Mutex
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user