Skip to content

Commit

Permalink
stacks: make mount separator configurable
Browse files Browse the repository at this point in the history
Right now, `;` is hard-coded to be the mount separator
in the stack-mounts, which inhibits this character from
being used for path names.

Introduce an appsody env APPSODY_MOUNT_SEPARATOR that can
be used by stacks that want to use a different separator.

Partially fixes: appsody#31
  • Loading branch information
gireeshpunathil committed Sep 18, 2019
1 parent e532224 commit 767d339
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
19 changes: 18 additions & 1 deletion cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ func getVolumeArgs() ([]string, error) {
Warning.log("The stack image does not contain APPSODY_MOUNTS")
return volumeArgs, nil
}
stackMountList := strings.Split(stackMounts, ";")
mountSeparator, err := GetMountSeparator()
if err != nil {
Warning.log("Could not determine mount separator from The stack image")
return volumeArgs, err
}
stackMountList := strings.Split(stackMounts, mountSeparator)
homeDir := UserHomeDir()
homeDirOverride := os.Getenv("APPSODY_MOUNT_HOME")
homeDirOverridden := false
Expand Down Expand Up @@ -1072,3 +1077,15 @@ func IsEmptyDir(name string) bool {

return err == io.EOF
}

func GetMountSeparator() (string, error) {
mountSeparator, err := GetEnvVar("APPSODY_MOUNT_SEPARATOR")
if err != nil {
return "", err
}
if mountSeparator == "" {
return ":", nil
}
Debug.log("The stack image uses special APPSODY_MOUNT_SEPARATOR: ", mountSeparator)
return mountSeparator, nil
}
6 changes: 5 additions & 1 deletion functest/extract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ func TestExtract(t *testing.T) {
}
log.Println("Stack's project dir:", pDir)

mountlist := strings.Split(mounts, ";")
mountSeparator, err := cmd.GetMountSeparator()
if err != nil {
t.Fatal(err)
}
mountlist := strings.Split(mounts, mountSeparator)
for _, mount := range mountlist {
log.Println("mount:", mount)
src := strings.Split(mount, ":")[0]
Expand Down

0 comments on commit 767d339

Please sign in to comment.