-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
273 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
core.coordinator/src/main/scala/dev/kamu/cli/transform/EngineUtils.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2018 kamu.dev | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package dev.kamu.cli.transform | ||
|
||
import java.nio.file.{Path, Paths} | ||
|
||
import dev.kamu.core.utils.OS | ||
|
||
trait EngineUtils { | ||
///////////////////////////////////////////////////////////////////////////// | ||
// Path mappings between host and container | ||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
protected val volumeDirInContainer: String = "/opt/engine/volume" | ||
protected val inOutDirInContainer: String = "/opt/engine/in-out" | ||
|
||
protected def isSubPathOf(p: Path, parent: Path): Boolean = { | ||
var pp = p.getParent | ||
while (pp != null) { | ||
if (pp == parent) | ||
return true | ||
pp = pp.getParent | ||
} | ||
false | ||
} | ||
|
||
protected def toContainerPath(ps: String, volumePath: Path): String = { | ||
val p = Paths.get(ps).normalize().toAbsolutePath | ||
val rel = volumePath.relativize(p) | ||
val x = if (!OS.isWindows) { | ||
Paths.get(volumeDirInContainer).resolve(rel).toString | ||
} else { | ||
volumeDirInContainer + "/" + rel.toString.replace("\\", "/") | ||
} | ||
println(s"Mapped path $ps to $x") | ||
x | ||
} | ||
} |
Oops, something went wrong.