Fix problems and adding functionnalities

Many fixes and enhancements:

- Add icon option
- Add env file managment
- Ordering compose parsing options
- Fix path with underscores
- Fix image and tag discovery
- Better documentation for labels
This commit is contained in:
2024-10-17 17:08:42 +02:00
parent 78dfb15cf5
commit 918f1b845b
22 changed files with 991 additions and 893 deletions

View File

@@ -2,6 +2,9 @@
package parser
import (
"log"
"path/filepath"
"github.com/compose-spec/compose-go/cli"
"github.com/compose-spec/compose-go/types"
)
@@ -12,6 +15,7 @@ func init() {
"compose.katenary.yml",
"compose.katenary.yaml",
}, cli.DefaultOverrideFileNames...)
// add podman-compose files
cli.DefaultOverrideFileNames = append(cli.DefaultOverrideFileNames,
[]string{
"podman-compose.katenary.yml",
@@ -22,18 +26,31 @@ func init() {
}
// Parse compose files and return a project. The project is parsed with dotenv, osenv and profiles.
func Parse(profiles []string, dockerComposeFile ...string) (*types.Project, error) {
func Parse(profiles []string, envFiles []string, dockerComposeFile ...string) (*types.Project, error) {
if len(dockerComposeFile) == 0 {
cli.DefaultOverrideFileNames = append(cli.DefaultOverrideFileNames, dockerComposeFile...)
}
log.Println("Loading compose files: ", cli.DefaultOverrideFileNames)
// resolve absolute paths of envFiles
for i := range envFiles {
var err error
envFiles[i], err = filepath.Abs(envFiles[i])
if err != nil {
log.Fatal(err)
}
}
log.Println("Loading env files: ", envFiles)
options, err := cli.NewProjectOptions(nil,
cli.WithProfiles(profiles),
cli.WithInterpolation(true),
cli.WithDefaultConfigPath,
cli.WithEnvFiles(envFiles...),
cli.WithOsEnv,
cli.WithDotEnv,
cli.WithNormalization(true),
cli.WithInterpolation(true),
cli.WithResolvedPaths(false),
)
if err != nil {