refactor: use central logger

This commit is contained in:
2024-07-07 23:45:37 +02:00
parent cf8ff410cc
commit ef108d63e1
86 changed files with 903 additions and 889 deletions

View File

@ -6,9 +6,9 @@ import (
"coopcloud.tech/abra/pkg/app"
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/log"
"coopcloud.tech/abra/pkg/recipe"
"github.com/AlecAivazis/survey/v2"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
@ -21,7 +21,7 @@ func ValidateRecipe(c *cli.Context) recipe.Recipe {
catl, err := recipe.ReadRecipeCatalogue(Offline)
if err != nil {
logrus.Fatal(err)
log.Fatal(err)
}
knownRecipes := make(map[string]bool)
@ -31,7 +31,7 @@ func ValidateRecipe(c *cli.Context) recipe.Recipe {
localRecipes, err := recipe.GetRecipesLocal()
if err != nil {
logrus.Fatal(err)
log.Fatal(err)
}
for _, recipeLocal := range localRecipes {
@ -49,7 +49,7 @@ func ValidateRecipe(c *cli.Context) recipe.Recipe {
Options: recipes,
}
if err := survey.AskOne(prompt, &recipeName); err != nil {
logrus.Fatal(err)
log.Fatal(err)
}
}
@ -61,18 +61,18 @@ func ValidateRecipe(c *cli.Context) recipe.Recipe {
if err != nil {
if c.Command.Name == "generate" {
if strings.Contains(err.Error(), "missing a compose") {
logrus.Fatal(err)
log.Fatal(err)
}
logrus.Warn(err)
log.Warn(err)
} else {
if strings.Contains(err.Error(), "template_driver is not allowed") {
logrus.Warnf("ensure %s recipe compose.* files include \"version: '3.8'\"", recipeName)
log.Warnf("ensure %s recipe compose.* files include \"version: '3.8'\"", recipeName)
}
logrus.Fatalf("unable to validate recipe: %s", err)
log.Fatalf("unable to validate recipe: %s", err)
}
}
logrus.Debugf("validated %s as recipe argument", recipeName)
log.Debugf("validated %s as recipe argument", recipeName)
return chosenRecipe
}
@ -87,10 +87,10 @@ func ValidateApp(c *cli.Context) app.App {
app, err := app.Get(appName)
if err != nil {
logrus.Fatal(err)
log.Fatal(err)
}
logrus.Debugf("validated %s as app argument", appName)
log.Debugf("validated %s as app argument", appName)
return app
}
@ -105,7 +105,7 @@ func ValidateDomain(c *cli.Context) string {
Default: "example.com",
}
if err := survey.AskOne(prompt, &domainName); err != nil {
logrus.Fatal(err)
log.Fatal(err)
}
}
@ -113,7 +113,7 @@ func ValidateDomain(c *cli.Context) string {
ShowSubcommandHelpAndError(c, errors.New("no domain provided"))
}
logrus.Debugf("validated %s as domain argument", domainName)
log.Debugf("validated %s as domain argument", domainName)
return domainName
}
@ -138,7 +138,7 @@ func ValidateServer(c *cli.Context) string {
serverNames, err := config.ReadServerNames()
if err != nil {
logrus.Fatal(err)
log.Fatal(err)
}
if serverName == "" && !NoInput {
@ -147,7 +147,7 @@ func ValidateServer(c *cli.Context) string {
Options: serverNames,
}
if err := survey.AskOne(prompt, &serverName); err != nil {
logrus.Fatal(err)
log.Fatal(err)
}
}
@ -166,7 +166,7 @@ func ValidateServer(c *cli.Context) string {
ShowSubcommandHelpAndError(c, errors.New("server doesn't exist?"))
}
logrus.Debugf("validated %s as server argument", serverName)
log.Debugf("validated %s as server argument", serverName)
return serverName
}