Code cleaning

Using gofumpt. Add documentation.
Some fixes on type checking and const icon type declaration.
This commit is contained in:
2024-04-05 07:56:27 +02:00
parent 2aad5d4b9d
commit 441b30a570
16 changed files with 86 additions and 93 deletions

View File

@@ -8,17 +8,17 @@ type Icon string
// Icons used in katenary.
const (
IconSuccess Icon = "✅"
IconFailure = "❌"
IconWarning = "⚠️'"
IconNote = "📝"
IconWorld = "🌐"
IconPlug = "🔌"
IconPackage = "📦"
IconCabinet = "🗄️"
IconInfo = "❕"
IconSecret = "🔒"
IconConfig = "🔧"
IconDependency = "🔗"
IconFailure Icon = "❌"
IconWarning Icon = "⚠️'"
IconNote Icon = "📝"
IconWorld Icon = "🌐"
IconPlug Icon = "🔌"
IconPackage Icon = "📦"
IconCabinet Icon = "🗄️"
IconInfo Icon = "❕"
IconSecret Icon = "🔒"
IconConfig Icon = "🔧"
IconDependency Icon = "🔗"
)
// Warn prints a warning message

View File

@@ -90,7 +90,6 @@ func GetContainerByName(name string, containers []corev1.Container) (*corev1.Con
// GetContainerByName returns a container by name and its index in the array.
func TplValue(serviceName, variable string, pipes ...string) string {
if len(pipes) == 0 {
return `{{ tpl .Values.` + serviceName + `.` + variable + ` $ }}`
} else {
@@ -108,8 +107,8 @@ func PathToName(path string) string {
if path[0] == '/' || path[0] == '.' {
path = path[1:]
}
path = strings.Replace(path, "/", "_", -1)
path = strings.Replace(path, ".", "_", -1)
path = strings.ReplaceAll(path, "/", "_")
path = strings.ReplaceAll(path, ".", "_")
return path
}
@@ -130,9 +129,9 @@ func GetValuesFromLabel(service types.ServiceConfig, LabelValues string) map[str
log.Fatal(err)
}
for _, value := range labelContent {
switch value.(type) {
switch val := value.(type) {
case string:
descriptions[value.(string)] = nil
descriptions[val] = nil
case map[string]interface{}:
for k, v := range value.(map[string]interface{}) {
descriptions[k] = &EnvConfig{Service: service, Description: v.(string)}