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

Allow users to use KEEP_LABEL on all resouces subjected by listRemovableResources #307

Closed
pkremens opened this issue Sep 6, 2019 · 1 comment

Comments

@pkremens
Copy link
Contributor

pkremens commented Sep 6, 2019

The is no way to prevent Openshift.clean() from deleting these:

		removables.addAll(getUserSecrets());
		removables.addAll(getUserServiceAccounts());
		removables.addAll(getUserRoleBindings());

but it should be doable, e.g.:

	List<HasMetadata> listRemovableResources() {
...
		removables.addAll(getUserSecrets().stream().filter(withoutKeepLabel()).collect(Collectors.toList()));
		removables.addAll(getUserServiceAccounts().stream().filter(withoutKeepLabel()).collect(Collectors.toList()));
		removables.addAll(getUserRoleBindings().stream().filter(withoutKeepLabel()).collect(Collectors.toList()));
		...

		return removables;
	}

	private Predicate<HasMetadata> withoutKeepLabel() {
		return (hasMetadata) -> {
			if (hasMetadata.getMetadata().getLabels() != null) {
				return !(hasMetadata.getMetadata().getLabels().containsKey(KEEP_LABEL));
			} else {
				return true;
			}
		};
	}
@pkremens
Copy link
Contributor Author

pkremens commented Sep 6, 2019

I see now that this is not an issue actually as getUser methods do take the KEEP_LABEL into account, I was fooled by #306. Closing this one.

@pkremens pkremens closed this as completed Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant