forked from LaconicNetwork/kompose
* 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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user