-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove content view version from environments if empty #1280
base: develop
Are you sure you want to change the base?
Conversation
current_environment_ids = {environment['id'] for environment in content_view_version['environments']} | ||
|
||
for environment_id in current_environment_ids: | ||
response = module.resource_action('content_views', 'remove_from_environment', params={'id': content_view['id'], 'environment_id': environment_id}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On newer releases of Katello, I think this can be done in one call via:
response = module.resource_action('content_views_versions', 'remove_from_environments', params={'id': content_view['id'], 'environment_ids': current_environment_ids})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newer is 4.0+? If there is a possible perfomance gain, I'd be in favor of an if/else?
BTW, the linter says this line is too damn long (170>160 chars) ;)
force=module.foreman_params['force_promote'], | ||
force_yum_metadata_regeneration=module.foreman_params['force_yum_metadata_regeneration'], | ||
) | ||
if module.foreman_params['lifecycle_environments'] == [] and content_view_version['environments']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this happen only if the user says []
or always when the list doesn't match?
The later has some complications as we never list Library
and I think the current user expectation is "promote to these envs, don't touch the others"?
8acdd61
to
741fdbf
Compare
Probably needs some testing added, did not want to forget about this change I encountered doing some cleanup tasks.