diff --git a/handlers/new_session.go b/handlers/new_session.go
index 818dac2..b0a98bd 100644
--- a/handlers/new_session.go
+++ b/handlers/new_session.go
@@ -28,6 +28,7 @@ func NewSession(rw http.ResponseWriter, req *http.Request) {
reqDur := req.Form.Get("session-duration")
stack := req.Form.Get("stack")
stackName := req.Form.Get("stack_name")
+ imageName := req.Form.Get("image_name")
if stack != "" {
stack = formatStack(stack)
@@ -43,7 +44,7 @@ func NewSession(rw http.ResponseWriter, req *http.Request) {
}
duration := config.GetDuration(reqDur)
- s, err := core.SessionNew(duration, stack, stackName)
+ s, err := core.SessionNew(duration, stack, stackName, imageName)
if err != nil {
log.Println(err)
//TODO: Return some error code
diff --git a/pwd/client_test.go b/pwd/client_test.go
index 6a7bf71..4aed04a 100644
--- a/pwd/client_test.go
+++ b/pwd/client_test.go
@@ -15,7 +15,7 @@ func TestClientNew(t *testing.T) {
p := NewPWD(docker, tasks, broadcast, storage)
- session, err := p.SessionNew(time.Hour, "", "")
+ session, err := p.SessionNew(time.Hour, "", "", "")
assert.Nil(t, err)
client := p.ClientNew("foobar", session)
@@ -43,7 +43,7 @@ func TestClientResizeViewPort(t *testing.T) {
p := NewPWD(docker, tasks, broadcast, storage)
- session, err := p.SessionNew(time.Hour, "", "")
+ session, err := p.SessionNew(time.Hour, "", "", "")
assert.Nil(t, err)
client := p.ClientNew("foobar", session)
diff --git a/pwd/instance_test.go b/pwd/instance_test.go
index 73b89fe..a97e1b8 100644
--- a/pwd/instance_test.go
+++ b/pwd/instance_test.go
@@ -53,7 +53,7 @@ func TestInstanceNew(t *testing.T) {
p := NewPWD(dock, tasks, broadcast, storage)
- session, err := p.SessionNew(time.Hour, "", "")
+ session, err := p.SessionNew(time.Hour, "", "", "")
assert.Nil(t, err)
@@ -103,7 +103,7 @@ func TestInstanceNew_Concurrency(t *testing.T) {
p := NewPWD(dock, tasks, broadcast, storage)
- session, err := p.SessionNew(time.Hour, "", "")
+ session, err := p.SessionNew(time.Hour, "", "", "")
assert.Nil(t, err)
@@ -144,7 +144,7 @@ func TestInstanceNew_WithNotAllowedImage(t *testing.T) {
p := NewPWD(dock, tasks, broadcast, storage)
- session, err := p.SessionNew(time.Hour, "", "")
+ session, err := p.SessionNew(time.Hour, "", "", "")
assert.Nil(t, err)
@@ -192,7 +192,7 @@ func TestInstanceNew_WithCustomHostname(t *testing.T) {
p := NewPWD(dock, tasks, broadcast, storage)
- session, err := p.SessionNew(time.Hour, "", "")
+ session, err := p.SessionNew(time.Hour, "", "", "")
assert.Nil(t, err)
diff --git a/pwd/pwd.go b/pwd/pwd.go
index f001211..124bd06 100644
--- a/pwd/pwd.go
+++ b/pwd/pwd.go
@@ -53,7 +53,7 @@ type pwd struct {
}
type PWDApi interface {
- SessionNew(duration time.Duration, stack string, stackName string) (*Session, error)
+ SessionNew(duration time.Duration, stack string, stackName, imageName string) (*Session, error)
SessionClose(session *Session) error
SessionGetSmallestViewPort(session *Session) ViewPort
SessionDeployStack(session *Session) error
diff --git a/pwd/session.go b/pwd/session.go
index e467065..e584dc4 100644
--- a/pwd/session.go
+++ b/pwd/session.go
@@ -45,13 +45,14 @@ type Session struct {
Ready bool `json:"ready"`
Stack string `json:"stack"`
StackName string `json:"stack_name"`
+ ImageName string `json:"image_name"`
closingTimer *time.Timer `json:"-"`
scheduled bool `json:"-"`
clients []*Client `json:"-"`
ticker *time.Ticker `json:"-"`
}
-func (p *pwd) SessionNew(duration time.Duration, stack, stackName string) (*Session, error) {
+func (p *pwd) SessionNew(duration time.Duration, stack, stackName, imageName string) (*Session, error) {
defer observeAction("SessionNew", time.Now())
sessionsMutex.Lock()
@@ -72,6 +73,7 @@ func (p *pwd) SessionNew(duration time.Duration, stack, stackName string) (*Sess
stackName = "pwd"
}
s.StackName = stackName
+ s.ImageName = imageName
log.Printf("NewSession id=[%s]\n", s.Id)
@@ -161,7 +163,7 @@ func (p *pwd) SessionDeployStack(s *Session) error {
s.Ready = false
p.broadcast.BroadcastTo(s.Id, "session ready", false)
- i, err := p.InstanceNew(s, InstanceConfig{})
+ i, err := p.InstanceNew(s, InstanceConfig{ImageName: s.ImageName})
if err != nil {
log.Printf("Error creating instance for stack [%s]: %s\n", s.Stack, err)
return err
diff --git a/pwd/session_test.go b/pwd/session_test.go
index 678495c..5432cc2 100644
--- a/pwd/session_test.go
+++ b/pwd/session_test.go
@@ -50,7 +50,7 @@ func TestSessionNew(t *testing.T) {
before := time.Now()
- s, e := p.SessionNew(time.Hour, "", "")
+ s, e := p.SessionNew(time.Hour, "", "", "")
expectedSessions[s.Id] = s
assert.Nil(t, e)
@@ -64,11 +64,12 @@ func TestSessionNew(t *testing.T) {
assert.Equal(t, s.Id, createdNetworkId)
assert.True(t, s.Ready)
- s, _ = p.SessionNew(time.Hour, "stackPath", "stackName")
+ s, _ = p.SessionNew(time.Hour, "stackPath", "stackName", "imageName")
expectedSessions[s.Id] = s
assert.Equal(t, "stackPath", s.Stack)
assert.Equal(t, "stackName", s.StackName)
+ assert.Equal(t, "imageName", s.ImageName)
assert.False(t, s.Ready)
assert.NotNil(t, s.closingTimer)
@@ -173,7 +174,7 @@ func TestSessionSetup(t *testing.T) {
storage := &mockStorage{}
p := NewPWD(dock, tasks, broadcast, storage)
- s, e := p.SessionNew(time.Hour, "", "")
+ s, e := p.SessionNew(time.Hour, "", "", "")
assert.Nil(t, e)
err := p.SessionSetup(s, SessionSetupConf{
diff --git a/www/bypass.html b/www/bypass.html
index c33922f..a06e7c7 100644
--- a/www/bypass.html
+++ b/www/bypass.html
@@ -13,6 +13,7 @@
+