diff --git a/cmd/discover.go b/cmd/discover.go index b2432a0..40679a5 100644 --- a/cmd/discover.go +++ b/cmd/discover.go @@ -28,11 +28,11 @@ type ExistingMonitors struct { func (em ExistingMonitors) HasMonitorByName(name string) bool { for _, value := range em.Monitors { if em.CurrentCode != "" { - if value.Code == em.CurrentCode { + if value.Attributes.Code == em.CurrentCode { continue } } else { - if value.Key == em.CurrentKey { + if value.Attributes.Key == em.CurrentKey { continue } } @@ -55,11 +55,11 @@ func (em ExistingMonitors) HasMonitorByName(name string) bool { func (em ExistingMonitors) GetNameForCurrent() (string, error) { for _, value := range em.Monitors { if em.CurrentCode != "" { - if value.Code == em.CurrentCode { + if value.Attributes.Code == em.CurrentCode { return value.Name, nil } } else { - if value.Key == em.CurrentKey { + if value.Attributes.Key == em.CurrentKey { return value.Name, nil } } @@ -503,7 +503,7 @@ func initialNameInputModel(defaultName string) nameInputModel { // Setup list items items := []list.Item{ item{title: UseDefaultName, desc: defaultName}, - item{title: EnterCustomName, desc: "A unique name is required"}, + item{title: EnterCustomName, desc: "Add a friendly, unique name for this job"}, item{title: SkipJob, desc: "Do not monitor this cron job"}, } @@ -608,8 +608,8 @@ func (m nameInputModel) View() string { } const ( - UseDefaultName = "Monitor this job - Use default name" - EnterCustomName = "Monitor this job - Enter custom name" + UseDefaultName = "Monitor this job - Use this name:" + EnterCustomName = "Monitor this job - Change the name" SkipJob = "Skip this job" ) diff --git a/lib/cronitor.go b/lib/cronitor.go index f8015c1..9d37805 100644 --- a/lib/cronitor.go +++ b/lib/cronitor.go @@ -45,6 +45,11 @@ const ( ) type Monitor struct { + Attributes struct { + GroupName string `json:"group_name"` + Key string `json:"key"` + Code string `json:"code"` + } `json:"attributes,omitempty"` Name string `json:"name,omitempty"` DefaultName string `json:"defaultName"` Key string `json:"key"` @@ -63,7 +68,12 @@ type MonitorSummary struct { Name string `json:"name,omitempty"` DefaultName string `json:"defaultName"` Key string `json:"key"` - Code string `json:"code,omitempty"` + Code string `json:"attributes.code,omitempty"` + Attributes struct { + GroupName string `json:"group_name"` + Key string `json:"key"` + Code string `json:"code"` + } `json:"attributes,omitempty"` } type CronitorApi struct { @@ -129,8 +139,8 @@ func (api CronitorApi) PutMonitors(monitors map[string]*Monitor) (map[string]*Mo } for _, value := range responseMonitors { - if _, ok := monitors[value.Key]; ok { - monitors[value.Key].Code = value.Code + if _, ok := monitors[value.Attributes.Key]; ok { + monitors[value.Attributes.Key].Attributes = value.Attributes } } diff --git a/lib/crontab.go b/lib/crontab.go index dc6a20b..d2f6a9d 100644 --- a/lib/crontab.go +++ b/lib/crontab.go @@ -304,7 +304,7 @@ func (l Line) Write() string { lineParts = append(lineParts, "--no-stdout") } lineParts = append(lineParts, "exec") - lineParts = append(lineParts, l.Mon.Code) + lineParts = append(lineParts, l.Mon.Attributes.Code) if len(l.CommandToRun) > 0 { if l.CommandIsComplex() {