summaryrefslogtreecommitdiff
path: root/internal/config
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config')
-rw-r--r--internal/config/config.go17
-rw-r--r--internal/config/config_test.go22
2 files changed, 34 insertions, 5 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index 4e40cdf..02f2fee 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -10,11 +10,13 @@ import (
// Organization represents a git organization with its host and name
type Organization struct {
- Host string `json:"host"`
- Name string `json:"name"`
- GitHubToken string `json:"github_token,omitempty"`
- CodebergToken string `json:"codeberg_token,omitempty"`
- BackupLocation bool `json:"backupLocation,omitempty"` // Mark this as a backup-only destination
+ Host string `json:"host"`
+ Name string `json:"name"`
+ GitHubToken string `json:"github_token,omitempty"`
+ CodebergToken string `json:"codeberg_token,omitempty"`
+ BackupLocation bool `json:"backupLocation,omitempty"` // Mark this as a backup-only destination
+ DescriptionSyncHost string `json:"descriptionSyncHost,omitempty"` // SSH host with shell access for updating backup descriptions
+ DescriptionSyncRoot string `json:"descriptionSyncRoot,omitempty"` // Filesystem path on DescriptionSyncHost where bare repos live
}
// Config holds the application configuration
@@ -101,6 +103,11 @@ func (c *Config) Validate() error {
if org.Name == "" && !strings.HasPrefix(org.Host, "file://") && !org.IsSSH() {
return fmt.Errorf("organization %d: missing name", i)
}
+ hasDescriptionSyncHost := strings.TrimSpace(org.DescriptionSyncHost) != ""
+ hasDescriptionSyncRoot := strings.TrimSpace(org.DescriptionSyncRoot) != ""
+ if hasDescriptionSyncHost != hasDescriptionSyncRoot {
+ return fmt.Errorf("organization %d: descriptionSyncHost and descriptionSyncRoot must be set together", i)
+ }
}
for repo, branch := range c.ShowcaseStatsBranches {
diff --git a/internal/config/config_test.go b/internal/config/config_test.go
index db70457..30b59df 100644
--- a/internal/config/config_test.go
+++ b/internal/config/config_test.go
@@ -25,3 +25,25 @@ func TestValidate_ShowcaseStatsBranchesRejectsEmptyBranch(t *testing.T) {
t.Fatalf("Validate() error = %q, want showcase_stats_branches context", err)
}
}
+
+func TestValidate_DescriptionSyncFieldsMustBePaired(t *testing.T) {
+ t.Parallel()
+
+ cfg := &Config{
+ Organizations: []Organization{
+ {
+ Host: "ssh://git@example.com/repos",
+ BackupLocation: true,
+ DescriptionSyncHost: "root@example.com",
+ },
+ },
+ }
+
+ err := cfg.Validate()
+ if err == nil {
+ t.Fatal("Validate() error = nil, want description sync validation error")
+ }
+ if !strings.Contains(err.Error(), "descriptionSyncHost") {
+ t.Fatalf("Validate() error = %q, want descriptionSyncHost context", err)
+ }
+}