refactoring of code

This commit is contained in:
Jonas Kaninda
2024-12-06 20:53:46 +01:00
parent f7d624fd15
commit d5a0adc981
18 changed files with 192 additions and 227 deletions

View File

@@ -26,7 +26,6 @@ package utils
import (
"fmt"
"github.com/jkaninda/mysql-bkup/pkg/logger"
"github.com/robfig/cron/v3"
"github.com/spf13/cobra"
"io"
@@ -36,7 +35,7 @@ import (
"time"
)
var Version = "development"
var Version = ""
// FileExists checks if the file does exist
func FileExists(filename string) bool {
@@ -112,7 +111,7 @@ func CopyFile(src, dst string) error {
}
func ChangePermission(filePath string, mod int) {
if err := os.Chmod(filePath, fs.FileMode(mod)); err != nil {
logger.Fatal("Error changing permissions of %s: %v\n", filePath, err)
Fatal("Error changing permissions of %s: %v\n", filePath, err)
}
}
@@ -174,7 +173,7 @@ func GetEnvVariable(envName, oldEnvName string) string {
if err != nil {
return value
}
logger.Warn("%s is deprecated, please use %s instead! ", oldEnvName, envName)
Warn("%s is deprecated, please use %s instead! ", oldEnvName, envName)
}
}
return value
@@ -221,7 +220,7 @@ func GetIntEnv(envName string) int {
}
ret, err := strconv.Atoi(val)
if err != nil {
logger.Error("Error: %v", err)
Error("Error: %v", err)
}
return ret
}
@@ -246,7 +245,7 @@ func CronNextTime(cronExpr string) time.Time {
// Parse the cron expression
schedule, err := cron.ParseStandard(cronExpr)
if err != nil {
logger.Error("Error parsing cron expression: %s", err)
Error("Error parsing cron expression: %s", err)
return time.Time{}
}
// Get the current time