* fix issue https://github.com/kubernetes/kompose/issues/1683

* add tests, die if inputfiles not specified

* fix GetComposeFileDir function and use it

* use fixed GetComposeFileDir instead of filepath.Dir

* return error instead of fatal

* add pod configmap creation to openshift
This commit is contained in:
Tomer Zait
2024-01-02 14:48:59 -05:00
committed by GitHub
parent 63f60e66fe
commit 92ca12ae5b
10 changed files with 241 additions and 11 deletions
+26
View File
@@ -18,6 +18,7 @@ package app
import (
"fmt"
"path/filepath"
"strings"
log "github.com/sirupsen/logrus"
@@ -224,6 +225,31 @@ func Convert(opt kobject.ConvertOptions) ([]runtime.Object, error) {
komposeObject.Namespace = opt.Namespace
// Get the directory of the compose file
workDir, err := transformer.GetComposeFileDir(opt.InputFiles)
if err != nil {
log.Fatalf("Unable to get compose file directory: %s", err)
}
// convert env_file from absolute to relative path
for _, service := range komposeObject.ServiceConfigs {
if len(service.EnvFile) <= 0 {
continue
}
for i, envFile := range service.EnvFile {
if !filepath.IsAbs(envFile) {
continue
}
relPath, err := filepath.Rel(workDir, envFile)
if err != nil {
log.Fatalf(err.Error())
}
service.EnvFile[i] = filepath.ToSlash(relPath)
}
}
// Get a transformer that maps komposeObject to provider's primitives
t := getTransformer(opt)