-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.go
More file actions
42 lines (36 loc) · 720 Bytes
/
api.go
File metadata and controls
42 lines (36 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package dksync
import (
"encoding/json"
log "github.com/sirupsen/logrus"
)
type ApiSync struct {
// Tag name
Tag string
// Enables Debug
Debug bool
// Args to update
Args Args
// Unexported fields
// jobs
jobs []job
}
// Processor retrieves jobs from API considering specific query filter
// then update each job in API
func (sync *ApiSync) Processor() {
checkHost()
if sync.Debug {
setDebug()
}
if jobs := getJobs(); jobs != nil {
if err := json.Unmarshal(jobs, &sync.jobs); err != nil {
log.Fatal(err)
}
for _, job := range sync.jobs {
// TODO - allow to filter for other options
if job.Tags[sync.Tag] != "" {
sync.Args.setFieldValue(&job)
job.update()
}
}
}
}