Repository: canonical/operator
Pull request #967 (2023-07-10 01:55:08)

Remove workaround for non-unique consumer labels bug (juju/juju#14916)
Also update has_secrets to 3.0.3 instead of 3.0.2. This removes a couple of old TODOs.


Patch:
diff --git a/ops/jujuversion.py b/ops/jujuversion.py
index e026273..bb8151b 100755
--- a/ops/jujuversion.py
+++ b/ops/jujuversion.py
@@ -121,8 +121,7 @@ class JujuVersion:
         # * In 3.0.2, secret-get "--update" was renamed to "--refresh", and
         #   secret-get-info was separated into its own hook tool
         # * In 3.0.3, a bug with observer labels was fixed (juju/juju#14916)
-        # TODO(benhoyt): update to 3.0.3+ once shipped (for juju/juju#14916 fix)
-        return (self.major, self.minor, self.patch) >= (3, 0, 2)
+        return (self.major, self.minor, self.patch) >= (3, 0, 3)
 
     @property
     def supports_open_port_on_k8s(self) -> bool:
diff --git a/ops/model.py b/ops/model.py
index ebb3c33..4756b2c 100644
--- a/ops/model.py
+++ b/ops/model.py
@@ -265,14 +265,8 @@ class Model:
         if id is not None:
             # Canonicalize to "secret:<id>" form for consistency in backend calls.
             id = Secret._canonicalize_id(id)
-        try:
-            content = self._backend.secret_get(id=id, label=label)
-            return Secret(self._backend, id=id, label=label, content=content)
-        except ModelError:
-            # TODO(benhoyt): remove the secret-info-get fallback once
-            #  juju/juju#14916 is fixed (should be in Juju 3.0.3)
-            info = self._backend.secret_info_get(id=id, label=label)
-            return Secret(self._backend, id=info.id, label=info.label)
+        content = self._backend.secret_get(id=id, label=label)
+        return Secret(self._backend, id=id, label=label, content=content)
 
 
 class _ModelCache:
diff --git a/tox.ini b/tox.ini
index 0bc99fa..a7700b0 100644
--- a/tox.ini
+++ b/tox.ini
@@ -3,7 +3,7 @@
 [tox]
 skipsdist=True
 skip_missing_interpreters = True
-envlist = lint, unit
+envlist = lint, static, unit
 
 [vars]
 # These need to be relative paths because autopep8 doesn't handle absolute


Test patch:
diff --git a/test/test_jujuversion.py b/test/test_jujuversion.py
index 6851179..7e04230 100755
--- a/test/test_jujuversion.py
+++ b/test/test_jujuversion.py
@@ -69,9 +69,9 @@ class TestJujuVersion(unittest.TestCase):
         self.assertFalse(ops.JujuVersion('2.7.9').has_controller_storage())
 
     def test_has_secrets(self):
-        self.assertTrue(ops.JujuVersion('3.0.2').has_secrets)
+        self.assertTrue(ops.JujuVersion('3.0.3').has_secrets)
         self.assertTrue(ops.JujuVersion('3.1.0').has_secrets)
-        self.assertFalse(ops.JujuVersion('3.0.1').has_secrets)
+        self.assertFalse(ops.JujuVersion('3.0.2').has_secrets)
         self.assertFalse(ops.JujuVersion('2.9.30').has_secrets)
 
     def test_supports_open_port_on_k8s(self):
diff --git a/test/test_model.py b/test/test_model.py
index 97b0c9c..2ff3205 100755
--- a/test/test_model.py
+++ b/test/test_model.py
@@ -2952,7 +2952,6 @@ class TestSecrets(unittest.TestCase):
     def test_get_secret_not_found(self):
         script = """echo 'ERROR secret "123" not found' >&2; exit 1"""
         fake_script(self, 'secret-get', script)
-        fake_script(self, 'secret-info-get', script)
 
         with self.assertRaises(ops.SecretNotFoundError):
             self.model.get_secret(id='123')
@@ -2960,7 +2959,6 @@ class TestSecrets(unittest.TestCase):
     def test_get_secret_other_error(self):
         script = """echo 'ERROR other error' >&2; exit 1"""
         fake_script(self, 'secret-get', script)
-        fake_script(self, 'secret-info-get', script)
 
         with self.assertRaises(ops.ModelError) as cm:
             self.model.get_secret(id='123')