For some reason, tests have been coming back as always positive (despite
some tests which are failing...)

This PR addresses it
This commit is contained in:
Charlie Drage 2019-10-25 05:33:11 -04:00 committed by Hang Yan
parent f63a961ca7
commit d0526d1d75
3 changed files with 11 additions and 13 deletions

View File

@ -621,15 +621,9 @@ func GetEnvsFromFile(file string, opt kobject.ConvertOptions) (map[string]string
return envLoad, nil return envLoad, nil
} }
// GetContentFromFile get content from file // GetContentFromFile gets the content from the file..
func GetContentFromFile(file string, opt kobject.ConvertOptions) (string, error) { func GetContentFromFile(file string, opt kobject.ConvertOptions) (string, error) {
// Get the correct file context / directory fileBytes, err := ioutil.ReadFile(file)
composeDir, err := transformer.GetComposeFileDir(opt.InputFiles)
if err != nil {
return "", errors.Wrap(err, "Unable to load file context")
}
fileLocation := path.Join(composeDir, file)
fileBytes, err := ioutil.ReadFile(fileLocation)
if err != nil { if err != nil {
return "", errors.Wrap(err, "Unable to read file") return "", errors.Wrap(err, "Unable to read file")
} }
@ -646,9 +640,13 @@ func FormatEnvName(name string) string {
// FormatFileName format file name // FormatFileName format file name
func FormatFileName(name string) string { func FormatFileName(name string) string {
envName := strings.Trim(name, "./") // Split the filepath name so that we use the
envName = strings.Replace(envName, "_", "-", -1) // file name (after the base) for ConfigMap,
return envName // it shouldn't matter whether it has special characters or not
_, file := path.Split(name)
// Make it DNS-1123 compliant for Kubernetes
return strings.Replace(file, "_", "-", -1)
} }
//FormatContainerName format Container name //FormatContainerName format Container name

View File

@ -259,6 +259,7 @@ func (k *Kubernetes) InitConfigMapFromFile(name string, service kobject.ServiceC
} }
originFileName := FormatFileName(fileName) originFileName := FormatFileName(fileName)
dataMap := make(map[string]string) dataMap := make(map[string]string)
dataMap[originFileName] = content dataMap[originFileName] = content
configMapName := "" configMapName := ""

View File

@ -844,10 +844,9 @@ convert::expect_success "$cmd" "/tmp/output-os.json"
cmd="kompose convert --stdout -j -f -" cmd="kompose convert --stdout -j -f -"
sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/stdin/output-k8s.json > /tmp/output-k8s.json sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/stdin/output-k8s.json > /tmp/output-k8s.json
cat $KOMPOSE_ROOT/script/test/fixtures/stdin/docker-compose.yaml | $cmd | diff /tmp/output-k8s.json - cat $KOMPOSE_ROOT/script/test/fixtures/stdin/docker-compose.yaml | $cmd | diff /tmp/output-k8s.json -
EXIT_STATUS=$?
echo -e "\n" echo -e "\n"
go test -v github.com/kubernetes/kompose/script/test/cmd go test -v github.com/kubernetes/kompose/script/test/cmd
rm /tmp/output-k8s.json /tmp/output-os.json rm /tmp/output-k8s.json /tmp/output-os.json
exit $EXIT_STATUS exit $EXIT_STATUS