This commit is contained in:
Tomer Zait
2024-02-18 10:50:15 +02:00
parent d872afb377
commit db6a4d7ce1
4 changed files with 5 additions and 23 deletions
+1 -1
View File
@@ -152,7 +152,7 @@ func checkUnsupportedKey(composeProject *types.Project) []string {
// LoadFile loads a compose file into KomposeObject
func (c *Compose) LoadFile(files []string, profiles []string) (kobject.KomposeObject, error) {
// Gather the working directory
workingDir, err := getComposeFileDir(files)
workingDir, err := transformer.GetComposeFileDir(files)
if err != nil {
return kobject.KomposeObject{}, err
}
-15
View File
@@ -19,7 +19,6 @@ package compose
import (
"io"
"os"
"path/filepath"
"regexp"
"strings"
@@ -133,20 +132,6 @@ func loadEnvVars(envars []string) []kobject.EnvVar {
return envs
}
// getComposeFileDir returns compose file directory
// Assume all the docker-compose files are in the same directory
func getComposeFileDir(inputFiles []string) (string, error) {
inputFile := inputFiles[0]
if strings.Index(inputFile, "/") != 0 {
workDir, err := os.Getwd()
if err != nil {
return "", errors.Wrap(err, "Unable to retrieve compose file directory")
}
inputFile = filepath.Join(workDir, inputFile)
}
return filepath.Dir(inputFile), nil
}
func handleServiceType(ServiceType string) (string, error) {
switch strings.ToLower(ServiceType) {
case "", "clusterip":