Skip to content

Commit

Permalink
Add JujuVersion.has_secrets() (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
beliaev-maksim authored Nov 23, 2022
1 parent 5f46da6 commit 74ce348
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ops/jujuversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,8 @@ def is_dispatch_aware(self) -> bool:
def has_controller_storage(self) -> bool:
"""Determine whether this juju version supports controller-side storage."""
return (self.major, self.minor, self.patch) >= (2, 8, 0)

@property
def has_secrets(self) -> bool:
"""Determine whether this Juju version supports the `secrets` feature."""
return (self.major, self.minor, self.patch) >= (3, 0, 2)
6 changes: 5 additions & 1 deletion test/test_jujuversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import os
import unittest
import unittest.mock # in this file, importing just 'patch' would be confusing

from ops.jujuversion import JujuVersion
Expand Down Expand Up @@ -69,6 +68,11 @@ def test_has_controller_storage(self):
self.assertTrue(JujuVersion('2.8.0').has_controller_storage())
self.assertFalse(JujuVersion('2.7.9').has_controller_storage())

def test_has_secrets(self):
self.assertTrue(JujuVersion('3.0.2').has_secrets)
self.assertFalse(JujuVersion('3.0.1').has_secrets)
self.assertFalse(JujuVersion('2.9.30').has_secrets)

def test_parsing_errors(self):
invalid_versions = [
"xyz",
Expand Down

0 comments on commit 74ce348

Please sign in to comment.