refactor(yaml): globalize fixups
The ToK8SYaml() function makes the job, it's now simpler to manage fixes
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
||||
var regexpLineWrap = regexp.MustCompile(`\n\s+}}`)
|
||||
@@ -84,3 +85,11 @@ func isIgnored(service types.ServiceConfig) bool {
|
||||
func UnWrapTPL(in []byte) []byte {
|
||||
return regexpLineWrap.ReplaceAll(in, []byte(" }}"))
|
||||
}
|
||||
|
||||
func ToK8SYaml(obj interface{}) ([]byte, error) {
|
||||
if o, err := yaml.Marshal(obj); err != nil {
|
||||
return nil, nil
|
||||
} else {
|
||||
return UnWrapTPL(o), nil
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user