diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/filesystem/base/Filesystem.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/filesystem/base/Filesystem.kt index db1b769..9329e05 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/filesystem/base/Filesystem.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/filesystem/base/Filesystem.kt @@ -341,20 +341,20 @@ fun Prov.deleteDir(dir: String, path: String, sudo: Boolean = false): ProvResult * Creates and validates a symlink. */ fun Prov.createSymlink( - source: File, - target: File, + originalFile: File, + link: File, sudo: Boolean = false, overwriteIfExisting: Boolean = true, - createTargetDirIfMissing: Boolean = true, + createLinkDirIfMissing: Boolean = true, ): ProvResult = task { - if (createTargetDirIfMissing) { - createParentDir(target, sudo) + if (createLinkDirIfMissing) { + createParentDir(link, sudo) } val overwriteFlag = if (overwriteIfExisting) "f" else "" - cmd("ln -s$overwriteFlag $source $target", sudo = sudo) + cmd("ln -s$overwriteFlag $originalFile $link", sudo = sudo) // ensure link works taskWithResult("validate link") { - ProvResult(checkFile(target.toString(), sudo = sudo)) + ProvResult(checkFile(link.toString(), sudo = sudo)) } } diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/filesystem/base/FilesystemKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/filesystem/base/FilesystemKtTest.kt index ae9ac38..9587af5 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/filesystem/base/FilesystemKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/filesystem/base/FilesystemKtTest.kt @@ -415,8 +415,8 @@ internal class FilesystemKtTest { fun test_createLink_without_dir() { // given val prov = defaultTestContainer() - val source = File("testlinksource") - val target = File("testlinktarget") + val source = File("testoriginalfile") + val target = File("testlink") prov.createFile(source.toString(), "textinlinkfile") // when @@ -436,8 +436,8 @@ internal class FilesystemKtTest { fun test_createLink_with_dirs() { // given val prov = defaultTestContainer() - val source = File("~/linksourcedir/testlinksource2") - val target = File("linkdir1/linkdir2/testlinktarget2") + val source = File("~/linkoriginalfiledir/testoriginalfile2") + val target = File("linkdir1/linkdir2/testlink2") prov.createFile(source.toString(), "textinlinkfile2") // when @@ -457,8 +457,8 @@ internal class FilesystemKtTest { fun test_createLink_with_dirs_and_sudo() { // given val prov = defaultTestContainer() - val source = File("/linksourcedirsudo/linksourcefilesudo") - val target = File("/linkdir1sudo/linkdir2sudo/linksudo") + val source = File("~/linkoriginalfiledirsudo/testoriginalfilesudo") + val target = File("linkdir1sudo/linkdir2sudo/testlinksudo") prov.createFile(source.toString(), "textinlinkfilesudo", sudo = true) // when