Skip to content

Commit

Permalink
Fix session setup
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosnils committed Apr 23, 2019
1 parent 172be6e commit b758b00
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion handlers/session_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func SessionSetup(rw http.ResponseWriter, req *http.Request) {
vars := mux.Vars(req)
sessionId := vars["sessionId"]

body := pwd.SessionSetupConf{PlaygroundFQDN: req.Host}
body := pwd.SessionSetupConf{PlaygroundFQDN: req.Host, DindVolumeSize: "5G"}

json.NewDecoder(req.Body).Decode(&body)

Expand All @@ -23,6 +23,17 @@ func SessionSetup(rw http.ResponseWriter, req *http.Request) {
return
}

playground := core.PlaygroundGet(s.PlaygroundId)
if playground == nil {
log.Printf("Playground with id %s for session %s was not found!", s.PlaygroundId, s.Id)
rw.WriteHeader(http.StatusBadRequest)
return
}

if len(playground.DindVolumeSize) > 0 {
body.DindVolumeSize = playground.DindVolumeSize
}

err = core.SessionSetup(s, body)
if err != nil {
if pwd.SessionNotEmpty(err) {
Expand Down
2 changes: 2 additions & 0 deletions pwd/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func (s *sessionBuilderWriter) Write(p []byte) (n int, err error) {
type SessionSetupConf struct {
Instances []SessionSetupInstanceConf `json:"instances"`
PlaygroundFQDN string
DindVolumeSize string
}

type SessionSetupInstanceConf struct {
Expand Down Expand Up @@ -250,6 +251,7 @@ func (p *pwd) SessionSetup(session *types.Session, sconf SessionSetupConf) error
PlaygroundFQDN: sconf.PlaygroundFQDN,
Type: conf.Type,
Tls: conf.Tls,
DindVolumeSize: sconf.DindVolumeSize,
}
i, err := p.InstanceNew(session, instanceConf)
if err != nil {
Expand Down

0 comments on commit b758b00

Please sign in to comment.