Multiple playgrounds support (#215)
* Add Playground struct and basic support for creating it and retrieving it * Add missing functions in pwd mock * Get playground from request domain and validate it exists. If valid set it on the newly created session. * Move playground specific configurations to the playground struct and use it everytime we need that conf. * Don't allow to specify a duration bigger that the allowed in the playground
This commit is contained in:
committed by
GitHub
parent
3dee0d3f0b
commit
3f5b3882dd
12
api.go
12
api.go
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/play-with-docker/play-with-docker/config"
|
||||
"github.com/play-with-docker/play-with-docker/docker"
|
||||
@@ -11,6 +12,7 @@ import (
|
||||
"github.com/play-with-docker/play-with-docker/id"
|
||||
"github.com/play-with-docker/play-with-docker/provisioner"
|
||||
"github.com/play-with-docker/play-with-docker/pwd"
|
||||
"github.com/play-with-docker/play-with-docker/pwd/types"
|
||||
"github.com/play-with-docker/play-with-docker/scheduler"
|
||||
"github.com/play-with-docker/play-with-docker/scheduler/task"
|
||||
"github.com/play-with-docker/play-with-docker/storage"
|
||||
@@ -41,6 +43,16 @@ func main() {
|
||||
|
||||
sch.Start()
|
||||
|
||||
d, err := time.ParseDuration(config.DefaultSessionDuration)
|
||||
if err != nil {
|
||||
log.Fatalf("Cannot parse duration %s. Got: %v", config.DefaultSessionDuration, err)
|
||||
}
|
||||
|
||||
playground := types.Playground{Domain: config.PlaygroundDomain, DefaultDinDInstanceImage: config.DefaultDinDImage, AllowWindowsInstances: config.NoWindows, DefaultSessionDuration: d, AvailableDinDInstanceImages: []string{config.DefaultDinDImage}}
|
||||
if _, err := core.PlaygroundNew(playground); err != nil {
|
||||
log.Fatalf("Cannot create default playground. Got: %v", err)
|
||||
}
|
||||
|
||||
handlers.Bootstrap(core, e)
|
||||
handlers.Register(nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user