Buddy Valastro put his drunk driving case to bed by making a surprise trip to the courthouse ... to plead guilty to driving while drunk.
As a result of the plea, the "Cake Boss" star's license will be suspended for three months, and he has to enter a drunk driving program. He also got a $300 fine.
Valastro says he told the judge he only had one drink before getting pulled over -- but added he'd learned his lesson ... "If you have even one drink you shouldn't drive."
He wasn't scheduled to be in court until February, but after today's hearing he tweeted he went in early because ... "I wanted to make this right."
As TMZ first reported, Valastro was arrested on November 13 after cops noticed the TLC star's 2014 yellow Corvette weaving on 10th Ave in Manhattan.