2024-06-28 15:28:54 +02:00
|
|
|
package cli
|
|
|
|
|
2024-07-03 10:00:21 +02:00
|
|
|
import (
|
|
|
|
"log/slog"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"code.lila.network/adoralaura/certwarden-deploy/internal/certificates"
|
|
|
|
"code.lila.network/adoralaura/certwarden-deploy/internal/configuration"
|
|
|
|
"code.lila.network/adoralaura/certwarden-deploy/internal/constants"
|
|
|
|
"code.lila.network/adoralaura/certwarden-deploy/internal/errlog"
|
|
|
|
"code.lila.network/adoralaura/certwarden-deploy/internal/logger"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
2024-06-28 15:28:54 +02:00
|
|
|
|
|
|
|
var RootCmd = &cobra.Command{
|
|
|
|
Use: "certwarden-deploy",
|
2024-07-03 10:00:21 +02:00
|
|
|
Short: "Deploy Certificates from CertWarden in a breeze",
|
|
|
|
Long: `certwarden-deploy is a CLI utility to deploy certificates managed by CertWarden.
|
|
|
|
Configuration is handled by a single YAML file, so you can get started quickly.
|
|
|
|
|
|
|
|
For more information on how to configure this tool, visit the docs at https://certwarden-deploy.adora.codes`,
|
|
|
|
Version: constants.Version,
|
|
|
|
CompletionOptions: cobra.CompletionOptions{DisableDefaultCmd: true},
|
|
|
|
Args: cobra.ExactArgs(0),
|
|
|
|
Run: handleRootCmd,
|
|
|
|
}
|
|
|
|
|
|
|
|
func handleRootCmd(cmd *cobra.Command, args []string) {
|
|
|
|
config, err := configuration.InitializeConfig()
|
|
|
|
if err != nil {
|
|
|
|
slog.Error("failed to initialize config", "error", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
log := logger.InitializeLogger()
|
|
|
|
err = errlog.SetupSentry(log, config.Sentry.DSN)
|
|
|
|
if err != nil {
|
|
|
|
slog.Error("failed to initialize sentry", "error", err)
|
|
|
|
}
|
2024-06-28 15:28:54 +02:00
|
|
|
|
2024-07-03 10:00:21 +02:00
|
|
|
certificates.HandleCertificates(log, config)
|
2024-06-28 15:28:54 +02:00
|
|
|
}
|