Lets see if this works
All checks were successful
Build (artifact) / build (push) Successful in 1m13s
All checks were successful
Build (artifact) / build (push) Successful in 1m13s
This commit is contained in:
@@ -47,17 +47,19 @@ 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 {
|
||||
|
||||
gitWorkspace := &common.GitWorkspace{
|
||||
Domain: domain,
|
||||
URL: config.Git.Server + "/" + config.Git.OrgName + "/" + domain + domainConfig.Repo.RepoSuffix + ".git",
|
||||
Storage: memory.NewStorage(),
|
||||
FS: memfs.New(),
|
||||
}
|
||||
if err := client.PullCerts(config, gitWorkspace); err != nil {
|
||||
return err
|
||||
}
|
||||
certsDir := common.EffectiveDataRoot(config, domainConfig)
|
||||
|
||||
@@ -67,13 +67,14 @@ func (d *Daemon) Tick() {
|
||||
}
|
||||
|
||||
gitWorkspace := &common.GitWorkspace{
|
||||
Domain: domainStr,
|
||||
URL: app.Config().Git.Server + "/" + config.Git.OrgName + "/" + domainStr + domainConfig.Repo.RepoSuffix + ".git",
|
||||
Storage: memory.NewStorage(),
|
||||
FS: memfs.New(),
|
||||
}
|
||||
// Ex: https://git.example.com/Org/Repo-suffix.git
|
||||
// Clones repo and stores in gitWorkspace, skip if clone fails (doesn't exist?)
|
||||
repoUrl := app.Config().Git.Server + "/" + config.Git.OrgName + "/" + domainStr + domainConfig.Repo.RepoSuffix + ".git"
|
||||
err := common.CloneRepo(repoUrl, gitWorkspace, common.Client, config)
|
||||
err := gitWorkspace.CloneRepo(common.Client, config)
|
||||
if err != nil {
|
||||
fmt.Printf("Error cloning domain repo %s: %v\n", domainStr, err)
|
||||
continue
|
||||
@@ -121,7 +122,8 @@ func (d *Daemon) Tick() {
|
||||
continue
|
||||
}
|
||||
|
||||
err = common.WriteCommitHash(headRef.Hash().String(), config, domainConfig)
|
||||
dataRoot := common.EffectiveDataRoot(config, domainConfig)
|
||||
err = client.WriteCommitHash(headRef.Hash().String(), dataRoot)
|
||||
if err != nil {
|
||||
fmt.Printf("Error writing commit hash: %v\n", err)
|
||||
continue
|
||||
|
||||
@@ -55,17 +55,17 @@ func init() {
|
||||
}
|
||||
|
||||
func devCmd(cmd *cobra.Command, args []string) {
|
||||
testDomain := "lunamc.org"
|
||||
err := LoadConfig()
|
||||
if err != nil {
|
||||
log.Fatalf("Error loading configuration: %v\n", err)
|
||||
}
|
||||
err = LoadDomainConfigs()
|
||||
if err != nil {
|
||||
log.Fatalf("Error loading configs: %v\n", err)
|
||||
}
|
||||
|
||||
fmt.Println(testDomain)
|
||||
//testDomain := "lunamc.org"
|
||||
//err := LoadConfig()
|
||||
//if err != nil {
|
||||
// log.Fatalf("Error loading configuration: %v\n", err)
|
||||
//}
|
||||
//err = LoadDomainConfigs()
|
||||
//if err != nil {
|
||||
// log.Fatalf("Error loading configs: %v\n", err)
|
||||
//}
|
||||
//
|
||||
//fmt.Println(testDomain)
|
||||
}
|
||||
|
||||
func versionCmd(cmd *cobra.Command, args []string) {
|
||||
|
||||
@@ -90,10 +90,9 @@ func renewCerts(domain string, noPush bool, mgr *server.ACMEManager) error {
|
||||
FS: memfs.New(),
|
||||
}
|
||||
|
||||
var repoUrl string
|
||||
if !domainConfig.Internal.RepoExists {
|
||||
repoUrl = common.CreateGiteaRepo(domain, giteaClient, config, domainConfig)
|
||||
if repoUrl == "" {
|
||||
gitWorkspace.URL = common.CreateGiteaRepo(domain, giteaClient, config, domainConfig)
|
||||
if gitWorkspace.URL == "" {
|
||||
return fmt.Errorf("error creating Gitea repo for domain %s", domain)
|
||||
}
|
||||
domainConfig.Internal.RepoExists = true
|
||||
@@ -102,19 +101,20 @@ func renewCerts(domain string, noPush bool, mgr *server.ACMEManager) error {
|
||||
return fmt.Errorf("error saving domain config %s: %v", domain, err)
|
||||
}
|
||||
|
||||
err = common.InitRepo(repoUrl, gitWorkspace)
|
||||
err = gitWorkspace.InitRepo()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error initializing repo for domain %s: %v", domain, err)
|
||||
}
|
||||
} else {
|
||||
repoUrl = config.Git.Server + "/" + config.Git.OrgName + "/" + domain + domainConfig.Repo.RepoSuffix + ".git"
|
||||
err = common.CloneRepo(repoUrl, gitWorkspace, common.Server, config)
|
||||
gitWorkspace.URL = config.Git.Server + "/" + config.Git.OrgName + "/" + domain + domainConfig.Repo.RepoSuffix + ".git"
|
||||
err = gitWorkspace.CloneRepo(common.Server, config)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error cloning repo for domain %s: %v", domain, err)
|
||||
}
|
||||
}
|
||||
|
||||
err = common.AddAndPushCerts(domain, gitWorkspace, config, domainConfig)
|
||||
dataRoot := common.EffectiveDataRoot(config, domainConfig)
|
||||
err = server.AddAndPushCerts(gitWorkspace, dataRoot, domainConfig.Repo.RepoSuffix, config)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error pushing certificates for domain %s: %v", domain, err)
|
||||
}
|
||||
|
||||
@@ -113,10 +113,9 @@ func (d *Daemon) Tick() {
|
||||
FS: memfs.New(),
|
||||
}
|
||||
|
||||
var repoUrl string
|
||||
if !domainConfig.Internal.RepoExists {
|
||||
repoUrl = common.CreateGiteaRepo(domainStr, giteaClient, config, domainConfig)
|
||||
if repoUrl == "" {
|
||||
gitWorkspace.URL = common.CreateGiteaRepo(domainStr, giteaClient, config, domainConfig)
|
||||
if gitWorkspace.URL == "" {
|
||||
fmt.Printf("Error creating Gitea repo for domain %s\n", domainStr)
|
||||
continue
|
||||
}
|
||||
@@ -127,21 +126,22 @@ func (d *Daemon) Tick() {
|
||||
continue
|
||||
}
|
||||
|
||||
err = common.InitRepo(repoUrl, gitWorkspace)
|
||||
err = gitWorkspace.InitRepo()
|
||||
if err != nil {
|
||||
fmt.Printf("Error initializing repo for domain %s: %v\n", domainStr, err)
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
repoUrl = appShared.Config().Git.Server + "/" + appShared.Config().Git.OrgName + "/" + domainStr + domainConfig.Repo.RepoSuffix + ".git"
|
||||
err = common.CloneRepo(repoUrl, gitWorkspace, common.Server, config)
|
||||
gitWorkspace.URL = appShared.Config().Git.Server + "/" + appShared.Config().Git.OrgName + "/" + domainStr + domainConfig.Repo.RepoSuffix + ".git"
|
||||
err = gitWorkspace.CloneRepo(common.Server, config)
|
||||
if err != nil {
|
||||
fmt.Printf("Error cloning repo for domain %s: %v\n", domainStr, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
err = common.AddAndPushCerts(domainStr, gitWorkspace, config, domainConfig)
|
||||
dataRoot := common.EffectiveDataRoot(config, domainConfig)
|
||||
err = server.AddAndPushCerts(gitWorkspace, dataRoot, domainConfig.Repo.RepoSuffix, config)
|
||||
if err != nil {
|
||||
fmt.Printf("Error pushing certificates for domain %s: %v\n", domainStr, err)
|
||||
continue
|
||||
|
||||
@@ -1,7 +1,37 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.nevets.tech/Steven/certman/app"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hello server")
|
||||
rootCmd := &cobra.Command{
|
||||
Use: "certman",
|
||||
Short: "CertMan",
|
||||
Long: "Certificate Manager",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return cmd.Help()
|
||||
},
|
||||
}
|
||||
|
||||
rootCmd.AddCommand(app.VersionCmd)
|
||||
rootCmd.AddCommand(app.NewKeyCmd)
|
||||
rootCmd.AddCommand(app.DevCmd)
|
||||
|
||||
rootCmd.AddCommand(app.NewDomainCmd)
|
||||
//-----------------------------------
|
||||
rootCmd.AddCommand(app.InstallCmd)
|
||||
|
||||
rootCmd.AddCommand(app.CertCmd)
|
||||
|
||||
rootCmd.AddCommand(app.DaemonCmd)
|
||||
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user