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
|
||||
}
|
||||
|
||||
/*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 {
|
||||
warren.WriteStringz(c, "ERROR: " + err.Error())
|
||||
return
|
||||
}*/
|
||||
}
|
||||
warren.WriteStringz(c, "Unregistered deployment " + args[0])
|
||||
}
|
||||
|
||||
|
|
|
@ -107,11 +107,19 @@ func Run() {
|
|||
// loop for Writes
|
||||
for {
|
||||
m := <- confChan
|
||||
|
||||
var err error = nil
|
||||
switch (m.mType) {
|
||||
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 (
|
||||
"errors"
|
||||
"os"
|
||||
"github.com/dballard/warren/lib/warren"
|
||||
|
||||
)
|
||||
|
||||
// reverse look up map
|
||||
|
@ -14,30 +16,36 @@ var dirToNick map[string]string = make(map[string]string)
|
|||
// internal, thread unsafe
|
||||
func addDeployment(d *Msg) error {
|
||||
if err := validateDeployment(d); err != nil {
|
||||
d.reply <- err
|
||||
return err
|
||||
}
|
||||
conf.Deployments[d.Args["name"]] = d.Args["path"]
|
||||
dirToNick[d.Args["path"]] = d.Args["name"]
|
||||
saveConf()
|
||||
d.reply <- nil
|
||||
return nil
|
||||
}
|
||||
/*
|
||||
func RmDeployment(string arg) error {
|
||||
reply = make(chan error)
|
||||
rmDeploymentChan <-
|
||||
|
||||
func rmDeployment(d *Msg) error {
|
||||
// Assume nick, check if registered
|
||||
deps := GetConf().Deployments
|
||||
arg := args[0]
|
||||
if _,ok := deps[arg]; !ok {
|
||||
// not a registered nick, try as path
|
||||
absPath := absPath(path, arg)
|
||||
// if _,ok := conf.
|
||||
if path,ok := deps[d.Args["arg"]]; ok {
|
||||
// registered nick
|
||||
delete(deps, d.Args["arg"])
|
||||
delete(dirToNick, path)
|
||||
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
|
||||
// internal thread unsafe
|
||||
func validateDeployment(d *Msg) error {
|
||||
|
|
|
@ -132,6 +132,7 @@ func main() {
|
|||
|
||||
warren.RegisterCommand(statusCmd)
|
||||
warren.RegisterCommand(regCmd)
|
||||
warren.RegisterCommand(unregCmd)
|
||||
|
||||
// Handle signals
|
||||
c := make(chan os.Signal, 1)
|
||||
|
|
Loading…
Reference in New Issue