stages/oscap.autotailor: rename new_profile
Rename the `new_profile` option to `tailoring_profile_id` for clarity. This also ensures that the change is backwards compatible by falling back to the `new_profile` option if that was set instead of the `tailoring_profile` id option.
This commit is contained in:
parent
16667ef260
commit
2a28acbc85
5 changed files with 19 additions and 11 deletions
|
|
@ -14,10 +14,15 @@ def main(tree, options):
|
||||||
profile = config.get("profile_id")
|
profile = config.get("profile_id")
|
||||||
new_profile = config.get("new_profile")
|
new_profile = config.get("new_profile")
|
||||||
tailoring_file = config.get("tailoring_file")
|
tailoring_file = config.get("tailoring_file")
|
||||||
|
# use `new_profile` as a fallback for backwards compatibility
|
||||||
|
tailored_profile_id = config.get("tailored_profile_id", new_profile)
|
||||||
|
|
||||||
|
if new_profile is not None:
|
||||||
|
print("WARNING: use the `tailored_profile_id` option instead")
|
||||||
|
|
||||||
# make sure either profile & new_profile are set
|
# make sure either profile & new_profile are set
|
||||||
# or tailoring_filepath is set
|
# or tailoring_filepath is set
|
||||||
if not ((profile and new_profile) or tailoring_file):
|
if not ((profile and tailored_profile_id) or tailoring_file):
|
||||||
raise ValueError("Either profile & new profile must be set or provide filepath to json tailoring file")
|
raise ValueError("Either profile & new profile must be set or provide filepath to json tailoring file")
|
||||||
|
|
||||||
if tailoring_file:
|
if tailoring_file:
|
||||||
|
|
@ -39,7 +44,7 @@ def main(tree, options):
|
||||||
cmd = [
|
cmd = [
|
||||||
"/usr/bin/autotailor",
|
"/usr/bin/autotailor",
|
||||||
"--output", f"{tree}/{filepath.lstrip('/')}",
|
"--output", f"{tree}/{filepath.lstrip('/')}",
|
||||||
"--new-profile-id", new_profile
|
"--new-profile-id", tailored_profile_id,
|
||||||
]
|
]
|
||||||
|
|
||||||
for s in selected:
|
for s in selected:
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,7 @@
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"profile_id",
|
"profile_id",
|
||||||
"datastream",
|
"datastream"
|
||||||
"new_profile"
|
|
||||||
],
|
],
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "OpenSCAP configuration variables",
|
"description": "OpenSCAP configuration variables",
|
||||||
|
|
@ -49,7 +48,11 @@
|
||||||
},
|
},
|
||||||
"new_profile": {
|
"new_profile": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The name of the new customized OpenSCAP profile"
|
"description": "The id of the new customized (tailored) OpenSCAP profile"
|
||||||
|
},
|
||||||
|
"tailored_profile_id": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The id of the new customized (tailored) OpenSCAP profile"
|
||||||
},
|
},
|
||||||
"selected": {
|
"selected": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ def fake_input_fixture():
|
||||||
"config": {
|
"config": {
|
||||||
"profile_id": "some-profile-id",
|
"profile_id": "some-profile-id",
|
||||||
"datastream": "some-datastream",
|
"datastream": "some-datastream",
|
||||||
"new_profile": "some-new-profile",
|
"tailoring_profile_id": "some-new-profile",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -90,7 +90,7 @@ def test_oscap_autotailor_overrides_smoke(mock_subprocess_run, fake_input, stage
|
||||||
"value": 50,
|
"value": 50,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}, "{'profile_id': 'some-profile-id', 'datastream': 'some-datastream', 'new_profile': 'some-new-profile',"
|
}, "{'profile_id': 'some-profile-id', 'datastream': 'some-datastream', 'tailoring_profile_id': 'some-new-profile',"
|
||||||
+ " 'overrides': [{'no': 'var', 'value': 50}]} is not valid under any of the given schemas"),
|
+ " 'overrides': [{'no': 'var', 'value': 50}]} is not valid under any of the given schemas"),
|
||||||
({
|
({
|
||||||
"overrides": [
|
"overrides": [
|
||||||
|
|
@ -99,7 +99,7 @@ def test_oscap_autotailor_overrides_smoke(mock_subprocess_run, fake_input, stage
|
||||||
"var": "some",
|
"var": "some",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}, "{'profile_id': 'some-profile-id', 'datastream': 'some-datastream', 'new_profile': 'some-new-profile',"
|
}, "{'profile_id': 'some-profile-id', 'datastream': 'some-datastream', 'tailoring_profile_id': 'some-new-profile',"
|
||||||
+ " 'overrides': [{'no': 'value', 'var': 'some'}]} is not valid under any of the given schemas"),
|
+ " 'overrides': [{'no': 'value', 'var': 'some'}]} is not valid under any of the given schemas"),
|
||||||
({
|
({
|
||||||
"overrides": [
|
"overrides": [
|
||||||
|
|
@ -108,7 +108,7 @@ def test_oscap_autotailor_overrides_smoke(mock_subprocess_run, fake_input, stage
|
||||||
"value": {"some": "object"},
|
"value": {"some": "object"},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}, "{'profile_id': 'some-profile-id', 'datastream': 'some-datastream', 'new_profile': 'some-new-profile',"
|
}, "{'profile_id': 'some-profile-id', 'datastream': 'some-datastream', 'tailoring_profile_id': 'some-new-profile',"
|
||||||
+ " 'overrides': [{'var': 'ssh_idle_timeout_value', 'value': {'some': 'object'}}]} is not valid under any of the given schemas"),
|
+ " 'overrides': [{'var': 'ssh_idle_timeout_value', 'value': {'some': 'object'}}]} is not valid under any of the given schemas"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -464,7 +464,7 @@
|
||||||
"config": {
|
"config": {
|
||||||
"datastream": "/usr/share/xml/scap/ssg/content/ssg-fedora-ds.xml",
|
"datastream": "/usr/share/xml/scap/ssg/content/ssg-fedora-ds.xml",
|
||||||
"profile_id": "xccdf_org.ssgproject.content_profile_ospp",
|
"profile_id": "xccdf_org.ssgproject.content_profile_ospp",
|
||||||
"new_profile": "xccdf_org.ssgproject.content_profile_ospp_osbuild_tailoring",
|
"tailored_profile_id": "xccdf_org.ssgproject.content_profile_ospp_osbuild_tailoring",
|
||||||
"selected": [
|
"selected": [
|
||||||
"partition_for_var_log"
|
"partition_for_var_log"
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ pipelines:
|
||||||
config:
|
config:
|
||||||
datastream: /usr/share/xml/scap/ssg/content/ssg-fedora-ds.xml
|
datastream: /usr/share/xml/scap/ssg/content/ssg-fedora-ds.xml
|
||||||
profile_id: xccdf_org.ssgproject.content_profile_ospp
|
profile_id: xccdf_org.ssgproject.content_profile_ospp
|
||||||
new_profile: xccdf_org.ssgproject.content_profile_ospp_osbuild_tailoring
|
tailored_profile_id: xccdf_org.ssgproject.content_profile_ospp_osbuild_tailoring
|
||||||
selected:
|
selected:
|
||||||
- partition_for_var_log
|
- partition_for_var_log
|
||||||
unselected:
|
unselected:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue