All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.gesellix.docker.client.node.NodeUtil.groovy Maven / Gradle / Ivy

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
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy