jasonpet closed pull request #274: Remove required access to the whole couchdb
database.
URL: https://github.com/apache/incubator-openwhisk-package-kafka/pull/274
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/provider/database.py b/provider/database.py
index 817f3a7..bed6296 100644
--- a/provider/database.py
+++ b/provider/database.py
@@ -23,6 +23,7 @@
import time
from cloudant.client import CouchDB
+from cloudant.client import CouchDatabase
from cloudant.result import Result
from datetime import datetime
@@ -46,12 +47,13 @@ def __init__(self, timeout=None):
self.client = CouchDB(self.username, self.password, url=self.url,
timeout=timeout, auto_renew=True)
self.client.connect()
- if self.dbname in self.client.all_dbs():
+ self.database = CouchDatabase(self.client, self.dbname)
+
+ if self.database.exists():
logging.info('Database exists - connecting to it.')
- self.database = self.client[self.dbname]
else:
logging.warn('Database does not exist - creating it.')
- self.database = self.client.create_database(self.dbname)
+ self.database.create()
def destroy(self):
if self.client is not None:
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services