← Back to team overview

bind-charmers team mailing list archive

[Merge] ~bind-charmers/charm-k8s-bind/+git/charmcraft-review:review into charm-k8s-bind:master

 

Barry Price has proposed merging ~bind-charmers/charm-k8s-bind/+git/charmcraft-review:review into charm-k8s-bind:master.

Commit message:
This is the branch approved by charmcraft in this MP:

https://code.launchpad.net/~bind-charmers/charm-k8s-bind/+git/charmcraft-review/+merge/389995

Requested reviews:
  Bind Charmers (bind-charmers)

For more details, see:
https://code.launchpad.net/~bind-charmers/charm-k8s-bind/+git/charmcraft-review/+merge/391965
-- 
Your team Bind Charmers is requested to review the proposed merge of ~bind-charmers/charm-k8s-bind/+git/charmcraft-review:review into charm-k8s-bind:master.
diff --git a/src/charm.py b/src/charm.py
index 913f69f..93fb69b 100755
--- a/src/charm.py
+++ b/src/charm.py
@@ -3,12 +3,19 @@
 # Copyright 2020 Canonical Ltd.
 # Licensed under the GPLv3, see LICENCE file for details.
 
+<<<<<<< src/charm.py
 import io
+=======
+>>>>>>> src/charm.py
 import logging
 from ops.charm import CharmBase
 from ops.main import main
 from ops.model import ActiveStatus, MaintenanceStatus
+<<<<<<< src/charm.py
 from pprint import pprint
+=======
+from pprint import pformat
+>>>>>>> src/charm.py
 from yaml import safe_load
 
 logger = logging.getLogger()
@@ -24,6 +31,7 @@ class BindK8sCharm(CharmBase):
         self.framework.observe(self.on.config_changed, self.on_config_changed)
 
     def _check_for_config_problems(self):
+<<<<<<< src/charm.py
         """Check for some simple configuration problems and return a
         string describing them, otherwise return an empty string."""
         problems = []
@@ -46,6 +54,27 @@ class BindK8sCharm(CharmBase):
             missing.append('bind_image_password')
 
         return sorted(list(set(missing)))
+=======
+        """Return a string describing any configuration problems (or an empty string if none)."""
+        problems = ''
+
+        missing = self._missing_charm_settings()
+        if missing:
+            problems = 'required setting(s) empty: {}'.format(', '.join(sorted(missing)))
+
+        return problems
+
+    def _missing_charm_settings(self):
+        """Return a list of missing configuration settings (or an empty list if none)."""
+        config = self.model.config
+
+        missing = {setting for setting in REQUIRED_SETTINGS if not config[setting]}
+
+        if config['bind_image_username'] and not config['bind_image_password']:
+            missing.add('bind_image_password')
+
+        return missing
+>>>>>>> src/charm.py
 
     def on_config_changed(self, event):
         """Check that we're leader, and if so, set up the pod."""
@@ -71,9 +100,13 @@ class BindK8sCharm(CharmBase):
         """Compile and return our pod resources (e.g. ingresses)."""
         # LP#1889746: We need to define a manual ingress here to work around LP#1889703.
         resources = {}  # TODO
+<<<<<<< src/charm.py
         out = io.StringIO()
         pprint(resources, out)
         logger.info("This is the Kubernetes Pod resources <<EOM\n{}\nEOM".format(out.getvalue()))
+=======
+        logger.info("This is the Kubernetes Pod resources <<EOM\n{}\nEOM".format(pformat(resources)))
+>>>>>>> src/charm.py
         return resources
 
     def generate_pod_config(self, secured=True):
@@ -130,9 +163,13 @@ class BindK8sCharm(CharmBase):
             ],
         }
 
+<<<<<<< src/charm.py
         out = io.StringIO()
         pprint(spec, out)
         logger.info("This is the Kubernetes Pod spec config (sans secrets) <<EOM\n{}\nEOM".format(out.getvalue()))
+=======
+        logger.info("This is the Kubernetes Pod spec config (sans secrets) <<EOM\n{}\nEOM".format(pformat(spec)))
+>>>>>>> src/charm.py
 
         if config.get("bind_image_username") and config.get("bind_image_password"):
             spec.get("containers")[0].get("imageDetails")["username"] = config["bind_image_username"]
diff --git a/tox.ini b/tox.ini
index 91adecf..d8b28cd 100644
--- a/tox.ini
+++ b/tox.ini
@@ -42,7 +42,10 @@ exclude =
     .git,
     __pycache__,
     .tox,
+<<<<<<< tox.ini
 # Ignore E231 because using black creates errors with this
 ignore = E231
+=======
+>>>>>>> tox.ini
 max-line-length = 120
 max-complexity = 10

Follow ups