From b7bbb41845b707a1af72cfe73beb2af97db90992 Mon Sep 17 00:00:00 2001 From: mixeme Date: Mon, 22 Jun 2026 21:21:56 +0300 Subject: [PATCH] P1.1: swap yaml struct tags for json in domain types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- docs/PRE-RELEASE-TASKS.md | 2 +- src/domain/config.go | 20 ++++++++++---------- src/domain/job.go | 20 ++++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/PRE-RELEASE-TASKS.md b/docs/PRE-RELEASE-TASKS.md index 50e56a4..897b3b7 100644 --- a/docs/PRE-RELEASE-TASKS.md +++ b/docs/PRE-RELEASE-TASKS.md @@ -80,7 +80,7 @@ These land together because both edit `domain/job.go` and `storage/store.go`. ## Completion checklist ### Phase 1 — Storage JSON + exit-code removal -- [ ] P1.1 — JSON struct tags +- [x] P1.1 — JSON struct tags - [ ] P1.2 — `writeJSON` + JSON unmarshal - [ ] P1.3 — `gosentry.json` / `jobs.json` paths; drop pysentry name - [ ] P1.4 — One-time YAML import diff --git a/src/domain/config.go b/src/domain/config.go index 3bfb3b1..8e5c173 100644 --- a/src/domain/config.go +++ b/src/domain/config.go @@ -5,21 +5,21 @@ package domain // launches omit this flag and open the normal window. 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 // how the desktop shell should behave. type Config struct { - JobsDir string `yaml:"jobs_dir"` - LogsDir string `yaml:"logs_dir"` - MaxLogFiles int `yaml:"max_log_files"` - MaxLogAgeDays int `yaml:"max_log_age_days"` - StartOnLogin bool `yaml:"start_on_login"` - KeepRunningInTray bool `yaml:"keep_running_in_tray"` - NotifyOnFailure bool `yaml:"notify_on_failure"` + JobsDir string `json:"jobs_dir"` + LogsDir string `json:"logs_dir"` + MaxLogFiles int `json:"max_log_files"` + MaxLogAgeDays int `json:"max_log_age_days"` + StartOnLogin bool `json:"start_on_login,omitempty"` + KeepRunningInTray bool `json:"keep_running_in_tray,omitempty"` + 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. type JobsFile struct { - Jobs []Job `yaml:"jobs"` + Jobs []Job `json:"jobs"` } diff --git a/src/domain/job.go b/src/domain/job.go index 0731713..e58b72d 100644 --- a/src/domain/job.go +++ b/src/domain/job.go @@ -1,18 +1,18 @@ package domain // 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 // separate JobRuntime so the jobs file stays a clean, hand-editable record of // configuration and never mixes in process-lifetime bookkeeping. type Job struct { - ID int `yaml:"id"` - Name string `yaml:"name"` - Folder string `yaml:"folder,omitempty"` - Schedule string `yaml:"schedule"` - Command string `yaml:"command"` - Arguments string `yaml:"arguments,omitempty"` - SuccessExitCodes string `yaml:"success_exit_codes,omitempty"` - StartOnly bool `yaml:"start_only,omitempty"` - Enabled bool `yaml:"enabled"` + ID int `json:"id"` + Name string `json:"name"` + Folder string `json:"folder,omitempty"` + Schedule string `json:"schedule"` + Command string `json:"command"` + Arguments string `json:"arguments,omitempty"` + SuccessExitCodes string `json:"success_exit_codes,omitempty"` + StartOnly bool `json:"start_only,omitempty"` + Enabled bool `json:"enabled"` }