File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010import zipfile
1111
1212from . import jasyncio , origin , errors
13+ from .client import client
1314
1415
1516async def execute_process (* cmd , log = None ):
@@ -403,3 +404,15 @@ def base_channel_to_series(channel):
403404 :return: str series (e.g. focal)
404405 """
405406 return get_version_series (origin .Channel .parse (channel ).track )
407+
408+
409+ def parse_base_arg (base ):
410+ """Parses a given base into a Client.Base object
411+ :param base str : The base to deploy a charm (e.g. ubuntu@22.04)
412+ """
413+ client .CharmBase ()
414+ if type (base ) != str or "@" not in base :
415+ raise errors .JujuError ("expected base string to contain os and channel separated by '@'" )
416+
417+ name , channel = base .split ('@' )
418+ return client .Base (name = name , channel = channel )
Original file line number Diff line number Diff line change 11import unittest
22
3- from juju .utils import juju_config_dir , juju_ssh_key_paths
3+ from juju .utils import juju_config_dir , juju_ssh_key_paths , parse_base_arg
4+ from juju .client import client
45
56
67class TestDirResolve (unittest .TestCase ):
@@ -12,3 +13,9 @@ def test_juju_ssh_key_paths(self):
1213 public , private = juju_ssh_key_paths ()
1314 assert public .endswith ('ssh/juju_id_rsa.pub' )
1415 assert private .endswith ('ssh/juju_id_rsa' )
16+
17+ def test_parse_base_arg (self ):
18+ base = parse_base_arg ('ubuntu@22.04' )
19+ assert isinstance (base , client .Base )
20+ assert base .name == 'ubuntu'
21+ assert base .channel == '22.04'
You can’t perform that action at this time.
0 commit comments