// toContainer takes an id mapping, and uses it to translate a
// host ID to the remapped ID. If no map is provided, then the translation
// assumes a 1-to-1 mapping and returns the passed in id
toContainer takes an id mapping, and uses it to translate a
host ID to the remapped ID. If no map is provided, then the translation
assumes a 1-to-1 mapping and returns the passed in id
// toContainer takes an id mapping and uses it to translate a // host ID to the remapped ID . If no map is provided then the translation // assumes a 1 - to - 1 mapping and returns the passed in id
func toContainer(hostID int, idMap []IDMap) (int, error) {
        if idMap == nil {
                return hostID, nil
        }
        for _, m := range idMap {
                if (hostID >= m.HostID) && (hostID <= (m.HostID + m.Size - 1)) {
                        contID := m.ContainerID + (hostID - m.HostID)
                        return contID, nil
                }
        }
        return -1, fmt.Errorf("Host ID %d cannot be mapped to a container ID", hostID)
}
func toContainer ( hostID int , idMap [ ] IDMap ) ( int , error ) { if idMap == nil { return hostID , nil } for _ , m := range idMap { if ( hostID >= m . HostID ) && ( hostID <= ( m . HostID + m . Size - 1 ) ) { contID := m . ContainerID + ( hostID - m . HostID ) return contID , nil } } return - 1 , fmt . Errorf ( " " , hostID ) }
toContainer takes an id mapping, and uses it to translate a
host ID to the remapped ID.
toContainer takes an id mapping and uses it to translate a host ID to the remapped ID .