func (c *ClusterTx) ContainerNodeAddress(project string, name string) (string, error) {
	stmt := `
SELECT nodes.id, nodes.address
  FROM nodes
  JOIN containers ON containers.node_id = nodes.id
  JOIN projects ON projects.id = containers.project_id
 WHERE projects.name = ? AND containers.name = ?
`
	var address string
	var id int64
	rows, err := c.tx.Query(stmt, project, name)
	if err != nil {
		return "", err
	}
	defer rows.Close()

	if !rows.Next() {
		return "", ErrNoSuchObject
	}

	err = rows.Scan(&id, &address)
	if err != nil {
		return "", err
	}

	if rows.Next() {
		return "", fmt.Errorf("more than one node associated with container")
	}

	err = rows.Err()
	if err != nil {
		return "", err
	}

	if id == c.nodeID {
		return "", nil
	}

	return address, nil
}
func (c *ClusterTx) ContainerNodeAddress(project string, name string) (string, error) {
	stmt := `
SELECT nodes.id, nodes.address
  FROM nodes
  JOIN containers ON containers.node_id = nodes.id
  JOIN projects ON projects.id = containers.project_id
 WHERE projects.name = ? AND containers.name = ?
`
	var address string
	var id int64
	rows, err := c.tx.Query(stmt, project, name)
	if err != nil {
		return "", err
	}
	defer rows.Close()

	if !rows.Next() {
		return "", ErrNoSuchObject
	}

	err = rows.Scan(&id, &address)
	if err != nil {
		return "", err
	}

	if rows.Next() {
		return "", fmt.Errorf("more than one node associated with container")
	}

	err = rows.Err()
	if err != nil {
		return "", err
	}

	if id == c.nodeID {
		return "", nil
	}

	return address, nil
}
func ( c * ClusterTx ) ContainerNodeAddress ( project string , name string ) ( string , error ) { stmt := `
SELECT nodes.id, nodes.address
  FROM nodes
  JOIN containers ON containers.node_id = nodes.id
  JOIN projects ON projects.id = containers.project_id
 WHERE projects.name = ? AND containers.name = ?
` var address string var id int64 rows , err := c . tx . Query ( stmt , project , name ) if err != nil { return " " , err } defer rows . Close ( ) if ! rows . Next ( ) { return " " , ErrNoSuchObject } err = rows . Scan ( & id , & address ) if err != nil { return " " , err } if rows . Next ( ) { return " " , fmt . Errorf ( " " ) } err = rows . Err ( ) if err != nil { return " " , err } if id == c . nodeID { return " " , nil } return address , nil }
// ContainerNodeAddress returns the address of the node hosting the container
// with the given name in the given project.
//
// It returns the empty string if the container is hosted on this node.
ContainerNodeAddress returns the address of the node hosting the container with the given name in the given project . It returns the empty string if the container is hosted on this node .