refactor(config): leave the default CI retention to the CI use case
- commit
- 47fa8def9d18d90770c631e09290ff47c14e4530
- author
- brice · · 2026-10-12 19:26 UTC
- parent
- c31fed8
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +4 -6
M internal/config/config.go +2 -4
| @@ -52,8 +52,6 @@ const ( | |||
| 52 | 52 | DefaultCommitterName = "ermite" | |
| 53 | 53 | // DefaultOwner is the owner login when ERMITE_OWNER is not set. | |
| 54 | 54 | DefaultOwner = "owner" | |
| 55 | - | // DefaultCIRetention is the retention of CI data. | |
| 56 | - | DefaultCIRetention = 90 * 24 * time.Hour | |
| 57 | 55 | ) | |
| 58 | 56 | ||
| 59 | 57 | // Values of ERMITE_GIT_READER. | |
| @@ -97,7 +95,8 @@ type Config struct { | |||
| 97 | 95 | CommitterName, CommitterEmail string | |
| 98 | 96 | // Owner is the owner login of the github context of CI runs. | |
| 99 | 97 | Owner string | |
| 100 | - | // CIRetention is how long CI data is kept. | |
| 98 | + | // CIRetention is how long CI data is kept; 0 (variable unset) leaves the | |
| 99 | + | // default to the CI use case. | |
| 101 | 100 | CIRetention time.Duration | |
| 102 | 101 | } | |
| 103 | 102 | ||
| @@ -239,7 +238,6 @@ func Load(get func(string) string) (Config, error) { | |||
| 239 | 238 | c.Owner = DefaultOwner | |
| 240 | 239 | } | |
| 241 | 240 | ||
| 242 | - | c.CIRetention = DefaultCIRetention | |
| 243 | 241 | if raw := strings.TrimSpace(get(EnvCILogRetention)); raw != "" { | |
| 244 | 242 | d, err := parseRetention(raw) | |
| 245 | 243 | if err != nil { | |
| @@ -52,8 +52,6 @@ const ( | |||||
| 52 | DefaultCommitterName = "ermite" | 52 | DefaultCommitterName = "ermite" | ||
| 53 | // DefaultOwner is the owner login when ERMITE_OWNER is not set. | 53 | // DefaultOwner is the owner login when ERMITE_OWNER is not set. | ||
| 54 | DefaultOwner = "owner" | 54 | DefaultOwner = "owner" | ||
| 55 | - | // DefaultCIRetention is the retention of CI data. | |||
| 56 | - | DefaultCIRetention = 90 * 24 * time.Hour | |||
| 57 | ) | 55 | ) | ||
| 58 | 56 | ||||
| 59 | // Values of ERMITE_GIT_READER. | 57 | // Values of ERMITE_GIT_READER. | ||
| @@ -97,7 +95,8 @@ type Config struct { | |||||
| 97 | CommitterName, CommitterEmail string | 95 | CommitterName, CommitterEmail string | ||
| 98 | // Owner is the owner login of the github context of CI runs. | 96 | // Owner is the owner login of the github context of CI runs. | ||
| 99 | Owner string | 97 | Owner string | ||
| 100 | - | // CIRetention is how long CI data is kept. | 98 | + | // CIRetention is how long CI data is kept; 0 (variable unset) leaves the |
| 99 | + | // default to the CI use case. | |||
| 101 | CIRetention time.Duration | 100 | CIRetention time.Duration | ||
| 102 | } | 101 | } | ||
| 103 | 102 | ||||
| @@ -239,7 +238,6 @@ func Load(get func(string) string) (Config, error) { | |||||
| 239 | c.Owner = DefaultOwner | 238 | c.Owner = DefaultOwner | ||
| 240 | } | 239 | } | ||
| 241 | 240 | ||||
| 242 | - | c.CIRetention = DefaultCIRetention | |||
| 243 | if raw := strings.TrimSpace(get(EnvCILogRetention)); raw != "" { | 241 | if raw := strings.TrimSpace(get(EnvCILogRetention)); raw != "" { | ||
| 244 | d, err := parseRetention(raw) | 242 | d, err := parseRetention(raw) | ||
| 245 | if err != nil { | 243 | if err != nil { | ||
M internal/config/config_test.go +2 -2
| @@ -230,8 +230,8 @@ func TestOwnerAndCIRetention(t *testing.T) { | |||
| 230 | 230 | if err != nil { | |
| 231 | 231 | t.Fatal(err) | |
| 232 | 232 | } | |
| 233 | - | if c.Owner != "owner" || c.CIRetention != 90*24*time.Hour { | |
| 234 | - | t.Fatalf("defaults: owner %q, retention %v", c.Owner, c.CIRetention) | |
| 233 | + | if c.Owner != "owner" || c.CIRetention != 0 { | |
| 234 | + | t.Fatalf("defaults (retention is left to the use case): owner %q, retention %v", c.Owner, c.CIRetention) | |
| 235 | 235 | } | |
| 236 | 236 | ||
| 237 | 237 | c, err = load(map[string]string{config.EnvOwner: "bnema", config.EnvCILogRetention: "30d"}) | |
| @@ -230,8 +230,8 @@ func TestOwnerAndCIRetention(t *testing.T) { | |||||
| 230 | if err != nil { | 230 | if err != nil { | ||
| 231 | t.Fatal(err) | 231 | t.Fatal(err) | ||
| 232 | } | 232 | } | ||
| 233 | - | if c.Owner != "owner" || c.CIRetention != 90*24*time.Hour { | 233 | + | if c.Owner != "owner" || c.CIRetention != 0 { |
| 234 | - | t.Fatalf("defaults: owner %q, retention %v", c.Owner, c.CIRetention) | 234 | + | t.Fatalf("defaults (retention is left to the use case): owner %q, retention %v", c.Owner, c.CIRetention) |
| 235 | } | 235 | } | ||
| 236 | 236 | ||||
| 237 | c, err = load(map[string]string{config.EnvOwner: "bnema", config.EnvCILogRetention: "30d"}) | 237 | c, err = load(map[string]string{config.EnvOwner: "bnema", config.EnvCILogRetention: "30d"}) | ||