Story highlights Peter Bergen says the sentence will not satisfy many in the military and it's been attacked by President Trump

But given the mitigating factors that the judge had to consider, his decision was right, Bergen says

Peter Bergen is CNN's national security analyst, a vice president at New America, a professor of practice at Arizona State University and chairman of the Global Special Operations Foundation. He is the author of "United States of Jihad: Investigating America's Homegrown Terrorists."

(CNN) The case of Bowe Bergdahl, who deserted his US military outpost in eastern Afghanistan in 2009 and was then captured by the Taliban, stirs strong emotions.

For many in the military, the fact that Bergdahl deserted and subsequently endangered the lives and the limbs of a number of soldiers who went hunting for him meant that he should have faced a lengthy prison sentence.

At Berghdahl's trial, prosecution witness Shannon Allen said her husband Mark was severely wounded on a mission to find Bergdahl and is today largely paralyzed and unable to care for himself.

The intensity of the anger directed at Bergdahl by some in the military is amplified by the fact that his freedom was gained by a 2014 prisoner swap for five mid- and high-level Taliban leaders who had been imprisoned at Guantanamo.

The prosecution in the case asked the judge, Army Col. Jeffery R. Nance, for 14 years of imprisonment. Nance opted for no prison time and a dishonorable discharge for Bergdahl.