de.gesellix.docker.client.node.NodeUtil.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of docker-client Show documentation
Show all versions of docker-client Show documentation
A Docker client for the JVM written in Groovy
The newest version!
package de.gesellix.docker.client.node
import de.gesellix.docker.client.system.ManageSystem
class NodeUtil {
ManageSystem manageSystem
NodeUtil(ManageSystem manageSystem) {
this.manageSystem = manageSystem
}
def resolveNodeId(nodeFilter) {
Closure ownNodeId = {
manageSystem.info().content.swarm.nodeID
}
Closure resolve = { String ref ->
(ref == "self") ? ownNodeId() : ref
}
def resolvedNodeFilter = nodeFilter
if (nodeFilter instanceof String) {
resolvedNodeFilter = resolve(nodeFilter)
}
else if (nodeFilter instanceof String[] || nodeFilter instanceof Collection) {
resolvedNodeFilter = nodeFilter.collect { String ref ->
resolve(ref)
}
}
resolvedNodeFilter
}
}