unreg deployment command works
This commit is contained in:
parent
be9e65bcd7
commit
42960560f3
|
@ -73,11 +73,14 @@ func unregRun(cmd *SockCommand, c net.Conn, path string, args ...string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
/*err := conf.RmDeployment(args[0])
|
d := conf.NewMsg(conf.RmDeploymen)
|
||||||
|
d.Args["arg"] = args[0]
|
||||||
|
d.Args["path"] = path
|
||||||
|
err := d.Call()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
warren.WriteStringz(c, "ERROR: " + err.Error())
|
warren.WriteStringz(c, "ERROR: " + err.Error())
|
||||||
return
|
return
|
||||||
}*/
|
}
|
||||||
warren.WriteStringz(c, "Unregistered deployment " + args[0])
|
warren.WriteStringz(c, "Unregistered deployment " + args[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,11 +107,19 @@ func Run() {
|
||||||
// loop for Writes
|
// loop for Writes
|
||||||
for {
|
for {
|
||||||
m := <- confChan
|
m := <- confChan
|
||||||
|
var err error = nil
|
||||||
switch (m.mType) {
|
switch (m.mType) {
|
||||||
case AddDeployment:
|
case AddDeployment:
|
||||||
addDeployment(&m)
|
err = addDeployment(&m)
|
||||||
|
break
|
||||||
|
case RmDeploymen:
|
||||||
|
err = rmDeployment(&m)
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
err = errors.New("Unknown command")
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
m.reply <- err
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package conf
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
|
"github.com/dballard/warren/lib/warren"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// reverse look up map
|
// reverse look up map
|
||||||
|
@ -14,30 +16,36 @@ var dirToNick map[string]string = make(map[string]string)
|
||||||
// internal, thread unsafe
|
// internal, thread unsafe
|
||||||
func addDeployment(d *Msg) error {
|
func addDeployment(d *Msg) error {
|
||||||
if err := validateDeployment(d); err != nil {
|
if err := validateDeployment(d); err != nil {
|
||||||
d.reply <- err
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
conf.Deployments[d.Args["name"]] = d.Args["path"]
|
conf.Deployments[d.Args["name"]] = d.Args["path"]
|
||||||
dirToNick[d.Args["path"]] = d.Args["name"]
|
dirToNick[d.Args["path"]] = d.Args["name"]
|
||||||
saveConf()
|
saveConf()
|
||||||
d.reply <- nil
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
func RmDeployment(string arg) error {
|
|
||||||
reply = make(chan error)
|
|
||||||
rmDeploymentChan <-
|
|
||||||
|
|
||||||
// Assume nick, check if registered
|
func rmDeployment(d *Msg) error {
|
||||||
|
// Assume nick, check if registered
|
||||||
deps := GetConf().Deployments
|
deps := GetConf().Deployments
|
||||||
arg := args[0]
|
if path,ok := deps[d.Args["arg"]]; ok {
|
||||||
if _,ok := deps[arg]; !ok {
|
// registered nick
|
||||||
// not a registered nick, try as path
|
delete(deps, d.Args["arg"])
|
||||||
absPath := absPath(path, arg)
|
delete(dirToNick, path)
|
||||||
// if _,ok := conf.
|
saveConf()
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
// Not a nick, try as path
|
||||||
|
absPath := warren.AbsPath(d.Args["path"], d.Args["arg"])
|
||||||
|
if nick,ok := dirToNick[absPath]; ok {
|
||||||
|
delete(deps, nick)
|
||||||
|
delete(dirToNick, absPath)
|
||||||
|
saveConf()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return errors.New("Cannot find deployment '" + d.Args["arg"] + "' to remove")
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
// Validate a deployment is ok to insert
|
// Validate a deployment is ok to insert
|
||||||
// internal thread unsafe
|
// internal thread unsafe
|
||||||
func validateDeployment(d *Msg) error {
|
func validateDeployment(d *Msg) error {
|
||||||
|
|
|
@ -132,6 +132,7 @@ func main() {
|
||||||
|
|
||||||
warren.RegisterCommand(statusCmd)
|
warren.RegisterCommand(statusCmd)
|
||||||
warren.RegisterCommand(regCmd)
|
warren.RegisterCommand(regCmd)
|
||||||
|
warren.RegisterCommand(unregCmd)
|
||||||
|
|
||||||
// Handle signals
|
// Handle signals
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
|
|
Loading…
Reference in New Issue