Skip to content

Commit

Permalink
add child phases to info endpoint (#139)
Browse files Browse the repository at this point in the history
* add child phases to info endpoint

* update dockerfile
  • Loading branch information
jbsmith7741 authored Jan 6, 2021
1 parent b40f6aa commit 8c5e7f5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
19 changes: 15 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@

FROM alpine:3.10.2
ADD https://github.com/kelseyhightower/confd/releases/download/v0.16.0/confd-0.16.0-linux-amd64 /usr/bin/confd
FROM alpine:3.12

RUN chmod +x /usr/bin/confd
RUN apk add ca-certificates
RUN apk add curl
RUN apk add jq

#confd
ADD https://github.com/kelseyhightower/confd/releases/download/v0.16.0/confd-0.16.0-linux-amd64 /usr/bin/confd
RUN chmod +x /usr/bin/confd

#gojq
ADD https://github.com/itchyny/gojq/releases/download/v0.12.0/gojq_v0.12.0_linux_amd64.tar.gz /tmp/jq.tar.gz
RUN cd /tmp && tar -xzf jq.tar.gz
RUN cp /tmp/gojq_v0.12.0_linux_amd64/gojq /usr/bin/jq
RUN rm -rf /tmp/*

#ll
RUN echo -e "#!/bin/sh \n ls -Alhp \$1" > /usr/bin/ll
RUN chmod +x /usr/bin/ll

COPY build/ /usr/bin/
20 changes: 17 additions & 3 deletions apps/taskmasters/flowlord/taskmaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ type stats struct {
RunTime string `json:"runtime"`
NextUpdate string `json:"next_cache_update"`
Workflow map[string]int `json:"workflow"`
Entries map[string]cEntry `json:"job"`
Entries map[string]cEntry `json:"cron"`
}

type cEntry struct {
Next time.Time
Prev time.Time
Schedule string
Child []string `json:"Child,omitempty"`
}

func New(app *bootstrap.TaskMaster) bootstrap.Runner {
Expand Down Expand Up @@ -94,8 +95,11 @@ func (tm *taskMaster) Info() interface{} {
Next: e.Next,
Prev: e.Prev,
Schedule: j.Schedule,
Child: make([]string, 0),
}
sts.Entries[j.Name] = ent
k := j.Topic + ":" + j.Name
ent.Child = tm.getAllChildren(j.Topic, j.Workflow, j.Name)
sts.Entries[k] = ent
}
if tm.Cache != nil {
for k, v := range tm.Workflows {
Expand All @@ -105,6 +109,17 @@ func (tm *taskMaster) Info() interface{} {
return sts
}

func (tm *taskMaster) getAllChildren(topic, workflow, job string) (s []string) {
for _, c := range tm.Children(task.Task{Type: topic, Meta: "workflow=" + workflow + "&job=" + job}) {
job := c.Task + ":" + c.Job()
if children := tm.getAllChildren(c.Task, workflow, c.Job()); len(children) > 0 {
job += " ➞ " + strings.Join(children, " ➞ ")
}
s = append(s, job)
}
return s
}

// AutoUpdate will create a go routine to auto update the cached files
// if any changes have been made to the workflow files
func (tm *taskMaster) AutoUpdate() {
Expand Down Expand Up @@ -185,7 +200,6 @@ func (tm *taskMaster) schedule() (err error) {
if _, err = tm.cron.AddJob(j.Schedule, j); err != nil {
return errors.Wrapf(err, "invalid rule for %s:%s %s", path, w.Task, w.Rule)
}
log.Printf("cron: task:%s, rule:%s, info:%s\t %v \n", w.Task, j.Schedule, w.Template, rules)
}
}
tm.cron.Start()
Expand Down
7 changes: 6 additions & 1 deletion workflow/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ func (p Phase) Job() string {
if len(s) > 1 {
return s[1]
}
return s[0]

r, _ := url.ParseQuery(p.Rule)
if j := r.Get("job"); j != "" {
return j
}
return ""
}

// Topic portion of the Task
Expand Down

0 comments on commit 8c5e7f5

Please sign in to comment.