1717#
1818import os
1919import logging
20- from typing import Literal
20+ from typing import (
21+ Literal , List , Optional
22+ )
2123import yaml
2224
2325# project
@@ -49,7 +51,7 @@ class RuntimeConfig:
4951
5052 :param bool reread: reread runtime config
5153 """
52- def __init__ (self , reread = False ):
54+ def __init__ (self , reread : bool = False ):
5355 global RUNTIME_CONFIG
5456
5557 if RUNTIME_CONFIG is None or reread :
@@ -75,7 +77,7 @@ def __init__(self, reread=False):
7577 with open (config_file , 'r' ) as config :
7678 RUNTIME_CONFIG = yaml .safe_load (config ) or {}
7779
78- def get_credentials_verification_metadata_signing_key_file (self ):
80+ def get_credentials_verification_metadata_signing_key_file (self ) -> str :
7981 """
8082 Return verification metadata signing key file, used for
8183 signature creation of rootfs verification metadata:
@@ -95,7 +97,7 @@ def get_credentials_verification_metadata_signing_key_file(self):
9597 )
9698 return signing_key_file if signing_key_file else ''
9799
98- def get_obs_download_server_url (self ):
100+ def get_obs_download_server_url (self ) -> str :
99101 """
100102 Return URL of buildservice download server in:
101103
@@ -115,7 +117,7 @@ def get_obs_download_server_url(self):
115117 return obs_download_server_url if obs_download_server_url else \
116118 Defaults .get_obs_download_server_url ()
117119
118- def get_obs_api_server_url (self ):
120+ def get_obs_api_server_url (self ) -> str :
119121 """
120122 Return URL of buildservice API server in:
121123
@@ -135,7 +137,7 @@ def get_obs_api_server_url(self):
135137 return obs_api_server_url if obs_api_server_url else \
136138 Defaults .get_obs_api_server_url ()
137139
138- def get_obs_api_credentials (self ):
140+ def get_obs_api_credentials (self ) -> List [ str ] :
139141 """
140142 Return OBS API credentials if configured:
141143
@@ -148,10 +150,9 @@ def get_obs_api_credentials(self):
148150 :rtype: list
149151 """
150152 obs_users = self ._get_attribute (element = 'obs' , attribute = 'user' ) or []
151- if obs_users :
152- return obs_users
153+ return obs_users
153154
154- def is_obs_public (self ):
155+ def is_obs_public (self ) -> bool :
155156 """
156157 Check if the buildservice configuration is public or private in:
157158
@@ -170,7 +171,7 @@ def is_obs_public(self):
170171 obs_public = True
171172 return bool (obs_public )
172173
173- def get_package_changes (self , default = True ):
174+ def get_package_changes (self , default : bool = True ) -> bool :
174175 """
175176 Return boolean value to express if the image build and bundle
176177 should contain a .changes file. The .changes file contains
@@ -201,7 +202,7 @@ def get_package_changes(self, default=True):
201202 bundle_package_changes = default
202203 return bool (bundle_package_changes )
203204
204- def get_bundle_compression (self , default = True ):
205+ def get_bundle_compression (self , default : bool = True ) -> bool :
205206 """
206207 Return boolean value to express if the image bundle should
207208 contain XZ compressed image results or not.
@@ -229,7 +230,7 @@ def get_bundle_compression(self, default=True):
229230 bundle_compress = default
230231 return bool (bundle_compress )
231232
232- def get_xz_options (self ):
233+ def get_xz_options (self ) -> Optional [ List [ str ]] :
233234 """
234235 Return list of XZ compression options in:
235236
@@ -250,7 +251,7 @@ def get_xz_options(self):
250251 xz_options = self ._get_attribute (element = 'xz' , attribute = 'options' )
251252 return xz_options .split () if xz_options else None
252253
253- def get_container_compression (self ):
254+ def get_container_compression (self ) -> bool :
254255 """
255256 Return compression for container images
256257
@@ -281,7 +282,7 @@ def get_container_compression(self):
281282 )
282283 return Defaults .get_container_compression ()
283284
284- def get_iso_tool_category (self ):
285+ def get_iso_tool_category (self ) -> str :
285286 """
286287 Return tool category which should be used to build iso images
287288
@@ -341,7 +342,7 @@ def get_iso_media_tag_tool(self) -> Literal['checkmedia', 'isomd5sum']:
341342 )
342343 return Defaults .get_iso_media_tag_tool ()
343344
344- def get_oci_archive_tool (self ):
345+ def get_oci_archive_tool (self ) -> str :
345346 """
346347 Return OCI archive tool which should be used on creation of
347348 container archives for OCI compliant images, e.g docker
@@ -361,7 +362,7 @@ def get_oci_archive_tool(self):
361362 )
362363 return oci_archive_tool or Defaults .get_oci_archive_tool ()
363364
364- def get_mapper_tool (self ):
365+ def get_mapper_tool (self ) -> str :
365366 """
366367 Return partition mapper tool
367368
@@ -380,7 +381,7 @@ def get_mapper_tool(self):
380381 )
381382 return part_mapper_tool or Defaults .get_part_mapper_tool ()
382383
383- def get_max_size_constraint (self ):
384+ def get_max_size_constraint (self ) -> Optional [ int ] :
384385 """
385386 Returns the maximum allowed size of the built image. The value is
386387 returned in bytes and it is specified in build_constraints element
@@ -401,7 +402,7 @@ def get_max_size_constraint(self):
401402 )
402403 return StringToSize .to_bytes (max_size ) if max_size else None
403404
404- def get_disabled_runtime_checks (self ):
405+ def get_disabled_runtime_checks (self ) -> List [ str ] :
405406 """
406407 Returns disabled runtime checks. Checks can be disabled with:
407408
@@ -413,10 +414,12 @@ def get_disabled_runtime_checks(self):
413414 """
414415 disabled_checks = self ._get_attribute (
415416 element = 'runtime_checks' , attribute = 'disable'
416- )
417- return disabled_checks or ''
417+ ) or []
418+ for check in disabled_checks :
419+ log .warning (f'Runtime check: { check } : disabled' )
420+ return disabled_checks
418421
419- def _get_attribute (self , element , attribute ):
422+ def _get_attribute (self , element : str , attribute : str ):
420423 if RUNTIME_CONFIG :
421424 try :
422425 if element in RUNTIME_CONFIG :
@@ -428,5 +431,5 @@ def _get_attribute(self, element, attribute):
428431 f'{ type (issue ).__name__ } : { issue } '
429432 )
430433
431- def _home_path (self ):
432- return os .environ .get ('HOME' )
434+ def _home_path (self ) -> str :
435+ return os .environ .get ('HOME' ) or ''
0 commit comments