Use real types to parse labels
We were using `yaml.Unmarshal` on basic types or inline structs. This was not efficient and not clear to defined what we expect in labels. We now use types to unmarshal the labels. Only the `values` label is, at this time, parsed by GetValuesFromLabel because this `utils` function is clearly a special case.
This commit is contained in:
19
generator/labelStructs/probes.go
Normal file
19
generator/labelStructs/probes.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package labelStructs
|
||||
|
||||
import (
|
||||
"gopkg.in/yaml.v3"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
type Probe struct {
|
||||
LivenessProbe *corev1.Probe `yaml:"livenessProbe,omitempty"`
|
||||
ReadinessProbe *corev1.Probe `yaml:"readinessProbe,omitempty"`
|
||||
}
|
||||
|
||||
func ProbeFrom(data string) (*Probe, error) {
|
||||
var mapping Probe
|
||||
if err := yaml.Unmarshal([]byte(data), &mapping); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &mapping, nil
|
||||
}
|
Reference in New Issue
Block a user