chore(convention): Respect Go convention, package name should be lowercase

This commit is contained in:
2025-07-06 14:34:16 +02:00
parent 1a5c95d240
commit 9e4663cc6e
22 changed files with 53 additions and 53 deletions

View File

@@ -0,0 +1,56 @@
package labelstructs
import (
"encoding/json"
"log"
"gopkg.in/yaml.v3"
corev1 "k8s.io/api/core/v1"
)
type HealthCheck struct {
LivenessProbe *corev1.Probe `yaml:"livenessProbe,omitempty" json:"livenessProbe,omitempty"`
ReadinessProbe *corev1.Probe `yaml:"readinessProbe,omitempty" json:"readinessProbe,omitempty"`
}
func ProbeFrom(data string) (*HealthCheck, error) {
mapping := HealthCheck{}
tmp := map[string]any{}
err := yaml.Unmarshal([]byte(data), &tmp)
if err != nil {
return nil, err
}
if livenessProbe, ok := tmp["livenessProbe"]; ok {
livenessProbeBytes, err := json.Marshal(livenessProbe)
if err != nil {
log.Printf("Error marshalling livenessProbe: %v", err)
return nil, err
}
livenessProbe := &corev1.Probe{}
err = json.Unmarshal(livenessProbeBytes, livenessProbe)
if err != nil {
log.Printf("Error unmarshalling livenessProbe: %v", err)
return nil, err
}
mapping.LivenessProbe = livenessProbe
}
if readinessProbe, ok := tmp["readinessProbe"]; ok {
readinessProbeBytes, err := json.Marshal(readinessProbe)
if err != nil {
log.Printf("Error marshalling readinessProbe: %v", err)
return nil, err
}
readinessProbe := &corev1.Probe{}
err = json.Unmarshal(readinessProbeBytes, readinessProbe)
if err != nil {
log.Printf("Error unmarshalling readinessProbe: %v", err)
return nil, err
}
mapping.ReadinessProbe = readinessProbe
}
return &mapping, err
}