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

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

There is a newer version: 2024-09-15T19-40-00-groovy-4
Show 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