From 894816a4b17fede78af5933b2aa0c4e52aa36bc0 Mon Sep 17 00:00:00 2001 From: Ben Hoyt Date: Mon, 10 Jul 2023 13:54:43 +1200 Subject: [PATCH] Remove workaround for non-unique consumer labels bug (juju/juju#14916) Also update has_secrets to 3.0.3 instead of 3.0.2 --- ops/jujuversion.py | 3 +-- ops/model.py | 10 ++-------- test/test_jujuversion.py | 4 ++-- test/test_model.py | 2 -- tox.ini | 2 +- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/ops/jujuversion.py b/ops/jujuversion.py index c5d075c4a..65c664ed6 100755 --- a/ops/jujuversion.py +++ b/ops/jujuversion.py @@ -121,5 +121,4 @@ def has_secrets(self) -> bool: # * 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) diff --git a/ops/model.py b/ops/model.py index ebb3c33f9..4756b2c06 100644 --- a/ops/model.py +++ b/ops/model.py @@ -265,14 +265,8 @@ def get_secret(self, *, id: Optional[str] = None, label: Optional[str] = None) - if id is not None: # Canonicalize to "secret:" 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/test/test_jujuversion.py b/test/test_jujuversion.py index 0d180a633..9f90f0c53 100755 --- a/test/test_jujuversion.py +++ b/test/test_jujuversion.py @@ -69,8 +69,8 @@ def test_has_controller_storage(self): 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.assertFalse(ops.JujuVersion('3.0.1').has_secrets) + self.assertTrue(ops.JujuVersion('3.0.3').has_secrets) + self.assertFalse(ops.JujuVersion('3.0.2').has_secrets) self.assertFalse(ops.JujuVersion('2.9.30').has_secrets) def test_parsing_errors(self): diff --git a/test/test_model.py b/test/test_model.py index 97b0c9ca4..2ff320598 100755 --- a/test/test_model.py +++ b/test/test_model.py @@ -2952,7 +2952,6 @@ def test_get_secret_no_args(self): 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 @@ def test_get_secret_not_found(self): 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') diff --git a/tox.ini b/tox.ini index 0bc99fa2a..a7700b048 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