func (e *GetAppEnvPortExecutor) Execute(t *Task) (err error) { if e.arg.App == "" { return errors.New("Please specify an app") } else if e.arg.Env == "" { return errors.New("Please specify an environment") } zkApp, err := datamodel.GetApp(e.arg.App) if err != nil { return err } zrp := datamodel.GetRouterPorts(zkApp.Internal) fmt.Printf("ROUTER PORTS: %+v\n", zrp) portStr := zrp.AppEnvMap[helper.GetAppEnvTrieName(e.arg.App, e.arg.Env)] if portStr == "" { return errors.New("port not found") } fmt.Printf("PORT STRING: %+v -> %+v\n", helper.GetAppEnvTrieName(e.arg.App, e.arg.Env), portStr) port, err := strconv.ParseUint(portStr, 10, 16) if err != nil { return err } helper.SetRouterRoot(zkApp.Internal) e.reply.Port, err = routerzk.GetPort(datamodel.Zk.Conn, uint16(port)) return err }
func (e *ListAppEnvsWithPortExecutor) Execute(t *Task) (err error) { zrp := datamodel.GetRouterPorts(e.arg.Internal) e.reply.AppEnvs = []AppEnv{} for _, appEnv := range zrp.PortMap { e.reply.AppEnvs = append(e.reply.AppEnvs, appEnv) } sort.Sort(AppEnvSortable(e.reply.AppEnvs)) return err }