Add image_name parameter to SessionDeploy
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user