apt: use wording final instead of elected to reduce coupling with mirror

The mirror model has the notion of primary candidates, staged primary
candidate and elected primary candidate. This is purely specific to the
mirror model and does not necessarily make sense from the outside.

In code that does not specifically need to know implmentation details of
the mirror model, we now prefer the wording "final configuration" over
"elected configuration".

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2023-02-10 10:47:26 +01:00
parent c5a0b567b4
commit eb255c6996
3 changed files with 8 additions and 8 deletions

View File

@ -112,9 +112,9 @@ class AptConfigurer:
self.install_tree: Optional[OverlayMountpoint] = None
self.install_mount = None
def apt_config(self, elected: bool):
def apt_config(self, final: bool):
cfg = {}
if elected:
if final:
merge_config(cfg,
self.app.base_model.mirror.get_apt_config_elected())
else:
@ -123,12 +123,12 @@ class AptConfigurer:
merge_config(cfg, self.app.base_model.proxy.get_apt_config())
return {'apt': cfg}
async def apply_apt_config(self, context, elected: bool):
async def apply_apt_config(self, context, final: bool):
self.configured_tree = await self.mounter.setup_overlay([self.source])
config_location = os.path.join(
self.app.root, 'var/log/installer/subiquity-curtin-apt.conf')
generate_config_yaml(config_location, self.apt_config(elected))
generate_config_yaml(config_location, self.apt_config(final))
self.app.note_data_for_apport("CurtinAptConfig", config_location)
await run_curtin_command(

View File

@ -241,11 +241,11 @@ class MirrorController(SubiquityController):
# recommended. Clients should do a POST request to /mirror with
# null as the body instead.
await self.find_and_elect_candidate_mirror(self.context)
await self.apt_configurer.apply_apt_config(self.context, elected=True)
await self.apt_configurer.apply_apt_config(self.context, final=True)
async def run_mirror_testing(self, output: io.StringIO) -> None:
await self.source_configured_event.wait()
await self.apt_configurer.apply_apt_config(self.context, elected=False)
await self.apt_configurer.apply_apt_config(self.context, final=False)
await self.apt_configurer.run_apt_config_check(output)
async def wait_config(self):

View File

@ -68,7 +68,7 @@ class TestAptConfigurer(SubiTestCase):
self.astart_sym = "subiquity.server.apt.astart_command"
def test_apt_config_noproxy(self):
config = self.configurer.apt_config(elected=True)
config = self.configurer.apt_config(final=True)
self.assertNotIn("http_proxy", config["apt"])
self.assertNotIn("https_proxy", config["apt"])
@ -76,7 +76,7 @@ class TestAptConfigurer(SubiTestCase):
proxy = 'http://apt-cacher-ng:3142'
self.model.proxy.proxy = proxy
config = self.configurer.apt_config(elected=True)
config = self.configurer.apt_config(final=True)
self.assertEqual(proxy, config["apt"]["http_proxy"])
self.assertEqual(proxy, config["apt"]["https_proxy"])