From 0622cac05b64b59cadd8ea3fa580b86787cbe82c Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 28 Feb 2016 01:03:16 -0600 Subject: [PATCH] Cleaned up config layout. --- dospin.json | 9 ++------- droplethandler.go | 2 +- servermanager.go | 8 +------- settings.go | 13 ++++--------- 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/dospin.json b/dospin.json index e9d14e5..18333d6 100644 --- a/dospin.json +++ b/dospin.json @@ -1,13 +1,8 @@ { "ApiToken": "", - "Services": { - "Minecraft": { - "Port": 25565, - "LogicalDroplet": "minecraft" - } - }, - "LogicalServers": { + "Servers": { "minecraft": { + "Ports": [25565], "Size": "4gb", "Region": "nyc3" } diff --git a/droplethandler.go b/droplethandler.go index caeb80c..365c097 100644 --- a/droplethandler.go +++ b/droplethandler.go @@ -57,7 +57,7 @@ func (me *DropletHandler) Spinup(name string) (string, error) { if err != nil { return "", err } - vd := me.settings.LogicalServers[name] + vd := me.settings.Servers[name] createRequest := &godo.DropletCreateRequest{ Name: DROPLET_NS + name, Region: vd.Region, diff --git a/servermanager.go b/servermanager.go index a0f7fc8..432e745 100644 --- a/servermanager.go +++ b/servermanager.go @@ -28,18 +28,12 @@ func NewServerManager(name string, server ServerHandler, settings Settings) *Ser sm := new(ServerManager) sm.name = name + sm.ports = settings.Servers[name].Ports sm.in = make(chan int) sm.done = make(chan interface{}) sm.usageScore = 5 sm.server = server - // find the ports associated with this server in settings - for _, s := range settings.Services { - if s.LogicalServer == name { - sm.ports = append(sm.ports, s.Port) - } - } - return sm } diff --git a/settings.go b/settings.go index 7fc2f32..d61d6b1 100644 --- a/settings.go +++ b/settings.go @@ -13,17 +13,12 @@ import ( ) type Settings struct { - ApiToken string - Services map[string]Service - LogicalServers map[string]LogicalServer + ApiToken string + Servers map[string]Server } -type Service struct { - Port int - LogicalServer string -} - -type LogicalServer struct { +type Server struct { + Ports []int Size string Region string }