Skip to content
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

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ehelms
Copy link
Member

@ehelms ehelms commented Aug 26, 2021

Probably needs some testing added, did not want to forget about this change I encountered doing some cleanup tasks.

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})
Copy link
Member Author

@ehelms ehelms Aug 26, 2021

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})

Copy link
Member

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) ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find this in the Katello API?

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']:
Copy link
Member

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"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants