Exemple #1
0
bool operator == (
    const ContainerInfo::DockerInfo& left,
    const ContainerInfo::DockerInfo& right)
{
    // Order of port mappings is not important.
    if (left.port_mappings().size() != right.port_mappings().size()) {
        return false;
    }

    for (int i = 0; i < left.port_mappings().size(); i++) {
        bool found = false;
        for (int j = 0; j < right.port_mappings().size(); j++) {
            if (left.port_mappings().Get(i) == right.port_mappings().Get(j)) {
                found = true;
                break;
            }
        }
        if (!found) {
            return false;
        }
    }

    // Order of parameters is not important.
    if (left.parameters().size() != right.parameters().size()) {
        return false;
    }

    for (int i = 0; i < left.parameters().size(); i++) {
        bool found = false;
        for (int j = 0; j < right.parameters().size(); j++) {
            if (left.parameters().Get(i) == right.parameters().Get(j)) {
                found = true;
                break;
            }
        }
        if (!found) {
            return false;
        }
    }

    return left.image() == right.image() &&
           left.network() == right.network() &&
           left.privileged() == right.privileged() &&
           left.force_pull_image() == right.force_pull_image();
}