Skip to content

Commit

Permalink
Add descriptor visibility filter to retention strategies (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
jetersen authored and pjdarton committed Nov 5, 2019
1 parent e81bbdb commit 911b50c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@

package org.jenkinsci.plugins.vsphere;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.model.ExecutorListener;
import hudson.model.Descriptor;
import hudson.model.DescriptorVisibilityFilter;
import hudson.model.Executor;
import hudson.model.Queue;
import hudson.slaves.AbstractCloudComputer;
Expand Down Expand Up @@ -178,4 +181,12 @@ public String getDisplayName() {
return "vSphere Run-Once Retention Strategy";
}
}

@Extension
public static class DescriptorVisibilityFilterImpl extends DescriptorVisibilityFilter {
@Override
public boolean filter(@CheckForNull Object context, @NonNull Descriptor descriptor) {
return !(descriptor instanceof DescriptorImpl);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.jenkinsci.plugins.vsphere;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.model.Descriptor;
import hudson.model.DescriptorVisibilityFilter;
import hudson.slaves.CloudRetentionStrategy;
import hudson.slaves.RetentionStrategy;

Expand Down Expand Up @@ -38,7 +41,15 @@ public String getDisplayName() {
return "vSphere Keep-Until-Idle Retention Strategy";
}
}


@Extension
public static class DescriptorVisibilityFilterImpl extends DescriptorVisibilityFilter {
@Override
public boolean filter(@CheckForNull Object context, @NonNull Descriptor descriptor) {
return !(descriptor instanceof DescriptorImpl);
}
}

private Object readResolve() {
// without this, super.idleMinutes is not restored from persistence
return new VSphereCloudRetentionStrategy(idleMinutes);
Expand Down

0 comments on commit 911b50c

Please sign in to comment.