summaryrefslogtreecommitdiff
path: root/src/repoList.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-07-22 22:14:31 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2019-07-22 22:14:31 +0100
commitdb00a9699e3b12e5f1b79b55a4fd35c4e1dee163 (patch)
tree1b706ea330f7399f7c0c5cb4dc43b5f7f7ba4815 /src/repoList.cpp
parentUnline git helpers and throw NetFS exceptions (diff)
downloadnetfs-gitfs-db00a9699e3b12e5f1b79b55a4fd35c4e1dee163.tar.bz2
netfs-gitfs-db00a9699e3b12e5f1b79b55a4fd35c4e1dee163.tar.xz
netfs-gitfs-db00a9699e3b12e5f1b79b55a4fd35c4e1dee163.zip
Replace hard-coded test values with properties
Diffstat (limited to 'src/repoList.cpp')
-rw-r--r--src/repoList.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/repoList.cpp b/src/repoList.cpp
index 51eb6b2..9fc2848 100644
--- a/src/repoList.cpp
+++ b/src/repoList.cpp
@@ -1,15 +1,29 @@
#include <Ice/ObjectAdapter.h>
+#include <Ice/Properties.h>
#include "repoList.h"
#include "repo.h"
-GitFS::RepoList::RepoList(const Ice::PropertiesPtr &)
+#include <compileTimeFormatter.h>
+
+GitFS::RepoList::RepoList(const Ice::PropertiesPtr & p) : properties(p)
{
}
+AdHocFormatter(RepoPropertyName, "GitFS.%?.%?");
+
NetFS::VolumePrxPtr
-GitFS::RepoList::connect(const ::std::string, const ::std::string,
+GitFS::RepoList::connect(const ::std::string volume, const ::std::string auth,
const ::Ice::Current & ice)
{
- return Ice::uncheckedCast<NetFS::VolumePrx>(ice.adapter->addWithUUID(std::make_shared<Repo>()));
+ if (volume.empty()) throw NetFS::ConfigError();
+
+ const auto propReader = std::bind(&Ice::Properties::getProperty, properties,
+ std::bind((std::string(*)(const std::string_view &, const std::string_view &))
+ (&RepoPropertyName::get), volume, std::placeholders::_1));
+
+ if (propReader("gitdir").empty()) throw NetFS::ConfigError();
+ if (propReader("authkey") != auth) throw NetFS::AuthError();
+ return Ice::uncheckedCast<NetFS::VolumePrx>(
+ ice.adapter->addWithUUID(std::make_shared<Repo>(propReader)));
}