chore(tests): enhance output
All checks were successful
Go-Tests / tests (push) Successful in 2m18s
Go-Tests / sonar (push) Successful in 55s

- use a better logger separation
- use tags not not overload the CI output
- removed lot of log.Println/Fatal/Error
This commit is contained in:
2025-09-15 13:02:54 +02:00
parent 9472952d65
commit debe43ce34
14 changed files with 106 additions and 77 deletions

View File

@@ -3,7 +3,6 @@ package katenaryfile
import (
"bytes"
"encoding/json"
"fmt"
"log"
"os"
"reflect"
@@ -11,7 +10,7 @@ import (
"katenary.io/internal/generator/labels"
"katenary.io/internal/generator/labels/labelstructs"
"katenary.io/internal/utils"
"katenary.io/internal/logger"
"github.com/compose-spec/compose-go/types"
"github.com/invopop/jsonschema"
@@ -60,7 +59,7 @@ func OverrideWithConfig(project *types.Project) {
// no katenary file found
return
}
fmt.Println(utils.IconInfo, "Using katenary file", yamlFile)
logger.Info("Using katenary file", yamlFile)
services := make(map[string]Service)
fp, err := os.Open(yamlFile)
@@ -102,7 +101,7 @@ func OverrideWithConfig(project *types.Project) {
mustGetLabelContent(s.ValuesFrom, &project.Services[i], labels.LabelValuesFrom)
}
}
fmt.Println(utils.IconInfo, "Katenary file loaded successfully, the services are now configured.")
logger.Info("Katenary file loaded successfully, the services are now configured.")
}
func getLabelContent(o any, service *types.ServiceConfig, labelName string) error {

View File

@@ -1,7 +1,6 @@
package katenaryfile
import (
"log"
"os"
"path/filepath"
"testing"
@@ -39,18 +38,15 @@ webapp:
composeFile := filepath.Join(tmpDir, "compose.yaml")
katenaryFile := filepath.Join(tmpDir, "katenary.yaml")
os.MkdirAll(tmpDir, 0755)
if err := os.WriteFile(composeFile, []byte(composeContent), 0644); err != nil {
os.MkdirAll(tmpDir, 0o755)
if err := os.WriteFile(composeFile, []byte(composeContent), 0o644); err != nil {
t.Log(err)
}
if err := os.WriteFile(katenaryFile, []byte(katenaryfileContent), 0644); err != nil {
if err := os.WriteFile(katenaryFile, []byte(katenaryfileContent), 0o644); err != nil {
t.Log(err)
}
defer os.RemoveAll(tmpDir)
c, _ := os.ReadFile(composeFile)
log.Println(string(c))
// chand dir to this directory
os.Chdir(tmpDir)
options, _ := cli.NewProjectOptions(nil,
@@ -92,18 +88,15 @@ webapp:
composeFile := filepath.Join(tmpDir, "compose.yaml")
katenaryFile := filepath.Join(tmpDir, "katenary.yaml")
os.MkdirAll(tmpDir, 0755)
if err := os.WriteFile(composeFile, []byte(composeContent), 0644); err != nil {
os.MkdirAll(tmpDir, 0o755)
if err := os.WriteFile(composeFile, []byte(composeContent), 0o644); err != nil {
t.Log(err)
}
if err := os.WriteFile(katenaryFile, []byte(katenaryfileContent), 0644); err != nil {
if err := os.WriteFile(katenaryFile, []byte(katenaryfileContent), 0o644); err != nil {
t.Log(err)
}
defer os.RemoveAll(tmpDir)
c, _ := os.ReadFile(composeFile)
log.Println(string(c))
// chand dir to this directory
os.Chdir(tmpDir)
options, _ := cli.NewProjectOptions(nil,
@@ -150,18 +143,15 @@ webapp:
composeFile := filepath.Join(tmpDir, "compose.yaml")
katenaryFile := filepath.Join(tmpDir, "katenary.yaml")
os.MkdirAll(tmpDir, 0755)
if err := os.WriteFile(composeFile, []byte(composeContent), 0644); err != nil {
os.MkdirAll(tmpDir, 0o755)
if err := os.WriteFile(composeFile, []byte(composeContent), 0o644); err != nil {
t.Log(err)
}
if err := os.WriteFile(katenaryFile, []byte(katenaryfileContent), 0644); err != nil {
if err := os.WriteFile(katenaryFile, []byte(katenaryfileContent), 0o644); err != nil {
t.Log(err)
}
defer os.RemoveAll(tmpDir)
c, _ := os.ReadFile(composeFile)
log.Println(string(c))
// chand dir to this directory
os.Chdir(tmpDir)
options, _ := cli.NewProjectOptions(nil,