Skip to content

Commit

Permalink
fixup! separate the actor into two
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterMocary committed Nov 15, 2023
1 parent 3678a43 commit 5ffc643
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
from leapp.libraries.common.testutils import create_report_mocked, CurrentActorMocked
from leapp.libraries.stdlib import api
from leapp.models import ConfigFile, DynamicLinkerConfiguration, MainConfigFile
from leapp.models import DynamicLinkerConfiguration, LDConfigFile, MainLDConfigFile

INCLUDED_CONFIG_PATHS = ['/etc/ld.so.conf.d/dyninst-x86_64.conf',
'/etc/ld.so.conf.d/mariadb-x86_64.conf',
Expand All @@ -26,10 +26,10 @@
def test_check_ld_so_configuration(monkeypatch, included_configs_modifications, used_variables, modified_lines):
assert len(INCLUDED_CONFIG_PATHS) == len(included_configs_modifications)

main_config = MainConfigFile(path="/etc/ld.so.conf", modified=any(modified_lines), modified_lines=modified_lines)
main_config = MainLDConfigFile(path="/etc/ld.so.conf", modified=any(modified_lines), modified_lines=modified_lines)
included_configs = []
for path, modified in zip(INCLUDED_CONFIG_PATHS, included_configs_modifications):
included_configs.append(ConfigFile(path=path, modified=modified))
included_configs.append(LDConfigFile(path=path, modified=modified))

configuration = DynamicLinkerConfiguration(main_config=main_config,
included_configs=included_configs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from leapp.libraries.common.rpms import has_package
from leapp.libraries.stdlib import api, CalledProcessError, run
from leapp.models import ConfigFile, DynamicLinkerConfiguration, InstalledRedHatSignedRPM, MainConfigFile
from leapp.models import DynamicLinkerConfiguration, InstalledRedHatSignedRPM, LDConfigFile, MainLDConfigFile

LD_SO_CONF_DIR = '/etc/ld.so.conf.d'
LD_SO_CONF_MAIN = '/etc/ld.so.conf'
Expand Down Expand Up @@ -92,7 +92,7 @@ def scan_dynamic_linker_configuration():
api.current_logger().debug('The default include "{}" is not the only include in '
'the {} file.'.format(LD_SO_CONF_DEFAULT_INCLUDE, LD_SO_CONF_MAIN))

main_config_file = MainConfigFile(path=LD_SO_CONF_MAIN, modified=any(other_lines), modified_lines=other_lines)
main_config_file = MainLDConfigFile(path=LD_SO_CONF_MAIN, modified=any(other_lines), modified_lines=other_lines)

# Expand the config paths from globs and ensure uniqueness of resulting paths
config_paths = set()
Expand All @@ -102,7 +102,7 @@ def scan_dynamic_linker_configuration():

included_config_files = []
for config_path in config_paths:
config_file = ConfigFile(path=config_path, modified=_is_included_config_custom(config_path))
config_file = LDConfigFile(path=config_path, modified=_is_included_config_custom(config_path))
included_config_files.append(config_file)

# Check if dynamic linker variables used for specifying custom libraries are set
Expand Down
26 changes: 22 additions & 4 deletions repos/system_upgrade/common/models/dynamiclinker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,40 @@
from leapp.topics import SystemFactsTopic


class ConfigFile(Model):
class LDConfigFile(Model):
"""
Represents a config file related to dynamic linker configuration
"""
topic = SystemFactsTopic

path = fields.String()
""" Absolute path to the configuration file """

modified = fields.Boolean()
""" If True the file is considered custom and will trigger a report """


class MainConfigFile(ConfigFile):
class MainLDConfigFile(LDConfigFile):
"""
Represents the main configuration file of the dynamic linker /etc/ld.so.conf
"""
topic = SystemFactsTopic

modified_lines = fields.List(fields.String(), default=[])
""" Lines that are considered custom, generaly those that are not includes of other configs """

Check failure on line 25 in repos/system_upgrade/common/models/dynamiclinker.py

View workflow job for this annotation

GitHub Actions / Check for spelling errors

generaly ==> generally


class DynamicLinkerConfiguration(Model):
"""
Facts about configuration of dynamic linker
"""
topic = SystemFactsTopic

main_config = fields.Model(MainConfigFile)
included_configs = fields.List(fields.Model(ConfigFile))
main_config = fields.Model(MainLDConfigFile)
""" The main configuration file of dynamic linker (/etc/ld.so.conf) """

included_configs = fields.List(fields.Model(LDConfigFile))
""" All the configs that are included by the main configuration file """

used_variables = fields.List(fields.String(), default=[])
""" Environment variables that are currently used to modify dynamic linker configuration """

0 comments on commit 5ffc643

Please sign in to comment.