Move security from modifiers to required in install template
- Security is now enabled by default in all install recipes - Add override handling to skip required fragment when modifier sets security - Fix modifier key lookup to handle both hyphen and underscore keys Closes #issue
This commit is contained in:
@@ -243,16 +243,22 @@ class RecipeGenerator:
|
||||
modifiers = modifiers.copy()
|
||||
modifiers['version'] = version
|
||||
|
||||
# Keys that can be overridden by modifiers
|
||||
override_keys = {'security'}
|
||||
|
||||
# Add required includes
|
||||
for item in template.get('required', []):
|
||||
if isinstance(item, dict):
|
||||
key = list(item.keys())[0]
|
||||
fragment_path = list(item.values())[0]
|
||||
else:
|
||||
continue
|
||||
|
||||
if fragment_path not in seen:
|
||||
includes.append(f"%ksappend {fragment_path}")
|
||||
seen.add(fragment_path)
|
||||
# Skip required fragment if modifier overrides it
|
||||
if key in override_keys and key in modifiers:
|
||||
continue
|
||||
|
||||
if fragment_path not in seen:
|
||||
includes.append(f"%ksappend {fragment_path}")
|
||||
seen.add(fragment_path)
|
||||
|
||||
# Add optional includes based on modifiers
|
||||
for opt_key, opt_config in template.get('optional', {}).items():
|
||||
@@ -312,12 +318,31 @@ class RecipeGenerator:
|
||||
# Normalize key: convert underscores to hyphens for template lookup
|
||||
mod_key_normalized = mod_key.replace('_', '-')
|
||||
if mod_key_normalized in template.get('modifiers', {}):
|
||||
mod_config = template['modifiers'][mod_key_normalized]
|
||||
mod_key_to_use = mod_key_normalized
|
||||
elif mod_key in template.get('modifiers', {}):
|
||||
mod_key_to_use = mod_key
|
||||
else:
|
||||
continue
|
||||
mod_config = template['modifiers'][mod_key_to_use]
|
||||
|
||||
# Handle nested dict modifiers
|
||||
if isinstance(mod_config, dict) and isinstance(mod_value, str):
|
||||
if mod_value in mod_config:
|
||||
fragment_path = mod_config[mod_value]
|
||||
# Handle nested dict modifiers
|
||||
if isinstance(mod_config, dict) and isinstance(mod_value, str):
|
||||
if mod_value in mod_config:
|
||||
fragment_path = mod_config[mod_value]
|
||||
if isinstance(fragment_path, list):
|
||||
for fp in fragment_path:
|
||||
if fp is not None and fp not in seen:
|
||||
includes.append(f"%ksappend {fp}")
|
||||
seen.add(fp)
|
||||
elif fragment_path and fragment_path not in seen:
|
||||
includes.append(f"%ksappend {fragment_path}")
|
||||
seen.add(fragment_path)
|
||||
|
||||
# Handle list modifiers
|
||||
elif isinstance(mod_config, dict) and isinstance(mod_value, list):
|
||||
for item in mod_value:
|
||||
if item in mod_config:
|
||||
fragment_path = mod_config[item]
|
||||
if isinstance(fragment_path, list):
|
||||
for fp in fragment_path:
|
||||
if fp is not None and fp not in seen:
|
||||
@@ -327,20 +352,6 @@ class RecipeGenerator:
|
||||
includes.append(f"%ksappend {fragment_path}")
|
||||
seen.add(fragment_path)
|
||||
|
||||
# Handle list modifiers
|
||||
elif isinstance(mod_config, dict) and isinstance(mod_value, list):
|
||||
for item in mod_value:
|
||||
if item in mod_config:
|
||||
fragment_path = mod_config[item]
|
||||
if isinstance(fragment_path, list):
|
||||
for fp in fragment_path:
|
||||
if fp is not None and fp not in seen:
|
||||
includes.append(f"%ksappend {fp}")
|
||||
seen.add(fp)
|
||||
elif fragment_path and fragment_path not in seen:
|
||||
includes.append(f"%ksappend {fragment_path}")
|
||||
seen.add(fragment_path)
|
||||
|
||||
return includes
|
||||
|
||||
def validate_recipe(self, content: str) -> List[str]:
|
||||
|
||||
@@ -18,6 +18,7 @@ templates:
|
||||
- packages: fragments/packages/core-group.ks
|
||||
- fedora-remix: fragments/packages/fedora-remix.ks
|
||||
- hand-picked: fragments/packages/hand-picked.ks
|
||||
- security: fragments/core/security/enabled.ks
|
||||
optional:
|
||||
hardware-support: fragments/packages/hardware-support.ks
|
||||
guest-agents: fragments/guest-agents/base.ks
|
||||
|
||||
Reference in New Issue
Block a user