提交 d00dc71b 编写于 作者: S Stephen Connolly

Merge pull request #1917 from stephenc/jenkins-31596

[FIXED JENKINS-31596] Provide an extension point for MasterKillSwitchConfiguration relevance
package jenkins.security.s2m;
import hudson.Extension;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import javax.inject.Inject;
import jenkins.model.GlobalConfiguration;
import jenkins.model.GlobalConfigurationCategory;
......@@ -52,8 +54,39 @@ public class MasterKillSwitchConfiguration extends GlobalConfiguration {
return jenkins.isUseSecurity() // if security is off, there's no point
&& (jenkins.getComputers().length>1 // if there's no slave,
|| !jenkins.clouds.isEmpty() // and no clouds, likewise this is pointless
|| Relevance.fromExtension() // unless a plugin thinks otherwise
)
;
}
/**
* Some plugins may cause the {@link MasterKillSwitchConfiguration} to be relevant for additional reasons,
* by implementing this extension point they can indicate such additional conditions.
*
* @since FIXME
*/
public static abstract class Relevance implements ExtensionPoint {
/**
* Is the {@link MasterKillSwitchConfiguration} relevant.
*
* @return {@code true} if the {@link MasterKillSwitchConfiguration} relevant.
*/
public abstract boolean isRelevant();
/**
* Is the {@link MasterKillSwitchConfiguration} relevant for any of the {@link Relevance} extensions.
*
* @return {@code true} if and only if {@link Relevance#isRelevant()} for at least one extension.
*/
public static boolean fromExtension() {
for (Relevance r : ExtensionList.lookup(Relevance.class)) {
if (r.isRelevant()) {
return true;
}
}
return false;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册