The ruling, a victory for the Trump administration, allows the Pentagon to reallocate money for the president's border wall.