[CI-SKIP] Upload current
This commit is contained in:
@@ -2,13 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"git.nevets.tech/Steven/certman/app"
|
||||
"git.nevets.tech/Steven/certman/client"
|
||||
"git.nevets.tech/Steven/certman/common"
|
||||
"github.com/go-git/go-billy/v5/memfs"
|
||||
"github.com/go-git/go-git/v5/storage/memory"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -47,21 +44,18 @@ func init() {
|
||||
}
|
||||
|
||||
func renewCert(domain string) error {
|
||||
gitWorkspace := &common.GitWorkspace{
|
||||
Domain: domain,
|
||||
Storage: memory.NewStorage(),
|
||||
FS: memfs.New(),
|
||||
}
|
||||
config := app.Config()
|
||||
domainConfig, exists := app.DomainStore().Get(domain)
|
||||
if !exists {
|
||||
return app.ErrConfigNotFound
|
||||
}
|
||||
if err := client.PullCerts(config, domainConfig, gitWorkspace); err != nil {
|
||||
return err
|
||||
url := common.RepoURL(config, domainConfig, domain)
|
||||
ws := common.NewGitWorkspace(domain, url)
|
||||
if err := common.CloneRepo(ws, config); err != nil {
|
||||
return fmt.Errorf("clone %s: %w", domain, err)
|
||||
}
|
||||
certsDir := common.EffectiveDataRoot(config, domainConfig)
|
||||
return client.DecryptAndWriteCertificates(certsDir, config, domainConfig, gitWorkspace)
|
||||
certsDir := common.CertsDir(config, domainConfig, domain)
|
||||
return client.DecryptAndWriteCertificates(certsDir, domainConfig, ws)
|
||||
}
|
||||
|
||||
func updateLinks(domain string) error {
|
||||
@@ -69,26 +63,6 @@ func updateLinks(domain string) error {
|
||||
if !exists {
|
||||
return fmt.Errorf("domain %s does not exist", domain)
|
||||
}
|
||||
|
||||
effectiveDataRoot := common.EffectiveDataRoot(app.Config(), domainConfig)
|
||||
certsDir := filepath.Join(effectiveDataRoot, "certificates", domain)
|
||||
|
||||
certLinks := domainConfig.Certificates.CertSymlinks
|
||||
for _, certLink := range certLinks {
|
||||
err := common.LinkFile(filepath.Join(certsDir, domain+".crt"), certLink, domain, ".crt")
|
||||
if err != nil {
|
||||
fmt.Printf("Error linking cert %s to %s: %v", certLink, domain, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
keyLinks := domainConfig.Certificates.KeySymlinks
|
||||
for _, keyLink := range keyLinks {
|
||||
err := common.LinkFile(filepath.Join(certsDir, domain+".key"), keyLink, domain, ".key")
|
||||
if err != nil {
|
||||
fmt.Printf("Error linking cert %s to %s: %v", keyLink, domain, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
return nil
|
||||
certsDir := common.CertsDir(app.Config(), domainConfig, domain)
|
||||
return client.UpdateSymlinks(domain, domainConfig, certsDir)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user