Use compose-go https://github.com/compose-spec/compose-go to make Katenary parsing compose file the official way. Add labels: - `volume-from` (with `same-pod`) to avoid volume repetition - `ignore` to ignore a service - `mapenv` (replaces the `env-to-service`) to map environment to helm variable (as a template string) - `secret-vars` declares variables as secret values More: - Now, environment (as secret vars) are set in values.yaml - Ingress has got annotations in values.yaml - Probes (liveness probe) are improved - fixed code to optimize - many others fixes about path, bad volume check, refactorisation, tests...
23 lines
553 B
Go
23 lines
553 B
Go
package generator
|
|
|
|
import (
|
|
"katenary/compose"
|
|
"regexp"
|
|
"strings"
|
|
)
|
|
|
|
// replaceChars replaces some chars in a string.
|
|
const replaceChars = `[^a-zA-Z0-9._]`
|
|
|
|
// GetRelPath return the relative path from the root of the project.
|
|
func GetRelPath(path string) string {
|
|
return strings.Replace(path, compose.GetCurrentDir(), ".", 1)
|
|
}
|
|
|
|
// PathToName transform a path to a yaml name.
|
|
func PathToName(path string) string {
|
|
path = strings.TrimPrefix(GetRelPath(path), "./")
|
|
path = regexp.MustCompile(replaceChars).ReplaceAllString(path, "-")
|
|
return path
|
|
}
|