P1.1: swap yaml struct tags for json in domain types
Replace yaml:"…" tags with json:"…" on Job, Config, and JobsFile. Add omitempty to bool fields in Config that previously lacked it. Update comments to reference .json filenames. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -80,7 +80,7 @@ These land together because both edit `domain/job.go` and `storage/store.go`.
|
|||||||
## Completion checklist
|
## Completion checklist
|
||||||
|
|
||||||
### Phase 1 — Storage JSON + exit-code removal
|
### Phase 1 — Storage JSON + exit-code removal
|
||||||
- [ ] P1.1 — JSON struct tags
|
- [x] P1.1 — JSON struct tags
|
||||||
- [ ] P1.2 — `writeJSON` + JSON unmarshal
|
- [ ] P1.2 — `writeJSON` + JSON unmarshal
|
||||||
- [ ] P1.3 — `gosentry.json` / `jobs.json` paths; drop pysentry name
|
- [ ] P1.3 — `gosentry.json` / `jobs.json` paths; drop pysentry name
|
||||||
- [ ] P1.4 — One-time YAML import
|
- [ ] P1.4 — One-time YAML import
|
||||||
|
|||||||
+10
-10
@@ -5,21 +5,21 @@ package domain
|
|||||||
// launches omit this flag and open the normal window.
|
// launches omit this flag and open the normal window.
|
||||||
const StartInTrayArgument = "--start-in-tray"
|
const StartInTrayArgument = "--start-in-tray"
|
||||||
|
|
||||||
// Config is stored in gosentry.yaml next to the program. It contains only
|
// Config is stored in gosentry.json next to the program. It contains only
|
||||||
// application-level choices: where to read jobs from, where to write logs, and
|
// application-level choices: where to read jobs from, where to write logs, and
|
||||||
// how the desktop shell should behave.
|
// how the desktop shell should behave.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
JobsDir string `yaml:"jobs_dir"`
|
JobsDir string `json:"jobs_dir"`
|
||||||
LogsDir string `yaml:"logs_dir"`
|
LogsDir string `json:"logs_dir"`
|
||||||
MaxLogFiles int `yaml:"max_log_files"`
|
MaxLogFiles int `json:"max_log_files"`
|
||||||
MaxLogAgeDays int `yaml:"max_log_age_days"`
|
MaxLogAgeDays int `json:"max_log_age_days"`
|
||||||
StartOnLogin bool `yaml:"start_on_login"`
|
StartOnLogin bool `json:"start_on_login,omitempty"`
|
||||||
KeepRunningInTray bool `yaml:"keep_running_in_tray"`
|
KeepRunningInTray bool `json:"keep_running_in_tray,omitempty"`
|
||||||
NotifyOnFailure bool `yaml:"notify_on_failure"`
|
NotifyOnFailure bool `json:"notify_on_failure,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// JobsFile is the on-disk shape of jobs.yaml. Wrapping the slice in a top-level
|
// JobsFile is the on-disk shape of jobs.json. Wrapping the slice in a top-level
|
||||||
// object leaves room for future metadata without breaking the basic file format.
|
// object leaves room for future metadata without breaking the basic file format.
|
||||||
type JobsFile struct {
|
type JobsFile struct {
|
||||||
Jobs []Job `yaml:"jobs"`
|
Jobs []Job `json:"jobs"`
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-10
@@ -1,18 +1,18 @@
|
|||||||
package domain
|
package domain
|
||||||
|
|
||||||
// Job is the user-visible scheduled command. It contains only durable
|
// Job is the user-visible scheduled command. It contains only durable
|
||||||
// configuration: every field is persisted to jobs.yaml. Transient execution
|
// configuration: every field is persisted to jobs.json. Transient execution
|
||||||
// state (last run, next run, command output, in-memory activity) lives in a
|
// state (last run, next run, command output, in-memory activity) lives in a
|
||||||
// separate JobRuntime so the jobs file stays a clean, hand-editable record of
|
// separate JobRuntime so the jobs file stays a clean, hand-editable record of
|
||||||
// configuration and never mixes in process-lifetime bookkeeping.
|
// configuration and never mixes in process-lifetime bookkeeping.
|
||||||
type Job struct {
|
type Job struct {
|
||||||
ID int `yaml:"id"`
|
ID int `json:"id"`
|
||||||
Name string `yaml:"name"`
|
Name string `json:"name"`
|
||||||
Folder string `yaml:"folder,omitempty"`
|
Folder string `json:"folder,omitempty"`
|
||||||
Schedule string `yaml:"schedule"`
|
Schedule string `json:"schedule"`
|
||||||
Command string `yaml:"command"`
|
Command string `json:"command"`
|
||||||
Arguments string `yaml:"arguments,omitempty"`
|
Arguments string `json:"arguments,omitempty"`
|
||||||
SuccessExitCodes string `yaml:"success_exit_codes,omitempty"`
|
SuccessExitCodes string `json:"success_exit_codes,omitempty"`
|
||||||
StartOnly bool `yaml:"start_only,omitempty"`
|
StartOnly bool `json:"start_only,omitempty"`
|
||||||
Enabled bool `yaml:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user