Refactored config system again
All checks were successful
Build (artifact) / build (push) Successful in 27s

This commit is contained in:
2026-06-30 16:48:05 -04:00
parent c01195643a
commit 0a78b70821
18 changed files with 478 additions and 175 deletions

View File

@@ -18,7 +18,7 @@ type Daemon struct{}
func (d *Daemon) Init() {
fmt.Println("Starting CertManager in client mode...")
err := app.LoadDomainConfigs()
err := app.LoadClientDomainConfigs()
if err != nil {
log.Fatalf("Error loading domain configs: %v", err)
}
@@ -31,7 +31,7 @@ func (d *Daemon) Tick() {
// Get local copy of configs
config := app.Config()
localDomainConfigs := app.DomainStore().Snapshot()
localDomainConfigs := app.ClientDomainStore().Snapshot()
// Loop over all domain configs (domains)
for domainStr, domainConfig := range localDomainConfigs {
@@ -40,32 +40,6 @@ func (d *Daemon) Tick() {
continue
}
// Skip domains with up-to-date commit hashes
// If the repo doesn't exist, we can't check for a remote commit, so stop the rest of the check
repoExists := domainConfig.Internal.RepoExists
if repoExists {
dataRoot := common.EffectiveDataRoot(config, domainConfig)
localHash, err := client.LocalCommitHash(domainStr, dataRoot)
if err != nil {
fmt.Printf("No local commit hash found for domain %s\n", domainStr)
}
gitSource, err := common.StrToGitSource(app.Config().Git.Host)
if err != nil {
fmt.Printf("Error getting git source for domain %s: %v\n", domainStr, err)
continue
}
remoteHash, err := client.RemoteCommitHash(domainStr, gitSource, config, domainConfig)
if err != nil {
fmt.Printf("Error getting remote commit hash for domain %s: %v\n", domainStr, err)
}
// If both hashes are blank (errored), break
// If localHash equals remoteHash (local is up-to-date), skip
if !(localHash == "" && remoteHash == "") && localHash == remoteHash {
fmt.Printf("Domain %s is up to date. Skipping...\n", domainStr)
continue
}
}
gitWorkspace := &common.GitWorkspace{
Domain: domainStr,
URL: app.Config().Git.Server + "/" + config.Git.OrgName + "/" + domainStr + domainConfig.Repo.RepoSuffix + ".git",
@@ -80,7 +54,7 @@ func (d *Daemon) Tick() {
continue
}
effectiveDataRoot := common.EffectiveDataRoot(config, domainConfig)
effectiveDataRoot := common.EffectiveDataRoot(config, domainConfig.Certificates.DataRoot)
certsDir := filepath.Join(effectiveDataRoot, "certificates", domainStr)
// Get files in repo
@@ -122,7 +96,7 @@ func (d *Daemon) Tick() {
continue
}
dataRoot := common.EffectiveDataRoot(config, domainConfig)
dataRoot := common.EffectiveDataRoot(config, domainConfig.Certificates.DataRoot)
err = client.WriteCommitHash(headRef.Hash().String(), dataRoot)
if err != nil {
fmt.Printf("Error writing commit hash: %v\n", err)
@@ -154,7 +128,7 @@ func (d *Daemon) Tick() {
func (d *Daemon) Reload() {
fmt.Println("Reloading configs...")
err := app.LoadDomainConfigs()
err := app.LoadClientDomainConfigs()
if err != nil {
fmt.Printf("Error loading domain configs: %v\n", err)
return