1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-03-12 13:32:07 +08:00
parent 340c1f15e3
commit bd3660f02e
6 changed files with 28 additions and 11 deletions

View File

@ -18,6 +18,10 @@ import (
) )
func _runtime_init(m *ice.Message) { func _runtime_init(m *ice.Message) {
if ice.Info.Make.Remote == "" {
ice.Info.Make.Remote = m.Cmdx(SYSTEM, GIT, "config", "--get", "remote.origin.url")
ice.Info.Make.Module = srtings.Split(ice.Info.Make.Remote, "://")[1]
}
count := kit.Int(m.Conf(RUNTIME, kit.Keys(BOOT, mdb.COUNT))) count := kit.Int(m.Conf(RUNTIME, kit.Keys(BOOT, mdb.COUNT)))
defer m.Conf(RUNTIME, kit.Keys(BOOT, mdb.COUNT), count+1) defer m.Conf(RUNTIME, kit.Keys(BOOT, mdb.COUNT), count+1)
kit.For(kit.UnMarshal(kit.Format(ice.Info.Make)), func(k string, v ice.Any) { m.Conf(RUNTIME, kit.Keys(MAKE, strings.ToLower(k)), v) }) kit.For(kit.UnMarshal(kit.Format(ice.Info.Make)), func(k string, v ice.Any) { m.Conf(RUNTIME, kit.Keys(MAKE, strings.ToLower(k)), v) })

View File

@ -97,7 +97,7 @@ func (f *Frame) parse(m *ice.Message, h, line string) string {
} }
msg := m.Spawn(f.target) msg := m.Spawn(f.target)
kit.If(h == STDIO, func() { msg.Option(ice.LOG_TRACEID, log.Traceid(m)) }) kit.If(h == STDIO, func() { msg.Option(ice.LOG_TRACEID, log.Traceid(m)) })
if msg.Cmdy(ls); h == STDIO && msg.IsErrNotFound() { if msg.Cmdy(ls); h == STDIO && msg.IsErrNotFoundIndex() {
msg.SetResult().Cmdy(cli.SYSTEM, ls) msg.SetResult().Cmdy(cli.SYSTEM, ls)
} }
kit.If(m.Option(ice.MSG_STATUS) == "", func() { m.StatusTimeCount() }) kit.If(m.Option(ice.MSG_STATUS) == "", func() { m.StatusTimeCount() })

View File

@ -56,12 +56,9 @@ func Render(m *ice.Message, cmd string, args ...ice.Any) bool {
case COOKIE: // value [name [path [expire]]] case COOKIE: // value [name [path [expire]]]
RenderCookie(m, arg[0], arg[1:]...) RenderCookie(m, arg[0], arg[1:]...)
case STATUS, ice.RENDER_STATUS: // [code [text]] case STATUS, ice.RENDER_STATUS: // [code [text]]
if m.IsCliUA() { // RenderStatus(m.W, kit.Int(kit.Select("200", arg, 0)), kit.Select(m.Result(), strings.Join(kit.Slice(arg, 1), " ")))
RenderStatus(m.W, kit.Int(kit.Select("200", arg, 0)), kit.Select(m.Result(), strings.Join(kit.Slice(arg, 1), " ")))
} else {
m.W.WriteHeader(kit.Int(kit.Select("200", arg, 0))) m.W.WriteHeader(kit.Int(kit.Select("200", arg, 0)))
renderMsg(m) renderMsg(m)
}
case ice.RENDER_REDIRECT: // url [arg...] case ice.RENDER_REDIRECT: // url [arg...]
http.Redirect(m.W, m.R, m.MergeLink(arg[0], arg[1:]), http.StatusTemporaryRedirect) http.Redirect(m.W, m.R, m.MergeLink(arg[0], arg[1:]), http.StatusTemporaryRedirect)
case ice.RENDER_DOWNLOAD: // file [type [name]] case ice.RENDER_DOWNLOAD: // file [type [name]]

View File

@ -434,6 +434,7 @@ func init() {
} }
func HostPort(m *ice.Message, host, port string, arg ...string) string { func HostPort(m *ice.Message, host, port string, arg ...string) string {
m.Info("what %v", host, port)
p := "" p := ""
if len(arg) > 0 { if len(arg) > 0 {
kit.If(kit.Select("", arg, 0), func(pod string) { p += S(pod) }) kit.If(kit.Select("", arg, 0), func(pod string) { p += S(pod) })
@ -466,7 +467,13 @@ func SpideDelete(m *ice.Message, arg ...ice.Any) ice.Any {
return kit.UnMarshal(m.Cmdx(http.MethodDelete, arg)) return kit.UnMarshal(m.Cmdx(http.MethodDelete, arg))
} }
func SpideSave(m *ice.Message, file, link string, cb func(count, total, value int)) *ice.Message { func SpideSave(m *ice.Message, file, link string, cb func(count, total, value int)) *ice.Message {
return m.Cmd(Prefix(SPIDE), ice.DEV_IP, SPIDE_SAVE, file, http.MethodGet, link, cb) for _, p := range []string{ice.DEV_IP, ice.DEV} {
msg := m.Cmd(Prefix(SPIDE), p, SPIDE_SAVE, file, http.MethodGet, link, cb)
if !msg.IsErr() {
return msg
}
}
return m
} }
func SpideCache(m *ice.Message, link string) *ice.Message { func SpideCache(m *ice.Message, link string) *ice.Message {
return m.Cmd(Prefix(SPIDE), ice.DEV_IP, SPIDE_CACHE, http.MethodGet, link) return m.Cmd(Prefix(SPIDE), ice.DEV_IP, SPIDE_CACHE, http.MethodGet, link)

View File

@ -53,12 +53,16 @@ func _publish_contexts(m *ice.Message, arg ...string) {
m.OptionDefault(web.DOMAIN, host) m.OptionDefault(web.DOMAIN, host)
env := []string{} env := []string{}
m.Option("ctx_dev_ip", web.HostPort(m, m.Cmd(tcp.HOST).Append(aaa.IP), m.Cmd(web.SERVE).Append(tcp.PORT))) // m.Option("ctx_dev_ip", tcp.PublishLocalhost(m, web.SpideOrigin(m, ice.OPS)))
m.Option("ctx_dev_ip", web.HostPort(m, web.AdminCmd(m, tcp.HOST).Append(aaa.IP), web.AdminCmd(m, web.SERVE).Append(tcp.PORT)))
// kit.If(m.Option("ctx_dev_ip"), func(p string) { env = append(env, "ctx_dev_ip", p) }) // kit.If(m.Option("ctx_dev_ip"), func(p string) { env = append(env, "ctx_dev_ip", p) })
kit.If(m.Option(ice.MSG_USERPOD), func(p string) { env = append(env, cli.CTX_POD, p) }) kit.If(m.Option(ice.MSG_USERPOD), func(p string) { env = append(env, cli.CTX_POD, p) })
kit.If(len(env) > 0, func() { m.Options(cli.CTX_ENV, lex.SP+kit.JoinKV(mdb.EQ, lex.SP, env...)) }) kit.If(len(env) > 0, func() { m.Options(cli.CTX_ENV, lex.SP+kit.JoinKV(mdb.EQ, lex.SP, env...)) })
m.OptionDefault("ctx_cli", "temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL $ctx_dev; else wget -O $temp -q $ctx_dev; fi; source $temp") m.OptionDefault("ctx_cli", "temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL $ctx_dev; else wget -O $temp -q $ctx_dev; fi; source $temp")
m.OptionDefault("ctx_arg", kit.JoinCmds(aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERNICK, m.Option(ice.MSG_USERNICK))) m.OptionDefault("ctx_arg", kit.JoinCmds(
aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERNICK, m.Option(ice.MSG_USERNICK),
aaa.LANGUAGE, m.Option(ice.MSG_LANGUAGE),
))
for _, k := range kit.Default(arg, ice.MISC) { for _, k := range kit.Default(arg, ice.MISC) {
switch k { switch k {
@ -69,7 +73,11 @@ func _publish_contexts(m *ice.Message, arg ...string) {
case ice.CORE: case ice.CORE:
m.Option(web.DOMAIN, web.SpideOrigin(m, ice.DEV)) m.Option(web.DOMAIN, web.SpideOrigin(m, ice.DEV))
case nfs.SOURCE, ice.DEV: case nfs.SOURCE, ice.DEV:
m.OptionDefault(nfs.SOURCE, ice.Info.Make.Remote) if m.Option(ice.MSG_USERPOD) == "" {
m.Option(nfs.SOURCE, web.AdminCmd(m, cli.RUNTIME, "make.remote").Result())
} else {
m.Option(nfs.SOURCE, web.AdminCmd(m, web.SPACE, m.Option(ice.MSG_USERPOD), cli.RUNTIME, "make.remote").Result())
}
case nfs.BINARY, ice.APP: case nfs.BINARY, ice.APP:
case cli.CURL, cli.WGET: case cli.CURL, cli.WGET:
case "manual": case "manual":

View File

@ -186,6 +186,7 @@ func (m *Message) IsErr(arg ...string) bool {
} }
func (m *Message) IsErrNotFound() bool { return m.IsErr(ErrNotFound) } func (m *Message) IsErrNotFound() bool { return m.IsErr(ErrNotFound) }
func (m *Message) IsErrNotFoundSpace() bool { return m.IsErr(ErrNotFoundSpace) } func (m *Message) IsErrNotFoundSpace() bool { return m.IsErr(ErrNotFoundSpace) }
func (m *Message) IsErrNotFoundIndex() bool { return m.IsErr(ErrNotFoundIndex) }
func (m *Message) Debug(str string, arg ...Any) { func (m *Message) Debug(str string, arg ...Any) {
if m.Option(MSG_DEBUG) == TRUE { if m.Option(MSG_DEBUG) == TRUE {
kit.Format(str == "", func() { str = m.FormatMeta() }) kit.Format(str == "", func() { str = m.FormatMeta() })