Merge pull request #1831 from realgam3/fix-configmap-volumes

fix issues #1829, #1830
This commit is contained in:
Kubernetes Prow Robot 2024-02-20 20:45:04 -08:00 committed by GitHub
commit b2514e1c81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 23 deletions

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
}

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":

View File

@ -966,11 +966,7 @@ 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)
}
// reformatSecretConfigUnderscoreWithDash takes a ServiceSecretConfig object as input and returns a new instance of ServiceSecretConfig

View File

@ -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)))
}