Skip to content

Commit

Permalink
Fix(inspect-code): Extracted method
Browse files Browse the repository at this point in the history
  • Loading branch information
rkubis committed Nov 22, 2024
1 parent f980c87 commit e58536c
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,7 @@ public static void deleteOperatorGroup(OperatorGroup operatorGroup) {
public static void deleteSubscription(Subscription subscription) {
String name = subscription.getMetadata().getName();
String namespace = subscription.getMetadata().getNamespace();
SubscriptionSpec spec = subscription.getSpec();
String startingCSV = spec.getStartingCSV();

String info = MessageFormat.format(
"{0} in namespace {1}: packageName={2}, catalogSourceName={3}, catalogSourceNamespace={4}, " +
"startingCSV={5}, channel={6}, installPlanApproval={7}",
name, namespace, spec.getName(), spec.getSource(), spec.getSourceNamespace(),
startingCSV, spec.getChannel(), spec.getInstallPlanApproval()
);
String info = getInfo(subscription, name, namespace);

if (Kubernetes.getSubscription(namespace, name) == null) {
LOGGER.info("Subscription {} already removed.", info);
Expand All @@ -259,6 +251,18 @@ public static void deleteSubscription(Subscription subscription) {
}
}

private static String getInfo(Subscription subscription, String name, String namespace) {
SubscriptionSpec spec = subscription.getSpec();
String startingCSV = spec.getStartingCSV();

return MessageFormat.format(
"{0} in namespace {1}: packageName={2}, catalogSourceName={3}, catalogSourceNamespace={4}, " +
"startingCSV={5}, channel={6}, installPlanApproval={7}",
name, namespace, spec.getName(), spec.getSource(), spec.getSourceNamespace(),
startingCSV, spec.getChannel(), spec.getInstallPlanApproval()
);
}

public static void deleteClusterServiceVersion(String namespace, String clusterServiceVersion) {
if (clusterServiceVersion != null && !clusterServiceVersion.isEmpty()) {
LOGGER.info("Removing ClusterServiceVersion {} in namespace {}...", clusterServiceVersion, namespace);
Expand Down

0 comments on commit e58536c

Please sign in to comment.