added support for multiple-compose files

This commit is contained in:
Abhishek
2017-01-03 17:18:34 +05:30
parent 9c3fdaa48d
commit a5a3805760
18 changed files with 739 additions and 34 deletions
+4 -2
View File
@@ -112,7 +112,9 @@ func getGitCurrentBranch(composeFileDir string) (string, error) {
}
// getComposeFileDir returns compose file directory
func getComposeFileDir(inputFile string) (string, error) {
func getComposeFileDir(inputFiles []string) (string, error) {
// Lets assume all the docker-compose files are in the same directory
inputFile := inputFiles[0]
if strings.Index(inputFile, "/") != 0 {
workDir, err := os.Getwd()
if err != nil {
@@ -332,7 +334,7 @@ func (o *OpenShift) Transform(komposeObject kobject.KomposeObject, opt kobject.C
// buildconfig needs to be added to objects after imagestream because of this Openshift bug: https://github.com/openshift/origin/issues/4518
if service.Build != "" {
if !hasBuild {
composeFileDir, err = getComposeFileDir(opt.InputFile)
composeFileDir, err = getComposeFileDir(opt.InputFiles)
if err != nil {
logrus.Warningf("Error in detecting compose file's directory.")
continue
+5 -5
View File
@@ -214,17 +214,17 @@ func TestGetComposeFileDir(t *testing.T) {
wd, _ := os.Getwd()
testCases := map[string]struct {
inputFile string
output string
inputFiles []string
output string
}{
"Get compose file dir for relative input file path": {"foo/bar.yaml", filepath.Join(wd, "foo")},
"Get compose file dir for abs input file path": {"/abs/path/to/compose.yaml", "/abs/path/to"},
"Get compose file dir for relative input file path": {[]string{"foo/bar.yaml"}, filepath.Join(wd, "foo")},
"Get compose file dir for abs input file path": {[]string{"/abs/path/to/compose.yaml"}, "/abs/path/to"},
}
for name, test := range testCases {
t.Log("Test case: ", name)
output, err = getComposeFileDir(test.inputFile)
output, err = getComposeFileDir(test.inputFiles)
if err != nil {
t.Errorf("Expected success, got error: %#v", err)