forked from LaconicNetwork/kompose
parent
d872afb377
commit
db6a4d7ce1
@ -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
|
||||
}
|
||||
|
||||
@ -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":
|
||||
|
||||
@ -965,9 +965,5 @@ func GetContainerArgs(service kobject.ServiceConfig) []string {
|
||||
// The function does not format the file name further, as it may contain periods or other valid characters.
|
||||
// Returns the extracted file name.
|
||||
func GetFileName(fileName string) string {
|
||||
if strings.Contains(fileName, "/") {
|
||||
fileName = fileName[strings.LastIndex(fileName, "/")+1:]
|
||||
}
|
||||
// Not format filename because can begin with .fileName
|
||||
return fileName
|
||||
return filepath.Base(fileName)
|
||||
}
|
||||
|
||||
@ -319,9 +319,10 @@ func initConfigMapData(configMap *api.ConfigMap, data map[string]string) {
|
||||
binData := map[string][]byte{}
|
||||
|
||||
for k, v := range data {
|
||||
isText := util.IsText([]byte(v))
|
||||
lfText := strings.Replace(v, "\r\n", "\n", -1)
|
||||
isText := util.IsText([]byte(lfText))
|
||||
if isText {
|
||||
stringData[k] = v
|
||||
stringData[k] = lfText
|
||||
} else {
|
||||
binData[k] = []byte(base64.StdEncoding.EncodeToString([]byte(v)))
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user