make gopass mount store idem-potent
This commit is contained in:
parent
59c5c8ba5a
commit
0c648eeac7
2 changed files with 8 additions and 2 deletions
|
@ -71,8 +71,13 @@ fun Prov.configureGopass(gopassRootFolder: String? = null, publicGpgKey: Secret?
|
|||
}
|
||||
|
||||
|
||||
fun Prov.gopassMountStore(storeName: String, path: String) = task {
|
||||
cmd("gopass mounts add $storeName $path")
|
||||
fun Prov.gopassMountStore(storeName: String, path: String) = taskWithResult {
|
||||
val mounts = cmdNoEval("gopass mounts").out ?: return@taskWithResult ProvResult(false, err = "could not determin gopass mounts")
|
||||
if (mounts.contains(storeName)) {
|
||||
ProvResult(true, out = "Store $storeName already mounted.")
|
||||
} else {
|
||||
cmd("gopass mounts add $storeName $path")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ internal class GopassKtTest {
|
|||
configureGopass(prov.userHome() + gopassRootDir)
|
||||
gopassInitStoreFolder("~/exampleStoreFolder")
|
||||
gopassMountStore("exampleStore", "~/exampleStoreFolder")
|
||||
gopassMountStore("exampleStore", "~/exampleStoreFolder") // check that mounting twice gives no error
|
||||
prov.cmd("gopass ls")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue