Skip to content

Commit

Permalink
extract default values from schema
Browse files Browse the repository at this point in the history
Instead of defining the default config values in the code, just use the
defaults provided in the schema. By that we also ensure that these are
consistent.

No functional change.

Signed-off-by: Felix Moessbauer <[email protected]>
Signed-off-by: Jan Kiszka <[email protected]>
  • Loading branch information
fmoessbauer authored and jan-kiszka committed Dec 5, 2024
1 parent 3cb9d38 commit 73872d0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions kas/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from .repos import Repo
from .includehandler import IncludeHandler, IncludeException
from .kasusererror import ArtifactNotFoundError
from .configschema import CONFIGSCHEMA

__license__ = 'MIT'
__copyright__ = 'Copyright (c) Siemens AG, 2017-2021'
Expand Down Expand Up @@ -156,7 +157,8 @@ def get_bitbake_targets(self):
if i]
if environ_targets:
return environ_targets
target = self._config.get('target', 'core-image-minimal')
def_target = CONFIGSCHEMA['properties']['target']['default']
target = self._config.get('target', def_target)
if isinstance(target, str):
return [target]
return target
Expand All @@ -167,8 +169,9 @@ def get_bitbake_task(self):
"""
if self._override_task:
return self._override_task
default = CONFIGSCHEMA['properties']['task']['default']
return os.environ.get('KAS_TASK',
self._config.get('task', 'build'))
self._config.get('task', default))

def _get_conf_header(self, header_name):
"""
Expand All @@ -195,15 +198,17 @@ def get_machine(self):
"""
Returns the machine
"""
default = CONFIGSCHEMA['properties']['machine']['default']
return os.environ.get('KAS_MACHINE',
self._config.get('machine', 'qemux86-64'))
self._config.get('machine', default))

def get_distro(self):
"""
Returns the distro
"""
default = CONFIGSCHEMA['properties']['distro']['default']
return os.environ.get('KAS_DISTRO',
self._config.get('distro', 'poky'))
self._config.get('distro', default))

def get_environment(self):
"""
Expand Down

0 comments on commit 73872d0

Please sign in to comment.