← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/lp-codeimport:charm-strip-rabbitmq-password into lp-codeimport:master

 

Colin Watson has proposed merging ~cjwatson/lp-codeimport:charm-strip-rabbitmq-password into lp-codeimport:master.

Commit message:
charm: Strip trailing newline from rabbitmq_password

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/lp-codeimport/+git/lp-codeimport/+merge/400186

Since this is a secret, it may be included from a file and have a trailing newline, which will cause problems when substituted into the crontab.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/lp-codeimport:charm-strip-rabbitmq-password into lp-codeimport:master.
diff --git a/charm/lp-codeimport/reactive/lp-codeimport.py b/charm/lp-codeimport/reactive/lp-codeimport.py
index e05990a..e35106a 100644
--- a/charm/lp-codeimport/reactive/lp-codeimport.py
+++ b/charm/lp-codeimport/reactive/lp-codeimport.py
@@ -203,6 +203,9 @@ def configure():
         svc_config['gpg_keyid'] = [
             line for line in gpg_key_colons.splitlines()
             if line.startswith('sec:')][0].split(':')[4]
+    if svc_config['rabbitmq_password']:
+        svc_config['rabbitmq_password'] = (
+            svc_config['rabbitmq_password'].rstrip('\n'))
 
     hookenv.log('Writing service configuration.')
     templating.render(