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,9 +71,14 @@ fun Prov.configureGopass(gopassRootFolder: String? = null, publicGpgKey: Secret?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun Prov.gopassMountStore(storeName: String, path: String) = task {
|
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")
|
cmd("gopass mounts add $storeName $path")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun Prov.gopassInitStoreFolder(path: String, gpgFingerprint: String? = null ) = task {
|
fun Prov.gopassInitStoreFolder(path: String, gpgFingerprint: String? = null ) = task {
|
||||||
|
|
|
@ -41,6 +41,7 @@ internal class GopassKtTest {
|
||||||
configureGopass(prov.userHome() + gopassRootDir)
|
configureGopass(prov.userHome() + gopassRootDir)
|
||||||
gopassInitStoreFolder("~/exampleStoreFolder")
|
gopassInitStoreFolder("~/exampleStoreFolder")
|
||||||
gopassMountStore("exampleStore", "~/exampleStoreFolder")
|
gopassMountStore("exampleStore", "~/exampleStoreFolder")
|
||||||
|
gopassMountStore("exampleStore", "~/exampleStoreFolder") // check that mounting twice gives no error
|
||||||
prov.cmd("gopass ls")
|
prov.cmd("gopass ls")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue