kubemodel_codecs.go 271 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // DO NOT MODIFY
  4. //
  5. // ┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻
  6. //
  7. //
  8. // This source file was automatically generated by bingen.
  9. //
  10. ////////////////////////////////////////////////////////////////////////////////
  11. package kubemodel
  12. import (
  13. "cmp"
  14. "fmt"
  15. "github.com/opencost/opencost/core/pkg/cloud"
  16. "io"
  17. "iter"
  18. "os"
  19. "reflect"
  20. "slices"
  21. "strings"
  22. "sync"
  23. "time"
  24. "unsafe"
  25. util "github.com/opencost/bingen/pkg/util"
  26. )
  27. const (
  28. // GeneratorPackageName is the package the generator is targetting
  29. GeneratorPackageName string = "kubemodel"
  30. StringHeaderSize = int64(unsafe.Sizeof(""))
  31. // BinaryTagStringTable is written and/or read prior to the existence of a string
  32. // table (where each index is encoded as a string entry in the resource
  33. BinaryTagStringTable string = "BGST"
  34. // DefaultCodecVersion is used for any resources listed in the Default version set
  35. DefaultCodecVersion uint8 = 3
  36. )
  37. //--------------------------------------------------------------------------
  38. // Configuration
  39. //--------------------------------------------------------------------------
  40. var (
  41. bingenConfigLock sync.RWMutex
  42. bingenConfig *BingenConfiguration = DefaultBingenConfiguration()
  43. )
  44. // BingenConfiguration is used to set any custom configuration in the way files are encoded
  45. // or decoded.
  46. type BingenConfiguration struct {
  47. // FileBackedStringTableEnabled enables the use of file-backed string tables for streaming
  48. // bingen decoding.
  49. FileBackedStringTableEnabled bool
  50. // FileBackedStringTableDir is the directory to write the string table files for reading.
  51. FileBackedStringTableDir string
  52. // FileBackedStringTableMemoMaxBytes limits in-memory memoization for file-backed table lookups.
  53. // 0 disables memoization.
  54. FileBackedStringTableMemoMaxBytes int64
  55. }
  56. // DefaultBingenConfiguration creates the default implementation of the bingen configuration
  57. // and returns it.
  58. func DefaultBingenConfiguration() *BingenConfiguration {
  59. return &BingenConfiguration{
  60. FileBackedStringTableEnabled: false,
  61. FileBackedStringTableDir: os.TempDir(),
  62. FileBackedStringTableMemoMaxBytes: 0,
  63. }
  64. }
  65. // ConfigureBingen accepts a new *BingenConfiguration instance which updates the internal decoder
  66. // and encoder behavior.
  67. func ConfigureBingen(config *BingenConfiguration) {
  68. bingenConfigLock.Lock()
  69. defer bingenConfigLock.Unlock()
  70. if config == nil {
  71. config = DefaultBingenConfiguration()
  72. }
  73. bingenConfig = config
  74. }
  75. // IsBingenFileBackedStringTableEnabled accessor for file backed string table configuration
  76. func IsBingenFileBackedStringTableEnabled() bool {
  77. bingenConfigLock.RLock()
  78. defer bingenConfigLock.RUnlock()
  79. return bingenConfig.FileBackedStringTableEnabled
  80. }
  81. // BingenFileBackedStringTableDir returns the directory configured for file backed string tables.
  82. func BingenFileBackedStringTableDir() string {
  83. bingenConfigLock.RLock()
  84. defer bingenConfigLock.RUnlock()
  85. return bingenConfig.FileBackedStringTableDir
  86. }
  87. // BingenFileBackedStringTableMemoMaxBytes returns the maximum bytes used for file-backed memo cache.
  88. func BingenFileBackedStringTableMemoMaxBytes() int64 {
  89. bingenConfigLock.RLock()
  90. defer bingenConfigLock.RUnlock()
  91. return bingenConfig.FileBackedStringTableMemoMaxBytes
  92. }
  93. //--------------------------------------------------------------------------
  94. // Type Map
  95. //--------------------------------------------------------------------------
  96. // Generated type map for resolving interface implementations to to concrete types
  97. var typeMap map[string]reflect.Type = map[string]reflect.Type{
  98. "Cluster": reflect.TypeFor[Cluster](),
  99. "Container": reflect.TypeFor[Container](),
  100. "CronJob": reflect.TypeFor[CronJob](),
  101. "DaemonSet": reflect.TypeFor[DaemonSet](),
  102. "Deployment": reflect.TypeFor[Deployment](),
  103. "Device": reflect.TypeFor[Device](),
  104. "DeviceUsage": reflect.TypeFor[DeviceUsage](),
  105. "Diagnostic": reflect.TypeFor[Diagnostic](),
  106. "FileSystem": reflect.TypeFor[FileSystem](),
  107. "Job": reflect.TypeFor[Job](),
  108. "KubeModelSet": reflect.TypeFor[KubeModelSet](),
  109. "Metadata": reflect.TypeFor[Metadata](),
  110. "Namespace": reflect.TypeFor[Namespace](),
  111. "NetworkTrafficDetail": reflect.TypeFor[NetworkTrafficDetail](),
  112. "Node": reflect.TypeFor[Node](),
  113. "Owner": reflect.TypeFor[Owner](),
  114. "PersistentVolume": reflect.TypeFor[PersistentVolume](),
  115. "PersistentVolumeClaim": reflect.TypeFor[PersistentVolumeClaim](),
  116. "Pod": reflect.TypeFor[Pod](),
  117. "PodPVCVolume": reflect.TypeFor[PodPVCVolume](),
  118. "ReplicaSet": reflect.TypeFor[ReplicaSet](),
  119. "ResourceQuantity": reflect.TypeFor[ResourceQuantity](),
  120. "ResourceQuota": reflect.TypeFor[ResourceQuota](),
  121. "ResourceQuotaSpec": reflect.TypeFor[ResourceQuotaSpec](),
  122. "ResourceQuotaSpecHard": reflect.TypeFor[ResourceQuotaSpecHard](),
  123. "ResourceQuotaStatus": reflect.TypeFor[ResourceQuotaStatus](),
  124. "ResourceQuotaStatusUsed": reflect.TypeFor[ResourceQuotaStatusUsed](),
  125. "Service": reflect.TypeFor[Service](),
  126. "StatefulSet": reflect.TypeFor[StatefulSet](),
  127. "Window": reflect.TypeFor[Window](),
  128. }
  129. //--------------------------------------------------------------------------
  130. // Type Helpers
  131. //--------------------------------------------------------------------------
  132. // isBinaryTag returns true when the first bytes in the provided binary matches the tag
  133. func isBinaryTag(data []byte, tag string) bool {
  134. if len(data) < len(tag) {
  135. return false
  136. }
  137. return string(data[:len(tag)]) == tag
  138. }
  139. // isReaderBinaryTag is used to peek the header for an io.Reader Buffer
  140. func isReaderBinaryTag(buff *util.Buffer, tag string) bool {
  141. data, err := buff.Peek(len(tag))
  142. if err != nil && err != io.EOF {
  143. panic(fmt.Sprintf("called Peek() on a non buffered reader: %s", err))
  144. }
  145. if len(data) < len(tag) {
  146. return false
  147. }
  148. return string(data[:len(tag)]) == tag
  149. }
  150. // typeToString determines the basic properties of the type, the qualifier, package path, and
  151. // type name, and returns the qualified type
  152. func typeToString(f interface{}) string {
  153. qual := ""
  154. t := reflect.TypeOf(f)
  155. if t.Kind() == reflect.Ptr {
  156. t = t.Elem()
  157. qual = "*"
  158. }
  159. return fmt.Sprintf("%s%s.%s", qual, t.PkgPath(), t.Name())
  160. }
  161. // resolveType uses the name of a type and returns the package, base type name, and whether
  162. // or not it's a pointer.
  163. func resolveType(t string) (pkg string, name string, isPtr bool) {
  164. isPtr = t[:1] == "*"
  165. if isPtr {
  166. t = t[1:]
  167. }
  168. slashIndex := strings.LastIndex(t, "/")
  169. if slashIndex >= 0 {
  170. t = t[slashIndex+1:]
  171. }
  172. parts := strings.Split(t, ".")
  173. if parts[0] == GeneratorPackageName {
  174. parts[0] = ""
  175. }
  176. pkg = parts[0]
  177. name = parts[1]
  178. return
  179. }
  180. //--------------------------------------------------------------------------
  181. // Stream Helpers
  182. //--------------------------------------------------------------------------
  183. // StreamFactoryFunc is an alias for a func that creates a BingenStream implementation.
  184. type StreamFactoryFunc func(io.Reader) BingenStream
  185. // Generated streamable factory map for finding the specific new stream methods
  186. // by T type
  187. var streamFactoryMap map[reflect.Type]StreamFactoryFunc = map[reflect.Type]StreamFactoryFunc{
  188. reflect.TypeFor[KubeModelSet](): NewKubeModelSetStream,
  189. }
  190. // NewStreamFor accepts an io.Reader, and returns a new BingenStream for the generic T
  191. // type provided _if_ it is a registered bingen type that is annotated as 'streamable'. See
  192. // the streamFactoryMap for generated type listings.
  193. func NewStreamFor[T any](reader io.Reader) (BingenStream, error) {
  194. typeKey := reflect.TypeFor[T]()
  195. factory, ok := streamFactoryMap[typeKey]
  196. if !ok {
  197. return nil, fmt.Errorf("the type: %s is not a registered bingen streamable type", typeKey.Name())
  198. }
  199. return factory(reader), nil
  200. }
  201. // BingenStream is the stream interface for all streamable types
  202. type BingenStream interface {
  203. // Stream returns the iterator which will stream each field of the target type and
  204. // return the field info as well as the value.
  205. Stream() iter.Seq2[BingenFieldInfo, *BingenValue]
  206. // Close will close any dynamic io.Reader used to stream in the fields
  207. Close()
  208. // Error returns an error if one occurred during the process of streaming the type's fields.
  209. // This can be checked after iterating through the Stream().
  210. Error() error
  211. }
  212. // BingenValue contains the value of a field as well as any index/key associated with that value.
  213. type BingenValue struct {
  214. Value any
  215. Index any
  216. }
  217. // IsNil is just a method accessor way to check to see if the value returned was nil
  218. func (bv *BingenValue) IsNil() bool {
  219. return bv == nil
  220. }
  221. // creates a single BingenValue instance without a key or index
  222. func singleV(value any) *BingenValue {
  223. return &BingenValue{
  224. Value: value,
  225. }
  226. }
  227. // creates a pair of key/index and value.
  228. func pairV(index any, value any) *BingenValue {
  229. return &BingenValue{
  230. Value: value,
  231. Index: index,
  232. }
  233. }
  234. // BingenFieldInfo contains the type of the field being streamed as well as the name of the field.
  235. type BingenFieldInfo struct {
  236. Type reflect.Type
  237. Name string
  238. }
  239. //--------------------------------------------------------------------------
  240. // String Table Writer
  241. //--------------------------------------------------------------------------
  242. // StringTableWriter is the interface used to write the string table for encoding.
  243. type StringTableWriter interface {
  244. // AddOrGet adds a string to the string table and returns the new index or
  245. // an existing index.
  246. AddOrGet(s string) int
  247. // WriteTo will write the StringTable data (with the header) to the provided
  248. // Buffer starting a the current write position
  249. WriteTo(b *util.Buffer)
  250. }
  251. // IndexedStringTableWriter maps strings to specific indices for encoding
  252. type IndexedStringTableWriter struct {
  253. indices map[string]int
  254. next int
  255. }
  256. // NewIndexedStringTableWriter Creates a new IndexedStringTableWriter instance.
  257. func NewIndexedStringTableWriter() *IndexedStringTableWriter {
  258. return &IndexedStringTableWriter{
  259. indices: make(map[string]int),
  260. next: 0,
  261. }
  262. }
  263. // AddOrGet retrieves a string entry's index if it exists. Otherwise, it adds the entry and returns the new index.
  264. func (st *IndexedStringTableWriter) AddOrGet(s string) int {
  265. if ind, ok := st.indices[s]; ok {
  266. return ind
  267. }
  268. current := st.next
  269. st.next++
  270. st.indices[s] = current
  271. return current
  272. }
  273. // ToSlice Converts the contents to a string array for encoding.
  274. func (st *IndexedStringTableWriter) ToSlice() []string {
  275. if st.next == 0 {
  276. return []string{}
  277. }
  278. sl := make([]string, st.next)
  279. for s, i := range st.indices {
  280. sl[i] = s
  281. }
  282. return sl
  283. }
  284. // ToBytes Converts the contents to a binary encoded representation
  285. func (st *IndexedStringTableWriter) ToBytes() []byte {
  286. buff := util.NewBuffer()
  287. st.WriteTo(buff)
  288. return buff.Bytes()
  289. }
  290. // WriteTo will write the StringTable data (with the header) to the provided
  291. // Buffer starting a the current write position
  292. func (st *IndexedStringTableWriter) WriteTo(buff *util.Buffer) {
  293. // bingen string table header
  294. buff.WriteBytes([]byte(BinaryTagStringTable))
  295. // get an ordered string slice to encode
  296. strs := st.ToSlice()
  297. buff.WriteInt(len(strs)) // table length
  298. for _, s := range strs {
  299. buff.WriteString(s)
  300. }
  301. }
  302. type indexed struct {
  303. s string
  304. count uint64
  305. index int
  306. }
  307. func newIndexed(s string, index int) *indexed {
  308. return &indexed{
  309. s: s,
  310. count: 1,
  311. index: index,
  312. }
  313. }
  314. // PrepassStringTableWriter maps strings to specific indices for encoding, sorted by the total
  315. // number of times they're accessed
  316. type PrepassStringTableWriter struct {
  317. prepass map[string]*indexed
  318. next int
  319. }
  320. // NewPrepassStringTableWriter creates a new PrepassStringTableWriter instance.
  321. func NewPrepassStringTableWriter() *PrepassStringTableWriter {
  322. return &PrepassStringTableWriter{
  323. prepass: make(map[string]*indexed),
  324. }
  325. }
  326. // AddOrGet retrieves a string entry's index if it exists. Otherwise, it adds the entry and returns the new index.
  327. func (st *PrepassStringTableWriter) AddOrGet(s string) int {
  328. if ind, ok := st.prepass[s]; ok {
  329. ind.count += 1
  330. return ind.index
  331. }
  332. current := st.next
  333. st.next++
  334. st.prepass[s] = newIndexed(s, current)
  335. return current
  336. }
  337. // WriteSortedTo sorts the string table by the number of accesses, writes the table in that
  338. // order, then returns a new StringTableWriter implementation that can be used for the new
  339. // sorted order index lookups.
  340. func (st *PrepassStringTableWriter) WriteSortedTo(buff *util.Buffer) StringTableWriter {
  341. sl := make([]*indexed, st.next)
  342. for _, ind := range st.prepass {
  343. sl[ind.index] = ind
  344. }
  345. slices.SortFunc(sl, func(a *indexed, b *indexed) int {
  346. return -cmp.Compare(a.count, b.count)
  347. })
  348. sti := NewIndexedStringTableWriter()
  349. for _, ind := range sl {
  350. sti.AddOrGet(ind.s)
  351. }
  352. sti.WriteTo(buff)
  353. return sti
  354. }
  355. // WriteTo will write the StringTable data (with the header) to the provided
  356. // Buffer starting a the current write position
  357. func (st *PrepassStringTableWriter) WriteTo(buff *util.Buffer) {
  358. panic("Prepass StringTableWriter cannot write directly")
  359. }
  360. //--------------------------------------------------------------------------
  361. // String Table Reader
  362. //--------------------------------------------------------------------------
  363. // StringTableReader is the interface used to read the string table from the decoding.
  364. type StringTableReader interface {
  365. // At returns the string entry at a specific index, or panics on out of bounds.
  366. At(index int) string
  367. // Len returns the total number of strings loaded in the string table.
  368. Len() int
  369. // Close will clear the loaded table, and drop any external resources used.
  370. Close() error
  371. }
  372. // SliceStringTableReader is a basic pre-loaded []string that provides index-based access.
  373. // The cost of this implementation is holding all strings in memory, which provides faster
  374. // lookup performance at the expense of memory usage.
  375. type SliceStringTableReader struct {
  376. table []string
  377. }
  378. // NewSliceStringTableReaderFrom creates a new SliceStringTableReader instance loading
  379. // data directly from the buffer. The buffer's position should start at the table length.
  380. func NewSliceStringTableReaderFrom(buffer *util.Buffer) StringTableReader {
  381. // table length
  382. tl := buffer.ReadInt()
  383. var table []string
  384. if tl > 0 {
  385. table = make([]string, tl)
  386. for i := range tl {
  387. table[i] = buffer.ReadString()
  388. }
  389. }
  390. return &SliceStringTableReader{
  391. table: table,
  392. }
  393. }
  394. // At returns the string entry at a specific index, or panics on out of bounds.
  395. func (sstr *SliceStringTableReader) At(index int) string {
  396. if index < 0 || index >= len(sstr.table) {
  397. panic(fmt.Errorf("%s: string table index out of bounds: %d", GeneratorPackageName, index))
  398. }
  399. return sstr.table[index]
  400. }
  401. // Len returns the total number of strings loaded in the string table.
  402. func (sstr *SliceStringTableReader) Len() int {
  403. if sstr == nil {
  404. return 0
  405. }
  406. return len(sstr.table)
  407. }
  408. // Close for the slice tables just nils out the slice and returns
  409. func (sstr *SliceStringTableReader) Close() error {
  410. sstr.table = nil
  411. return nil
  412. }
  413. // fileStringRef maps a bingen string-table index to a payload stored in a temp file.
  414. type fileStringRef struct {
  415. off int64
  416. length int
  417. }
  418. // FileStringTableReader leverages a local file to write string table data for lookup. On
  419. // memory focused systems, this allows a slower parse with a significant decrease in memory
  420. // usage. This implementation is often pair with streaming readers for high throughput with
  421. // reduced memory usage.
  422. type FileStringTableReader struct {
  423. f *os.File
  424. refs []fileStringRef
  425. memo []string
  426. }
  427. // NewFileStringTableFromBuffer reads exactly tl length-prefixed (uint16) string payloads from buffer
  428. // and appends each payload to a new temp file. It does not retain full strings in memory.
  429. func NewFileStringTableReaderFrom(buffer *util.Buffer, dir string, memoMaxBytes int64) StringTableReader {
  430. // helper func to cast a string in-place to a byte slice.
  431. // NOTE: Return value is READ-ONLY. DO NOT MODIFY!
  432. byteSliceFor := func(s string) []byte {
  433. return unsafe.Slice(unsafe.StringData(s), len(s))
  434. }
  435. err := os.MkdirAll(dir, 0755)
  436. if err != nil {
  437. panic(fmt.Errorf("%s: failed to create string table directory: %w", GeneratorPackageName, err))
  438. }
  439. f, err := os.CreateTemp(dir, fmt.Sprintf("%s-bgst-*", GeneratorPackageName))
  440. if err != nil {
  441. panic(fmt.Errorf("%s: failed to create string table file: %w", GeneratorPackageName, err))
  442. }
  443. var writeErr error
  444. defer func() {
  445. if writeErr != nil {
  446. _ = f.Close()
  447. }
  448. }()
  449. // table length
  450. tl := buffer.ReadInt()
  451. var refs []fileStringRef
  452. if tl > 0 {
  453. refs = make([]fileStringRef, tl)
  454. for i := range tl {
  455. payload := byteSliceFor(buffer.ReadString())
  456. var off int64
  457. if len(payload) > 0 {
  458. off, err = f.Seek(0, io.SeekEnd)
  459. if err != nil {
  460. writeErr = fmt.Errorf("%s: failed to seek string table file: %w", GeneratorPackageName, err)
  461. panic(writeErr)
  462. }
  463. if _, err := f.Write(payload); err != nil {
  464. writeErr = fmt.Errorf("%s: failed to write string table entry %d: %w", GeneratorPackageName, i, err)
  465. panic(writeErr)
  466. }
  467. }
  468. refs[i] = fileStringRef{
  469. off: off,
  470. length: len(payload),
  471. }
  472. }
  473. }
  474. var memo []string
  475. // Pre-load cache with strings up to memoMaxBytes, respecting string boundaries
  476. if memoMaxBytes > 0 && len(refs) > 0 {
  477. memo = make([]string, len(refs))
  478. var cumulativeSize int64
  479. for i, ref := range refs {
  480. // Check if adding this string would exceed the limit
  481. if cumulativeSize+int64(ref.length)+StringHeaderSize > memoMaxBytes {
  482. // Would exceed limit, stop here
  483. break
  484. }
  485. // Read string from file and cache it
  486. if ref.length > 0 {
  487. b := make([]byte, ref.length)
  488. _, err := f.ReadAt(b, ref.off)
  489. if err != nil {
  490. // If we can't read, skip this entry but continue
  491. continue
  492. }
  493. // Cast the allocated bytes to a string in-place
  494. str := unsafe.String(unsafe.SliceData(b), len(b))
  495. memo[i] = str
  496. cumulativeSize += int64(ref.length) + StringHeaderSize
  497. }
  498. }
  499. }
  500. return &FileStringTableReader{
  501. f: f,
  502. refs: refs,
  503. memo: memo,
  504. }
  505. }
  506. // At returns the string from the internal file using the reference's offset and length.
  507. func (fstr *FileStringTableReader) At(index int) string {
  508. if fstr == nil || fstr.f == nil {
  509. panic(fmt.Errorf("%s: failed to read file string table data", GeneratorPackageName))
  510. }
  511. if index < 0 || index >= len(fstr.refs) {
  512. panic(fmt.Errorf("%s: string table index out of bounds: %d", GeneratorPackageName, index))
  513. }
  514. ref := fstr.refs[index]
  515. if ref.length == 0 {
  516. return ""
  517. }
  518. // Check cache first
  519. if fstr.memo != nil && len(fstr.memo) > index && fstr.memo[index] != "" {
  520. return fstr.memo[index]
  521. }
  522. // Cache miss - read from file
  523. b := make([]byte, ref.length)
  524. _, err := fstr.f.ReadAt(b, ref.off)
  525. if err != nil {
  526. return ""
  527. }
  528. // Cast the allocated bytes to a string in-place, as we were the ones that allocated the bytes
  529. return unsafe.String(unsafe.SliceData(b), len(b))
  530. }
  531. // Len returns the total number of strings loaded in the string table.
  532. func (fstr *FileStringTableReader) Len() int {
  533. if fstr == nil {
  534. return 0
  535. }
  536. return len(fstr.refs)
  537. }
  538. // Close for the file string table reader closes the file and deletes it.
  539. func (fstr *FileStringTableReader) Close() error {
  540. if fstr == nil || fstr.f == nil {
  541. return nil
  542. }
  543. path := fstr.f.Name()
  544. err := fstr.f.Close()
  545. fstr.f = nil
  546. fstr.refs = nil
  547. fstr.memo = nil
  548. if path != "" {
  549. _ = os.Remove(path)
  550. }
  551. return err
  552. }
  553. //--------------------------------------------------------------------------
  554. // Codec Context
  555. //--------------------------------------------------------------------------
  556. // EncodingContext is a context object passed to the encoders to ensure reuse of buffer
  557. // and table data
  558. type EncodingContext struct {
  559. Buffer *util.Buffer
  560. Table StringTableWriter
  561. }
  562. // NewEncodingContext creates a new EncodingContext instance that will create a new []byte buffer
  563. // for writing, and return the context
  564. func NewEncodingContext(tableWriter StringTableWriter) *EncodingContext {
  565. return &EncodingContext{
  566. Buffer: util.NewBuffer(),
  567. Table: tableWriter,
  568. }
  569. }
  570. // NewEncodingContextFromWriter creates a new EncodingContext instance that will create a new Buffer
  571. // from the provided io.Writer and StringTableWriter.
  572. func NewEncodingContextFromWriter(writer io.Writer, tableWriter StringTableWriter) *EncodingContext {
  573. return &EncodingContext{
  574. Buffer: util.NewBufferFromWriter(writer),
  575. Table: tableWriter,
  576. }
  577. }
  578. // NewEncodingContextFromBuffer creates a new EncodingContext instance that will leverage an existing
  579. // Buffer and StringTableWriter.
  580. func NewEncodingContextFromBuffer(buffer *util.Buffer, tableWriter StringTableWriter) *EncodingContext {
  581. return &EncodingContext{
  582. Buffer: buffer,
  583. Table: tableWriter,
  584. }
  585. }
  586. // ToBytes returns the encoded string table bytes (if applicable) combined with the encoded buffer bytes. If
  587. // a string table is being used, the string table bytes will be written first to ensure correct ordering for
  588. // decoding.
  589. func (ec *EncodingContext) ToBytes() []byte {
  590. encBytes := ec.Buffer.Bytes()
  591. if ec.Table != nil {
  592. buff := util.NewBuffer()
  593. ec.Table.WriteTo(buff)
  594. buff.WriteBytes(encBytes)
  595. return buff.Bytes()
  596. }
  597. return encBytes
  598. }
  599. // IsStringTable returns true if the table is available
  600. func (ec *EncodingContext) IsStringTable() bool {
  601. return ec.Table != nil
  602. }
  603. // DecodingContext is a context object passed to the decoders to ensure parent objects
  604. // reuse as much data as possible
  605. type DecodingContext struct {
  606. Buffer *util.Buffer
  607. Table StringTableReader
  608. }
  609. // NewDecodingContextFromBytes creates a new DecodingContext instance using an byte slice
  610. func NewDecodingContextFromBytes(data []byte) *DecodingContext {
  611. var table StringTableReader
  612. buff := util.NewBufferFromBytes(data)
  613. // string table header validation
  614. if isBinaryTag(data, BinaryTagStringTable) {
  615. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  616. // always use a slice string table with a byte array since the
  617. // data is already in memory
  618. table = NewSliceStringTableReaderFrom(buff)
  619. }
  620. return &DecodingContext{
  621. Buffer: buff,
  622. Table: table,
  623. }
  624. }
  625. // NewDecodingContextFromReader creates a new DecodingContext instance using an io.Reader
  626. // implementation
  627. func NewDecodingContextFromReader(reader io.Reader) *DecodingContext {
  628. var table StringTableReader
  629. buff := util.NewBufferFromReader(reader)
  630. if isReaderBinaryTag(buff, BinaryTagStringTable) {
  631. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  632. // create correct string table implementation
  633. if IsBingenFileBackedStringTableEnabled() {
  634. table = NewFileStringTableReaderFrom(buff, BingenFileBackedStringTableDir(), BingenFileBackedStringTableMemoMaxBytes())
  635. } else {
  636. table = NewSliceStringTableReaderFrom(buff)
  637. }
  638. }
  639. return &DecodingContext{
  640. Buffer: buff,
  641. Table: table,
  642. }
  643. }
  644. // IsStringTable returns true if the table is available
  645. func (dc *DecodingContext) IsStringTable() bool {
  646. return dc.Table != nil && dc.Table.Len() > 0
  647. }
  648. // Close will ensure that any string table resources and buffer resources are
  649. // cleaned up.
  650. func (dc *DecodingContext) Close() {
  651. if dc.Table != nil {
  652. _ = dc.Table.Close()
  653. dc.Table = nil
  654. }
  655. }
  656. //--------------------------------------------------------------------------
  657. // Binary Codec
  658. //--------------------------------------------------------------------------
  659. // BinEncoder is an encoding interface which defines a context based marshal contract.
  660. type BinEncoder interface {
  661. MarshalBinaryWithContext(*EncodingContext) error
  662. }
  663. // BinDecoder is a decoding interface which defines a context based unmarshal contract.
  664. type BinDecoder interface {
  665. UnmarshalBinaryWithContext(*DecodingContext) error
  666. }
  667. //--------------------------------------------------------------------------
  668. // Cluster
  669. //--------------------------------------------------------------------------
  670. // MarshalBinary serializes the internal properties of this Cluster instance
  671. // into a byte array
  672. func (target *Cluster) MarshalBinary() (data []byte, err error) {
  673. ctx := NewEncodingContext(nil)
  674. e := target.MarshalBinaryWithContext(ctx)
  675. if e != nil {
  676. return nil, e
  677. }
  678. return ctx.ToBytes(), nil
  679. }
  680. // MarshalBinary serializes the internal properties of this Cluster instance
  681. // into an io.Writer.
  682. func (target *Cluster) MarshalBinaryTo(writer io.Writer) error {
  683. buff := util.NewBufferFromWriter(writer)
  684. defer buff.Flush()
  685. ctx := NewEncodingContextFromBuffer(buff, nil)
  686. return target.MarshalBinaryWithContext(ctx)
  687. }
  688. // MarshalBinaryWithContext serializes the internal properties of this Cluster instance
  689. // into a byte array leveraging a predefined context.
  690. func (target *Cluster) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  691. // panics are recovered and propagated as errors
  692. defer func() {
  693. if r := recover(); r != nil {
  694. if e, ok := r.(error); ok {
  695. err = e
  696. } else if s, ok := r.(string); ok {
  697. err = fmt.Errorf("unexpected panic: %s", s)
  698. } else {
  699. err = fmt.Errorf("unexpected panic: %+v", r)
  700. }
  701. }
  702. }()
  703. buff := ctx.Buffer
  704. buff.WriteUInt8(DefaultCodecVersion) // version
  705. if ctx.IsStringTable() {
  706. a := ctx.Table.AddOrGet(target.UID)
  707. buff.WriteInt(a) // write table index
  708. } else {
  709. buff.WriteString(target.UID) // write string
  710. }
  711. // --- [begin][write][alias](cloud.Provider) ---
  712. if ctx.IsStringTable() {
  713. b := ctx.Table.AddOrGet(string(target.Provider))
  714. buff.WriteInt(b) // write table index
  715. } else {
  716. buff.WriteString(string(target.Provider)) // write string
  717. }
  718. // --- [end][write][alias](cloud.Provider) ---
  719. if ctx.IsStringTable() {
  720. c := ctx.Table.AddOrGet(target.Account)
  721. buff.WriteInt(c) // write table index
  722. } else {
  723. buff.WriteString(target.Account) // write string
  724. }
  725. if ctx.IsStringTable() {
  726. d := ctx.Table.AddOrGet(target.Name)
  727. buff.WriteInt(d) // write table index
  728. } else {
  729. buff.WriteString(target.Name) // write string
  730. }
  731. if ctx.IsStringTable() {
  732. e := ctx.Table.AddOrGet(target.Region)
  733. buff.WriteInt(e) // write table index
  734. } else {
  735. buff.WriteString(target.Region) // write string
  736. }
  737. // --- [begin][write][reference](time.Time) ---
  738. f, errA := target.Start.MarshalBinary()
  739. if errA != nil {
  740. return errA
  741. }
  742. buff.WriteInt(len(f))
  743. buff.WriteBytes(f)
  744. // --- [end][write][reference](time.Time) ---
  745. // --- [begin][write][reference](time.Time) ---
  746. g, errB := target.End.MarshalBinary()
  747. if errB != nil {
  748. return errB
  749. }
  750. buff.WriteInt(len(g))
  751. buff.WriteBytes(g)
  752. // --- [end][write][reference](time.Time) ---
  753. return nil
  754. }
  755. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  756. // the Cluster type
  757. func (target *Cluster) UnmarshalBinary(data []byte) error {
  758. ctx := NewDecodingContextFromBytes(data)
  759. defer ctx.Close()
  760. err := target.UnmarshalBinaryWithContext(ctx)
  761. if err != nil {
  762. return err
  763. }
  764. return nil
  765. }
  766. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  767. // the Cluster type
  768. func (target *Cluster) UnmarshalBinaryFromReader(reader io.Reader) error {
  769. ctx := NewDecodingContextFromReader(reader)
  770. defer ctx.Close()
  771. err := target.UnmarshalBinaryWithContext(ctx)
  772. if err != nil {
  773. return err
  774. }
  775. return nil
  776. }
  777. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  778. // the Cluster type
  779. func (target *Cluster) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  780. // panics are recovered and propagated as errors
  781. defer func() {
  782. if r := recover(); r != nil {
  783. if e, ok := r.(error); ok {
  784. err = e
  785. } else if s, ok := r.(string); ok {
  786. err = fmt.Errorf("unexpected panic: %s", s)
  787. } else {
  788. err = fmt.Errorf("unexpected panic: %+v", r)
  789. }
  790. }
  791. }()
  792. buff := ctx.Buffer
  793. version := buff.ReadUInt8()
  794. if version > DefaultCodecVersion {
  795. return fmt.Errorf("Invalid Version Unmarshalling Cluster. Expected %d or less, got %d", DefaultCodecVersion, version)
  796. }
  797. // field version check
  798. if uint8(1) <= version {
  799. var b string
  800. if ctx.IsStringTable() {
  801. c := buff.ReadInt() // read string index
  802. b = ctx.Table.At(c)
  803. } else {
  804. b = buff.ReadString() // read string
  805. }
  806. a := b
  807. target.UID = a
  808. } else {
  809. target.UID = "" // default
  810. }
  811. // field version check
  812. if uint8(1) <= version {
  813. // --- [begin][read][alias](cloud.Provider) ---
  814. var d string
  815. var f string
  816. if ctx.IsStringTable() {
  817. g := buff.ReadInt() // read string index
  818. f = ctx.Table.At(g)
  819. } else {
  820. f = buff.ReadString() // read string
  821. }
  822. e := f
  823. d = e
  824. target.Provider = cloud.Provider(d)
  825. // --- [end][read][alias](cloud.Provider) ---
  826. } else {
  827. }
  828. // field version check
  829. if uint8(1) <= version {
  830. var l string
  831. if ctx.IsStringTable() {
  832. m := buff.ReadInt() // read string index
  833. l = ctx.Table.At(m)
  834. } else {
  835. l = buff.ReadString() // read string
  836. }
  837. h := l
  838. target.Account = h
  839. } else {
  840. target.Account = "" // default
  841. }
  842. // field version check
  843. if uint8(1) <= version {
  844. var o string
  845. if ctx.IsStringTable() {
  846. p := buff.ReadInt() // read string index
  847. o = ctx.Table.At(p)
  848. } else {
  849. o = buff.ReadString() // read string
  850. }
  851. n := o
  852. target.Name = n
  853. } else {
  854. target.Name = "" // default
  855. }
  856. // field version check
  857. if uint8(2) <= version {
  858. var r string
  859. if ctx.IsStringTable() {
  860. s := buff.ReadInt() // read string index
  861. r = ctx.Table.At(s)
  862. } else {
  863. r = buff.ReadString() // read string
  864. }
  865. q := r
  866. target.Region = q
  867. } else {
  868. target.Region = "" // default
  869. }
  870. // field version check
  871. if uint8(1) <= version {
  872. // --- [begin][read][reference](time.Time) ---
  873. t := new(time.Time)
  874. u := buff.ReadInt() // byte array length
  875. w := buff.ReadBytes(u)
  876. errA := t.UnmarshalBinary(w)
  877. if errA != nil {
  878. return errA
  879. }
  880. target.Start = *t
  881. // --- [end][read][reference](time.Time) ---
  882. } else {
  883. }
  884. // field version check
  885. if uint8(1) <= version {
  886. // --- [begin][read][reference](time.Time) ---
  887. x := new(time.Time)
  888. y := buff.ReadInt() // byte array length
  889. aa := buff.ReadBytes(y)
  890. errB := x.UnmarshalBinary(aa)
  891. if errB != nil {
  892. return errB
  893. }
  894. target.End = *x
  895. // --- [end][read][reference](time.Time) ---
  896. } else {
  897. }
  898. return nil
  899. }
  900. //--------------------------------------------------------------------------
  901. // Container
  902. //--------------------------------------------------------------------------
  903. // MarshalBinary serializes the internal properties of this Container instance
  904. // into a byte array
  905. func (target *Container) MarshalBinary() (data []byte, err error) {
  906. ctx := NewEncodingContext(nil)
  907. e := target.MarshalBinaryWithContext(ctx)
  908. if e != nil {
  909. return nil, e
  910. }
  911. return ctx.ToBytes(), nil
  912. }
  913. // MarshalBinary serializes the internal properties of this Container instance
  914. // into an io.Writer.
  915. func (target *Container) MarshalBinaryTo(writer io.Writer) error {
  916. buff := util.NewBufferFromWriter(writer)
  917. defer buff.Flush()
  918. ctx := NewEncodingContextFromBuffer(buff, nil)
  919. return target.MarshalBinaryWithContext(ctx)
  920. }
  921. // MarshalBinaryWithContext serializes the internal properties of this Container instance
  922. // into a byte array leveraging a predefined context.
  923. func (target *Container) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  924. // panics are recovered and propagated as errors
  925. defer func() {
  926. if r := recover(); r != nil {
  927. if e, ok := r.(error); ok {
  928. err = e
  929. } else if s, ok := r.(string); ok {
  930. err = fmt.Errorf("unexpected panic: %s", s)
  931. } else {
  932. err = fmt.Errorf("unexpected panic: %+v", r)
  933. }
  934. }
  935. }()
  936. buff := ctx.Buffer
  937. buff.WriteUInt8(DefaultCodecVersion) // version
  938. if ctx.IsStringTable() {
  939. a := ctx.Table.AddOrGet(target.PodUID)
  940. buff.WriteInt(a) // write table index
  941. } else {
  942. buff.WriteString(target.PodUID) // write string
  943. }
  944. if ctx.IsStringTable() {
  945. b := ctx.Table.AddOrGet(target.Name)
  946. buff.WriteInt(b) // write table index
  947. } else {
  948. buff.WriteString(target.Name) // write string
  949. }
  950. // --- [begin][write][alias](ResourceQuantities) ---
  951. if map[Resource]ResourceQuantity(target.ResourceRequests) == nil {
  952. buff.WriteUInt8(uint8(0)) // write nil byte
  953. } else {
  954. buff.WriteUInt8(uint8(1)) // write non-nil byte
  955. // --- [begin][write][map](map[Resource]ResourceQuantity) ---
  956. buff.WriteInt(len(map[Resource]ResourceQuantity(target.ResourceRequests))) // map length
  957. for v, z := range map[Resource]ResourceQuantity(target.ResourceRequests) {
  958. // --- [begin][write][alias](Resource) ---
  959. if ctx.IsStringTable() {
  960. c := ctx.Table.AddOrGet(string(v))
  961. buff.WriteInt(c) // write table index
  962. } else {
  963. buff.WriteString(string(v)) // write string
  964. }
  965. // --- [end][write][alias](Resource) ---
  966. // --- [begin][write][struct](ResourceQuantity) ---
  967. buff.WriteInt(0) // [compatibility, unused]
  968. errA := z.MarshalBinaryWithContext(ctx)
  969. if errA != nil {
  970. return errA
  971. }
  972. // --- [end][write][struct](ResourceQuantity) ---
  973. }
  974. // --- [end][write][map](map[Resource]ResourceQuantity) ---
  975. }
  976. // --- [end][write][alias](ResourceQuantities) ---
  977. // --- [begin][write][alias](ResourceQuantities) ---
  978. if map[Resource]ResourceQuantity(target.ResourceLimits) == nil {
  979. buff.WriteUInt8(uint8(0)) // write nil byte
  980. } else {
  981. buff.WriteUInt8(uint8(1)) // write non-nil byte
  982. // --- [begin][write][map](map[Resource]ResourceQuantity) ---
  983. buff.WriteInt(len(map[Resource]ResourceQuantity(target.ResourceLimits))) // map length
  984. for vv, zz := range map[Resource]ResourceQuantity(target.ResourceLimits) {
  985. // --- [begin][write][alias](Resource) ---
  986. if ctx.IsStringTable() {
  987. d := ctx.Table.AddOrGet(string(vv))
  988. buff.WriteInt(d) // write table index
  989. } else {
  990. buff.WriteString(string(vv)) // write string
  991. }
  992. // --- [end][write][alias](Resource) ---
  993. // --- [begin][write][struct](ResourceQuantity) ---
  994. buff.WriteInt(0) // [compatibility, unused]
  995. errB := zz.MarshalBinaryWithContext(ctx)
  996. if errB != nil {
  997. return errB
  998. }
  999. // --- [end][write][struct](ResourceQuantity) ---
  1000. }
  1001. // --- [end][write][map](map[Resource]ResourceQuantity) ---
  1002. }
  1003. // --- [end][write][alias](ResourceQuantities) ---
  1004. buff.WriteFloat64(target.CPUCoreAllocationAvg) // write float64
  1005. buff.WriteFloat64(target.CPUCoreUsageAvg) // write float64
  1006. buff.WriteFloat64(target.CPUCoreUsageMax) // write float64
  1007. buff.WriteFloat64(target.RAMBytesAllocationAvg) // write float64
  1008. buff.WriteFloat64(target.RAMBytesUsageAvg) // write float64
  1009. buff.WriteFloat64(target.RAMBytesUsageMax) // write float64
  1010. if target.DeviceUsages == nil {
  1011. buff.WriteUInt8(uint8(0)) // write nil byte
  1012. } else {
  1013. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1014. // --- [begin][write][map](map[string]DeviceUsage) ---
  1015. buff.WriteInt(len(target.DeviceUsages)) // map length
  1016. for vvv, zzz := range target.DeviceUsages {
  1017. if ctx.IsStringTable() {
  1018. e := ctx.Table.AddOrGet(vvv)
  1019. buff.WriteInt(e) // write table index
  1020. } else {
  1021. buff.WriteString(vvv) // write string
  1022. }
  1023. // --- [begin][write][struct](DeviceUsage) ---
  1024. buff.WriteInt(0) // [compatibility, unused]
  1025. errC := zzz.MarshalBinaryWithContext(ctx)
  1026. if errC != nil {
  1027. return errC
  1028. }
  1029. // --- [end][write][struct](DeviceUsage) ---
  1030. }
  1031. // --- [end][write][map](map[string]DeviceUsage) ---
  1032. }
  1033. // --- [begin][write][reference](time.Time) ---
  1034. f, errD := target.Start.MarshalBinary()
  1035. if errD != nil {
  1036. return errD
  1037. }
  1038. buff.WriteInt(len(f))
  1039. buff.WriteBytes(f)
  1040. // --- [end][write][reference](time.Time) ---
  1041. // --- [begin][write][reference](time.Time) ---
  1042. g, errE := target.End.MarshalBinary()
  1043. if errE != nil {
  1044. return errE
  1045. }
  1046. buff.WriteInt(len(g))
  1047. buff.WriteBytes(g)
  1048. // --- [end][write][reference](time.Time) ---
  1049. return nil
  1050. }
  1051. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1052. // the Container type
  1053. func (target *Container) UnmarshalBinary(data []byte) error {
  1054. ctx := NewDecodingContextFromBytes(data)
  1055. defer ctx.Close()
  1056. err := target.UnmarshalBinaryWithContext(ctx)
  1057. if err != nil {
  1058. return err
  1059. }
  1060. return nil
  1061. }
  1062. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  1063. // the Container type
  1064. func (target *Container) UnmarshalBinaryFromReader(reader io.Reader) error {
  1065. ctx := NewDecodingContextFromReader(reader)
  1066. defer ctx.Close()
  1067. err := target.UnmarshalBinaryWithContext(ctx)
  1068. if err != nil {
  1069. return err
  1070. }
  1071. return nil
  1072. }
  1073. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  1074. // the Container type
  1075. func (target *Container) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  1076. // panics are recovered and propagated as errors
  1077. defer func() {
  1078. if r := recover(); r != nil {
  1079. if e, ok := r.(error); ok {
  1080. err = e
  1081. } else if s, ok := r.(string); ok {
  1082. err = fmt.Errorf("unexpected panic: %s", s)
  1083. } else {
  1084. err = fmt.Errorf("unexpected panic: %+v", r)
  1085. }
  1086. }
  1087. }()
  1088. buff := ctx.Buffer
  1089. version := buff.ReadUInt8()
  1090. if version > DefaultCodecVersion {
  1091. return fmt.Errorf("Invalid Version Unmarshalling Container. Expected %d or less, got %d", DefaultCodecVersion, version)
  1092. }
  1093. var b string
  1094. if ctx.IsStringTable() {
  1095. c := buff.ReadInt() // read string index
  1096. b = ctx.Table.At(c)
  1097. } else {
  1098. b = buff.ReadString() // read string
  1099. }
  1100. a := b
  1101. target.PodUID = a
  1102. var e string
  1103. if ctx.IsStringTable() {
  1104. f := buff.ReadInt() // read string index
  1105. e = ctx.Table.At(f)
  1106. } else {
  1107. e = buff.ReadString() // read string
  1108. }
  1109. d := e
  1110. target.Name = d
  1111. // --- [begin][read][alias](ResourceQuantities) ---
  1112. var g map[Resource]ResourceQuantity
  1113. if buff.ReadUInt8() == uint8(0) {
  1114. g = nil
  1115. } else {
  1116. // --- [begin][read][map](map[Resource]ResourceQuantity) ---
  1117. l := buff.ReadInt() // map len
  1118. h := make(map[Resource]ResourceQuantity, l)
  1119. for range l {
  1120. // --- [begin][read][alias](Resource) ---
  1121. var m string
  1122. var o string
  1123. if ctx.IsStringTable() {
  1124. p := buff.ReadInt() // read string index
  1125. o = ctx.Table.At(p)
  1126. } else {
  1127. o = buff.ReadString() // read string
  1128. }
  1129. n := o
  1130. m = n
  1131. v := Resource(m)
  1132. // --- [end][read][alias](Resource) ---
  1133. // --- [begin][read][struct](ResourceQuantity) ---
  1134. q := new(ResourceQuantity)
  1135. buff.ReadInt() // [compatibility, unused]
  1136. errA := q.UnmarshalBinaryWithContext(ctx)
  1137. if errA != nil {
  1138. return errA
  1139. }
  1140. z := *q
  1141. // --- [end][read][struct](ResourceQuantity) ---
  1142. h[v] = z
  1143. }
  1144. g = h
  1145. // --- [end][read][map](map[Resource]ResourceQuantity) ---
  1146. }
  1147. target.ResourceRequests = ResourceQuantities(g)
  1148. // --- [end][read][alias](ResourceQuantities) ---
  1149. // --- [begin][read][alias](ResourceQuantities) ---
  1150. var r map[Resource]ResourceQuantity
  1151. if buff.ReadUInt8() == uint8(0) {
  1152. r = nil
  1153. } else {
  1154. // --- [begin][read][map](map[Resource]ResourceQuantity) ---
  1155. t := buff.ReadInt() // map len
  1156. s := make(map[Resource]ResourceQuantity, t)
  1157. for range t {
  1158. // --- [begin][read][alias](Resource) ---
  1159. var u string
  1160. var x string
  1161. if ctx.IsStringTable() {
  1162. y := buff.ReadInt() // read string index
  1163. x = ctx.Table.At(y)
  1164. } else {
  1165. x = buff.ReadString() // read string
  1166. }
  1167. w := x
  1168. u = w
  1169. vv := Resource(u)
  1170. // --- [end][read][alias](Resource) ---
  1171. // --- [begin][read][struct](ResourceQuantity) ---
  1172. aa := new(ResourceQuantity)
  1173. buff.ReadInt() // [compatibility, unused]
  1174. errB := aa.UnmarshalBinaryWithContext(ctx)
  1175. if errB != nil {
  1176. return errB
  1177. }
  1178. zz := *aa
  1179. // --- [end][read][struct](ResourceQuantity) ---
  1180. s[vv] = zz
  1181. }
  1182. r = s
  1183. // --- [end][read][map](map[Resource]ResourceQuantity) ---
  1184. }
  1185. target.ResourceLimits = ResourceQuantities(r)
  1186. // --- [end][read][alias](ResourceQuantities) ---
  1187. bb := buff.ReadFloat64() // read float64
  1188. target.CPUCoreAllocationAvg = bb
  1189. cc := buff.ReadFloat64() // read float64
  1190. target.CPUCoreUsageAvg = cc
  1191. dd := buff.ReadFloat64() // read float64
  1192. target.CPUCoreUsageMax = dd
  1193. ee := buff.ReadFloat64() // read float64
  1194. target.RAMBytesAllocationAvg = ee
  1195. ff := buff.ReadFloat64() // read float64
  1196. target.RAMBytesUsageAvg = ff
  1197. gg := buff.ReadFloat64() // read float64
  1198. target.RAMBytesUsageMax = gg
  1199. // field version check
  1200. if uint8(3) <= version {
  1201. if buff.ReadUInt8() == uint8(0) {
  1202. target.DeviceUsages = nil
  1203. } else {
  1204. // --- [begin][read][map](map[string]DeviceUsage) ---
  1205. ll := buff.ReadInt() // map len
  1206. hh := make(map[string]DeviceUsage, ll)
  1207. for range ll {
  1208. var vvv string
  1209. var nn string
  1210. if ctx.IsStringTable() {
  1211. oo := buff.ReadInt() // read string index
  1212. nn = ctx.Table.At(oo)
  1213. } else {
  1214. nn = buff.ReadString() // read string
  1215. }
  1216. mm := nn
  1217. vvv = mm
  1218. // --- [begin][read][struct](DeviceUsage) ---
  1219. pp := new(DeviceUsage)
  1220. buff.ReadInt() // [compatibility, unused]
  1221. errC := pp.UnmarshalBinaryWithContext(ctx)
  1222. if errC != nil {
  1223. return errC
  1224. }
  1225. zzz := *pp
  1226. // --- [end][read][struct](DeviceUsage) ---
  1227. hh[vvv] = zzz
  1228. }
  1229. target.DeviceUsages = hh
  1230. // --- [end][read][map](map[string]DeviceUsage) ---
  1231. }
  1232. } else {
  1233. target.DeviceUsages = nil
  1234. }
  1235. // --- [begin][read][reference](time.Time) ---
  1236. qq := new(time.Time)
  1237. rr := buff.ReadInt() // byte array length
  1238. ss := buff.ReadBytes(rr)
  1239. errD := qq.UnmarshalBinary(ss)
  1240. if errD != nil {
  1241. return errD
  1242. }
  1243. target.Start = *qq
  1244. // --- [end][read][reference](time.Time) ---
  1245. // --- [begin][read][reference](time.Time) ---
  1246. tt := new(time.Time)
  1247. uu := buff.ReadInt() // byte array length
  1248. ww := buff.ReadBytes(uu)
  1249. errE := tt.UnmarshalBinary(ww)
  1250. if errE != nil {
  1251. return errE
  1252. }
  1253. target.End = *tt
  1254. // --- [end][read][reference](time.Time) ---
  1255. return nil
  1256. }
  1257. //--------------------------------------------------------------------------
  1258. // CronJob
  1259. //--------------------------------------------------------------------------
  1260. // MarshalBinary serializes the internal properties of this CronJob instance
  1261. // into a byte array
  1262. func (target *CronJob) MarshalBinary() (data []byte, err error) {
  1263. ctx := NewEncodingContext(nil)
  1264. e := target.MarshalBinaryWithContext(ctx)
  1265. if e != nil {
  1266. return nil, e
  1267. }
  1268. return ctx.ToBytes(), nil
  1269. }
  1270. // MarshalBinary serializes the internal properties of this CronJob instance
  1271. // into an io.Writer.
  1272. func (target *CronJob) MarshalBinaryTo(writer io.Writer) error {
  1273. buff := util.NewBufferFromWriter(writer)
  1274. defer buff.Flush()
  1275. ctx := NewEncodingContextFromBuffer(buff, nil)
  1276. return target.MarshalBinaryWithContext(ctx)
  1277. }
  1278. // MarshalBinaryWithContext serializes the internal properties of this CronJob instance
  1279. // into a byte array leveraging a predefined context.
  1280. func (target *CronJob) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  1281. // panics are recovered and propagated as errors
  1282. defer func() {
  1283. if r := recover(); r != nil {
  1284. if e, ok := r.(error); ok {
  1285. err = e
  1286. } else if s, ok := r.(string); ok {
  1287. err = fmt.Errorf("unexpected panic: %s", s)
  1288. } else {
  1289. err = fmt.Errorf("unexpected panic: %+v", r)
  1290. }
  1291. }
  1292. }()
  1293. buff := ctx.Buffer
  1294. buff.WriteUInt8(DefaultCodecVersion) // version
  1295. if ctx.IsStringTable() {
  1296. a := ctx.Table.AddOrGet(target.UID)
  1297. buff.WriteInt(a) // write table index
  1298. } else {
  1299. buff.WriteString(target.UID) // write string
  1300. }
  1301. if ctx.IsStringTable() {
  1302. b := ctx.Table.AddOrGet(target.NamespaceUID)
  1303. buff.WriteInt(b) // write table index
  1304. } else {
  1305. buff.WriteString(target.NamespaceUID) // write string
  1306. }
  1307. if ctx.IsStringTable() {
  1308. c := ctx.Table.AddOrGet(target.Name)
  1309. buff.WriteInt(c) // write table index
  1310. } else {
  1311. buff.WriteString(target.Name) // write string
  1312. }
  1313. if target.Labels == nil {
  1314. buff.WriteUInt8(uint8(0)) // write nil byte
  1315. } else {
  1316. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1317. // --- [begin][write][map](map[string]string) ---
  1318. buff.WriteInt(len(target.Labels)) // map length
  1319. for v, z := range target.Labels {
  1320. if ctx.IsStringTable() {
  1321. d := ctx.Table.AddOrGet(v)
  1322. buff.WriteInt(d) // write table index
  1323. } else {
  1324. buff.WriteString(v) // write string
  1325. }
  1326. if ctx.IsStringTable() {
  1327. e := ctx.Table.AddOrGet(z)
  1328. buff.WriteInt(e) // write table index
  1329. } else {
  1330. buff.WriteString(z) // write string
  1331. }
  1332. }
  1333. // --- [end][write][map](map[string]string) ---
  1334. }
  1335. if target.Annotations == nil {
  1336. buff.WriteUInt8(uint8(0)) // write nil byte
  1337. } else {
  1338. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1339. // --- [begin][write][map](map[string]string) ---
  1340. buff.WriteInt(len(target.Annotations)) // map length
  1341. for vv, zz := range target.Annotations {
  1342. if ctx.IsStringTable() {
  1343. f := ctx.Table.AddOrGet(vv)
  1344. buff.WriteInt(f) // write table index
  1345. } else {
  1346. buff.WriteString(vv) // write string
  1347. }
  1348. if ctx.IsStringTable() {
  1349. g := ctx.Table.AddOrGet(zz)
  1350. buff.WriteInt(g) // write table index
  1351. } else {
  1352. buff.WriteString(zz) // write string
  1353. }
  1354. }
  1355. // --- [end][write][map](map[string]string) ---
  1356. }
  1357. // --- [begin][write][reference](time.Time) ---
  1358. h, errA := target.Start.MarshalBinary()
  1359. if errA != nil {
  1360. return errA
  1361. }
  1362. buff.WriteInt(len(h))
  1363. buff.WriteBytes(h)
  1364. // --- [end][write][reference](time.Time) ---
  1365. // --- [begin][write][reference](time.Time) ---
  1366. l, errB := target.End.MarshalBinary()
  1367. if errB != nil {
  1368. return errB
  1369. }
  1370. buff.WriteInt(len(l))
  1371. buff.WriteBytes(l)
  1372. // --- [end][write][reference](time.Time) ---
  1373. return nil
  1374. }
  1375. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1376. // the CronJob type
  1377. func (target *CronJob) UnmarshalBinary(data []byte) error {
  1378. ctx := NewDecodingContextFromBytes(data)
  1379. defer ctx.Close()
  1380. err := target.UnmarshalBinaryWithContext(ctx)
  1381. if err != nil {
  1382. return err
  1383. }
  1384. return nil
  1385. }
  1386. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  1387. // the CronJob type
  1388. func (target *CronJob) UnmarshalBinaryFromReader(reader io.Reader) error {
  1389. ctx := NewDecodingContextFromReader(reader)
  1390. defer ctx.Close()
  1391. err := target.UnmarshalBinaryWithContext(ctx)
  1392. if err != nil {
  1393. return err
  1394. }
  1395. return nil
  1396. }
  1397. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  1398. // the CronJob type
  1399. func (target *CronJob) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  1400. // panics are recovered and propagated as errors
  1401. defer func() {
  1402. if r := recover(); r != nil {
  1403. if e, ok := r.(error); ok {
  1404. err = e
  1405. } else if s, ok := r.(string); ok {
  1406. err = fmt.Errorf("unexpected panic: %s", s)
  1407. } else {
  1408. err = fmt.Errorf("unexpected panic: %+v", r)
  1409. }
  1410. }
  1411. }()
  1412. buff := ctx.Buffer
  1413. version := buff.ReadUInt8()
  1414. if version > DefaultCodecVersion {
  1415. return fmt.Errorf("Invalid Version Unmarshalling CronJob. Expected %d or less, got %d", DefaultCodecVersion, version)
  1416. }
  1417. var b string
  1418. if ctx.IsStringTable() {
  1419. c := buff.ReadInt() // read string index
  1420. b = ctx.Table.At(c)
  1421. } else {
  1422. b = buff.ReadString() // read string
  1423. }
  1424. a := b
  1425. target.UID = a
  1426. var e string
  1427. if ctx.IsStringTable() {
  1428. f := buff.ReadInt() // read string index
  1429. e = ctx.Table.At(f)
  1430. } else {
  1431. e = buff.ReadString() // read string
  1432. }
  1433. d := e
  1434. target.NamespaceUID = d
  1435. var h string
  1436. if ctx.IsStringTable() {
  1437. l := buff.ReadInt() // read string index
  1438. h = ctx.Table.At(l)
  1439. } else {
  1440. h = buff.ReadString() // read string
  1441. }
  1442. g := h
  1443. target.Name = g
  1444. if buff.ReadUInt8() == uint8(0) {
  1445. target.Labels = nil
  1446. } else {
  1447. // --- [begin][read][map](map[string]string) ---
  1448. n := buff.ReadInt() // map len
  1449. m := make(map[string]string, n)
  1450. for range n {
  1451. var v string
  1452. var p string
  1453. if ctx.IsStringTable() {
  1454. q := buff.ReadInt() // read string index
  1455. p = ctx.Table.At(q)
  1456. } else {
  1457. p = buff.ReadString() // read string
  1458. }
  1459. o := p
  1460. v = o
  1461. var z string
  1462. var s string
  1463. if ctx.IsStringTable() {
  1464. t := buff.ReadInt() // read string index
  1465. s = ctx.Table.At(t)
  1466. } else {
  1467. s = buff.ReadString() // read string
  1468. }
  1469. r := s
  1470. z = r
  1471. m[v] = z
  1472. }
  1473. target.Labels = m
  1474. // --- [end][read][map](map[string]string) ---
  1475. }
  1476. if buff.ReadUInt8() == uint8(0) {
  1477. target.Annotations = nil
  1478. } else {
  1479. // --- [begin][read][map](map[string]string) ---
  1480. w := buff.ReadInt() // map len
  1481. u := make(map[string]string, w)
  1482. for range w {
  1483. var vv string
  1484. var y string
  1485. if ctx.IsStringTable() {
  1486. aa := buff.ReadInt() // read string index
  1487. y = ctx.Table.At(aa)
  1488. } else {
  1489. y = buff.ReadString() // read string
  1490. }
  1491. x := y
  1492. vv = x
  1493. var zz string
  1494. var cc string
  1495. if ctx.IsStringTable() {
  1496. dd := buff.ReadInt() // read string index
  1497. cc = ctx.Table.At(dd)
  1498. } else {
  1499. cc = buff.ReadString() // read string
  1500. }
  1501. bb := cc
  1502. zz = bb
  1503. u[vv] = zz
  1504. }
  1505. target.Annotations = u
  1506. // --- [end][read][map](map[string]string) ---
  1507. }
  1508. // --- [begin][read][reference](time.Time) ---
  1509. ee := new(time.Time)
  1510. ff := buff.ReadInt() // byte array length
  1511. gg := buff.ReadBytes(ff)
  1512. errA := ee.UnmarshalBinary(gg)
  1513. if errA != nil {
  1514. return errA
  1515. }
  1516. target.Start = *ee
  1517. // --- [end][read][reference](time.Time) ---
  1518. // --- [begin][read][reference](time.Time) ---
  1519. hh := new(time.Time)
  1520. ll := buff.ReadInt() // byte array length
  1521. mm := buff.ReadBytes(ll)
  1522. errB := hh.UnmarshalBinary(mm)
  1523. if errB != nil {
  1524. return errB
  1525. }
  1526. target.End = *hh
  1527. // --- [end][read][reference](time.Time) ---
  1528. return nil
  1529. }
  1530. //--------------------------------------------------------------------------
  1531. // DaemonSet
  1532. //--------------------------------------------------------------------------
  1533. // MarshalBinary serializes the internal properties of this DaemonSet instance
  1534. // into a byte array
  1535. func (target *DaemonSet) MarshalBinary() (data []byte, err error) {
  1536. ctx := NewEncodingContext(nil)
  1537. e := target.MarshalBinaryWithContext(ctx)
  1538. if e != nil {
  1539. return nil, e
  1540. }
  1541. return ctx.ToBytes(), nil
  1542. }
  1543. // MarshalBinary serializes the internal properties of this DaemonSet instance
  1544. // into an io.Writer.
  1545. func (target *DaemonSet) MarshalBinaryTo(writer io.Writer) error {
  1546. buff := util.NewBufferFromWriter(writer)
  1547. defer buff.Flush()
  1548. ctx := NewEncodingContextFromBuffer(buff, nil)
  1549. return target.MarshalBinaryWithContext(ctx)
  1550. }
  1551. // MarshalBinaryWithContext serializes the internal properties of this DaemonSet instance
  1552. // into a byte array leveraging a predefined context.
  1553. func (target *DaemonSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  1554. // panics are recovered and propagated as errors
  1555. defer func() {
  1556. if r := recover(); r != nil {
  1557. if e, ok := r.(error); ok {
  1558. err = e
  1559. } else if s, ok := r.(string); ok {
  1560. err = fmt.Errorf("unexpected panic: %s", s)
  1561. } else {
  1562. err = fmt.Errorf("unexpected panic: %+v", r)
  1563. }
  1564. }
  1565. }()
  1566. buff := ctx.Buffer
  1567. buff.WriteUInt8(DefaultCodecVersion) // version
  1568. if ctx.IsStringTable() {
  1569. a := ctx.Table.AddOrGet(target.UID)
  1570. buff.WriteInt(a) // write table index
  1571. } else {
  1572. buff.WriteString(target.UID) // write string
  1573. }
  1574. if ctx.IsStringTable() {
  1575. b := ctx.Table.AddOrGet(target.NamespaceUID)
  1576. buff.WriteInt(b) // write table index
  1577. } else {
  1578. buff.WriteString(target.NamespaceUID) // write string
  1579. }
  1580. if ctx.IsStringTable() {
  1581. c := ctx.Table.AddOrGet(target.Name)
  1582. buff.WriteInt(c) // write table index
  1583. } else {
  1584. buff.WriteString(target.Name) // write string
  1585. }
  1586. if target.Labels == nil {
  1587. buff.WriteUInt8(uint8(0)) // write nil byte
  1588. } else {
  1589. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1590. // --- [begin][write][map](map[string]string) ---
  1591. buff.WriteInt(len(target.Labels)) // map length
  1592. for v, z := range target.Labels {
  1593. if ctx.IsStringTable() {
  1594. d := ctx.Table.AddOrGet(v)
  1595. buff.WriteInt(d) // write table index
  1596. } else {
  1597. buff.WriteString(v) // write string
  1598. }
  1599. if ctx.IsStringTable() {
  1600. e := ctx.Table.AddOrGet(z)
  1601. buff.WriteInt(e) // write table index
  1602. } else {
  1603. buff.WriteString(z) // write string
  1604. }
  1605. }
  1606. // --- [end][write][map](map[string]string) ---
  1607. }
  1608. if target.Annotations == nil {
  1609. buff.WriteUInt8(uint8(0)) // write nil byte
  1610. } else {
  1611. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1612. // --- [begin][write][map](map[string]string) ---
  1613. buff.WriteInt(len(target.Annotations)) // map length
  1614. for vv, zz := range target.Annotations {
  1615. if ctx.IsStringTable() {
  1616. f := ctx.Table.AddOrGet(vv)
  1617. buff.WriteInt(f) // write table index
  1618. } else {
  1619. buff.WriteString(vv) // write string
  1620. }
  1621. if ctx.IsStringTable() {
  1622. g := ctx.Table.AddOrGet(zz)
  1623. buff.WriteInt(g) // write table index
  1624. } else {
  1625. buff.WriteString(zz) // write string
  1626. }
  1627. }
  1628. // --- [end][write][map](map[string]string) ---
  1629. }
  1630. if target.Arguments == nil {
  1631. buff.WriteUInt8(uint8(0)) // write nil byte
  1632. } else {
  1633. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1634. // --- [begin][write][map](map[string]string) ---
  1635. buff.WriteInt(len(target.Arguments)) // map length
  1636. for vvv, zzz := range target.Arguments {
  1637. if ctx.IsStringTable() {
  1638. h := ctx.Table.AddOrGet(vvv)
  1639. buff.WriteInt(h) // write table index
  1640. } else {
  1641. buff.WriteString(vvv) // write string
  1642. }
  1643. if ctx.IsStringTable() {
  1644. l := ctx.Table.AddOrGet(zzz)
  1645. buff.WriteInt(l) // write table index
  1646. } else {
  1647. buff.WriteString(zzz) // write string
  1648. }
  1649. }
  1650. // --- [end][write][map](map[string]string) ---
  1651. }
  1652. // --- [begin][write][reference](time.Time) ---
  1653. m, errA := target.Start.MarshalBinary()
  1654. if errA != nil {
  1655. return errA
  1656. }
  1657. buff.WriteInt(len(m))
  1658. buff.WriteBytes(m)
  1659. // --- [end][write][reference](time.Time) ---
  1660. // --- [begin][write][reference](time.Time) ---
  1661. n, errB := target.End.MarshalBinary()
  1662. if errB != nil {
  1663. return errB
  1664. }
  1665. buff.WriteInt(len(n))
  1666. buff.WriteBytes(n)
  1667. // --- [end][write][reference](time.Time) ---
  1668. return nil
  1669. }
  1670. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1671. // the DaemonSet type
  1672. func (target *DaemonSet) UnmarshalBinary(data []byte) error {
  1673. ctx := NewDecodingContextFromBytes(data)
  1674. defer ctx.Close()
  1675. err := target.UnmarshalBinaryWithContext(ctx)
  1676. if err != nil {
  1677. return err
  1678. }
  1679. return nil
  1680. }
  1681. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  1682. // the DaemonSet type
  1683. func (target *DaemonSet) UnmarshalBinaryFromReader(reader io.Reader) error {
  1684. ctx := NewDecodingContextFromReader(reader)
  1685. defer ctx.Close()
  1686. err := target.UnmarshalBinaryWithContext(ctx)
  1687. if err != nil {
  1688. return err
  1689. }
  1690. return nil
  1691. }
  1692. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  1693. // the DaemonSet type
  1694. func (target *DaemonSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  1695. // panics are recovered and propagated as errors
  1696. defer func() {
  1697. if r := recover(); r != nil {
  1698. if e, ok := r.(error); ok {
  1699. err = e
  1700. } else if s, ok := r.(string); ok {
  1701. err = fmt.Errorf("unexpected panic: %s", s)
  1702. } else {
  1703. err = fmt.Errorf("unexpected panic: %+v", r)
  1704. }
  1705. }
  1706. }()
  1707. buff := ctx.Buffer
  1708. version := buff.ReadUInt8()
  1709. if version > DefaultCodecVersion {
  1710. return fmt.Errorf("Invalid Version Unmarshalling DaemonSet. Expected %d or less, got %d", DefaultCodecVersion, version)
  1711. }
  1712. var b string
  1713. if ctx.IsStringTable() {
  1714. c := buff.ReadInt() // read string index
  1715. b = ctx.Table.At(c)
  1716. } else {
  1717. b = buff.ReadString() // read string
  1718. }
  1719. a := b
  1720. target.UID = a
  1721. var e string
  1722. if ctx.IsStringTable() {
  1723. f := buff.ReadInt() // read string index
  1724. e = ctx.Table.At(f)
  1725. } else {
  1726. e = buff.ReadString() // read string
  1727. }
  1728. d := e
  1729. target.NamespaceUID = d
  1730. var h string
  1731. if ctx.IsStringTable() {
  1732. l := buff.ReadInt() // read string index
  1733. h = ctx.Table.At(l)
  1734. } else {
  1735. h = buff.ReadString() // read string
  1736. }
  1737. g := h
  1738. target.Name = g
  1739. if buff.ReadUInt8() == uint8(0) {
  1740. target.Labels = nil
  1741. } else {
  1742. // --- [begin][read][map](map[string]string) ---
  1743. n := buff.ReadInt() // map len
  1744. m := make(map[string]string, n)
  1745. for range n {
  1746. var v string
  1747. var p string
  1748. if ctx.IsStringTable() {
  1749. q := buff.ReadInt() // read string index
  1750. p = ctx.Table.At(q)
  1751. } else {
  1752. p = buff.ReadString() // read string
  1753. }
  1754. o := p
  1755. v = o
  1756. var z string
  1757. var s string
  1758. if ctx.IsStringTable() {
  1759. t := buff.ReadInt() // read string index
  1760. s = ctx.Table.At(t)
  1761. } else {
  1762. s = buff.ReadString() // read string
  1763. }
  1764. r := s
  1765. z = r
  1766. m[v] = z
  1767. }
  1768. target.Labels = m
  1769. // --- [end][read][map](map[string]string) ---
  1770. }
  1771. if buff.ReadUInt8() == uint8(0) {
  1772. target.Annotations = nil
  1773. } else {
  1774. // --- [begin][read][map](map[string]string) ---
  1775. w := buff.ReadInt() // map len
  1776. u := make(map[string]string, w)
  1777. for range w {
  1778. var vv string
  1779. var y string
  1780. if ctx.IsStringTable() {
  1781. aa := buff.ReadInt() // read string index
  1782. y = ctx.Table.At(aa)
  1783. } else {
  1784. y = buff.ReadString() // read string
  1785. }
  1786. x := y
  1787. vv = x
  1788. var zz string
  1789. var cc string
  1790. if ctx.IsStringTable() {
  1791. dd := buff.ReadInt() // read string index
  1792. cc = ctx.Table.At(dd)
  1793. } else {
  1794. cc = buff.ReadString() // read string
  1795. }
  1796. bb := cc
  1797. zz = bb
  1798. u[vv] = zz
  1799. }
  1800. target.Annotations = u
  1801. // --- [end][read][map](map[string]string) ---
  1802. }
  1803. if buff.ReadUInt8() == uint8(0) {
  1804. target.Arguments = nil
  1805. } else {
  1806. // --- [begin][read][map](map[string]string) ---
  1807. ff := buff.ReadInt() // map len
  1808. ee := make(map[string]string, ff)
  1809. for range ff {
  1810. var vvv string
  1811. var hh string
  1812. if ctx.IsStringTable() {
  1813. ll := buff.ReadInt() // read string index
  1814. hh = ctx.Table.At(ll)
  1815. } else {
  1816. hh = buff.ReadString() // read string
  1817. }
  1818. gg := hh
  1819. vvv = gg
  1820. var zzz string
  1821. var nn string
  1822. if ctx.IsStringTable() {
  1823. oo := buff.ReadInt() // read string index
  1824. nn = ctx.Table.At(oo)
  1825. } else {
  1826. nn = buff.ReadString() // read string
  1827. }
  1828. mm := nn
  1829. zzz = mm
  1830. ee[vvv] = zzz
  1831. }
  1832. target.Arguments = ee
  1833. // --- [end][read][map](map[string]string) ---
  1834. }
  1835. // --- [begin][read][reference](time.Time) ---
  1836. pp := new(time.Time)
  1837. qq := buff.ReadInt() // byte array length
  1838. rr := buff.ReadBytes(qq)
  1839. errA := pp.UnmarshalBinary(rr)
  1840. if errA != nil {
  1841. return errA
  1842. }
  1843. target.Start = *pp
  1844. // --- [end][read][reference](time.Time) ---
  1845. // --- [begin][read][reference](time.Time) ---
  1846. ss := new(time.Time)
  1847. tt := buff.ReadInt() // byte array length
  1848. uu := buff.ReadBytes(tt)
  1849. errB := ss.UnmarshalBinary(uu)
  1850. if errB != nil {
  1851. return errB
  1852. }
  1853. target.End = *ss
  1854. // --- [end][read][reference](time.Time) ---
  1855. return nil
  1856. }
  1857. //--------------------------------------------------------------------------
  1858. // Deployment
  1859. //--------------------------------------------------------------------------
  1860. // MarshalBinary serializes the internal properties of this Deployment instance
  1861. // into a byte array
  1862. func (target *Deployment) MarshalBinary() (data []byte, err error) {
  1863. ctx := NewEncodingContext(nil)
  1864. e := target.MarshalBinaryWithContext(ctx)
  1865. if e != nil {
  1866. return nil, e
  1867. }
  1868. return ctx.ToBytes(), nil
  1869. }
  1870. // MarshalBinary serializes the internal properties of this Deployment instance
  1871. // into an io.Writer.
  1872. func (target *Deployment) MarshalBinaryTo(writer io.Writer) error {
  1873. buff := util.NewBufferFromWriter(writer)
  1874. defer buff.Flush()
  1875. ctx := NewEncodingContextFromBuffer(buff, nil)
  1876. return target.MarshalBinaryWithContext(ctx)
  1877. }
  1878. // MarshalBinaryWithContext serializes the internal properties of this Deployment instance
  1879. // into a byte array leveraging a predefined context.
  1880. func (target *Deployment) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  1881. // panics are recovered and propagated as errors
  1882. defer func() {
  1883. if r := recover(); r != nil {
  1884. if e, ok := r.(error); ok {
  1885. err = e
  1886. } else if s, ok := r.(string); ok {
  1887. err = fmt.Errorf("unexpected panic: %s", s)
  1888. } else {
  1889. err = fmt.Errorf("unexpected panic: %+v", r)
  1890. }
  1891. }
  1892. }()
  1893. buff := ctx.Buffer
  1894. buff.WriteUInt8(DefaultCodecVersion) // version
  1895. if ctx.IsStringTable() {
  1896. a := ctx.Table.AddOrGet(target.UID)
  1897. buff.WriteInt(a) // write table index
  1898. } else {
  1899. buff.WriteString(target.UID) // write string
  1900. }
  1901. if ctx.IsStringTable() {
  1902. b := ctx.Table.AddOrGet(target.NamespaceUID)
  1903. buff.WriteInt(b) // write table index
  1904. } else {
  1905. buff.WriteString(target.NamespaceUID) // write string
  1906. }
  1907. if ctx.IsStringTable() {
  1908. c := ctx.Table.AddOrGet(target.Name)
  1909. buff.WriteInt(c) // write table index
  1910. } else {
  1911. buff.WriteString(target.Name) // write string
  1912. }
  1913. if target.Labels == nil {
  1914. buff.WriteUInt8(uint8(0)) // write nil byte
  1915. } else {
  1916. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1917. // --- [begin][write][map](map[string]string) ---
  1918. buff.WriteInt(len(target.Labels)) // map length
  1919. for v, z := range target.Labels {
  1920. if ctx.IsStringTable() {
  1921. d := ctx.Table.AddOrGet(v)
  1922. buff.WriteInt(d) // write table index
  1923. } else {
  1924. buff.WriteString(v) // write string
  1925. }
  1926. if ctx.IsStringTable() {
  1927. e := ctx.Table.AddOrGet(z)
  1928. buff.WriteInt(e) // write table index
  1929. } else {
  1930. buff.WriteString(z) // write string
  1931. }
  1932. }
  1933. // --- [end][write][map](map[string]string) ---
  1934. }
  1935. if target.Annotations == nil {
  1936. buff.WriteUInt8(uint8(0)) // write nil byte
  1937. } else {
  1938. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1939. // --- [begin][write][map](map[string]string) ---
  1940. buff.WriteInt(len(target.Annotations)) // map length
  1941. for vv, zz := range target.Annotations {
  1942. if ctx.IsStringTable() {
  1943. f := ctx.Table.AddOrGet(vv)
  1944. buff.WriteInt(f) // write table index
  1945. } else {
  1946. buff.WriteString(vv) // write string
  1947. }
  1948. if ctx.IsStringTable() {
  1949. g := ctx.Table.AddOrGet(zz)
  1950. buff.WriteInt(g) // write table index
  1951. } else {
  1952. buff.WriteString(zz) // write string
  1953. }
  1954. }
  1955. // --- [end][write][map](map[string]string) ---
  1956. }
  1957. if target.MatchLabels == nil {
  1958. buff.WriteUInt8(uint8(0)) // write nil byte
  1959. } else {
  1960. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1961. // --- [begin][write][map](map[string]string) ---
  1962. buff.WriteInt(len(target.MatchLabels)) // map length
  1963. for vvv, zzz := range target.MatchLabels {
  1964. if ctx.IsStringTable() {
  1965. h := ctx.Table.AddOrGet(vvv)
  1966. buff.WriteInt(h) // write table index
  1967. } else {
  1968. buff.WriteString(vvv) // write string
  1969. }
  1970. if ctx.IsStringTable() {
  1971. l := ctx.Table.AddOrGet(zzz)
  1972. buff.WriteInt(l) // write table index
  1973. } else {
  1974. buff.WriteString(zzz) // write string
  1975. }
  1976. }
  1977. // --- [end][write][map](map[string]string) ---
  1978. }
  1979. // --- [begin][write][reference](time.Time) ---
  1980. m, errA := target.Start.MarshalBinary()
  1981. if errA != nil {
  1982. return errA
  1983. }
  1984. buff.WriteInt(len(m))
  1985. buff.WriteBytes(m)
  1986. // --- [end][write][reference](time.Time) ---
  1987. // --- [begin][write][reference](time.Time) ---
  1988. n, errB := target.End.MarshalBinary()
  1989. if errB != nil {
  1990. return errB
  1991. }
  1992. buff.WriteInt(len(n))
  1993. buff.WriteBytes(n)
  1994. // --- [end][write][reference](time.Time) ---
  1995. return nil
  1996. }
  1997. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1998. // the Deployment type
  1999. func (target *Deployment) UnmarshalBinary(data []byte) error {
  2000. ctx := NewDecodingContextFromBytes(data)
  2001. defer ctx.Close()
  2002. err := target.UnmarshalBinaryWithContext(ctx)
  2003. if err != nil {
  2004. return err
  2005. }
  2006. return nil
  2007. }
  2008. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  2009. // the Deployment type
  2010. func (target *Deployment) UnmarshalBinaryFromReader(reader io.Reader) error {
  2011. ctx := NewDecodingContextFromReader(reader)
  2012. defer ctx.Close()
  2013. err := target.UnmarshalBinaryWithContext(ctx)
  2014. if err != nil {
  2015. return err
  2016. }
  2017. return nil
  2018. }
  2019. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  2020. // the Deployment type
  2021. func (target *Deployment) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  2022. // panics are recovered and propagated as errors
  2023. defer func() {
  2024. if r := recover(); r != nil {
  2025. if e, ok := r.(error); ok {
  2026. err = e
  2027. } else if s, ok := r.(string); ok {
  2028. err = fmt.Errorf("unexpected panic: %s", s)
  2029. } else {
  2030. err = fmt.Errorf("unexpected panic: %+v", r)
  2031. }
  2032. }
  2033. }()
  2034. buff := ctx.Buffer
  2035. version := buff.ReadUInt8()
  2036. if version > DefaultCodecVersion {
  2037. return fmt.Errorf("Invalid Version Unmarshalling Deployment. Expected %d or less, got %d", DefaultCodecVersion, version)
  2038. }
  2039. var b string
  2040. if ctx.IsStringTable() {
  2041. c := buff.ReadInt() // read string index
  2042. b = ctx.Table.At(c)
  2043. } else {
  2044. b = buff.ReadString() // read string
  2045. }
  2046. a := b
  2047. target.UID = a
  2048. var e string
  2049. if ctx.IsStringTable() {
  2050. f := buff.ReadInt() // read string index
  2051. e = ctx.Table.At(f)
  2052. } else {
  2053. e = buff.ReadString() // read string
  2054. }
  2055. d := e
  2056. target.NamespaceUID = d
  2057. var h string
  2058. if ctx.IsStringTable() {
  2059. l := buff.ReadInt() // read string index
  2060. h = ctx.Table.At(l)
  2061. } else {
  2062. h = buff.ReadString() // read string
  2063. }
  2064. g := h
  2065. target.Name = g
  2066. if buff.ReadUInt8() == uint8(0) {
  2067. target.Labels = nil
  2068. } else {
  2069. // --- [begin][read][map](map[string]string) ---
  2070. n := buff.ReadInt() // map len
  2071. m := make(map[string]string, n)
  2072. for range n {
  2073. var v string
  2074. var p string
  2075. if ctx.IsStringTable() {
  2076. q := buff.ReadInt() // read string index
  2077. p = ctx.Table.At(q)
  2078. } else {
  2079. p = buff.ReadString() // read string
  2080. }
  2081. o := p
  2082. v = o
  2083. var z string
  2084. var s string
  2085. if ctx.IsStringTable() {
  2086. t := buff.ReadInt() // read string index
  2087. s = ctx.Table.At(t)
  2088. } else {
  2089. s = buff.ReadString() // read string
  2090. }
  2091. r := s
  2092. z = r
  2093. m[v] = z
  2094. }
  2095. target.Labels = m
  2096. // --- [end][read][map](map[string]string) ---
  2097. }
  2098. if buff.ReadUInt8() == uint8(0) {
  2099. target.Annotations = nil
  2100. } else {
  2101. // --- [begin][read][map](map[string]string) ---
  2102. w := buff.ReadInt() // map len
  2103. u := make(map[string]string, w)
  2104. for range w {
  2105. var vv string
  2106. var y string
  2107. if ctx.IsStringTable() {
  2108. aa := buff.ReadInt() // read string index
  2109. y = ctx.Table.At(aa)
  2110. } else {
  2111. y = buff.ReadString() // read string
  2112. }
  2113. x := y
  2114. vv = x
  2115. var zz string
  2116. var cc string
  2117. if ctx.IsStringTable() {
  2118. dd := buff.ReadInt() // read string index
  2119. cc = ctx.Table.At(dd)
  2120. } else {
  2121. cc = buff.ReadString() // read string
  2122. }
  2123. bb := cc
  2124. zz = bb
  2125. u[vv] = zz
  2126. }
  2127. target.Annotations = u
  2128. // --- [end][read][map](map[string]string) ---
  2129. }
  2130. if buff.ReadUInt8() == uint8(0) {
  2131. target.MatchLabels = nil
  2132. } else {
  2133. // --- [begin][read][map](map[string]string) ---
  2134. ff := buff.ReadInt() // map len
  2135. ee := make(map[string]string, ff)
  2136. for range ff {
  2137. var vvv string
  2138. var hh string
  2139. if ctx.IsStringTable() {
  2140. ll := buff.ReadInt() // read string index
  2141. hh = ctx.Table.At(ll)
  2142. } else {
  2143. hh = buff.ReadString() // read string
  2144. }
  2145. gg := hh
  2146. vvv = gg
  2147. var zzz string
  2148. var nn string
  2149. if ctx.IsStringTable() {
  2150. oo := buff.ReadInt() // read string index
  2151. nn = ctx.Table.At(oo)
  2152. } else {
  2153. nn = buff.ReadString() // read string
  2154. }
  2155. mm := nn
  2156. zzz = mm
  2157. ee[vvv] = zzz
  2158. }
  2159. target.MatchLabels = ee
  2160. // --- [end][read][map](map[string]string) ---
  2161. }
  2162. // --- [begin][read][reference](time.Time) ---
  2163. pp := new(time.Time)
  2164. qq := buff.ReadInt() // byte array length
  2165. rr := buff.ReadBytes(qq)
  2166. errA := pp.UnmarshalBinary(rr)
  2167. if errA != nil {
  2168. return errA
  2169. }
  2170. target.Start = *pp
  2171. // --- [end][read][reference](time.Time) ---
  2172. // --- [begin][read][reference](time.Time) ---
  2173. ss := new(time.Time)
  2174. tt := buff.ReadInt() // byte array length
  2175. uu := buff.ReadBytes(tt)
  2176. errB := ss.UnmarshalBinary(uu)
  2177. if errB != nil {
  2178. return errB
  2179. }
  2180. target.End = *ss
  2181. // --- [end][read][reference](time.Time) ---
  2182. return nil
  2183. }
  2184. //--------------------------------------------------------------------------
  2185. // Device
  2186. //--------------------------------------------------------------------------
  2187. // MarshalBinary serializes the internal properties of this Device instance
  2188. // into a byte array
  2189. func (target *Device) MarshalBinary() (data []byte, err error) {
  2190. ctx := NewEncodingContext(nil)
  2191. e := target.MarshalBinaryWithContext(ctx)
  2192. if e != nil {
  2193. return nil, e
  2194. }
  2195. return ctx.ToBytes(), nil
  2196. }
  2197. // MarshalBinary serializes the internal properties of this Device instance
  2198. // into an io.Writer.
  2199. func (target *Device) MarshalBinaryTo(writer io.Writer) error {
  2200. buff := util.NewBufferFromWriter(writer)
  2201. defer buff.Flush()
  2202. ctx := NewEncodingContextFromBuffer(buff, nil)
  2203. return target.MarshalBinaryWithContext(ctx)
  2204. }
  2205. // MarshalBinaryWithContext serializes the internal properties of this Device instance
  2206. // into a byte array leveraging a predefined context.
  2207. func (target *Device) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  2208. // panics are recovered and propagated as errors
  2209. defer func() {
  2210. if r := recover(); r != nil {
  2211. if e, ok := r.(error); ok {
  2212. err = e
  2213. } else if s, ok := r.(string); ok {
  2214. err = fmt.Errorf("unexpected panic: %s", s)
  2215. } else {
  2216. err = fmt.Errorf("unexpected panic: %+v", r)
  2217. }
  2218. }
  2219. }()
  2220. buff := ctx.Buffer
  2221. buff.WriteUInt8(DefaultCodecVersion) // version
  2222. if ctx.IsStringTable() {
  2223. a := ctx.Table.AddOrGet(target.UUID)
  2224. buff.WriteInt(a) // write table index
  2225. } else {
  2226. buff.WriteString(target.UUID) // write string
  2227. }
  2228. // --- [begin][write][reference](time.Time) ---
  2229. b, errA := target.Start.MarshalBinary()
  2230. if errA != nil {
  2231. return errA
  2232. }
  2233. buff.WriteInt(len(b))
  2234. buff.WriteBytes(b)
  2235. // --- [end][write][reference](time.Time) ---
  2236. // --- [begin][write][reference](time.Time) ---
  2237. c, errB := target.End.MarshalBinary()
  2238. if errB != nil {
  2239. return errB
  2240. }
  2241. buff.WriteInt(len(c))
  2242. buff.WriteBytes(c)
  2243. // --- [end][write][reference](time.Time) ---
  2244. if ctx.IsStringTable() {
  2245. d := ctx.Table.AddOrGet(target.Device)
  2246. buff.WriteInt(d) // write table index
  2247. } else {
  2248. buff.WriteString(target.Device) // write string
  2249. }
  2250. if ctx.IsStringTable() {
  2251. e := ctx.Table.AddOrGet(target.ModelName)
  2252. buff.WriteInt(e) // write table index
  2253. } else {
  2254. buff.WriteString(target.ModelName) // write string
  2255. }
  2256. return nil
  2257. }
  2258. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2259. // the Device type
  2260. func (target *Device) UnmarshalBinary(data []byte) error {
  2261. ctx := NewDecodingContextFromBytes(data)
  2262. defer ctx.Close()
  2263. err := target.UnmarshalBinaryWithContext(ctx)
  2264. if err != nil {
  2265. return err
  2266. }
  2267. return nil
  2268. }
  2269. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  2270. // the Device type
  2271. func (target *Device) UnmarshalBinaryFromReader(reader io.Reader) error {
  2272. ctx := NewDecodingContextFromReader(reader)
  2273. defer ctx.Close()
  2274. err := target.UnmarshalBinaryWithContext(ctx)
  2275. if err != nil {
  2276. return err
  2277. }
  2278. return nil
  2279. }
  2280. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  2281. // the Device type
  2282. func (target *Device) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  2283. // panics are recovered and propagated as errors
  2284. defer func() {
  2285. if r := recover(); r != nil {
  2286. if e, ok := r.(error); ok {
  2287. err = e
  2288. } else if s, ok := r.(string); ok {
  2289. err = fmt.Errorf("unexpected panic: %s", s)
  2290. } else {
  2291. err = fmt.Errorf("unexpected panic: %+v", r)
  2292. }
  2293. }
  2294. }()
  2295. buff := ctx.Buffer
  2296. version := buff.ReadUInt8()
  2297. if version > DefaultCodecVersion {
  2298. return fmt.Errorf("Invalid Version Unmarshalling Device. Expected %d or less, got %d", DefaultCodecVersion, version)
  2299. }
  2300. var b string
  2301. if ctx.IsStringTable() {
  2302. c := buff.ReadInt() // read string index
  2303. b = ctx.Table.At(c)
  2304. } else {
  2305. b = buff.ReadString() // read string
  2306. }
  2307. a := b
  2308. target.UUID = a
  2309. // --- [begin][read][reference](time.Time) ---
  2310. d := new(time.Time)
  2311. e := buff.ReadInt() // byte array length
  2312. f := buff.ReadBytes(e)
  2313. errA := d.UnmarshalBinary(f)
  2314. if errA != nil {
  2315. return errA
  2316. }
  2317. target.Start = *d
  2318. // --- [end][read][reference](time.Time) ---
  2319. // --- [begin][read][reference](time.Time) ---
  2320. g := new(time.Time)
  2321. h := buff.ReadInt() // byte array length
  2322. l := buff.ReadBytes(h)
  2323. errB := g.UnmarshalBinary(l)
  2324. if errB != nil {
  2325. return errB
  2326. }
  2327. target.End = *g
  2328. // --- [end][read][reference](time.Time) ---
  2329. var n string
  2330. if ctx.IsStringTable() {
  2331. o := buff.ReadInt() // read string index
  2332. n = ctx.Table.At(o)
  2333. } else {
  2334. n = buff.ReadString() // read string
  2335. }
  2336. m := n
  2337. target.Device = m
  2338. var q string
  2339. if ctx.IsStringTable() {
  2340. r := buff.ReadInt() // read string index
  2341. q = ctx.Table.At(r)
  2342. } else {
  2343. q = buff.ReadString() // read string
  2344. }
  2345. p := q
  2346. target.ModelName = p
  2347. return nil
  2348. }
  2349. //--------------------------------------------------------------------------
  2350. // DeviceUsage
  2351. //--------------------------------------------------------------------------
  2352. // MarshalBinary serializes the internal properties of this DeviceUsage instance
  2353. // into a byte array
  2354. func (target *DeviceUsage) MarshalBinary() (data []byte, err error) {
  2355. ctx := NewEncodingContext(nil)
  2356. e := target.MarshalBinaryWithContext(ctx)
  2357. if e != nil {
  2358. return nil, e
  2359. }
  2360. return ctx.ToBytes(), nil
  2361. }
  2362. // MarshalBinary serializes the internal properties of this DeviceUsage instance
  2363. // into an io.Writer.
  2364. func (target *DeviceUsage) MarshalBinaryTo(writer io.Writer) error {
  2365. buff := util.NewBufferFromWriter(writer)
  2366. defer buff.Flush()
  2367. ctx := NewEncodingContextFromBuffer(buff, nil)
  2368. return target.MarshalBinaryWithContext(ctx)
  2369. }
  2370. // MarshalBinaryWithContext serializes the internal properties of this DeviceUsage instance
  2371. // into a byte array leveraging a predefined context.
  2372. func (target *DeviceUsage) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  2373. // panics are recovered and propagated as errors
  2374. defer func() {
  2375. if r := recover(); r != nil {
  2376. if e, ok := r.(error); ok {
  2377. err = e
  2378. } else if s, ok := r.(string); ok {
  2379. err = fmt.Errorf("unexpected panic: %s", s)
  2380. } else {
  2381. err = fmt.Errorf("unexpected panic: %+v", r)
  2382. }
  2383. }
  2384. }()
  2385. buff := ctx.Buffer
  2386. buff.WriteUInt8(DefaultCodecVersion) // version
  2387. buff.WriteFloat64(target.UsageAvg) // write float64
  2388. buff.WriteFloat64(target.UsageMax) // write float64
  2389. return nil
  2390. }
  2391. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2392. // the DeviceUsage type
  2393. func (target *DeviceUsage) UnmarshalBinary(data []byte) error {
  2394. ctx := NewDecodingContextFromBytes(data)
  2395. defer ctx.Close()
  2396. err := target.UnmarshalBinaryWithContext(ctx)
  2397. if err != nil {
  2398. return err
  2399. }
  2400. return nil
  2401. }
  2402. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  2403. // the DeviceUsage type
  2404. func (target *DeviceUsage) UnmarshalBinaryFromReader(reader io.Reader) error {
  2405. ctx := NewDecodingContextFromReader(reader)
  2406. defer ctx.Close()
  2407. err := target.UnmarshalBinaryWithContext(ctx)
  2408. if err != nil {
  2409. return err
  2410. }
  2411. return nil
  2412. }
  2413. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  2414. // the DeviceUsage type
  2415. func (target *DeviceUsage) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  2416. // panics are recovered and propagated as errors
  2417. defer func() {
  2418. if r := recover(); r != nil {
  2419. if e, ok := r.(error); ok {
  2420. err = e
  2421. } else if s, ok := r.(string); ok {
  2422. err = fmt.Errorf("unexpected panic: %s", s)
  2423. } else {
  2424. err = fmt.Errorf("unexpected panic: %+v", r)
  2425. }
  2426. }
  2427. }()
  2428. buff := ctx.Buffer
  2429. version := buff.ReadUInt8()
  2430. if version > DefaultCodecVersion {
  2431. return fmt.Errorf("Invalid Version Unmarshalling DeviceUsage. Expected %d or less, got %d", DefaultCodecVersion, version)
  2432. }
  2433. a := buff.ReadFloat64() // read float64
  2434. target.UsageAvg = a
  2435. b := buff.ReadFloat64() // read float64
  2436. target.UsageMax = b
  2437. return nil
  2438. }
  2439. //--------------------------------------------------------------------------
  2440. // Diagnostic
  2441. //--------------------------------------------------------------------------
  2442. // MarshalBinary serializes the internal properties of this Diagnostic instance
  2443. // into a byte array
  2444. func (target *Diagnostic) MarshalBinary() (data []byte, err error) {
  2445. ctx := NewEncodingContext(nil)
  2446. e := target.MarshalBinaryWithContext(ctx)
  2447. if e != nil {
  2448. return nil, e
  2449. }
  2450. return ctx.ToBytes(), nil
  2451. }
  2452. // MarshalBinary serializes the internal properties of this Diagnostic instance
  2453. // into an io.Writer.
  2454. func (target *Diagnostic) MarshalBinaryTo(writer io.Writer) error {
  2455. buff := util.NewBufferFromWriter(writer)
  2456. defer buff.Flush()
  2457. ctx := NewEncodingContextFromBuffer(buff, nil)
  2458. return target.MarshalBinaryWithContext(ctx)
  2459. }
  2460. // MarshalBinaryWithContext serializes the internal properties of this Diagnostic instance
  2461. // into a byte array leveraging a predefined context.
  2462. func (target *Diagnostic) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  2463. // panics are recovered and propagated as errors
  2464. defer func() {
  2465. if r := recover(); r != nil {
  2466. if e, ok := r.(error); ok {
  2467. err = e
  2468. } else if s, ok := r.(string); ok {
  2469. err = fmt.Errorf("unexpected panic: %s", s)
  2470. } else {
  2471. err = fmt.Errorf("unexpected panic: %+v", r)
  2472. }
  2473. }
  2474. }()
  2475. buff := ctx.Buffer
  2476. buff.WriteUInt8(DefaultCodecVersion) // version
  2477. // --- [begin][write][reference](time.Time) ---
  2478. a, errA := target.Timestamp.MarshalBinary()
  2479. if errA != nil {
  2480. return errA
  2481. }
  2482. buff.WriteInt(len(a))
  2483. buff.WriteBytes(a)
  2484. // --- [end][write][reference](time.Time) ---
  2485. // --- [begin][write][alias](DiagnosticLevel) ---
  2486. buff.WriteInt(int(target.Level)) // write int
  2487. // --- [end][write][alias](DiagnosticLevel) ---
  2488. if ctx.IsStringTable() {
  2489. b := ctx.Table.AddOrGet(target.Message)
  2490. buff.WriteInt(b) // write table index
  2491. } else {
  2492. buff.WriteString(target.Message) // write string
  2493. }
  2494. if target.Details == nil {
  2495. buff.WriteUInt8(uint8(0)) // write nil byte
  2496. } else {
  2497. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2498. // --- [begin][write][map](map[string]string) ---
  2499. buff.WriteInt(len(target.Details)) // map length
  2500. for v, z := range target.Details {
  2501. if ctx.IsStringTable() {
  2502. c := ctx.Table.AddOrGet(v)
  2503. buff.WriteInt(c) // write table index
  2504. } else {
  2505. buff.WriteString(v) // write string
  2506. }
  2507. if ctx.IsStringTable() {
  2508. d := ctx.Table.AddOrGet(z)
  2509. buff.WriteInt(d) // write table index
  2510. } else {
  2511. buff.WriteString(z) // write string
  2512. }
  2513. }
  2514. // --- [end][write][map](map[string]string) ---
  2515. }
  2516. return nil
  2517. }
  2518. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2519. // the Diagnostic type
  2520. func (target *Diagnostic) UnmarshalBinary(data []byte) error {
  2521. ctx := NewDecodingContextFromBytes(data)
  2522. defer ctx.Close()
  2523. err := target.UnmarshalBinaryWithContext(ctx)
  2524. if err != nil {
  2525. return err
  2526. }
  2527. return nil
  2528. }
  2529. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  2530. // the Diagnostic type
  2531. func (target *Diagnostic) UnmarshalBinaryFromReader(reader io.Reader) error {
  2532. ctx := NewDecodingContextFromReader(reader)
  2533. defer ctx.Close()
  2534. err := target.UnmarshalBinaryWithContext(ctx)
  2535. if err != nil {
  2536. return err
  2537. }
  2538. return nil
  2539. }
  2540. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  2541. // the Diagnostic type
  2542. func (target *Diagnostic) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  2543. // panics are recovered and propagated as errors
  2544. defer func() {
  2545. if r := recover(); r != nil {
  2546. if e, ok := r.(error); ok {
  2547. err = e
  2548. } else if s, ok := r.(string); ok {
  2549. err = fmt.Errorf("unexpected panic: %s", s)
  2550. } else {
  2551. err = fmt.Errorf("unexpected panic: %+v", r)
  2552. }
  2553. }
  2554. }()
  2555. buff := ctx.Buffer
  2556. version := buff.ReadUInt8()
  2557. if version > DefaultCodecVersion {
  2558. return fmt.Errorf("Invalid Version Unmarshalling Diagnostic. Expected %d or less, got %d", DefaultCodecVersion, version)
  2559. }
  2560. // field version check
  2561. if uint8(1) <= version {
  2562. // --- [begin][read][reference](time.Time) ---
  2563. a := new(time.Time)
  2564. b := buff.ReadInt() // byte array length
  2565. c := buff.ReadBytes(b)
  2566. errA := a.UnmarshalBinary(c)
  2567. if errA != nil {
  2568. return errA
  2569. }
  2570. target.Timestamp = *a
  2571. // --- [end][read][reference](time.Time) ---
  2572. } else {
  2573. }
  2574. // field version check
  2575. if uint8(1) <= version {
  2576. // --- [begin][read][alias](DiagnosticLevel) ---
  2577. var d int
  2578. e := buff.ReadInt() // read int
  2579. d = e
  2580. target.Level = DiagnosticLevel(d)
  2581. // --- [end][read][alias](DiagnosticLevel) ---
  2582. } else {
  2583. }
  2584. // field version check
  2585. if uint8(1) <= version {
  2586. var g string
  2587. if ctx.IsStringTable() {
  2588. h := buff.ReadInt() // read string index
  2589. g = ctx.Table.At(h)
  2590. } else {
  2591. g = buff.ReadString() // read string
  2592. }
  2593. f := g
  2594. target.Message = f
  2595. } else {
  2596. target.Message = "" // default
  2597. }
  2598. // field version check
  2599. if uint8(1) <= version {
  2600. if buff.ReadUInt8() == uint8(0) {
  2601. target.Details = nil
  2602. } else {
  2603. // --- [begin][read][map](map[string]string) ---
  2604. m := buff.ReadInt() // map len
  2605. l := make(map[string]string, m)
  2606. for range m {
  2607. var v string
  2608. var o string
  2609. if ctx.IsStringTable() {
  2610. p := buff.ReadInt() // read string index
  2611. o = ctx.Table.At(p)
  2612. } else {
  2613. o = buff.ReadString() // read string
  2614. }
  2615. n := o
  2616. v = n
  2617. var z string
  2618. var r string
  2619. if ctx.IsStringTable() {
  2620. s := buff.ReadInt() // read string index
  2621. r = ctx.Table.At(s)
  2622. } else {
  2623. r = buff.ReadString() // read string
  2624. }
  2625. q := r
  2626. z = q
  2627. l[v] = z
  2628. }
  2629. target.Details = l
  2630. // --- [end][read][map](map[string]string) ---
  2631. }
  2632. } else {
  2633. target.Details = nil
  2634. }
  2635. return nil
  2636. }
  2637. //--------------------------------------------------------------------------
  2638. // FileSystem
  2639. //--------------------------------------------------------------------------
  2640. // MarshalBinary serializes the internal properties of this FileSystem instance
  2641. // into a byte array
  2642. func (target *FileSystem) MarshalBinary() (data []byte, err error) {
  2643. ctx := NewEncodingContext(nil)
  2644. e := target.MarshalBinaryWithContext(ctx)
  2645. if e != nil {
  2646. return nil, e
  2647. }
  2648. return ctx.ToBytes(), nil
  2649. }
  2650. // MarshalBinary serializes the internal properties of this FileSystem instance
  2651. // into an io.Writer.
  2652. func (target *FileSystem) MarshalBinaryTo(writer io.Writer) error {
  2653. buff := util.NewBufferFromWriter(writer)
  2654. defer buff.Flush()
  2655. ctx := NewEncodingContextFromBuffer(buff, nil)
  2656. return target.MarshalBinaryWithContext(ctx)
  2657. }
  2658. // MarshalBinaryWithContext serializes the internal properties of this FileSystem instance
  2659. // into a byte array leveraging a predefined context.
  2660. func (target *FileSystem) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  2661. // panics are recovered and propagated as errors
  2662. defer func() {
  2663. if r := recover(); r != nil {
  2664. if e, ok := r.(error); ok {
  2665. err = e
  2666. } else if s, ok := r.(string); ok {
  2667. err = fmt.Errorf("unexpected panic: %s", s)
  2668. } else {
  2669. err = fmt.Errorf("unexpected panic: %+v", r)
  2670. }
  2671. }
  2672. }()
  2673. buff := ctx.Buffer
  2674. buff.WriteUInt8(DefaultCodecVersion) // version
  2675. buff.WriteFloat64(target.CapacityBytes) // write float64
  2676. buff.WriteFloat64(target.UsageByteAvg) // write float64
  2677. buff.WriteFloat64(target.UsageByteMax) // write float64
  2678. return nil
  2679. }
  2680. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2681. // the FileSystem type
  2682. func (target *FileSystem) UnmarshalBinary(data []byte) error {
  2683. ctx := NewDecodingContextFromBytes(data)
  2684. defer ctx.Close()
  2685. err := target.UnmarshalBinaryWithContext(ctx)
  2686. if err != nil {
  2687. return err
  2688. }
  2689. return nil
  2690. }
  2691. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  2692. // the FileSystem type
  2693. func (target *FileSystem) UnmarshalBinaryFromReader(reader io.Reader) error {
  2694. ctx := NewDecodingContextFromReader(reader)
  2695. defer ctx.Close()
  2696. err := target.UnmarshalBinaryWithContext(ctx)
  2697. if err != nil {
  2698. return err
  2699. }
  2700. return nil
  2701. }
  2702. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  2703. // the FileSystem type
  2704. func (target *FileSystem) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  2705. // panics are recovered and propagated as errors
  2706. defer func() {
  2707. if r := recover(); r != nil {
  2708. if e, ok := r.(error); ok {
  2709. err = e
  2710. } else if s, ok := r.(string); ok {
  2711. err = fmt.Errorf("unexpected panic: %s", s)
  2712. } else {
  2713. err = fmt.Errorf("unexpected panic: %+v", r)
  2714. }
  2715. }
  2716. }()
  2717. buff := ctx.Buffer
  2718. version := buff.ReadUInt8()
  2719. if version > DefaultCodecVersion {
  2720. return fmt.Errorf("Invalid Version Unmarshalling FileSystem. Expected %d or less, got %d", DefaultCodecVersion, version)
  2721. }
  2722. a := buff.ReadFloat64() // read float64
  2723. target.CapacityBytes = a
  2724. b := buff.ReadFloat64() // read float64
  2725. target.UsageByteAvg = b
  2726. c := buff.ReadFloat64() // read float64
  2727. target.UsageByteMax = c
  2728. return nil
  2729. }
  2730. //--------------------------------------------------------------------------
  2731. // Job
  2732. //--------------------------------------------------------------------------
  2733. // MarshalBinary serializes the internal properties of this Job instance
  2734. // into a byte array
  2735. func (target *Job) MarshalBinary() (data []byte, err error) {
  2736. ctx := NewEncodingContext(nil)
  2737. e := target.MarshalBinaryWithContext(ctx)
  2738. if e != nil {
  2739. return nil, e
  2740. }
  2741. return ctx.ToBytes(), nil
  2742. }
  2743. // MarshalBinary serializes the internal properties of this Job instance
  2744. // into an io.Writer.
  2745. func (target *Job) MarshalBinaryTo(writer io.Writer) error {
  2746. buff := util.NewBufferFromWriter(writer)
  2747. defer buff.Flush()
  2748. ctx := NewEncodingContextFromBuffer(buff, nil)
  2749. return target.MarshalBinaryWithContext(ctx)
  2750. }
  2751. // MarshalBinaryWithContext serializes the internal properties of this Job instance
  2752. // into a byte array leveraging a predefined context.
  2753. func (target *Job) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  2754. // panics are recovered and propagated as errors
  2755. defer func() {
  2756. if r := recover(); r != nil {
  2757. if e, ok := r.(error); ok {
  2758. err = e
  2759. } else if s, ok := r.(string); ok {
  2760. err = fmt.Errorf("unexpected panic: %s", s)
  2761. } else {
  2762. err = fmt.Errorf("unexpected panic: %+v", r)
  2763. }
  2764. }
  2765. }()
  2766. buff := ctx.Buffer
  2767. buff.WriteUInt8(DefaultCodecVersion) // version
  2768. if ctx.IsStringTable() {
  2769. a := ctx.Table.AddOrGet(target.UID)
  2770. buff.WriteInt(a) // write table index
  2771. } else {
  2772. buff.WriteString(target.UID) // write string
  2773. }
  2774. if ctx.IsStringTable() {
  2775. b := ctx.Table.AddOrGet(target.NamespaceUID)
  2776. buff.WriteInt(b) // write table index
  2777. } else {
  2778. buff.WriteString(target.NamespaceUID) // write string
  2779. }
  2780. if ctx.IsStringTable() {
  2781. c := ctx.Table.AddOrGet(target.Name)
  2782. buff.WriteInt(c) // write table index
  2783. } else {
  2784. buff.WriteString(target.Name) // write string
  2785. }
  2786. if target.Labels == nil {
  2787. buff.WriteUInt8(uint8(0)) // write nil byte
  2788. } else {
  2789. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2790. // --- [begin][write][map](map[string]string) ---
  2791. buff.WriteInt(len(target.Labels)) // map length
  2792. for v, z := range target.Labels {
  2793. if ctx.IsStringTable() {
  2794. d := ctx.Table.AddOrGet(v)
  2795. buff.WriteInt(d) // write table index
  2796. } else {
  2797. buff.WriteString(v) // write string
  2798. }
  2799. if ctx.IsStringTable() {
  2800. e := ctx.Table.AddOrGet(z)
  2801. buff.WriteInt(e) // write table index
  2802. } else {
  2803. buff.WriteString(z) // write string
  2804. }
  2805. }
  2806. // --- [end][write][map](map[string]string) ---
  2807. }
  2808. if target.Annotations == nil {
  2809. buff.WriteUInt8(uint8(0)) // write nil byte
  2810. } else {
  2811. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2812. // --- [begin][write][map](map[string]string) ---
  2813. buff.WriteInt(len(target.Annotations)) // map length
  2814. for vv, zz := range target.Annotations {
  2815. if ctx.IsStringTable() {
  2816. f := ctx.Table.AddOrGet(vv)
  2817. buff.WriteInt(f) // write table index
  2818. } else {
  2819. buff.WriteString(vv) // write string
  2820. }
  2821. if ctx.IsStringTable() {
  2822. g := ctx.Table.AddOrGet(zz)
  2823. buff.WriteInt(g) // write table index
  2824. } else {
  2825. buff.WriteString(zz) // write string
  2826. }
  2827. }
  2828. // --- [end][write][map](map[string]string) ---
  2829. }
  2830. // --- [begin][write][reference](time.Time) ---
  2831. h, errA := target.Start.MarshalBinary()
  2832. if errA != nil {
  2833. return errA
  2834. }
  2835. buff.WriteInt(len(h))
  2836. buff.WriteBytes(h)
  2837. // --- [end][write][reference](time.Time) ---
  2838. // --- [begin][write][reference](time.Time) ---
  2839. l, errB := target.End.MarshalBinary()
  2840. if errB != nil {
  2841. return errB
  2842. }
  2843. buff.WriteInt(len(l))
  2844. buff.WriteBytes(l)
  2845. // --- [end][write][reference](time.Time) ---
  2846. return nil
  2847. }
  2848. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2849. // the Job type
  2850. func (target *Job) UnmarshalBinary(data []byte) error {
  2851. ctx := NewDecodingContextFromBytes(data)
  2852. defer ctx.Close()
  2853. err := target.UnmarshalBinaryWithContext(ctx)
  2854. if err != nil {
  2855. return err
  2856. }
  2857. return nil
  2858. }
  2859. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  2860. // the Job type
  2861. func (target *Job) UnmarshalBinaryFromReader(reader io.Reader) error {
  2862. ctx := NewDecodingContextFromReader(reader)
  2863. defer ctx.Close()
  2864. err := target.UnmarshalBinaryWithContext(ctx)
  2865. if err != nil {
  2866. return err
  2867. }
  2868. return nil
  2869. }
  2870. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  2871. // the Job type
  2872. func (target *Job) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  2873. // panics are recovered and propagated as errors
  2874. defer func() {
  2875. if r := recover(); r != nil {
  2876. if e, ok := r.(error); ok {
  2877. err = e
  2878. } else if s, ok := r.(string); ok {
  2879. err = fmt.Errorf("unexpected panic: %s", s)
  2880. } else {
  2881. err = fmt.Errorf("unexpected panic: %+v", r)
  2882. }
  2883. }
  2884. }()
  2885. buff := ctx.Buffer
  2886. version := buff.ReadUInt8()
  2887. if version > DefaultCodecVersion {
  2888. return fmt.Errorf("Invalid Version Unmarshalling Job. Expected %d or less, got %d", DefaultCodecVersion, version)
  2889. }
  2890. var b string
  2891. if ctx.IsStringTable() {
  2892. c := buff.ReadInt() // read string index
  2893. b = ctx.Table.At(c)
  2894. } else {
  2895. b = buff.ReadString() // read string
  2896. }
  2897. a := b
  2898. target.UID = a
  2899. var e string
  2900. if ctx.IsStringTable() {
  2901. f := buff.ReadInt() // read string index
  2902. e = ctx.Table.At(f)
  2903. } else {
  2904. e = buff.ReadString() // read string
  2905. }
  2906. d := e
  2907. target.NamespaceUID = d
  2908. var h string
  2909. if ctx.IsStringTable() {
  2910. l := buff.ReadInt() // read string index
  2911. h = ctx.Table.At(l)
  2912. } else {
  2913. h = buff.ReadString() // read string
  2914. }
  2915. g := h
  2916. target.Name = g
  2917. if buff.ReadUInt8() == uint8(0) {
  2918. target.Labels = nil
  2919. } else {
  2920. // --- [begin][read][map](map[string]string) ---
  2921. n := buff.ReadInt() // map len
  2922. m := make(map[string]string, n)
  2923. for range n {
  2924. var v string
  2925. var p string
  2926. if ctx.IsStringTable() {
  2927. q := buff.ReadInt() // read string index
  2928. p = ctx.Table.At(q)
  2929. } else {
  2930. p = buff.ReadString() // read string
  2931. }
  2932. o := p
  2933. v = o
  2934. var z string
  2935. var s string
  2936. if ctx.IsStringTable() {
  2937. t := buff.ReadInt() // read string index
  2938. s = ctx.Table.At(t)
  2939. } else {
  2940. s = buff.ReadString() // read string
  2941. }
  2942. r := s
  2943. z = r
  2944. m[v] = z
  2945. }
  2946. target.Labels = m
  2947. // --- [end][read][map](map[string]string) ---
  2948. }
  2949. if buff.ReadUInt8() == uint8(0) {
  2950. target.Annotations = nil
  2951. } else {
  2952. // --- [begin][read][map](map[string]string) ---
  2953. w := buff.ReadInt() // map len
  2954. u := make(map[string]string, w)
  2955. for range w {
  2956. var vv string
  2957. var y string
  2958. if ctx.IsStringTable() {
  2959. aa := buff.ReadInt() // read string index
  2960. y = ctx.Table.At(aa)
  2961. } else {
  2962. y = buff.ReadString() // read string
  2963. }
  2964. x := y
  2965. vv = x
  2966. var zz string
  2967. var cc string
  2968. if ctx.IsStringTable() {
  2969. dd := buff.ReadInt() // read string index
  2970. cc = ctx.Table.At(dd)
  2971. } else {
  2972. cc = buff.ReadString() // read string
  2973. }
  2974. bb := cc
  2975. zz = bb
  2976. u[vv] = zz
  2977. }
  2978. target.Annotations = u
  2979. // --- [end][read][map](map[string]string) ---
  2980. }
  2981. // --- [begin][read][reference](time.Time) ---
  2982. ee := new(time.Time)
  2983. ff := buff.ReadInt() // byte array length
  2984. gg := buff.ReadBytes(ff)
  2985. errA := ee.UnmarshalBinary(gg)
  2986. if errA != nil {
  2987. return errA
  2988. }
  2989. target.Start = *ee
  2990. // --- [end][read][reference](time.Time) ---
  2991. // --- [begin][read][reference](time.Time) ---
  2992. hh := new(time.Time)
  2993. ll := buff.ReadInt() // byte array length
  2994. mm := buff.ReadBytes(ll)
  2995. errB := hh.UnmarshalBinary(mm)
  2996. if errB != nil {
  2997. return errB
  2998. }
  2999. target.End = *hh
  3000. // --- [end][read][reference](time.Time) ---
  3001. return nil
  3002. }
  3003. //--------------------------------------------------------------------------
  3004. // KubeModelSet
  3005. //--------------------------------------------------------------------------
  3006. // MarshalBinary serializes the internal properties of this KubeModelSet instance
  3007. // into a byte array
  3008. func (target *KubeModelSet) MarshalBinary() (data []byte, err error) {
  3009. ctx := NewEncodingContext(NewIndexedStringTableWriter())
  3010. e := target.MarshalBinaryWithContext(ctx)
  3011. if e != nil {
  3012. return nil, e
  3013. }
  3014. return ctx.ToBytes(), nil
  3015. }
  3016. // MarshalBinary serializes the internal properties of this KubeModelSet instance
  3017. // into an io.Writer.
  3018. func (target *KubeModelSet) MarshalBinaryTo(writer io.Writer) error {
  3019. buff := util.NewBufferFromWriter(writer)
  3020. defer buff.Flush()
  3021. // run a pre-pass to collect all strings into the string table and discard all writes to the main
  3022. // buffer. Then, we write the string table, sorted by number of repeated uses (descending), to the
  3023. // main buffer, and use the resulting table as part of the context for the main pass.
  3024. prepass := NewPrepassStringTableWriter()
  3025. prepassCtx := NewEncodingContextFromWriter(io.Discard, prepass)
  3026. e := target.MarshalBinaryWithContext(prepassCtx)
  3027. if e != nil {
  3028. return e
  3029. }
  3030. tableWriter := prepass.WriteSortedTo(buff)
  3031. ctx := NewEncodingContextFromBuffer(buff, tableWriter)
  3032. return target.MarshalBinaryWithContext(ctx)
  3033. }
  3034. // MarshalBinaryWithContext serializes the internal properties of this KubeModelSet instance
  3035. // into a byte array leveraging a predefined context.
  3036. func (target *KubeModelSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  3037. // panics are recovered and propagated as errors
  3038. defer func() {
  3039. if r := recover(); r != nil {
  3040. if e, ok := r.(error); ok {
  3041. err = e
  3042. } else if s, ok := r.(string); ok {
  3043. err = fmt.Errorf("unexpected panic: %s", s)
  3044. } else {
  3045. err = fmt.Errorf("unexpected panic: %+v", r)
  3046. }
  3047. }
  3048. }()
  3049. buff := ctx.Buffer
  3050. buff.WriteUInt8(DefaultCodecVersion) // version
  3051. if target.Metadata == nil {
  3052. buff.WriteUInt8(uint8(0)) // write nil byte
  3053. } else {
  3054. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3055. // --- [begin][write][struct](Metadata) ---
  3056. buff.WriteInt(0) // [compatibility, unused]
  3057. errA := target.Metadata.MarshalBinaryWithContext(ctx)
  3058. if errA != nil {
  3059. return errA
  3060. }
  3061. // --- [end][write][struct](Metadata) ---
  3062. }
  3063. // --- [begin][write][struct](Window) ---
  3064. buff.WriteInt(0) // [compatibility, unused]
  3065. errB := target.Window.MarshalBinaryWithContext(ctx)
  3066. if errB != nil {
  3067. return errB
  3068. }
  3069. // --- [end][write][struct](Window) ---
  3070. if target.Cluster == nil {
  3071. buff.WriteUInt8(uint8(0)) // write nil byte
  3072. } else {
  3073. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3074. // --- [begin][write][struct](Cluster) ---
  3075. buff.WriteInt(0) // [compatibility, unused]
  3076. errC := target.Cluster.MarshalBinaryWithContext(ctx)
  3077. if errC != nil {
  3078. return errC
  3079. }
  3080. // --- [end][write][struct](Cluster) ---
  3081. }
  3082. if target.Namespaces == nil {
  3083. buff.WriteUInt8(uint8(0)) // write nil byte
  3084. } else {
  3085. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3086. // --- [begin][write][map](map[string]*Namespace) ---
  3087. buff.WriteInt(len(target.Namespaces)) // map length
  3088. for v, z := range target.Namespaces {
  3089. if ctx.IsStringTable() {
  3090. a := ctx.Table.AddOrGet(v)
  3091. buff.WriteInt(a) // write table index
  3092. } else {
  3093. buff.WriteString(v) // write string
  3094. }
  3095. if z == nil {
  3096. buff.WriteUInt8(uint8(0)) // write nil byte
  3097. } else {
  3098. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3099. // --- [begin][write][struct](Namespace) ---
  3100. buff.WriteInt(0) // [compatibility, unused]
  3101. errD := z.MarshalBinaryWithContext(ctx)
  3102. if errD != nil {
  3103. return errD
  3104. }
  3105. // --- [end][write][struct](Namespace) ---
  3106. }
  3107. }
  3108. // --- [end][write][map](map[string]*Namespace) ---
  3109. }
  3110. if target.ResourceQuotas == nil {
  3111. buff.WriteUInt8(uint8(0)) // write nil byte
  3112. } else {
  3113. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3114. // --- [begin][write][map](map[string]*ResourceQuota) ---
  3115. buff.WriteInt(len(target.ResourceQuotas)) // map length
  3116. for vv, zz := range target.ResourceQuotas {
  3117. if ctx.IsStringTable() {
  3118. b := ctx.Table.AddOrGet(vv)
  3119. buff.WriteInt(b) // write table index
  3120. } else {
  3121. buff.WriteString(vv) // write string
  3122. }
  3123. if zz == nil {
  3124. buff.WriteUInt8(uint8(0)) // write nil byte
  3125. } else {
  3126. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3127. // --- [begin][write][struct](ResourceQuota) ---
  3128. buff.WriteInt(0) // [compatibility, unused]
  3129. errE := zz.MarshalBinaryWithContext(ctx)
  3130. if errE != nil {
  3131. return errE
  3132. }
  3133. // --- [end][write][struct](ResourceQuota) ---
  3134. }
  3135. }
  3136. // --- [end][write][map](map[string]*ResourceQuota) ---
  3137. }
  3138. if target.Services == nil {
  3139. buff.WriteUInt8(uint8(0)) // write nil byte
  3140. } else {
  3141. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3142. // --- [begin][write][map](map[string]*Service) ---
  3143. buff.WriteInt(len(target.Services)) // map length
  3144. for vvv, zzz := range target.Services {
  3145. if ctx.IsStringTable() {
  3146. c := ctx.Table.AddOrGet(vvv)
  3147. buff.WriteInt(c) // write table index
  3148. } else {
  3149. buff.WriteString(vvv) // write string
  3150. }
  3151. if zzz == nil {
  3152. buff.WriteUInt8(uint8(0)) // write nil byte
  3153. } else {
  3154. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3155. // --- [begin][write][struct](Service) ---
  3156. buff.WriteInt(0) // [compatibility, unused]
  3157. errF := zzz.MarshalBinaryWithContext(ctx)
  3158. if errF != nil {
  3159. return errF
  3160. }
  3161. // --- [end][write][struct](Service) ---
  3162. }
  3163. }
  3164. // --- [end][write][map](map[string]*Service) ---
  3165. }
  3166. if target.Deployments == nil {
  3167. buff.WriteUInt8(uint8(0)) // write nil byte
  3168. } else {
  3169. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3170. // --- [begin][write][map](map[string]*Deployment) ---
  3171. buff.WriteInt(len(target.Deployments)) // map length
  3172. for vvvv, zzzz := range target.Deployments {
  3173. if ctx.IsStringTable() {
  3174. d := ctx.Table.AddOrGet(vvvv)
  3175. buff.WriteInt(d) // write table index
  3176. } else {
  3177. buff.WriteString(vvvv) // write string
  3178. }
  3179. if zzzz == nil {
  3180. buff.WriteUInt8(uint8(0)) // write nil byte
  3181. } else {
  3182. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3183. // --- [begin][write][struct](Deployment) ---
  3184. buff.WriteInt(0) // [compatibility, unused]
  3185. errG := zzzz.MarshalBinaryWithContext(ctx)
  3186. if errG != nil {
  3187. return errG
  3188. }
  3189. // --- [end][write][struct](Deployment) ---
  3190. }
  3191. }
  3192. // --- [end][write][map](map[string]*Deployment) ---
  3193. }
  3194. if target.StatefulSets == nil {
  3195. buff.WriteUInt8(uint8(0)) // write nil byte
  3196. } else {
  3197. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3198. // --- [begin][write][map](map[string]*StatefulSet) ---
  3199. buff.WriteInt(len(target.StatefulSets)) // map length
  3200. for vvvvv, zzzzz := range target.StatefulSets {
  3201. if ctx.IsStringTable() {
  3202. e := ctx.Table.AddOrGet(vvvvv)
  3203. buff.WriteInt(e) // write table index
  3204. } else {
  3205. buff.WriteString(vvvvv) // write string
  3206. }
  3207. if zzzzz == nil {
  3208. buff.WriteUInt8(uint8(0)) // write nil byte
  3209. } else {
  3210. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3211. // --- [begin][write][struct](StatefulSet) ---
  3212. buff.WriteInt(0) // [compatibility, unused]
  3213. errH := zzzzz.MarshalBinaryWithContext(ctx)
  3214. if errH != nil {
  3215. return errH
  3216. }
  3217. // --- [end][write][struct](StatefulSet) ---
  3218. }
  3219. }
  3220. // --- [end][write][map](map[string]*StatefulSet) ---
  3221. }
  3222. if target.DaemonSets == nil {
  3223. buff.WriteUInt8(uint8(0)) // write nil byte
  3224. } else {
  3225. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3226. // --- [begin][write][map](map[string]*DaemonSet) ---
  3227. buff.WriteInt(len(target.DaemonSets)) // map length
  3228. for vvvvvv, zzzzzz := range target.DaemonSets {
  3229. if ctx.IsStringTable() {
  3230. f := ctx.Table.AddOrGet(vvvvvv)
  3231. buff.WriteInt(f) // write table index
  3232. } else {
  3233. buff.WriteString(vvvvvv) // write string
  3234. }
  3235. if zzzzzz == nil {
  3236. buff.WriteUInt8(uint8(0)) // write nil byte
  3237. } else {
  3238. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3239. // --- [begin][write][struct](DaemonSet) ---
  3240. buff.WriteInt(0) // [compatibility, unused]
  3241. errI := zzzzzz.MarshalBinaryWithContext(ctx)
  3242. if errI != nil {
  3243. return errI
  3244. }
  3245. // --- [end][write][struct](DaemonSet) ---
  3246. }
  3247. }
  3248. // --- [end][write][map](map[string]*DaemonSet) ---
  3249. }
  3250. if target.Jobs == nil {
  3251. buff.WriteUInt8(uint8(0)) // write nil byte
  3252. } else {
  3253. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3254. // --- [begin][write][map](map[string]*Job) ---
  3255. buff.WriteInt(len(target.Jobs)) // map length
  3256. for vvvvvvv, zzzzzzz := range target.Jobs {
  3257. if ctx.IsStringTable() {
  3258. g := ctx.Table.AddOrGet(vvvvvvv)
  3259. buff.WriteInt(g) // write table index
  3260. } else {
  3261. buff.WriteString(vvvvvvv) // write string
  3262. }
  3263. if zzzzzzz == nil {
  3264. buff.WriteUInt8(uint8(0)) // write nil byte
  3265. } else {
  3266. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3267. // --- [begin][write][struct](Job) ---
  3268. buff.WriteInt(0) // [compatibility, unused]
  3269. errJ := zzzzzzz.MarshalBinaryWithContext(ctx)
  3270. if errJ != nil {
  3271. return errJ
  3272. }
  3273. // --- [end][write][struct](Job) ---
  3274. }
  3275. }
  3276. // --- [end][write][map](map[string]*Job) ---
  3277. }
  3278. if target.CronJobs == nil {
  3279. buff.WriteUInt8(uint8(0)) // write nil byte
  3280. } else {
  3281. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3282. // --- [begin][write][map](map[string]*CronJob) ---
  3283. buff.WriteInt(len(target.CronJobs)) // map length
  3284. for vvvvvvvv, zzzzzzzz := range target.CronJobs {
  3285. if ctx.IsStringTable() {
  3286. h := ctx.Table.AddOrGet(vvvvvvvv)
  3287. buff.WriteInt(h) // write table index
  3288. } else {
  3289. buff.WriteString(vvvvvvvv) // write string
  3290. }
  3291. if zzzzzzzz == nil {
  3292. buff.WriteUInt8(uint8(0)) // write nil byte
  3293. } else {
  3294. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3295. // --- [begin][write][struct](CronJob) ---
  3296. buff.WriteInt(0) // [compatibility, unused]
  3297. errK := zzzzzzzz.MarshalBinaryWithContext(ctx)
  3298. if errK != nil {
  3299. return errK
  3300. }
  3301. // --- [end][write][struct](CronJob) ---
  3302. }
  3303. }
  3304. // --- [end][write][map](map[string]*CronJob) ---
  3305. }
  3306. if target.ReplicaSets == nil {
  3307. buff.WriteUInt8(uint8(0)) // write nil byte
  3308. } else {
  3309. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3310. // --- [begin][write][map](map[string]*ReplicaSet) ---
  3311. buff.WriteInt(len(target.ReplicaSets)) // map length
  3312. for vvvvvvvvv, zzzzzzzzz := range target.ReplicaSets {
  3313. if ctx.IsStringTable() {
  3314. l := ctx.Table.AddOrGet(vvvvvvvvv)
  3315. buff.WriteInt(l) // write table index
  3316. } else {
  3317. buff.WriteString(vvvvvvvvv) // write string
  3318. }
  3319. if zzzzzzzzz == nil {
  3320. buff.WriteUInt8(uint8(0)) // write nil byte
  3321. } else {
  3322. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3323. // --- [begin][write][struct](ReplicaSet) ---
  3324. buff.WriteInt(0) // [compatibility, unused]
  3325. errL := zzzzzzzzz.MarshalBinaryWithContext(ctx)
  3326. if errL != nil {
  3327. return errL
  3328. }
  3329. // --- [end][write][struct](ReplicaSet) ---
  3330. }
  3331. }
  3332. // --- [end][write][map](map[string]*ReplicaSet) ---
  3333. }
  3334. if target.Nodes == nil {
  3335. buff.WriteUInt8(uint8(0)) // write nil byte
  3336. } else {
  3337. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3338. // --- [begin][write][map](map[string]*Node) ---
  3339. buff.WriteInt(len(target.Nodes)) // map length
  3340. for vvvvvvvvvv, zzzzzzzzzz := range target.Nodes {
  3341. if ctx.IsStringTable() {
  3342. m := ctx.Table.AddOrGet(vvvvvvvvvv)
  3343. buff.WriteInt(m) // write table index
  3344. } else {
  3345. buff.WriteString(vvvvvvvvvv) // write string
  3346. }
  3347. if zzzzzzzzzz == nil {
  3348. buff.WriteUInt8(uint8(0)) // write nil byte
  3349. } else {
  3350. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3351. // --- [begin][write][struct](Node) ---
  3352. buff.WriteInt(0) // [compatibility, unused]
  3353. errM := zzzzzzzzzz.MarshalBinaryWithContext(ctx)
  3354. if errM != nil {
  3355. return errM
  3356. }
  3357. // --- [end][write][struct](Node) ---
  3358. }
  3359. }
  3360. // --- [end][write][map](map[string]*Node) ---
  3361. }
  3362. if target.PersistentVolumes == nil {
  3363. buff.WriteUInt8(uint8(0)) // write nil byte
  3364. } else {
  3365. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3366. // --- [begin][write][map](map[string]*PersistentVolume) ---
  3367. buff.WriteInt(len(target.PersistentVolumes)) // map length
  3368. for vvvvvvvvvvv, zzzzzzzzzzz := range target.PersistentVolumes {
  3369. if ctx.IsStringTable() {
  3370. n := ctx.Table.AddOrGet(vvvvvvvvvvv)
  3371. buff.WriteInt(n) // write table index
  3372. } else {
  3373. buff.WriteString(vvvvvvvvvvv) // write string
  3374. }
  3375. if zzzzzzzzzzz == nil {
  3376. buff.WriteUInt8(uint8(0)) // write nil byte
  3377. } else {
  3378. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3379. // --- [begin][write][struct](PersistentVolume) ---
  3380. buff.WriteInt(0) // [compatibility, unused]
  3381. errN := zzzzzzzzzzz.MarshalBinaryWithContext(ctx)
  3382. if errN != nil {
  3383. return errN
  3384. }
  3385. // --- [end][write][struct](PersistentVolume) ---
  3386. }
  3387. }
  3388. // --- [end][write][map](map[string]*PersistentVolume) ---
  3389. }
  3390. if target.PersistentVolumeClaims == nil {
  3391. buff.WriteUInt8(uint8(0)) // write nil byte
  3392. } else {
  3393. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3394. // --- [begin][write][map](map[string]*PersistentVolumeClaim) ---
  3395. buff.WriteInt(len(target.PersistentVolumeClaims)) // map length
  3396. for vvvvvvvvvvvv, zzzzzzzzzzzz := range target.PersistentVolumeClaims {
  3397. if ctx.IsStringTable() {
  3398. o := ctx.Table.AddOrGet(vvvvvvvvvvvv)
  3399. buff.WriteInt(o) // write table index
  3400. } else {
  3401. buff.WriteString(vvvvvvvvvvvv) // write string
  3402. }
  3403. if zzzzzzzzzzzz == nil {
  3404. buff.WriteUInt8(uint8(0)) // write nil byte
  3405. } else {
  3406. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3407. // --- [begin][write][struct](PersistentVolumeClaim) ---
  3408. buff.WriteInt(0) // [compatibility, unused]
  3409. errO := zzzzzzzzzzzz.MarshalBinaryWithContext(ctx)
  3410. if errO != nil {
  3411. return errO
  3412. }
  3413. // --- [end][write][struct](PersistentVolumeClaim) ---
  3414. }
  3415. }
  3416. // --- [end][write][map](map[string]*PersistentVolumeClaim) ---
  3417. }
  3418. if target.Pods == nil {
  3419. buff.WriteUInt8(uint8(0)) // write nil byte
  3420. } else {
  3421. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3422. // --- [begin][write][map](map[string]*Pod) ---
  3423. buff.WriteInt(len(target.Pods)) // map length
  3424. for vvvvvvvvvvvvv, zzzzzzzzzzzzz := range target.Pods {
  3425. if ctx.IsStringTable() {
  3426. p := ctx.Table.AddOrGet(vvvvvvvvvvvvv)
  3427. buff.WriteInt(p) // write table index
  3428. } else {
  3429. buff.WriteString(vvvvvvvvvvvvv) // write string
  3430. }
  3431. if zzzzzzzzzzzzz == nil {
  3432. buff.WriteUInt8(uint8(0)) // write nil byte
  3433. } else {
  3434. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3435. // --- [begin][write][struct](Pod) ---
  3436. buff.WriteInt(0) // [compatibility, unused]
  3437. errP := zzzzzzzzzzzzz.MarshalBinaryWithContext(ctx)
  3438. if errP != nil {
  3439. return errP
  3440. }
  3441. // --- [end][write][struct](Pod) ---
  3442. }
  3443. }
  3444. // --- [end][write][map](map[string]*Pod) ---
  3445. }
  3446. if target.Containers == nil {
  3447. buff.WriteUInt8(uint8(0)) // write nil byte
  3448. } else {
  3449. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3450. // --- [begin][write][map](map[string]*Container) ---
  3451. buff.WriteInt(len(target.Containers)) // map length
  3452. for vvvvvvvvvvvvvv, zzzzzzzzzzzzzz := range target.Containers {
  3453. if ctx.IsStringTable() {
  3454. q := ctx.Table.AddOrGet(vvvvvvvvvvvvvv)
  3455. buff.WriteInt(q) // write table index
  3456. } else {
  3457. buff.WriteString(vvvvvvvvvvvvvv) // write string
  3458. }
  3459. if zzzzzzzzzzzzzz == nil {
  3460. buff.WriteUInt8(uint8(0)) // write nil byte
  3461. } else {
  3462. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3463. // --- [begin][write][struct](Container) ---
  3464. buff.WriteInt(0) // [compatibility, unused]
  3465. errQ := zzzzzzzzzzzzzz.MarshalBinaryWithContext(ctx)
  3466. if errQ != nil {
  3467. return errQ
  3468. }
  3469. // --- [end][write][struct](Container) ---
  3470. }
  3471. }
  3472. // --- [end][write][map](map[string]*Container) ---
  3473. }
  3474. if target.Devices == nil {
  3475. buff.WriteUInt8(uint8(0)) // write nil byte
  3476. } else {
  3477. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3478. // --- [begin][write][map](map[string]*Device) ---
  3479. buff.WriteInt(len(target.Devices)) // map length
  3480. for vvvvvvvvvvvvvvv, zzzzzzzzzzzzzzz := range target.Devices {
  3481. if ctx.IsStringTable() {
  3482. r := ctx.Table.AddOrGet(vvvvvvvvvvvvvvv)
  3483. buff.WriteInt(r) // write table index
  3484. } else {
  3485. buff.WriteString(vvvvvvvvvvvvvvv) // write string
  3486. }
  3487. if zzzzzzzzzzzzzzz == nil {
  3488. buff.WriteUInt8(uint8(0)) // write nil byte
  3489. } else {
  3490. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3491. // --- [begin][write][struct](Device) ---
  3492. buff.WriteInt(0) // [compatibility, unused]
  3493. errR := zzzzzzzzzzzzzzz.MarshalBinaryWithContext(ctx)
  3494. if errR != nil {
  3495. return errR
  3496. }
  3497. // --- [end][write][struct](Device) ---
  3498. }
  3499. }
  3500. // --- [end][write][map](map[string]*Device) ---
  3501. }
  3502. return nil
  3503. }
  3504. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  3505. // the KubeModelSet type
  3506. func (target *KubeModelSet) UnmarshalBinary(data []byte) error {
  3507. ctx := NewDecodingContextFromBytes(data)
  3508. defer ctx.Close()
  3509. err := target.UnmarshalBinaryWithContext(ctx)
  3510. if err != nil {
  3511. return err
  3512. }
  3513. return nil
  3514. }
  3515. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  3516. // the KubeModelSet type
  3517. func (target *KubeModelSet) UnmarshalBinaryFromReader(reader io.Reader) error {
  3518. ctx := NewDecodingContextFromReader(reader)
  3519. defer ctx.Close()
  3520. err := target.UnmarshalBinaryWithContext(ctx)
  3521. if err != nil {
  3522. return err
  3523. }
  3524. return nil
  3525. }
  3526. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  3527. // the KubeModelSet type
  3528. func (target *KubeModelSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  3529. // panics are recovered and propagated as errors
  3530. defer func() {
  3531. if r := recover(); r != nil {
  3532. if e, ok := r.(error); ok {
  3533. err = e
  3534. } else if s, ok := r.(string); ok {
  3535. err = fmt.Errorf("unexpected panic: %s", s)
  3536. } else {
  3537. err = fmt.Errorf("unexpected panic: %+v", r)
  3538. }
  3539. }
  3540. }()
  3541. buff := ctx.Buffer
  3542. version := buff.ReadUInt8()
  3543. if version > DefaultCodecVersion {
  3544. return fmt.Errorf("Invalid Version Unmarshalling KubeModelSet. Expected %d or less, got %d", DefaultCodecVersion, version)
  3545. }
  3546. // field version check
  3547. if uint8(1) <= version {
  3548. if buff.ReadUInt8() == uint8(0) {
  3549. target.Metadata = nil
  3550. } else {
  3551. // --- [begin][read][struct](Metadata) ---
  3552. a := new(Metadata)
  3553. buff.ReadInt() // [compatibility, unused]
  3554. errA := a.UnmarshalBinaryWithContext(ctx)
  3555. if errA != nil {
  3556. return errA
  3557. }
  3558. target.Metadata = a
  3559. // --- [end][read][struct](Metadata) ---
  3560. }
  3561. } else {
  3562. target.Metadata = nil
  3563. }
  3564. // field version check
  3565. if uint8(1) <= version {
  3566. // --- [begin][read][struct](Window) ---
  3567. b := new(Window)
  3568. buff.ReadInt() // [compatibility, unused]
  3569. errB := b.UnmarshalBinaryWithContext(ctx)
  3570. if errB != nil {
  3571. return errB
  3572. }
  3573. target.Window = *b
  3574. // --- [end][read][struct](Window) ---
  3575. } else {
  3576. }
  3577. // field version check
  3578. if uint8(1) <= version {
  3579. if buff.ReadUInt8() == uint8(0) {
  3580. target.Cluster = nil
  3581. } else {
  3582. // --- [begin][read][struct](Cluster) ---
  3583. c := new(Cluster)
  3584. buff.ReadInt() // [compatibility, unused]
  3585. errC := c.UnmarshalBinaryWithContext(ctx)
  3586. if errC != nil {
  3587. return errC
  3588. }
  3589. target.Cluster = c
  3590. // --- [end][read][struct](Cluster) ---
  3591. }
  3592. } else {
  3593. target.Cluster = nil
  3594. }
  3595. // field version check
  3596. if uint8(1) <= version {
  3597. if buff.ReadUInt8() == uint8(0) {
  3598. target.Namespaces = nil
  3599. } else {
  3600. // --- [begin][read][map](map[string]*Namespace) ---
  3601. e := buff.ReadInt() // map len
  3602. d := make(map[string]*Namespace, e)
  3603. for range e {
  3604. var v string
  3605. var g string
  3606. if ctx.IsStringTable() {
  3607. h := buff.ReadInt() // read string index
  3608. g = ctx.Table.At(h)
  3609. } else {
  3610. g = buff.ReadString() // read string
  3611. }
  3612. f := g
  3613. v = f
  3614. var z *Namespace
  3615. if buff.ReadUInt8() == uint8(0) {
  3616. z = nil
  3617. } else {
  3618. // --- [begin][read][struct](Namespace) ---
  3619. l := new(Namespace)
  3620. buff.ReadInt() // [compatibility, unused]
  3621. errD := l.UnmarshalBinaryWithContext(ctx)
  3622. if errD != nil {
  3623. return errD
  3624. }
  3625. z = l
  3626. // --- [end][read][struct](Namespace) ---
  3627. }
  3628. d[v] = z
  3629. }
  3630. target.Namespaces = d
  3631. // --- [end][read][map](map[string]*Namespace) ---
  3632. }
  3633. } else {
  3634. target.Namespaces = nil
  3635. }
  3636. // field version check
  3637. if uint8(1) <= version {
  3638. if buff.ReadUInt8() == uint8(0) {
  3639. target.ResourceQuotas = nil
  3640. } else {
  3641. // --- [begin][read][map](map[string]*ResourceQuota) ---
  3642. n := buff.ReadInt() // map len
  3643. m := make(map[string]*ResourceQuota, n)
  3644. for range n {
  3645. var vv string
  3646. var p string
  3647. if ctx.IsStringTable() {
  3648. q := buff.ReadInt() // read string index
  3649. p = ctx.Table.At(q)
  3650. } else {
  3651. p = buff.ReadString() // read string
  3652. }
  3653. o := p
  3654. vv = o
  3655. var zz *ResourceQuota
  3656. if buff.ReadUInt8() == uint8(0) {
  3657. zz = nil
  3658. } else {
  3659. // --- [begin][read][struct](ResourceQuota) ---
  3660. r := new(ResourceQuota)
  3661. buff.ReadInt() // [compatibility, unused]
  3662. errE := r.UnmarshalBinaryWithContext(ctx)
  3663. if errE != nil {
  3664. return errE
  3665. }
  3666. zz = r
  3667. // --- [end][read][struct](ResourceQuota) ---
  3668. }
  3669. m[vv] = zz
  3670. }
  3671. target.ResourceQuotas = m
  3672. // --- [end][read][map](map[string]*ResourceQuota) ---
  3673. }
  3674. } else {
  3675. target.ResourceQuotas = nil
  3676. }
  3677. // field version check
  3678. if uint8(2) <= version {
  3679. if buff.ReadUInt8() == uint8(0) {
  3680. target.Services = nil
  3681. } else {
  3682. // --- [begin][read][map](map[string]*Service) ---
  3683. t := buff.ReadInt() // map len
  3684. s := make(map[string]*Service, t)
  3685. for range t {
  3686. var vvv string
  3687. var w string
  3688. if ctx.IsStringTable() {
  3689. x := buff.ReadInt() // read string index
  3690. w = ctx.Table.At(x)
  3691. } else {
  3692. w = buff.ReadString() // read string
  3693. }
  3694. u := w
  3695. vvv = u
  3696. var zzz *Service
  3697. if buff.ReadUInt8() == uint8(0) {
  3698. zzz = nil
  3699. } else {
  3700. // --- [begin][read][struct](Service) ---
  3701. y := new(Service)
  3702. buff.ReadInt() // [compatibility, unused]
  3703. errF := y.UnmarshalBinaryWithContext(ctx)
  3704. if errF != nil {
  3705. return errF
  3706. }
  3707. zzz = y
  3708. // --- [end][read][struct](Service) ---
  3709. }
  3710. s[vvv] = zzz
  3711. }
  3712. target.Services = s
  3713. // --- [end][read][map](map[string]*Service) ---
  3714. }
  3715. } else {
  3716. target.Services = nil
  3717. }
  3718. // field version check
  3719. if uint8(2) <= version {
  3720. if buff.ReadUInt8() == uint8(0) {
  3721. target.Deployments = nil
  3722. } else {
  3723. // --- [begin][read][map](map[string]*Deployment) ---
  3724. bb := buff.ReadInt() // map len
  3725. aa := make(map[string]*Deployment, bb)
  3726. for range bb {
  3727. var vvvv string
  3728. var dd string
  3729. if ctx.IsStringTable() {
  3730. ee := buff.ReadInt() // read string index
  3731. dd = ctx.Table.At(ee)
  3732. } else {
  3733. dd = buff.ReadString() // read string
  3734. }
  3735. cc := dd
  3736. vvvv = cc
  3737. var zzzz *Deployment
  3738. if buff.ReadUInt8() == uint8(0) {
  3739. zzzz = nil
  3740. } else {
  3741. // --- [begin][read][struct](Deployment) ---
  3742. ff := new(Deployment)
  3743. buff.ReadInt() // [compatibility, unused]
  3744. errG := ff.UnmarshalBinaryWithContext(ctx)
  3745. if errG != nil {
  3746. return errG
  3747. }
  3748. zzzz = ff
  3749. // --- [end][read][struct](Deployment) ---
  3750. }
  3751. aa[vvvv] = zzzz
  3752. }
  3753. target.Deployments = aa
  3754. // --- [end][read][map](map[string]*Deployment) ---
  3755. }
  3756. } else {
  3757. target.Deployments = nil
  3758. }
  3759. // field version check
  3760. if uint8(2) <= version {
  3761. if buff.ReadUInt8() == uint8(0) {
  3762. target.StatefulSets = nil
  3763. } else {
  3764. // --- [begin][read][map](map[string]*StatefulSet) ---
  3765. hh := buff.ReadInt() // map len
  3766. gg := make(map[string]*StatefulSet, hh)
  3767. for range hh {
  3768. var vvvvv string
  3769. var mm string
  3770. if ctx.IsStringTable() {
  3771. nn := buff.ReadInt() // read string index
  3772. mm = ctx.Table.At(nn)
  3773. } else {
  3774. mm = buff.ReadString() // read string
  3775. }
  3776. ll := mm
  3777. vvvvv = ll
  3778. var zzzzz *StatefulSet
  3779. if buff.ReadUInt8() == uint8(0) {
  3780. zzzzz = nil
  3781. } else {
  3782. // --- [begin][read][struct](StatefulSet) ---
  3783. oo := new(StatefulSet)
  3784. buff.ReadInt() // [compatibility, unused]
  3785. errH := oo.UnmarshalBinaryWithContext(ctx)
  3786. if errH != nil {
  3787. return errH
  3788. }
  3789. zzzzz = oo
  3790. // --- [end][read][struct](StatefulSet) ---
  3791. }
  3792. gg[vvvvv] = zzzzz
  3793. }
  3794. target.StatefulSets = gg
  3795. // --- [end][read][map](map[string]*StatefulSet) ---
  3796. }
  3797. } else {
  3798. target.StatefulSets = nil
  3799. }
  3800. // field version check
  3801. if uint8(2) <= version {
  3802. if buff.ReadUInt8() == uint8(0) {
  3803. target.DaemonSets = nil
  3804. } else {
  3805. // --- [begin][read][map](map[string]*DaemonSet) ---
  3806. qq := buff.ReadInt() // map len
  3807. pp := make(map[string]*DaemonSet, qq)
  3808. for range qq {
  3809. var vvvvvv string
  3810. var ss string
  3811. if ctx.IsStringTable() {
  3812. tt := buff.ReadInt() // read string index
  3813. ss = ctx.Table.At(tt)
  3814. } else {
  3815. ss = buff.ReadString() // read string
  3816. }
  3817. rr := ss
  3818. vvvvvv = rr
  3819. var zzzzzz *DaemonSet
  3820. if buff.ReadUInt8() == uint8(0) {
  3821. zzzzzz = nil
  3822. } else {
  3823. // --- [begin][read][struct](DaemonSet) ---
  3824. uu := new(DaemonSet)
  3825. buff.ReadInt() // [compatibility, unused]
  3826. errI := uu.UnmarshalBinaryWithContext(ctx)
  3827. if errI != nil {
  3828. return errI
  3829. }
  3830. zzzzzz = uu
  3831. // --- [end][read][struct](DaemonSet) ---
  3832. }
  3833. pp[vvvvvv] = zzzzzz
  3834. }
  3835. target.DaemonSets = pp
  3836. // --- [end][read][map](map[string]*DaemonSet) ---
  3837. }
  3838. } else {
  3839. target.DaemonSets = nil
  3840. }
  3841. // field version check
  3842. if uint8(2) <= version {
  3843. if buff.ReadUInt8() == uint8(0) {
  3844. target.Jobs = nil
  3845. } else {
  3846. // --- [begin][read][map](map[string]*Job) ---
  3847. xx := buff.ReadInt() // map len
  3848. ww := make(map[string]*Job, xx)
  3849. for range xx {
  3850. var vvvvvvv string
  3851. var aaa string
  3852. if ctx.IsStringTable() {
  3853. bbb := buff.ReadInt() // read string index
  3854. aaa = ctx.Table.At(bbb)
  3855. } else {
  3856. aaa = buff.ReadString() // read string
  3857. }
  3858. yy := aaa
  3859. vvvvvvv = yy
  3860. var zzzzzzz *Job
  3861. if buff.ReadUInt8() == uint8(0) {
  3862. zzzzzzz = nil
  3863. } else {
  3864. // --- [begin][read][struct](Job) ---
  3865. ccc := new(Job)
  3866. buff.ReadInt() // [compatibility, unused]
  3867. errJ := ccc.UnmarshalBinaryWithContext(ctx)
  3868. if errJ != nil {
  3869. return errJ
  3870. }
  3871. zzzzzzz = ccc
  3872. // --- [end][read][struct](Job) ---
  3873. }
  3874. ww[vvvvvvv] = zzzzzzz
  3875. }
  3876. target.Jobs = ww
  3877. // --- [end][read][map](map[string]*Job) ---
  3878. }
  3879. } else {
  3880. target.Jobs = nil
  3881. }
  3882. // field version check
  3883. if uint8(2) <= version {
  3884. if buff.ReadUInt8() == uint8(0) {
  3885. target.CronJobs = nil
  3886. } else {
  3887. // --- [begin][read][map](map[string]*CronJob) ---
  3888. eee := buff.ReadInt() // map len
  3889. ddd := make(map[string]*CronJob, eee)
  3890. for range eee {
  3891. var vvvvvvvv string
  3892. var ggg string
  3893. if ctx.IsStringTable() {
  3894. hhh := buff.ReadInt() // read string index
  3895. ggg = ctx.Table.At(hhh)
  3896. } else {
  3897. ggg = buff.ReadString() // read string
  3898. }
  3899. fff := ggg
  3900. vvvvvvvv = fff
  3901. var zzzzzzzz *CronJob
  3902. if buff.ReadUInt8() == uint8(0) {
  3903. zzzzzzzz = nil
  3904. } else {
  3905. // --- [begin][read][struct](CronJob) ---
  3906. lll := new(CronJob)
  3907. buff.ReadInt() // [compatibility, unused]
  3908. errK := lll.UnmarshalBinaryWithContext(ctx)
  3909. if errK != nil {
  3910. return errK
  3911. }
  3912. zzzzzzzz = lll
  3913. // --- [end][read][struct](CronJob) ---
  3914. }
  3915. ddd[vvvvvvvv] = zzzzzzzz
  3916. }
  3917. target.CronJobs = ddd
  3918. // --- [end][read][map](map[string]*CronJob) ---
  3919. }
  3920. } else {
  3921. target.CronJobs = nil
  3922. }
  3923. // field version check
  3924. if uint8(2) <= version {
  3925. if buff.ReadUInt8() == uint8(0) {
  3926. target.ReplicaSets = nil
  3927. } else {
  3928. // --- [begin][read][map](map[string]*ReplicaSet) ---
  3929. nnn := buff.ReadInt() // map len
  3930. mmm := make(map[string]*ReplicaSet, nnn)
  3931. for range nnn {
  3932. var vvvvvvvvv string
  3933. var ppp string
  3934. if ctx.IsStringTable() {
  3935. qqq := buff.ReadInt() // read string index
  3936. ppp = ctx.Table.At(qqq)
  3937. } else {
  3938. ppp = buff.ReadString() // read string
  3939. }
  3940. ooo := ppp
  3941. vvvvvvvvv = ooo
  3942. var zzzzzzzzz *ReplicaSet
  3943. if buff.ReadUInt8() == uint8(0) {
  3944. zzzzzzzzz = nil
  3945. } else {
  3946. // --- [begin][read][struct](ReplicaSet) ---
  3947. rrr := new(ReplicaSet)
  3948. buff.ReadInt() // [compatibility, unused]
  3949. errL := rrr.UnmarshalBinaryWithContext(ctx)
  3950. if errL != nil {
  3951. return errL
  3952. }
  3953. zzzzzzzzz = rrr
  3954. // --- [end][read][struct](ReplicaSet) ---
  3955. }
  3956. mmm[vvvvvvvvv] = zzzzzzzzz
  3957. }
  3958. target.ReplicaSets = mmm
  3959. // --- [end][read][map](map[string]*ReplicaSet) ---
  3960. }
  3961. } else {
  3962. target.ReplicaSets = nil
  3963. }
  3964. // field version check
  3965. if uint8(2) <= version {
  3966. if buff.ReadUInt8() == uint8(0) {
  3967. target.Nodes = nil
  3968. } else {
  3969. // --- [begin][read][map](map[string]*Node) ---
  3970. ttt := buff.ReadInt() // map len
  3971. sss := make(map[string]*Node, ttt)
  3972. for range ttt {
  3973. var vvvvvvvvvv string
  3974. var www string
  3975. if ctx.IsStringTable() {
  3976. xxx := buff.ReadInt() // read string index
  3977. www = ctx.Table.At(xxx)
  3978. } else {
  3979. www = buff.ReadString() // read string
  3980. }
  3981. uuu := www
  3982. vvvvvvvvvv = uuu
  3983. var zzzzzzzzzz *Node
  3984. if buff.ReadUInt8() == uint8(0) {
  3985. zzzzzzzzzz = nil
  3986. } else {
  3987. // --- [begin][read][struct](Node) ---
  3988. yyy := new(Node)
  3989. buff.ReadInt() // [compatibility, unused]
  3990. errM := yyy.UnmarshalBinaryWithContext(ctx)
  3991. if errM != nil {
  3992. return errM
  3993. }
  3994. zzzzzzzzzz = yyy
  3995. // --- [end][read][struct](Node) ---
  3996. }
  3997. sss[vvvvvvvvvv] = zzzzzzzzzz
  3998. }
  3999. target.Nodes = sss
  4000. // --- [end][read][map](map[string]*Node) ---
  4001. }
  4002. } else {
  4003. target.Nodes = nil
  4004. }
  4005. // field version check
  4006. if uint8(2) <= version {
  4007. if buff.ReadUInt8() == uint8(0) {
  4008. target.PersistentVolumes = nil
  4009. } else {
  4010. // --- [begin][read][map](map[string]*PersistentVolume) ---
  4011. bbbb := buff.ReadInt() // map len
  4012. aaaa := make(map[string]*PersistentVolume, bbbb)
  4013. for range bbbb {
  4014. var vvvvvvvvvvv string
  4015. var dddd string
  4016. if ctx.IsStringTable() {
  4017. eeee := buff.ReadInt() // read string index
  4018. dddd = ctx.Table.At(eeee)
  4019. } else {
  4020. dddd = buff.ReadString() // read string
  4021. }
  4022. cccc := dddd
  4023. vvvvvvvvvvv = cccc
  4024. var zzzzzzzzzzz *PersistentVolume
  4025. if buff.ReadUInt8() == uint8(0) {
  4026. zzzzzzzzzzz = nil
  4027. } else {
  4028. // --- [begin][read][struct](PersistentVolume) ---
  4029. ffff := new(PersistentVolume)
  4030. buff.ReadInt() // [compatibility, unused]
  4031. errN := ffff.UnmarshalBinaryWithContext(ctx)
  4032. if errN != nil {
  4033. return errN
  4034. }
  4035. zzzzzzzzzzz = ffff
  4036. // --- [end][read][struct](PersistentVolume) ---
  4037. }
  4038. aaaa[vvvvvvvvvvv] = zzzzzzzzzzz
  4039. }
  4040. target.PersistentVolumes = aaaa
  4041. // --- [end][read][map](map[string]*PersistentVolume) ---
  4042. }
  4043. } else {
  4044. target.PersistentVolumes = nil
  4045. }
  4046. // field version check
  4047. if uint8(2) <= version {
  4048. if buff.ReadUInt8() == uint8(0) {
  4049. target.PersistentVolumeClaims = nil
  4050. } else {
  4051. // --- [begin][read][map](map[string]*PersistentVolumeClaim) ---
  4052. hhhh := buff.ReadInt() // map len
  4053. gggg := make(map[string]*PersistentVolumeClaim, hhhh)
  4054. for range hhhh {
  4055. var vvvvvvvvvvvv string
  4056. var mmmm string
  4057. if ctx.IsStringTable() {
  4058. nnnn := buff.ReadInt() // read string index
  4059. mmmm = ctx.Table.At(nnnn)
  4060. } else {
  4061. mmmm = buff.ReadString() // read string
  4062. }
  4063. llll := mmmm
  4064. vvvvvvvvvvvv = llll
  4065. var zzzzzzzzzzzz *PersistentVolumeClaim
  4066. if buff.ReadUInt8() == uint8(0) {
  4067. zzzzzzzzzzzz = nil
  4068. } else {
  4069. // --- [begin][read][struct](PersistentVolumeClaim) ---
  4070. oooo := new(PersistentVolumeClaim)
  4071. buff.ReadInt() // [compatibility, unused]
  4072. errO := oooo.UnmarshalBinaryWithContext(ctx)
  4073. if errO != nil {
  4074. return errO
  4075. }
  4076. zzzzzzzzzzzz = oooo
  4077. // --- [end][read][struct](PersistentVolumeClaim) ---
  4078. }
  4079. gggg[vvvvvvvvvvvv] = zzzzzzzzzzzz
  4080. }
  4081. target.PersistentVolumeClaims = gggg
  4082. // --- [end][read][map](map[string]*PersistentVolumeClaim) ---
  4083. }
  4084. } else {
  4085. target.PersistentVolumeClaims = nil
  4086. }
  4087. // field version check
  4088. if uint8(2) <= version {
  4089. if buff.ReadUInt8() == uint8(0) {
  4090. target.Pods = nil
  4091. } else {
  4092. // --- [begin][read][map](map[string]*Pod) ---
  4093. qqqq := buff.ReadInt() // map len
  4094. pppp := make(map[string]*Pod, qqqq)
  4095. for range qqqq {
  4096. var vvvvvvvvvvvvv string
  4097. var ssss string
  4098. if ctx.IsStringTable() {
  4099. tttt := buff.ReadInt() // read string index
  4100. ssss = ctx.Table.At(tttt)
  4101. } else {
  4102. ssss = buff.ReadString() // read string
  4103. }
  4104. rrrr := ssss
  4105. vvvvvvvvvvvvv = rrrr
  4106. var zzzzzzzzzzzzz *Pod
  4107. if buff.ReadUInt8() == uint8(0) {
  4108. zzzzzzzzzzzzz = nil
  4109. } else {
  4110. // --- [begin][read][struct](Pod) ---
  4111. uuuu := new(Pod)
  4112. buff.ReadInt() // [compatibility, unused]
  4113. errP := uuuu.UnmarshalBinaryWithContext(ctx)
  4114. if errP != nil {
  4115. return errP
  4116. }
  4117. zzzzzzzzzzzzz = uuuu
  4118. // --- [end][read][struct](Pod) ---
  4119. }
  4120. pppp[vvvvvvvvvvvvv] = zzzzzzzzzzzzz
  4121. }
  4122. target.Pods = pppp
  4123. // --- [end][read][map](map[string]*Pod) ---
  4124. }
  4125. } else {
  4126. target.Pods = nil
  4127. }
  4128. // field version check
  4129. if uint8(2) <= version {
  4130. if buff.ReadUInt8() == uint8(0) {
  4131. target.Containers = nil
  4132. } else {
  4133. // --- [begin][read][map](map[string]*Container) ---
  4134. xxxx := buff.ReadInt() // map len
  4135. wwww := make(map[string]*Container, xxxx)
  4136. for range xxxx {
  4137. var vvvvvvvvvvvvvv string
  4138. var aaaaa string
  4139. if ctx.IsStringTable() {
  4140. bbbbb := buff.ReadInt() // read string index
  4141. aaaaa = ctx.Table.At(bbbbb)
  4142. } else {
  4143. aaaaa = buff.ReadString() // read string
  4144. }
  4145. yyyy := aaaaa
  4146. vvvvvvvvvvvvvv = yyyy
  4147. var zzzzzzzzzzzzzz *Container
  4148. if buff.ReadUInt8() == uint8(0) {
  4149. zzzzzzzzzzzzzz = nil
  4150. } else {
  4151. // --- [begin][read][struct](Container) ---
  4152. ccccc := new(Container)
  4153. buff.ReadInt() // [compatibility, unused]
  4154. errQ := ccccc.UnmarshalBinaryWithContext(ctx)
  4155. if errQ != nil {
  4156. return errQ
  4157. }
  4158. zzzzzzzzzzzzzz = ccccc
  4159. // --- [end][read][struct](Container) ---
  4160. }
  4161. wwww[vvvvvvvvvvvvvv] = zzzzzzzzzzzzzz
  4162. }
  4163. target.Containers = wwww
  4164. // --- [end][read][map](map[string]*Container) ---
  4165. }
  4166. } else {
  4167. target.Containers = nil
  4168. }
  4169. // field version check
  4170. if uint8(3) <= version {
  4171. if buff.ReadUInt8() == uint8(0) {
  4172. target.Devices = nil
  4173. } else {
  4174. // --- [begin][read][map](map[string]*Device) ---
  4175. eeeee := buff.ReadInt() // map len
  4176. ddddd := make(map[string]*Device, eeeee)
  4177. for range eeeee {
  4178. var vvvvvvvvvvvvvvv string
  4179. var ggggg string
  4180. if ctx.IsStringTable() {
  4181. hhhhh := buff.ReadInt() // read string index
  4182. ggggg = ctx.Table.At(hhhhh)
  4183. } else {
  4184. ggggg = buff.ReadString() // read string
  4185. }
  4186. fffff := ggggg
  4187. vvvvvvvvvvvvvvv = fffff
  4188. var zzzzzzzzzzzzzzz *Device
  4189. if buff.ReadUInt8() == uint8(0) {
  4190. zzzzzzzzzzzzzzz = nil
  4191. } else {
  4192. // --- [begin][read][struct](Device) ---
  4193. lllll := new(Device)
  4194. buff.ReadInt() // [compatibility, unused]
  4195. errR := lllll.UnmarshalBinaryWithContext(ctx)
  4196. if errR != nil {
  4197. return errR
  4198. }
  4199. zzzzzzzzzzzzzzz = lllll
  4200. // --- [end][read][struct](Device) ---
  4201. }
  4202. ddddd[vvvvvvvvvvvvvvv] = zzzzzzzzzzzzzzz
  4203. }
  4204. target.Devices = ddddd
  4205. // --- [end][read][map](map[string]*Device) ---
  4206. }
  4207. } else {
  4208. target.Devices = nil
  4209. }
  4210. return nil
  4211. }
  4212. //--------------------------------------------------------------------------
  4213. // KubeModelSetStream
  4214. //--------------------------------------------------------------------------
  4215. // KubeModelSetStream is a single use field stream for the contents of an KubeModelSet instance. Instead of creating an instance and populating
  4216. // the fields on that instance, we provide a streaming iterator which yields (BingenFieldInfo, *BingenValue) tuples for each
  4217. // streamable element. All slices and maps will be flattened one depth and each element streamed individually.
  4218. type KubeModelSetStream struct {
  4219. reader io.Reader
  4220. ctx *DecodingContext
  4221. err error
  4222. }
  4223. // Closes closes the internal io.Reader used to read and parse the KubeModelSet fields.
  4224. // This should be called once the stream is no longer needed.
  4225. func (stream *KubeModelSetStream) Close() {
  4226. if closer, ok := stream.reader.(io.Closer); ok {
  4227. closer.Close()
  4228. }
  4229. stream.ctx.Close()
  4230. }
  4231. // Error returns an error if one occurred during the process of streaming the KubeModelSet
  4232. // This can be checked after iterating through the Stream().
  4233. func (stream *KubeModelSetStream) Error() error {
  4234. return stream.err
  4235. }
  4236. // NewKubeModelSetStream creates a new KubeModelSetStream, which uses the io.Reader data to stream all internal fields of an KubeModelSet instance
  4237. func NewKubeModelSetStream(reader io.Reader) BingenStream {
  4238. ctx := NewDecodingContextFromReader(reader)
  4239. return &KubeModelSetStream{
  4240. ctx: ctx,
  4241. reader: reader,
  4242. }
  4243. }
  4244. // Stream returns the iterator which will stream each field of the target type.
  4245. func (stream *KubeModelSetStream) Stream() iter.Seq2[BingenFieldInfo, *BingenValue] {
  4246. return func(yield func(BingenFieldInfo, *BingenValue) bool) {
  4247. var fi BingenFieldInfo
  4248. ctx := stream.ctx
  4249. buff := ctx.Buffer
  4250. version := buff.ReadUInt8()
  4251. if version > DefaultCodecVersion {
  4252. stream.err = fmt.Errorf("Invalid Version Unmarshalling KubeModelSet. Expected %d or less, got %d", DefaultCodecVersion, version)
  4253. return
  4254. }
  4255. fi = BingenFieldInfo{
  4256. Type: reflect.TypeFor[*Metadata](),
  4257. Name: "Metadata",
  4258. }
  4259. // field version check
  4260. if uint8(1) <= version {
  4261. if buff.ReadUInt8() == uint8(0) {
  4262. if !yield(fi, nil) {
  4263. return
  4264. }
  4265. } else {
  4266. // --- [begin][read][struct](Metadata) ---
  4267. b := new(Metadata)
  4268. buff.ReadInt() // [compatibility, unused]
  4269. errA := b.UnmarshalBinaryWithContext(ctx)
  4270. if errA != nil {
  4271. stream.err = errA
  4272. return
  4273. }
  4274. a := b
  4275. // --- [end][read][struct](Metadata) ---
  4276. if !yield(fi, singleV(a)) {
  4277. return
  4278. }
  4279. }
  4280. } else {
  4281. if !yield(fi, nil) {
  4282. return
  4283. }
  4284. }
  4285. fi = BingenFieldInfo{
  4286. Type: reflect.TypeFor[Window](),
  4287. Name: "Window",
  4288. }
  4289. // field version check
  4290. if uint8(1) <= version {
  4291. // --- [begin][read][struct](Window) ---
  4292. d := new(Window)
  4293. buff.ReadInt() // [compatibility, unused]
  4294. errB := d.UnmarshalBinaryWithContext(ctx)
  4295. if errB != nil {
  4296. stream.err = errB
  4297. return
  4298. }
  4299. c := *d
  4300. // --- [end][read][struct](Window) ---
  4301. if !yield(fi, singleV(c)) {
  4302. return
  4303. }
  4304. } else {
  4305. }
  4306. fi = BingenFieldInfo{
  4307. Type: reflect.TypeFor[*Cluster](),
  4308. Name: "Cluster",
  4309. }
  4310. // field version check
  4311. if uint8(1) <= version {
  4312. if buff.ReadUInt8() == uint8(0) {
  4313. if !yield(fi, nil) {
  4314. return
  4315. }
  4316. } else {
  4317. // --- [begin][read][struct](Cluster) ---
  4318. f := new(Cluster)
  4319. buff.ReadInt() // [compatibility, unused]
  4320. errC := f.UnmarshalBinaryWithContext(ctx)
  4321. if errC != nil {
  4322. stream.err = errC
  4323. return
  4324. }
  4325. e := f
  4326. // --- [end][read][struct](Cluster) ---
  4327. if !yield(fi, singleV(e)) {
  4328. return
  4329. }
  4330. }
  4331. } else {
  4332. if !yield(fi, nil) {
  4333. return
  4334. }
  4335. }
  4336. fi = BingenFieldInfo{
  4337. Type: reflect.TypeFor[map[string]*Namespace](),
  4338. Name: "Namespaces",
  4339. }
  4340. // field version check
  4341. if uint8(1) <= version {
  4342. if buff.ReadUInt8() == uint8(0) {
  4343. if !yield(fi, nil) {
  4344. return
  4345. }
  4346. } else {
  4347. // --- [begin][read][streaming-map](map[string]*Namespace) ---
  4348. g := buff.ReadInt() // map len
  4349. for range g {
  4350. var v string
  4351. var l string
  4352. if ctx.IsStringTable() {
  4353. m := buff.ReadInt() // read string index
  4354. l = ctx.Table.At(m)
  4355. } else {
  4356. l = buff.ReadString() // read string
  4357. }
  4358. h := l
  4359. v = h
  4360. var z *Namespace
  4361. if buff.ReadUInt8() == uint8(0) {
  4362. z = nil
  4363. } else {
  4364. // --- [begin][read][struct](Namespace) ---
  4365. n := new(Namespace)
  4366. buff.ReadInt() // [compatibility, unused]
  4367. errD := n.UnmarshalBinaryWithContext(ctx)
  4368. if errD != nil {
  4369. stream.err = errD
  4370. return
  4371. }
  4372. z = n
  4373. // --- [end][read][struct](Namespace) ---
  4374. }
  4375. if !yield(fi, pairV(v, z)) {
  4376. return
  4377. }
  4378. }
  4379. // --- [end][read][streaming-map](map[string]*Namespace) ---
  4380. }
  4381. } else {
  4382. if !yield(fi, nil) {
  4383. return
  4384. }
  4385. }
  4386. fi = BingenFieldInfo{
  4387. Type: reflect.TypeFor[map[string]*ResourceQuota](),
  4388. Name: "ResourceQuotas",
  4389. }
  4390. // field version check
  4391. if uint8(1) <= version {
  4392. if buff.ReadUInt8() == uint8(0) {
  4393. if !yield(fi, nil) {
  4394. return
  4395. }
  4396. } else {
  4397. // --- [begin][read][streaming-map](map[string]*ResourceQuota) ---
  4398. o := buff.ReadInt() // map len
  4399. for range o {
  4400. var vv string
  4401. var q string
  4402. if ctx.IsStringTable() {
  4403. r := buff.ReadInt() // read string index
  4404. q = ctx.Table.At(r)
  4405. } else {
  4406. q = buff.ReadString() // read string
  4407. }
  4408. p := q
  4409. vv = p
  4410. var zz *ResourceQuota
  4411. if buff.ReadUInt8() == uint8(0) {
  4412. zz = nil
  4413. } else {
  4414. // --- [begin][read][struct](ResourceQuota) ---
  4415. s := new(ResourceQuota)
  4416. buff.ReadInt() // [compatibility, unused]
  4417. errE := s.UnmarshalBinaryWithContext(ctx)
  4418. if errE != nil {
  4419. stream.err = errE
  4420. return
  4421. }
  4422. zz = s
  4423. // --- [end][read][struct](ResourceQuota) ---
  4424. }
  4425. if !yield(fi, pairV(vv, zz)) {
  4426. return
  4427. }
  4428. }
  4429. // --- [end][read][streaming-map](map[string]*ResourceQuota) ---
  4430. }
  4431. } else {
  4432. if !yield(fi, nil) {
  4433. return
  4434. }
  4435. }
  4436. fi = BingenFieldInfo{
  4437. Type: reflect.TypeFor[map[string]*Service](),
  4438. Name: "Services",
  4439. }
  4440. // field version check
  4441. if uint8(2) <= version {
  4442. if buff.ReadUInt8() == uint8(0) {
  4443. if !yield(fi, nil) {
  4444. return
  4445. }
  4446. } else {
  4447. // --- [begin][read][streaming-map](map[string]*Service) ---
  4448. t := buff.ReadInt() // map len
  4449. for range t {
  4450. var vvv string
  4451. var w string
  4452. if ctx.IsStringTable() {
  4453. x := buff.ReadInt() // read string index
  4454. w = ctx.Table.At(x)
  4455. } else {
  4456. w = buff.ReadString() // read string
  4457. }
  4458. u := w
  4459. vvv = u
  4460. var zzz *Service
  4461. if buff.ReadUInt8() == uint8(0) {
  4462. zzz = nil
  4463. } else {
  4464. // --- [begin][read][struct](Service) ---
  4465. y := new(Service)
  4466. buff.ReadInt() // [compatibility, unused]
  4467. errF := y.UnmarshalBinaryWithContext(ctx)
  4468. if errF != nil {
  4469. stream.err = errF
  4470. return
  4471. }
  4472. zzz = y
  4473. // --- [end][read][struct](Service) ---
  4474. }
  4475. if !yield(fi, pairV(vvv, zzz)) {
  4476. return
  4477. }
  4478. }
  4479. // --- [end][read][streaming-map](map[string]*Service) ---
  4480. }
  4481. } else {
  4482. if !yield(fi, nil) {
  4483. return
  4484. }
  4485. }
  4486. fi = BingenFieldInfo{
  4487. Type: reflect.TypeFor[map[string]*Deployment](),
  4488. Name: "Deployments",
  4489. }
  4490. // field version check
  4491. if uint8(2) <= version {
  4492. if buff.ReadUInt8() == uint8(0) {
  4493. if !yield(fi, nil) {
  4494. return
  4495. }
  4496. } else {
  4497. // --- [begin][read][streaming-map](map[string]*Deployment) ---
  4498. aa := buff.ReadInt() // map len
  4499. for range aa {
  4500. var vvvv string
  4501. var cc string
  4502. if ctx.IsStringTable() {
  4503. dd := buff.ReadInt() // read string index
  4504. cc = ctx.Table.At(dd)
  4505. } else {
  4506. cc = buff.ReadString() // read string
  4507. }
  4508. bb := cc
  4509. vvvv = bb
  4510. var zzzz *Deployment
  4511. if buff.ReadUInt8() == uint8(0) {
  4512. zzzz = nil
  4513. } else {
  4514. // --- [begin][read][struct](Deployment) ---
  4515. ee := new(Deployment)
  4516. buff.ReadInt() // [compatibility, unused]
  4517. errG := ee.UnmarshalBinaryWithContext(ctx)
  4518. if errG != nil {
  4519. stream.err = errG
  4520. return
  4521. }
  4522. zzzz = ee
  4523. // --- [end][read][struct](Deployment) ---
  4524. }
  4525. if !yield(fi, pairV(vvvv, zzzz)) {
  4526. return
  4527. }
  4528. }
  4529. // --- [end][read][streaming-map](map[string]*Deployment) ---
  4530. }
  4531. } else {
  4532. if !yield(fi, nil) {
  4533. return
  4534. }
  4535. }
  4536. fi = BingenFieldInfo{
  4537. Type: reflect.TypeFor[map[string]*StatefulSet](),
  4538. Name: "StatefulSets",
  4539. }
  4540. // field version check
  4541. if uint8(2) <= version {
  4542. if buff.ReadUInt8() == uint8(0) {
  4543. if !yield(fi, nil) {
  4544. return
  4545. }
  4546. } else {
  4547. // --- [begin][read][streaming-map](map[string]*StatefulSet) ---
  4548. ff := buff.ReadInt() // map len
  4549. for range ff {
  4550. var vvvvv string
  4551. var hh string
  4552. if ctx.IsStringTable() {
  4553. ll := buff.ReadInt() // read string index
  4554. hh = ctx.Table.At(ll)
  4555. } else {
  4556. hh = buff.ReadString() // read string
  4557. }
  4558. gg := hh
  4559. vvvvv = gg
  4560. var zzzzz *StatefulSet
  4561. if buff.ReadUInt8() == uint8(0) {
  4562. zzzzz = nil
  4563. } else {
  4564. // --- [begin][read][struct](StatefulSet) ---
  4565. mm := new(StatefulSet)
  4566. buff.ReadInt() // [compatibility, unused]
  4567. errH := mm.UnmarshalBinaryWithContext(ctx)
  4568. if errH != nil {
  4569. stream.err = errH
  4570. return
  4571. }
  4572. zzzzz = mm
  4573. // --- [end][read][struct](StatefulSet) ---
  4574. }
  4575. if !yield(fi, pairV(vvvvv, zzzzz)) {
  4576. return
  4577. }
  4578. }
  4579. // --- [end][read][streaming-map](map[string]*StatefulSet) ---
  4580. }
  4581. } else {
  4582. if !yield(fi, nil) {
  4583. return
  4584. }
  4585. }
  4586. fi = BingenFieldInfo{
  4587. Type: reflect.TypeFor[map[string]*DaemonSet](),
  4588. Name: "DaemonSets",
  4589. }
  4590. // field version check
  4591. if uint8(2) <= version {
  4592. if buff.ReadUInt8() == uint8(0) {
  4593. if !yield(fi, nil) {
  4594. return
  4595. }
  4596. } else {
  4597. // --- [begin][read][streaming-map](map[string]*DaemonSet) ---
  4598. nn := buff.ReadInt() // map len
  4599. for range nn {
  4600. var vvvvvv string
  4601. var pp string
  4602. if ctx.IsStringTable() {
  4603. qq := buff.ReadInt() // read string index
  4604. pp = ctx.Table.At(qq)
  4605. } else {
  4606. pp = buff.ReadString() // read string
  4607. }
  4608. oo := pp
  4609. vvvvvv = oo
  4610. var zzzzzz *DaemonSet
  4611. if buff.ReadUInt8() == uint8(0) {
  4612. zzzzzz = nil
  4613. } else {
  4614. // --- [begin][read][struct](DaemonSet) ---
  4615. rr := new(DaemonSet)
  4616. buff.ReadInt() // [compatibility, unused]
  4617. errI := rr.UnmarshalBinaryWithContext(ctx)
  4618. if errI != nil {
  4619. stream.err = errI
  4620. return
  4621. }
  4622. zzzzzz = rr
  4623. // --- [end][read][struct](DaemonSet) ---
  4624. }
  4625. if !yield(fi, pairV(vvvvvv, zzzzzz)) {
  4626. return
  4627. }
  4628. }
  4629. // --- [end][read][streaming-map](map[string]*DaemonSet) ---
  4630. }
  4631. } else {
  4632. if !yield(fi, nil) {
  4633. return
  4634. }
  4635. }
  4636. fi = BingenFieldInfo{
  4637. Type: reflect.TypeFor[map[string]*Job](),
  4638. Name: "Jobs",
  4639. }
  4640. // field version check
  4641. if uint8(2) <= version {
  4642. if buff.ReadUInt8() == uint8(0) {
  4643. if !yield(fi, nil) {
  4644. return
  4645. }
  4646. } else {
  4647. // --- [begin][read][streaming-map](map[string]*Job) ---
  4648. ss := buff.ReadInt() // map len
  4649. for range ss {
  4650. var vvvvvvv string
  4651. var uu string
  4652. if ctx.IsStringTable() {
  4653. ww := buff.ReadInt() // read string index
  4654. uu = ctx.Table.At(ww)
  4655. } else {
  4656. uu = buff.ReadString() // read string
  4657. }
  4658. tt := uu
  4659. vvvvvvv = tt
  4660. var zzzzzzz *Job
  4661. if buff.ReadUInt8() == uint8(0) {
  4662. zzzzzzz = nil
  4663. } else {
  4664. // --- [begin][read][struct](Job) ---
  4665. xx := new(Job)
  4666. buff.ReadInt() // [compatibility, unused]
  4667. errJ := xx.UnmarshalBinaryWithContext(ctx)
  4668. if errJ != nil {
  4669. stream.err = errJ
  4670. return
  4671. }
  4672. zzzzzzz = xx
  4673. // --- [end][read][struct](Job) ---
  4674. }
  4675. if !yield(fi, pairV(vvvvvvv, zzzzzzz)) {
  4676. return
  4677. }
  4678. }
  4679. // --- [end][read][streaming-map](map[string]*Job) ---
  4680. }
  4681. } else {
  4682. if !yield(fi, nil) {
  4683. return
  4684. }
  4685. }
  4686. fi = BingenFieldInfo{
  4687. Type: reflect.TypeFor[map[string]*CronJob](),
  4688. Name: "CronJobs",
  4689. }
  4690. // field version check
  4691. if uint8(2) <= version {
  4692. if buff.ReadUInt8() == uint8(0) {
  4693. if !yield(fi, nil) {
  4694. return
  4695. }
  4696. } else {
  4697. // --- [begin][read][streaming-map](map[string]*CronJob) ---
  4698. yy := buff.ReadInt() // map len
  4699. for range yy {
  4700. var vvvvvvvv string
  4701. var bbb string
  4702. if ctx.IsStringTable() {
  4703. ccc := buff.ReadInt() // read string index
  4704. bbb = ctx.Table.At(ccc)
  4705. } else {
  4706. bbb = buff.ReadString() // read string
  4707. }
  4708. aaa := bbb
  4709. vvvvvvvv = aaa
  4710. var zzzzzzzz *CronJob
  4711. if buff.ReadUInt8() == uint8(0) {
  4712. zzzzzzzz = nil
  4713. } else {
  4714. // --- [begin][read][struct](CronJob) ---
  4715. ddd := new(CronJob)
  4716. buff.ReadInt() // [compatibility, unused]
  4717. errK := ddd.UnmarshalBinaryWithContext(ctx)
  4718. if errK != nil {
  4719. stream.err = errK
  4720. return
  4721. }
  4722. zzzzzzzz = ddd
  4723. // --- [end][read][struct](CronJob) ---
  4724. }
  4725. if !yield(fi, pairV(vvvvvvvv, zzzzzzzz)) {
  4726. return
  4727. }
  4728. }
  4729. // --- [end][read][streaming-map](map[string]*CronJob) ---
  4730. }
  4731. } else {
  4732. if !yield(fi, nil) {
  4733. return
  4734. }
  4735. }
  4736. fi = BingenFieldInfo{
  4737. Type: reflect.TypeFor[map[string]*ReplicaSet](),
  4738. Name: "ReplicaSets",
  4739. }
  4740. // field version check
  4741. if uint8(2) <= version {
  4742. if buff.ReadUInt8() == uint8(0) {
  4743. if !yield(fi, nil) {
  4744. return
  4745. }
  4746. } else {
  4747. // --- [begin][read][streaming-map](map[string]*ReplicaSet) ---
  4748. eee := buff.ReadInt() // map len
  4749. for range eee {
  4750. var vvvvvvvvv string
  4751. var ggg string
  4752. if ctx.IsStringTable() {
  4753. hhh := buff.ReadInt() // read string index
  4754. ggg = ctx.Table.At(hhh)
  4755. } else {
  4756. ggg = buff.ReadString() // read string
  4757. }
  4758. fff := ggg
  4759. vvvvvvvvv = fff
  4760. var zzzzzzzzz *ReplicaSet
  4761. if buff.ReadUInt8() == uint8(0) {
  4762. zzzzzzzzz = nil
  4763. } else {
  4764. // --- [begin][read][struct](ReplicaSet) ---
  4765. lll := new(ReplicaSet)
  4766. buff.ReadInt() // [compatibility, unused]
  4767. errL := lll.UnmarshalBinaryWithContext(ctx)
  4768. if errL != nil {
  4769. stream.err = errL
  4770. return
  4771. }
  4772. zzzzzzzzz = lll
  4773. // --- [end][read][struct](ReplicaSet) ---
  4774. }
  4775. if !yield(fi, pairV(vvvvvvvvv, zzzzzzzzz)) {
  4776. return
  4777. }
  4778. }
  4779. // --- [end][read][streaming-map](map[string]*ReplicaSet) ---
  4780. }
  4781. } else {
  4782. if !yield(fi, nil) {
  4783. return
  4784. }
  4785. }
  4786. fi = BingenFieldInfo{
  4787. Type: reflect.TypeFor[map[string]*Node](),
  4788. Name: "Nodes",
  4789. }
  4790. // field version check
  4791. if uint8(2) <= version {
  4792. if buff.ReadUInt8() == uint8(0) {
  4793. if !yield(fi, nil) {
  4794. return
  4795. }
  4796. } else {
  4797. // --- [begin][read][streaming-map](map[string]*Node) ---
  4798. mmm := buff.ReadInt() // map len
  4799. for range mmm {
  4800. var vvvvvvvvvv string
  4801. var ooo string
  4802. if ctx.IsStringTable() {
  4803. ppp := buff.ReadInt() // read string index
  4804. ooo = ctx.Table.At(ppp)
  4805. } else {
  4806. ooo = buff.ReadString() // read string
  4807. }
  4808. nnn := ooo
  4809. vvvvvvvvvv = nnn
  4810. var zzzzzzzzzz *Node
  4811. if buff.ReadUInt8() == uint8(0) {
  4812. zzzzzzzzzz = nil
  4813. } else {
  4814. // --- [begin][read][struct](Node) ---
  4815. qqq := new(Node)
  4816. buff.ReadInt() // [compatibility, unused]
  4817. errM := qqq.UnmarshalBinaryWithContext(ctx)
  4818. if errM != nil {
  4819. stream.err = errM
  4820. return
  4821. }
  4822. zzzzzzzzzz = qqq
  4823. // --- [end][read][struct](Node) ---
  4824. }
  4825. if !yield(fi, pairV(vvvvvvvvvv, zzzzzzzzzz)) {
  4826. return
  4827. }
  4828. }
  4829. // --- [end][read][streaming-map](map[string]*Node) ---
  4830. }
  4831. } else {
  4832. if !yield(fi, nil) {
  4833. return
  4834. }
  4835. }
  4836. fi = BingenFieldInfo{
  4837. Type: reflect.TypeFor[map[string]*PersistentVolume](),
  4838. Name: "PersistentVolumes",
  4839. }
  4840. // field version check
  4841. if uint8(2) <= version {
  4842. if buff.ReadUInt8() == uint8(0) {
  4843. if !yield(fi, nil) {
  4844. return
  4845. }
  4846. } else {
  4847. // --- [begin][read][streaming-map](map[string]*PersistentVolume) ---
  4848. rrr := buff.ReadInt() // map len
  4849. for range rrr {
  4850. var vvvvvvvvvvv string
  4851. var ttt string
  4852. if ctx.IsStringTable() {
  4853. uuu := buff.ReadInt() // read string index
  4854. ttt = ctx.Table.At(uuu)
  4855. } else {
  4856. ttt = buff.ReadString() // read string
  4857. }
  4858. sss := ttt
  4859. vvvvvvvvvvv = sss
  4860. var zzzzzzzzzzz *PersistentVolume
  4861. if buff.ReadUInt8() == uint8(0) {
  4862. zzzzzzzzzzz = nil
  4863. } else {
  4864. // --- [begin][read][struct](PersistentVolume) ---
  4865. www := new(PersistentVolume)
  4866. buff.ReadInt() // [compatibility, unused]
  4867. errN := www.UnmarshalBinaryWithContext(ctx)
  4868. if errN != nil {
  4869. stream.err = errN
  4870. return
  4871. }
  4872. zzzzzzzzzzz = www
  4873. // --- [end][read][struct](PersistentVolume) ---
  4874. }
  4875. if !yield(fi, pairV(vvvvvvvvvvv, zzzzzzzzzzz)) {
  4876. return
  4877. }
  4878. }
  4879. // --- [end][read][streaming-map](map[string]*PersistentVolume) ---
  4880. }
  4881. } else {
  4882. if !yield(fi, nil) {
  4883. return
  4884. }
  4885. }
  4886. fi = BingenFieldInfo{
  4887. Type: reflect.TypeFor[map[string]*PersistentVolumeClaim](),
  4888. Name: "PersistentVolumeClaims",
  4889. }
  4890. // field version check
  4891. if uint8(2) <= version {
  4892. if buff.ReadUInt8() == uint8(0) {
  4893. if !yield(fi, nil) {
  4894. return
  4895. }
  4896. } else {
  4897. // --- [begin][read][streaming-map](map[string]*PersistentVolumeClaim) ---
  4898. xxx := buff.ReadInt() // map len
  4899. for range xxx {
  4900. var vvvvvvvvvvvv string
  4901. var aaaa string
  4902. if ctx.IsStringTable() {
  4903. bbbb := buff.ReadInt() // read string index
  4904. aaaa = ctx.Table.At(bbbb)
  4905. } else {
  4906. aaaa = buff.ReadString() // read string
  4907. }
  4908. yyy := aaaa
  4909. vvvvvvvvvvvv = yyy
  4910. var zzzzzzzzzzzz *PersistentVolumeClaim
  4911. if buff.ReadUInt8() == uint8(0) {
  4912. zzzzzzzzzzzz = nil
  4913. } else {
  4914. // --- [begin][read][struct](PersistentVolumeClaim) ---
  4915. cccc := new(PersistentVolumeClaim)
  4916. buff.ReadInt() // [compatibility, unused]
  4917. errO := cccc.UnmarshalBinaryWithContext(ctx)
  4918. if errO != nil {
  4919. stream.err = errO
  4920. return
  4921. }
  4922. zzzzzzzzzzzz = cccc
  4923. // --- [end][read][struct](PersistentVolumeClaim) ---
  4924. }
  4925. if !yield(fi, pairV(vvvvvvvvvvvv, zzzzzzzzzzzz)) {
  4926. return
  4927. }
  4928. }
  4929. // --- [end][read][streaming-map](map[string]*PersistentVolumeClaim) ---
  4930. }
  4931. } else {
  4932. if !yield(fi, nil) {
  4933. return
  4934. }
  4935. }
  4936. fi = BingenFieldInfo{
  4937. Type: reflect.TypeFor[map[string]*Pod](),
  4938. Name: "Pods",
  4939. }
  4940. // field version check
  4941. if uint8(2) <= version {
  4942. if buff.ReadUInt8() == uint8(0) {
  4943. if !yield(fi, nil) {
  4944. return
  4945. }
  4946. } else {
  4947. // --- [begin][read][streaming-map](map[string]*Pod) ---
  4948. dddd := buff.ReadInt() // map len
  4949. for range dddd {
  4950. var vvvvvvvvvvvvv string
  4951. var ffff string
  4952. if ctx.IsStringTable() {
  4953. gggg := buff.ReadInt() // read string index
  4954. ffff = ctx.Table.At(gggg)
  4955. } else {
  4956. ffff = buff.ReadString() // read string
  4957. }
  4958. eeee := ffff
  4959. vvvvvvvvvvvvv = eeee
  4960. var zzzzzzzzzzzzz *Pod
  4961. if buff.ReadUInt8() == uint8(0) {
  4962. zzzzzzzzzzzzz = nil
  4963. } else {
  4964. // --- [begin][read][struct](Pod) ---
  4965. hhhh := new(Pod)
  4966. buff.ReadInt() // [compatibility, unused]
  4967. errP := hhhh.UnmarshalBinaryWithContext(ctx)
  4968. if errP != nil {
  4969. stream.err = errP
  4970. return
  4971. }
  4972. zzzzzzzzzzzzz = hhhh
  4973. // --- [end][read][struct](Pod) ---
  4974. }
  4975. if !yield(fi, pairV(vvvvvvvvvvvvv, zzzzzzzzzzzzz)) {
  4976. return
  4977. }
  4978. }
  4979. // --- [end][read][streaming-map](map[string]*Pod) ---
  4980. }
  4981. } else {
  4982. if !yield(fi, nil) {
  4983. return
  4984. }
  4985. }
  4986. fi = BingenFieldInfo{
  4987. Type: reflect.TypeFor[map[string]*Container](),
  4988. Name: "Containers",
  4989. }
  4990. // field version check
  4991. if uint8(2) <= version {
  4992. if buff.ReadUInt8() == uint8(0) {
  4993. if !yield(fi, nil) {
  4994. return
  4995. }
  4996. } else {
  4997. // --- [begin][read][streaming-map](map[string]*Container) ---
  4998. llll := buff.ReadInt() // map len
  4999. for range llll {
  5000. var vvvvvvvvvvvvvv string
  5001. var nnnn string
  5002. if ctx.IsStringTable() {
  5003. oooo := buff.ReadInt() // read string index
  5004. nnnn = ctx.Table.At(oooo)
  5005. } else {
  5006. nnnn = buff.ReadString() // read string
  5007. }
  5008. mmmm := nnnn
  5009. vvvvvvvvvvvvvv = mmmm
  5010. var zzzzzzzzzzzzzz *Container
  5011. if buff.ReadUInt8() == uint8(0) {
  5012. zzzzzzzzzzzzzz = nil
  5013. } else {
  5014. // --- [begin][read][struct](Container) ---
  5015. pppp := new(Container)
  5016. buff.ReadInt() // [compatibility, unused]
  5017. errQ := pppp.UnmarshalBinaryWithContext(ctx)
  5018. if errQ != nil {
  5019. stream.err = errQ
  5020. return
  5021. }
  5022. zzzzzzzzzzzzzz = pppp
  5023. // --- [end][read][struct](Container) ---
  5024. }
  5025. if !yield(fi, pairV(vvvvvvvvvvvvvv, zzzzzzzzzzzzzz)) {
  5026. return
  5027. }
  5028. }
  5029. // --- [end][read][streaming-map](map[string]*Container) ---
  5030. }
  5031. } else {
  5032. if !yield(fi, nil) {
  5033. return
  5034. }
  5035. }
  5036. fi = BingenFieldInfo{
  5037. Type: reflect.TypeFor[map[string]*Device](),
  5038. Name: "Devices",
  5039. }
  5040. // field version check
  5041. if uint8(3) <= version {
  5042. if buff.ReadUInt8() == uint8(0) {
  5043. if !yield(fi, nil) {
  5044. return
  5045. }
  5046. } else {
  5047. // --- [begin][read][streaming-map](map[string]*Device) ---
  5048. qqqq := buff.ReadInt() // map len
  5049. for range qqqq {
  5050. var vvvvvvvvvvvvvvv string
  5051. var ssss string
  5052. if ctx.IsStringTable() {
  5053. tttt := buff.ReadInt() // read string index
  5054. ssss = ctx.Table.At(tttt)
  5055. } else {
  5056. ssss = buff.ReadString() // read string
  5057. }
  5058. rrrr := ssss
  5059. vvvvvvvvvvvvvvv = rrrr
  5060. var zzzzzzzzzzzzzzz *Device
  5061. if buff.ReadUInt8() == uint8(0) {
  5062. zzzzzzzzzzzzzzz = nil
  5063. } else {
  5064. // --- [begin][read][struct](Device) ---
  5065. uuuu := new(Device)
  5066. buff.ReadInt() // [compatibility, unused]
  5067. errR := uuuu.UnmarshalBinaryWithContext(ctx)
  5068. if errR != nil {
  5069. stream.err = errR
  5070. return
  5071. }
  5072. zzzzzzzzzzzzzzz = uuuu
  5073. // --- [end][read][struct](Device) ---
  5074. }
  5075. if !yield(fi, pairV(vvvvvvvvvvvvvvv, zzzzzzzzzzzzzzz)) {
  5076. return
  5077. }
  5078. }
  5079. // --- [end][read][streaming-map](map[string]*Device) ---
  5080. }
  5081. } else {
  5082. if !yield(fi, nil) {
  5083. return
  5084. }
  5085. }
  5086. }
  5087. }
  5088. //--------------------------------------------------------------------------
  5089. // Metadata
  5090. //--------------------------------------------------------------------------
  5091. // MarshalBinary serializes the internal properties of this Metadata instance
  5092. // into a byte array
  5093. func (target *Metadata) MarshalBinary() (data []byte, err error) {
  5094. ctx := NewEncodingContext(nil)
  5095. e := target.MarshalBinaryWithContext(ctx)
  5096. if e != nil {
  5097. return nil, e
  5098. }
  5099. return ctx.ToBytes(), nil
  5100. }
  5101. // MarshalBinary serializes the internal properties of this Metadata instance
  5102. // into an io.Writer.
  5103. func (target *Metadata) MarshalBinaryTo(writer io.Writer) error {
  5104. buff := util.NewBufferFromWriter(writer)
  5105. defer buff.Flush()
  5106. ctx := NewEncodingContextFromBuffer(buff, nil)
  5107. return target.MarshalBinaryWithContext(ctx)
  5108. }
  5109. // MarshalBinaryWithContext serializes the internal properties of this Metadata instance
  5110. // into a byte array leveraging a predefined context.
  5111. func (target *Metadata) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5112. // panics are recovered and propagated as errors
  5113. defer func() {
  5114. if r := recover(); r != nil {
  5115. if e, ok := r.(error); ok {
  5116. err = e
  5117. } else if s, ok := r.(string); ok {
  5118. err = fmt.Errorf("unexpected panic: %s", s)
  5119. } else {
  5120. err = fmt.Errorf("unexpected panic: %+v", r)
  5121. }
  5122. }
  5123. }()
  5124. buff := ctx.Buffer
  5125. buff.WriteUInt8(DefaultCodecVersion) // version
  5126. // --- [begin][write][reference](time.Time) ---
  5127. a, errA := target.CreatedAt.MarshalBinary()
  5128. if errA != nil {
  5129. return errA
  5130. }
  5131. buff.WriteInt(len(a))
  5132. buff.WriteBytes(a)
  5133. // --- [end][write][reference](time.Time) ---
  5134. // --- [begin][write][reference](time.Time) ---
  5135. b, errB := target.CompletedAt.MarshalBinary()
  5136. if errB != nil {
  5137. return errB
  5138. }
  5139. buff.WriteInt(len(b))
  5140. buff.WriteBytes(b)
  5141. // --- [end][write][reference](time.Time) ---
  5142. buff.WriteInt(target.ObjectCount) // write int
  5143. if target.Diagnostics == nil {
  5144. buff.WriteUInt8(uint8(0)) // write nil byte
  5145. } else {
  5146. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5147. // --- [begin][write][slice]([]Diagnostic) ---
  5148. buff.WriteInt(len(target.Diagnostics)) // slice length
  5149. for i := range target.Diagnostics {
  5150. // --- [begin][write][struct](Diagnostic) ---
  5151. buff.WriteInt(0) // [compatibility, unused]
  5152. errC := target.Diagnostics[i].MarshalBinaryWithContext(ctx)
  5153. if errC != nil {
  5154. return errC
  5155. }
  5156. // --- [end][write][struct](Diagnostic) ---
  5157. }
  5158. // --- [end][write][slice]([]Diagnostic) ---
  5159. }
  5160. // --- [begin][write][alias](DiagnosticLevel) ---
  5161. buff.WriteInt(int(target.DiagnosticLevel)) // write int
  5162. // --- [end][write][alias](DiagnosticLevel) ---
  5163. return nil
  5164. }
  5165. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5166. // the Metadata type
  5167. func (target *Metadata) UnmarshalBinary(data []byte) error {
  5168. ctx := NewDecodingContextFromBytes(data)
  5169. defer ctx.Close()
  5170. err := target.UnmarshalBinaryWithContext(ctx)
  5171. if err != nil {
  5172. return err
  5173. }
  5174. return nil
  5175. }
  5176. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  5177. // the Metadata type
  5178. func (target *Metadata) UnmarshalBinaryFromReader(reader io.Reader) error {
  5179. ctx := NewDecodingContextFromReader(reader)
  5180. defer ctx.Close()
  5181. err := target.UnmarshalBinaryWithContext(ctx)
  5182. if err != nil {
  5183. return err
  5184. }
  5185. return nil
  5186. }
  5187. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5188. // the Metadata type
  5189. func (target *Metadata) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5190. // panics are recovered and propagated as errors
  5191. defer func() {
  5192. if r := recover(); r != nil {
  5193. if e, ok := r.(error); ok {
  5194. err = e
  5195. } else if s, ok := r.(string); ok {
  5196. err = fmt.Errorf("unexpected panic: %s", s)
  5197. } else {
  5198. err = fmt.Errorf("unexpected panic: %+v", r)
  5199. }
  5200. }
  5201. }()
  5202. buff := ctx.Buffer
  5203. version := buff.ReadUInt8()
  5204. if version > DefaultCodecVersion {
  5205. return fmt.Errorf("Invalid Version Unmarshalling Metadata. Expected %d or less, got %d", DefaultCodecVersion, version)
  5206. }
  5207. // field version check
  5208. if uint8(1) <= version {
  5209. // --- [begin][read][reference](time.Time) ---
  5210. a := new(time.Time)
  5211. b := buff.ReadInt() // byte array length
  5212. c := buff.ReadBytes(b)
  5213. errA := a.UnmarshalBinary(c)
  5214. if errA != nil {
  5215. return errA
  5216. }
  5217. target.CreatedAt = *a
  5218. // --- [end][read][reference](time.Time) ---
  5219. } else {
  5220. }
  5221. // field version check
  5222. if uint8(1) <= version {
  5223. // --- [begin][read][reference](time.Time) ---
  5224. d := new(time.Time)
  5225. e := buff.ReadInt() // byte array length
  5226. f := buff.ReadBytes(e)
  5227. errB := d.UnmarshalBinary(f)
  5228. if errB != nil {
  5229. return errB
  5230. }
  5231. target.CompletedAt = *d
  5232. // --- [end][read][reference](time.Time) ---
  5233. } else {
  5234. }
  5235. // field version check
  5236. if uint8(1) <= version {
  5237. g := buff.ReadInt() // read int
  5238. target.ObjectCount = g
  5239. } else {
  5240. target.ObjectCount = int(0) // default
  5241. }
  5242. // field version check
  5243. if uint8(1) <= version {
  5244. if buff.ReadUInt8() == uint8(0) {
  5245. target.Diagnostics = nil
  5246. } else {
  5247. // --- [begin][read][slice]([]Diagnostic) ---
  5248. l := buff.ReadInt() // slice len
  5249. h := make([]Diagnostic, l)
  5250. for i := range l {
  5251. // --- [begin][read][struct](Diagnostic) ---
  5252. n := new(Diagnostic)
  5253. buff.ReadInt() // [compatibility, unused]
  5254. errC := n.UnmarshalBinaryWithContext(ctx)
  5255. if errC != nil {
  5256. return errC
  5257. }
  5258. m := *n
  5259. // --- [end][read][struct](Diagnostic) ---
  5260. h[i] = m
  5261. }
  5262. target.Diagnostics = h
  5263. // --- [end][read][slice]([]Diagnostic) ---
  5264. }
  5265. } else {
  5266. target.Diagnostics = nil
  5267. }
  5268. // field version check
  5269. if uint8(1) <= version {
  5270. // --- [begin][read][alias](DiagnosticLevel) ---
  5271. var o int
  5272. p := buff.ReadInt() // read int
  5273. o = p
  5274. target.DiagnosticLevel = DiagnosticLevel(o)
  5275. // --- [end][read][alias](DiagnosticLevel) ---
  5276. } else {
  5277. }
  5278. return nil
  5279. }
  5280. //--------------------------------------------------------------------------
  5281. // Namespace
  5282. //--------------------------------------------------------------------------
  5283. // MarshalBinary serializes the internal properties of this Namespace instance
  5284. // into a byte array
  5285. func (target *Namespace) MarshalBinary() (data []byte, err error) {
  5286. ctx := NewEncodingContext(nil)
  5287. e := target.MarshalBinaryWithContext(ctx)
  5288. if e != nil {
  5289. return nil, e
  5290. }
  5291. return ctx.ToBytes(), nil
  5292. }
  5293. // MarshalBinary serializes the internal properties of this Namespace instance
  5294. // into an io.Writer.
  5295. func (target *Namespace) MarshalBinaryTo(writer io.Writer) error {
  5296. buff := util.NewBufferFromWriter(writer)
  5297. defer buff.Flush()
  5298. ctx := NewEncodingContextFromBuffer(buff, nil)
  5299. return target.MarshalBinaryWithContext(ctx)
  5300. }
  5301. // MarshalBinaryWithContext serializes the internal properties of this Namespace instance
  5302. // into a byte array leveraging a predefined context.
  5303. func (target *Namespace) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5304. // panics are recovered and propagated as errors
  5305. defer func() {
  5306. if r := recover(); r != nil {
  5307. if e, ok := r.(error); ok {
  5308. err = e
  5309. } else if s, ok := r.(string); ok {
  5310. err = fmt.Errorf("unexpected panic: %s", s)
  5311. } else {
  5312. err = fmt.Errorf("unexpected panic: %+v", r)
  5313. }
  5314. }
  5315. }()
  5316. buff := ctx.Buffer
  5317. buff.WriteUInt8(DefaultCodecVersion) // version
  5318. if ctx.IsStringTable() {
  5319. a := ctx.Table.AddOrGet(target.UID)
  5320. buff.WriteInt(a) // write table index
  5321. } else {
  5322. buff.WriteString(target.UID) // write string
  5323. }
  5324. if ctx.IsStringTable() {
  5325. b := ctx.Table.AddOrGet(target.bingenPlaceHolder)
  5326. buff.WriteInt(b) // write table index
  5327. } else {
  5328. buff.WriteString(target.bingenPlaceHolder) // write string
  5329. }
  5330. if ctx.IsStringTable() {
  5331. c := ctx.Table.AddOrGet(target.Name)
  5332. buff.WriteInt(c) // write table index
  5333. } else {
  5334. buff.WriteString(target.Name) // write string
  5335. }
  5336. if target.Labels == nil {
  5337. buff.WriteUInt8(uint8(0)) // write nil byte
  5338. } else {
  5339. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5340. // --- [begin][write][map](map[string]string) ---
  5341. buff.WriteInt(len(target.Labels)) // map length
  5342. for v, z := range target.Labels {
  5343. if ctx.IsStringTable() {
  5344. d := ctx.Table.AddOrGet(v)
  5345. buff.WriteInt(d) // write table index
  5346. } else {
  5347. buff.WriteString(v) // write string
  5348. }
  5349. if ctx.IsStringTable() {
  5350. e := ctx.Table.AddOrGet(z)
  5351. buff.WriteInt(e) // write table index
  5352. } else {
  5353. buff.WriteString(z) // write string
  5354. }
  5355. }
  5356. // --- [end][write][map](map[string]string) ---
  5357. }
  5358. if target.Annotations == nil {
  5359. buff.WriteUInt8(uint8(0)) // write nil byte
  5360. } else {
  5361. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5362. // --- [begin][write][map](map[string]string) ---
  5363. buff.WriteInt(len(target.Annotations)) // map length
  5364. for vv, zz := range target.Annotations {
  5365. if ctx.IsStringTable() {
  5366. f := ctx.Table.AddOrGet(vv)
  5367. buff.WriteInt(f) // write table index
  5368. } else {
  5369. buff.WriteString(vv) // write string
  5370. }
  5371. if ctx.IsStringTable() {
  5372. g := ctx.Table.AddOrGet(zz)
  5373. buff.WriteInt(g) // write table index
  5374. } else {
  5375. buff.WriteString(zz) // write string
  5376. }
  5377. }
  5378. // --- [end][write][map](map[string]string) ---
  5379. }
  5380. // --- [begin][write][reference](time.Time) ---
  5381. h, errA := target.Start.MarshalBinary()
  5382. if errA != nil {
  5383. return errA
  5384. }
  5385. buff.WriteInt(len(h))
  5386. buff.WriteBytes(h)
  5387. // --- [end][write][reference](time.Time) ---
  5388. // --- [begin][write][reference](time.Time) ---
  5389. l, errB := target.End.MarshalBinary()
  5390. if errB != nil {
  5391. return errB
  5392. }
  5393. buff.WriteInt(len(l))
  5394. buff.WriteBytes(l)
  5395. // --- [end][write][reference](time.Time) ---
  5396. return nil
  5397. }
  5398. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5399. // the Namespace type
  5400. func (target *Namespace) UnmarshalBinary(data []byte) error {
  5401. ctx := NewDecodingContextFromBytes(data)
  5402. defer ctx.Close()
  5403. err := target.UnmarshalBinaryWithContext(ctx)
  5404. if err != nil {
  5405. return err
  5406. }
  5407. return nil
  5408. }
  5409. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  5410. // the Namespace type
  5411. func (target *Namespace) UnmarshalBinaryFromReader(reader io.Reader) error {
  5412. ctx := NewDecodingContextFromReader(reader)
  5413. defer ctx.Close()
  5414. err := target.UnmarshalBinaryWithContext(ctx)
  5415. if err != nil {
  5416. return err
  5417. }
  5418. return nil
  5419. }
  5420. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5421. // the Namespace type
  5422. func (target *Namespace) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5423. // panics are recovered and propagated as errors
  5424. defer func() {
  5425. if r := recover(); r != nil {
  5426. if e, ok := r.(error); ok {
  5427. err = e
  5428. } else if s, ok := r.(string); ok {
  5429. err = fmt.Errorf("unexpected panic: %s", s)
  5430. } else {
  5431. err = fmt.Errorf("unexpected panic: %+v", r)
  5432. }
  5433. }
  5434. }()
  5435. buff := ctx.Buffer
  5436. version := buff.ReadUInt8()
  5437. if version > DefaultCodecVersion {
  5438. return fmt.Errorf("Invalid Version Unmarshalling Namespace. Expected %d or less, got %d", DefaultCodecVersion, version)
  5439. }
  5440. // field version check
  5441. if uint8(1) <= version {
  5442. var b string
  5443. if ctx.IsStringTable() {
  5444. c := buff.ReadInt() // read string index
  5445. b = ctx.Table.At(c)
  5446. } else {
  5447. b = buff.ReadString() // read string
  5448. }
  5449. a := b
  5450. target.UID = a
  5451. } else {
  5452. target.UID = "" // default
  5453. }
  5454. // field version check
  5455. if uint8(1) <= version {
  5456. var e string
  5457. if ctx.IsStringTable() {
  5458. f := buff.ReadInt() // read string index
  5459. e = ctx.Table.At(f)
  5460. } else {
  5461. e = buff.ReadString() // read string
  5462. }
  5463. d := e
  5464. target.bingenPlaceHolder = d
  5465. } else {
  5466. target.bingenPlaceHolder = "" // default
  5467. }
  5468. // field version check
  5469. if uint8(1) <= version {
  5470. var h string
  5471. if ctx.IsStringTable() {
  5472. l := buff.ReadInt() // read string index
  5473. h = ctx.Table.At(l)
  5474. } else {
  5475. h = buff.ReadString() // read string
  5476. }
  5477. g := h
  5478. target.Name = g
  5479. } else {
  5480. target.Name = "" // default
  5481. }
  5482. // field version check
  5483. if uint8(1) <= version {
  5484. if buff.ReadUInt8() == uint8(0) {
  5485. target.Labels = nil
  5486. } else {
  5487. // --- [begin][read][map](map[string]string) ---
  5488. n := buff.ReadInt() // map len
  5489. m := make(map[string]string, n)
  5490. for range n {
  5491. var v string
  5492. var p string
  5493. if ctx.IsStringTable() {
  5494. q := buff.ReadInt() // read string index
  5495. p = ctx.Table.At(q)
  5496. } else {
  5497. p = buff.ReadString() // read string
  5498. }
  5499. o := p
  5500. v = o
  5501. var z string
  5502. var s string
  5503. if ctx.IsStringTable() {
  5504. t := buff.ReadInt() // read string index
  5505. s = ctx.Table.At(t)
  5506. } else {
  5507. s = buff.ReadString() // read string
  5508. }
  5509. r := s
  5510. z = r
  5511. m[v] = z
  5512. }
  5513. target.Labels = m
  5514. // --- [end][read][map](map[string]string) ---
  5515. }
  5516. } else {
  5517. target.Labels = nil
  5518. }
  5519. // field version check
  5520. if uint8(1) <= version {
  5521. if buff.ReadUInt8() == uint8(0) {
  5522. target.Annotations = nil
  5523. } else {
  5524. // --- [begin][read][map](map[string]string) ---
  5525. w := buff.ReadInt() // map len
  5526. u := make(map[string]string, w)
  5527. for range w {
  5528. var vv string
  5529. var y string
  5530. if ctx.IsStringTable() {
  5531. aa := buff.ReadInt() // read string index
  5532. y = ctx.Table.At(aa)
  5533. } else {
  5534. y = buff.ReadString() // read string
  5535. }
  5536. x := y
  5537. vv = x
  5538. var zz string
  5539. var cc string
  5540. if ctx.IsStringTable() {
  5541. dd := buff.ReadInt() // read string index
  5542. cc = ctx.Table.At(dd)
  5543. } else {
  5544. cc = buff.ReadString() // read string
  5545. }
  5546. bb := cc
  5547. zz = bb
  5548. u[vv] = zz
  5549. }
  5550. target.Annotations = u
  5551. // --- [end][read][map](map[string]string) ---
  5552. }
  5553. } else {
  5554. target.Annotations = nil
  5555. }
  5556. // field version check
  5557. if uint8(1) <= version {
  5558. // --- [begin][read][reference](time.Time) ---
  5559. ee := new(time.Time)
  5560. ff := buff.ReadInt() // byte array length
  5561. gg := buff.ReadBytes(ff)
  5562. errA := ee.UnmarshalBinary(gg)
  5563. if errA != nil {
  5564. return errA
  5565. }
  5566. target.Start = *ee
  5567. // --- [end][read][reference](time.Time) ---
  5568. } else {
  5569. }
  5570. // field version check
  5571. if uint8(1) <= version {
  5572. // --- [begin][read][reference](time.Time) ---
  5573. hh := new(time.Time)
  5574. ll := buff.ReadInt() // byte array length
  5575. mm := buff.ReadBytes(ll)
  5576. errB := hh.UnmarshalBinary(mm)
  5577. if errB != nil {
  5578. return errB
  5579. }
  5580. target.End = *hh
  5581. // --- [end][read][reference](time.Time) ---
  5582. } else {
  5583. }
  5584. return nil
  5585. }
  5586. //--------------------------------------------------------------------------
  5587. // NetworkTrafficDetail
  5588. //--------------------------------------------------------------------------
  5589. // MarshalBinary serializes the internal properties of this NetworkTrafficDetail instance
  5590. // into a byte array
  5591. func (target *NetworkTrafficDetail) MarshalBinary() (data []byte, err error) {
  5592. ctx := NewEncodingContext(nil)
  5593. e := target.MarshalBinaryWithContext(ctx)
  5594. if e != nil {
  5595. return nil, e
  5596. }
  5597. return ctx.ToBytes(), nil
  5598. }
  5599. // MarshalBinary serializes the internal properties of this NetworkTrafficDetail instance
  5600. // into an io.Writer.
  5601. func (target *NetworkTrafficDetail) MarshalBinaryTo(writer io.Writer) error {
  5602. buff := util.NewBufferFromWriter(writer)
  5603. defer buff.Flush()
  5604. ctx := NewEncodingContextFromBuffer(buff, nil)
  5605. return target.MarshalBinaryWithContext(ctx)
  5606. }
  5607. // MarshalBinaryWithContext serializes the internal properties of this NetworkTrafficDetail instance
  5608. // into a byte array leveraging a predefined context.
  5609. func (target *NetworkTrafficDetail) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5610. // panics are recovered and propagated as errors
  5611. defer func() {
  5612. if r := recover(); r != nil {
  5613. if e, ok := r.(error); ok {
  5614. err = e
  5615. } else if s, ok := r.(string); ok {
  5616. err = fmt.Errorf("unexpected panic: %s", s)
  5617. } else {
  5618. err = fmt.Errorf("unexpected panic: %+v", r)
  5619. }
  5620. }
  5621. }()
  5622. buff := ctx.Buffer
  5623. buff.WriteUInt8(DefaultCodecVersion) // version
  5624. if ctx.IsStringTable() {
  5625. a := ctx.Table.AddOrGet(target.PodUID)
  5626. buff.WriteInt(a) // write table index
  5627. } else {
  5628. buff.WriteString(target.PodUID) // write string
  5629. }
  5630. if ctx.IsStringTable() {
  5631. b := ctx.Table.AddOrGet(target.Endpoint)
  5632. buff.WriteInt(b) // write table index
  5633. } else {
  5634. buff.WriteString(target.Endpoint) // write string
  5635. }
  5636. // --- [begin][write][alias](TrafficDirection) ---
  5637. if ctx.IsStringTable() {
  5638. c := ctx.Table.AddOrGet(string(target.TrafficDirection))
  5639. buff.WriteInt(c) // write table index
  5640. } else {
  5641. buff.WriteString(string(target.TrafficDirection)) // write string
  5642. }
  5643. // --- [end][write][alias](TrafficDirection) ---
  5644. // --- [begin][write][alias](TrafficType) ---
  5645. if ctx.IsStringTable() {
  5646. d := ctx.Table.AddOrGet(string(target.TrafficType))
  5647. buff.WriteInt(d) // write table index
  5648. } else {
  5649. buff.WriteString(string(target.TrafficType)) // write string
  5650. }
  5651. // --- [end][write][alias](TrafficType) ---
  5652. buff.WriteBool(target.IsNatGateway) // write bool
  5653. buff.WriteFloat64(target.Bytes) // write float64
  5654. return nil
  5655. }
  5656. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5657. // the NetworkTrafficDetail type
  5658. func (target *NetworkTrafficDetail) UnmarshalBinary(data []byte) error {
  5659. ctx := NewDecodingContextFromBytes(data)
  5660. defer ctx.Close()
  5661. err := target.UnmarshalBinaryWithContext(ctx)
  5662. if err != nil {
  5663. return err
  5664. }
  5665. return nil
  5666. }
  5667. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  5668. // the NetworkTrafficDetail type
  5669. func (target *NetworkTrafficDetail) UnmarshalBinaryFromReader(reader io.Reader) error {
  5670. ctx := NewDecodingContextFromReader(reader)
  5671. defer ctx.Close()
  5672. err := target.UnmarshalBinaryWithContext(ctx)
  5673. if err != nil {
  5674. return err
  5675. }
  5676. return nil
  5677. }
  5678. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5679. // the NetworkTrafficDetail type
  5680. func (target *NetworkTrafficDetail) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5681. // panics are recovered and propagated as errors
  5682. defer func() {
  5683. if r := recover(); r != nil {
  5684. if e, ok := r.(error); ok {
  5685. err = e
  5686. } else if s, ok := r.(string); ok {
  5687. err = fmt.Errorf("unexpected panic: %s", s)
  5688. } else {
  5689. err = fmt.Errorf("unexpected panic: %+v", r)
  5690. }
  5691. }
  5692. }()
  5693. buff := ctx.Buffer
  5694. version := buff.ReadUInt8()
  5695. if version > DefaultCodecVersion {
  5696. return fmt.Errorf("Invalid Version Unmarshalling NetworkTrafficDetail. Expected %d or less, got %d", DefaultCodecVersion, version)
  5697. }
  5698. var b string
  5699. if ctx.IsStringTable() {
  5700. c := buff.ReadInt() // read string index
  5701. b = ctx.Table.At(c)
  5702. } else {
  5703. b = buff.ReadString() // read string
  5704. }
  5705. a := b
  5706. target.PodUID = a
  5707. var e string
  5708. if ctx.IsStringTable() {
  5709. f := buff.ReadInt() // read string index
  5710. e = ctx.Table.At(f)
  5711. } else {
  5712. e = buff.ReadString() // read string
  5713. }
  5714. d := e
  5715. target.Endpoint = d
  5716. // --- [begin][read][alias](TrafficDirection) ---
  5717. var g string
  5718. var l string
  5719. if ctx.IsStringTable() {
  5720. m := buff.ReadInt() // read string index
  5721. l = ctx.Table.At(m)
  5722. } else {
  5723. l = buff.ReadString() // read string
  5724. }
  5725. h := l
  5726. g = h
  5727. target.TrafficDirection = TrafficDirection(g)
  5728. // --- [end][read][alias](TrafficDirection) ---
  5729. // --- [begin][read][alias](TrafficType) ---
  5730. var n string
  5731. var p string
  5732. if ctx.IsStringTable() {
  5733. q := buff.ReadInt() // read string index
  5734. p = ctx.Table.At(q)
  5735. } else {
  5736. p = buff.ReadString() // read string
  5737. }
  5738. o := p
  5739. n = o
  5740. target.TrafficType = TrafficType(n)
  5741. // --- [end][read][alias](TrafficType) ---
  5742. r := buff.ReadBool() // read bool
  5743. target.IsNatGateway = r
  5744. s := buff.ReadFloat64() // read float64
  5745. target.Bytes = s
  5746. return nil
  5747. }
  5748. //--------------------------------------------------------------------------
  5749. // Node
  5750. //--------------------------------------------------------------------------
  5751. // MarshalBinary serializes the internal properties of this Node instance
  5752. // into a byte array
  5753. func (target *Node) MarshalBinary() (data []byte, err error) {
  5754. ctx := NewEncodingContext(nil)
  5755. e := target.MarshalBinaryWithContext(ctx)
  5756. if e != nil {
  5757. return nil, e
  5758. }
  5759. return ctx.ToBytes(), nil
  5760. }
  5761. // MarshalBinary serializes the internal properties of this Node instance
  5762. // into an io.Writer.
  5763. func (target *Node) MarshalBinaryTo(writer io.Writer) error {
  5764. buff := util.NewBufferFromWriter(writer)
  5765. defer buff.Flush()
  5766. ctx := NewEncodingContextFromBuffer(buff, nil)
  5767. return target.MarshalBinaryWithContext(ctx)
  5768. }
  5769. // MarshalBinaryWithContext serializes the internal properties of this Node instance
  5770. // into a byte array leveraging a predefined context.
  5771. func (target *Node) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5772. // panics are recovered and propagated as errors
  5773. defer func() {
  5774. if r := recover(); r != nil {
  5775. if e, ok := r.(error); ok {
  5776. err = e
  5777. } else if s, ok := r.(string); ok {
  5778. err = fmt.Errorf("unexpected panic: %s", s)
  5779. } else {
  5780. err = fmt.Errorf("unexpected panic: %+v", r)
  5781. }
  5782. }
  5783. }()
  5784. buff := ctx.Buffer
  5785. buff.WriteUInt8(DefaultCodecVersion) // version
  5786. if ctx.IsStringTable() {
  5787. a := ctx.Table.AddOrGet(target.UID)
  5788. buff.WriteInt(a) // write table index
  5789. } else {
  5790. buff.WriteString(target.UID) // write string
  5791. }
  5792. if ctx.IsStringTable() {
  5793. b := ctx.Table.AddOrGet(target.ProviderID)
  5794. buff.WriteInt(b) // write table index
  5795. } else {
  5796. buff.WriteString(target.ProviderID) // write string
  5797. }
  5798. if ctx.IsStringTable() {
  5799. c := ctx.Table.AddOrGet(target.Name)
  5800. buff.WriteInt(c) // write table index
  5801. } else {
  5802. buff.WriteString(target.Name) // write string
  5803. }
  5804. if target.Labels == nil {
  5805. buff.WriteUInt8(uint8(0)) // write nil byte
  5806. } else {
  5807. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5808. // --- [begin][write][map](map[string]string) ---
  5809. buff.WriteInt(len(target.Labels)) // map length
  5810. for v, z := range target.Labels {
  5811. if ctx.IsStringTable() {
  5812. d := ctx.Table.AddOrGet(v)
  5813. buff.WriteInt(d) // write table index
  5814. } else {
  5815. buff.WriteString(v) // write string
  5816. }
  5817. if ctx.IsStringTable() {
  5818. e := ctx.Table.AddOrGet(z)
  5819. buff.WriteInt(e) // write table index
  5820. } else {
  5821. buff.WriteString(z) // write string
  5822. }
  5823. }
  5824. // --- [end][write][map](map[string]string) ---
  5825. }
  5826. // --- [begin][write][alias](ResourceQuantities) ---
  5827. if map[Resource]ResourceQuantity(target.ResourceCapacities) == nil {
  5828. buff.WriteUInt8(uint8(0)) // write nil byte
  5829. } else {
  5830. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5831. // --- [begin][write][map](map[Resource]ResourceQuantity) ---
  5832. buff.WriteInt(len(map[Resource]ResourceQuantity(target.ResourceCapacities))) // map length
  5833. for vv, zz := range map[Resource]ResourceQuantity(target.ResourceCapacities) {
  5834. // --- [begin][write][alias](Resource) ---
  5835. if ctx.IsStringTable() {
  5836. f := ctx.Table.AddOrGet(string(vv))
  5837. buff.WriteInt(f) // write table index
  5838. } else {
  5839. buff.WriteString(string(vv)) // write string
  5840. }
  5841. // --- [end][write][alias](Resource) ---
  5842. // --- [begin][write][struct](ResourceQuantity) ---
  5843. buff.WriteInt(0) // [compatibility, unused]
  5844. errA := zz.MarshalBinaryWithContext(ctx)
  5845. if errA != nil {
  5846. return errA
  5847. }
  5848. // --- [end][write][struct](ResourceQuantity) ---
  5849. }
  5850. // --- [end][write][map](map[Resource]ResourceQuantity) ---
  5851. }
  5852. // --- [end][write][alias](ResourceQuantities) ---
  5853. // --- [begin][write][alias](ResourceQuantities) ---
  5854. if map[Resource]ResourceQuantity(target.ResourcesAllocatable) == nil {
  5855. buff.WriteUInt8(uint8(0)) // write nil byte
  5856. } else {
  5857. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5858. // --- [begin][write][map](map[Resource]ResourceQuantity) ---
  5859. buff.WriteInt(len(map[Resource]ResourceQuantity(target.ResourcesAllocatable))) // map length
  5860. for vvv, zzz := range map[Resource]ResourceQuantity(target.ResourcesAllocatable) {
  5861. // --- [begin][write][alias](Resource) ---
  5862. if ctx.IsStringTable() {
  5863. g := ctx.Table.AddOrGet(string(vvv))
  5864. buff.WriteInt(g) // write table index
  5865. } else {
  5866. buff.WriteString(string(vvv)) // write string
  5867. }
  5868. // --- [end][write][alias](Resource) ---
  5869. // --- [begin][write][struct](ResourceQuantity) ---
  5870. buff.WriteInt(0) // [compatibility, unused]
  5871. errB := zzz.MarshalBinaryWithContext(ctx)
  5872. if errB != nil {
  5873. return errB
  5874. }
  5875. // --- [end][write][struct](ResourceQuantity) ---
  5876. }
  5877. // --- [end][write][map](map[Resource]ResourceQuantity) ---
  5878. }
  5879. // --- [end][write][alias](ResourceQuantities) ---
  5880. // --- [begin][write][struct](FileSystem) ---
  5881. buff.WriteInt(0) // [compatibility, unused]
  5882. errC := target.FileSystem.MarshalBinaryWithContext(ctx)
  5883. if errC != nil {
  5884. return errC
  5885. }
  5886. // --- [end][write][struct](FileSystem) ---
  5887. // --- [begin][write][reference](time.Time) ---
  5888. h, errD := target.Start.MarshalBinary()
  5889. if errD != nil {
  5890. return errD
  5891. }
  5892. buff.WriteInt(len(h))
  5893. buff.WriteBytes(h)
  5894. // --- [end][write][reference](time.Time) ---
  5895. // --- [begin][write][reference](time.Time) ---
  5896. l, errE := target.End.MarshalBinary()
  5897. if errE != nil {
  5898. return errE
  5899. }
  5900. buff.WriteInt(len(l))
  5901. buff.WriteBytes(l)
  5902. // --- [end][write][reference](time.Time) ---
  5903. return nil
  5904. }
  5905. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5906. // the Node type
  5907. func (target *Node) UnmarshalBinary(data []byte) error {
  5908. ctx := NewDecodingContextFromBytes(data)
  5909. defer ctx.Close()
  5910. err := target.UnmarshalBinaryWithContext(ctx)
  5911. if err != nil {
  5912. return err
  5913. }
  5914. return nil
  5915. }
  5916. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  5917. // the Node type
  5918. func (target *Node) UnmarshalBinaryFromReader(reader io.Reader) error {
  5919. ctx := NewDecodingContextFromReader(reader)
  5920. defer ctx.Close()
  5921. err := target.UnmarshalBinaryWithContext(ctx)
  5922. if err != nil {
  5923. return err
  5924. }
  5925. return nil
  5926. }
  5927. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5928. // the Node type
  5929. func (target *Node) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5930. // panics are recovered and propagated as errors
  5931. defer func() {
  5932. if r := recover(); r != nil {
  5933. if e, ok := r.(error); ok {
  5934. err = e
  5935. } else if s, ok := r.(string); ok {
  5936. err = fmt.Errorf("unexpected panic: %s", s)
  5937. } else {
  5938. err = fmt.Errorf("unexpected panic: %+v", r)
  5939. }
  5940. }
  5941. }()
  5942. buff := ctx.Buffer
  5943. version := buff.ReadUInt8()
  5944. if version > DefaultCodecVersion {
  5945. return fmt.Errorf("Invalid Version Unmarshalling Node. Expected %d or less, got %d", DefaultCodecVersion, version)
  5946. }
  5947. var b string
  5948. if ctx.IsStringTable() {
  5949. c := buff.ReadInt() // read string index
  5950. b = ctx.Table.At(c)
  5951. } else {
  5952. b = buff.ReadString() // read string
  5953. }
  5954. a := b
  5955. target.UID = a
  5956. var e string
  5957. if ctx.IsStringTable() {
  5958. f := buff.ReadInt() // read string index
  5959. e = ctx.Table.At(f)
  5960. } else {
  5961. e = buff.ReadString() // read string
  5962. }
  5963. d := e
  5964. target.ProviderID = d
  5965. var h string
  5966. if ctx.IsStringTable() {
  5967. l := buff.ReadInt() // read string index
  5968. h = ctx.Table.At(l)
  5969. } else {
  5970. h = buff.ReadString() // read string
  5971. }
  5972. g := h
  5973. target.Name = g
  5974. if buff.ReadUInt8() == uint8(0) {
  5975. target.Labels = nil
  5976. } else {
  5977. // --- [begin][read][map](map[string]string) ---
  5978. n := buff.ReadInt() // map len
  5979. m := make(map[string]string, n)
  5980. for range n {
  5981. var v string
  5982. var p string
  5983. if ctx.IsStringTable() {
  5984. q := buff.ReadInt() // read string index
  5985. p = ctx.Table.At(q)
  5986. } else {
  5987. p = buff.ReadString() // read string
  5988. }
  5989. o := p
  5990. v = o
  5991. var z string
  5992. var s string
  5993. if ctx.IsStringTable() {
  5994. t := buff.ReadInt() // read string index
  5995. s = ctx.Table.At(t)
  5996. } else {
  5997. s = buff.ReadString() // read string
  5998. }
  5999. r := s
  6000. z = r
  6001. m[v] = z
  6002. }
  6003. target.Labels = m
  6004. // --- [end][read][map](map[string]string) ---
  6005. }
  6006. // --- [begin][read][alias](ResourceQuantities) ---
  6007. var u map[Resource]ResourceQuantity
  6008. if buff.ReadUInt8() == uint8(0) {
  6009. u = nil
  6010. } else {
  6011. // --- [begin][read][map](map[Resource]ResourceQuantity) ---
  6012. x := buff.ReadInt() // map len
  6013. w := make(map[Resource]ResourceQuantity, x)
  6014. for range x {
  6015. // --- [begin][read][alias](Resource) ---
  6016. var y string
  6017. var bb string
  6018. if ctx.IsStringTable() {
  6019. cc := buff.ReadInt() // read string index
  6020. bb = ctx.Table.At(cc)
  6021. } else {
  6022. bb = buff.ReadString() // read string
  6023. }
  6024. aa := bb
  6025. y = aa
  6026. vv := Resource(y)
  6027. // --- [end][read][alias](Resource) ---
  6028. // --- [begin][read][struct](ResourceQuantity) ---
  6029. dd := new(ResourceQuantity)
  6030. buff.ReadInt() // [compatibility, unused]
  6031. errA := dd.UnmarshalBinaryWithContext(ctx)
  6032. if errA != nil {
  6033. return errA
  6034. }
  6035. zz := *dd
  6036. // --- [end][read][struct](ResourceQuantity) ---
  6037. w[vv] = zz
  6038. }
  6039. u = w
  6040. // --- [end][read][map](map[Resource]ResourceQuantity) ---
  6041. }
  6042. target.ResourceCapacities = ResourceQuantities(u)
  6043. // --- [end][read][alias](ResourceQuantities) ---
  6044. // --- [begin][read][alias](ResourceQuantities) ---
  6045. var ee map[Resource]ResourceQuantity
  6046. if buff.ReadUInt8() == uint8(0) {
  6047. ee = nil
  6048. } else {
  6049. // --- [begin][read][map](map[Resource]ResourceQuantity) ---
  6050. gg := buff.ReadInt() // map len
  6051. ff := make(map[Resource]ResourceQuantity, gg)
  6052. for range gg {
  6053. // --- [begin][read][alias](Resource) ---
  6054. var hh string
  6055. var mm string
  6056. if ctx.IsStringTable() {
  6057. nn := buff.ReadInt() // read string index
  6058. mm = ctx.Table.At(nn)
  6059. } else {
  6060. mm = buff.ReadString() // read string
  6061. }
  6062. ll := mm
  6063. hh = ll
  6064. vvv := Resource(hh)
  6065. // --- [end][read][alias](Resource) ---
  6066. // --- [begin][read][struct](ResourceQuantity) ---
  6067. oo := new(ResourceQuantity)
  6068. buff.ReadInt() // [compatibility, unused]
  6069. errB := oo.UnmarshalBinaryWithContext(ctx)
  6070. if errB != nil {
  6071. return errB
  6072. }
  6073. zzz := *oo
  6074. // --- [end][read][struct](ResourceQuantity) ---
  6075. ff[vvv] = zzz
  6076. }
  6077. ee = ff
  6078. // --- [end][read][map](map[Resource]ResourceQuantity) ---
  6079. }
  6080. target.ResourcesAllocatable = ResourceQuantities(ee)
  6081. // --- [end][read][alias](ResourceQuantities) ---
  6082. // --- [begin][read][struct](FileSystem) ---
  6083. pp := new(FileSystem)
  6084. buff.ReadInt() // [compatibility, unused]
  6085. errC := pp.UnmarshalBinaryWithContext(ctx)
  6086. if errC != nil {
  6087. return errC
  6088. }
  6089. target.FileSystem = *pp
  6090. // --- [end][read][struct](FileSystem) ---
  6091. // --- [begin][read][reference](time.Time) ---
  6092. qq := new(time.Time)
  6093. rr := buff.ReadInt() // byte array length
  6094. ss := buff.ReadBytes(rr)
  6095. errD := qq.UnmarshalBinary(ss)
  6096. if errD != nil {
  6097. return errD
  6098. }
  6099. target.Start = *qq
  6100. // --- [end][read][reference](time.Time) ---
  6101. // --- [begin][read][reference](time.Time) ---
  6102. tt := new(time.Time)
  6103. uu := buff.ReadInt() // byte array length
  6104. ww := buff.ReadBytes(uu)
  6105. errE := tt.UnmarshalBinary(ww)
  6106. if errE != nil {
  6107. return errE
  6108. }
  6109. target.End = *tt
  6110. // --- [end][read][reference](time.Time) ---
  6111. return nil
  6112. }
  6113. //--------------------------------------------------------------------------
  6114. // Owner
  6115. //--------------------------------------------------------------------------
  6116. // MarshalBinary serializes the internal properties of this Owner instance
  6117. // into a byte array
  6118. func (target *Owner) MarshalBinary() (data []byte, err error) {
  6119. ctx := NewEncodingContext(nil)
  6120. e := target.MarshalBinaryWithContext(ctx)
  6121. if e != nil {
  6122. return nil, e
  6123. }
  6124. return ctx.ToBytes(), nil
  6125. }
  6126. // MarshalBinary serializes the internal properties of this Owner instance
  6127. // into an io.Writer.
  6128. func (target *Owner) MarshalBinaryTo(writer io.Writer) error {
  6129. buff := util.NewBufferFromWriter(writer)
  6130. defer buff.Flush()
  6131. ctx := NewEncodingContextFromBuffer(buff, nil)
  6132. return target.MarshalBinaryWithContext(ctx)
  6133. }
  6134. // MarshalBinaryWithContext serializes the internal properties of this Owner instance
  6135. // into a byte array leveraging a predefined context.
  6136. func (target *Owner) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6137. // panics are recovered and propagated as errors
  6138. defer func() {
  6139. if r := recover(); r != nil {
  6140. if e, ok := r.(error); ok {
  6141. err = e
  6142. } else if s, ok := r.(string); ok {
  6143. err = fmt.Errorf("unexpected panic: %s", s)
  6144. } else {
  6145. err = fmt.Errorf("unexpected panic: %+v", r)
  6146. }
  6147. }
  6148. }()
  6149. buff := ctx.Buffer
  6150. buff.WriteUInt8(DefaultCodecVersion) // version
  6151. if ctx.IsStringTable() {
  6152. a := ctx.Table.AddOrGet(target.UID)
  6153. buff.WriteInt(a) // write table index
  6154. } else {
  6155. buff.WriteString(target.UID) // write string
  6156. }
  6157. buff.WriteBool(target.Controller) // write bool
  6158. // --- [begin][write][alias](OwnerKind) ---
  6159. if ctx.IsStringTable() {
  6160. b := ctx.Table.AddOrGet(string(target.Kind))
  6161. buff.WriteInt(b) // write table index
  6162. } else {
  6163. buff.WriteString(string(target.Kind)) // write string
  6164. }
  6165. // --- [end][write][alias](OwnerKind) ---
  6166. return nil
  6167. }
  6168. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6169. // the Owner type
  6170. func (target *Owner) UnmarshalBinary(data []byte) error {
  6171. ctx := NewDecodingContextFromBytes(data)
  6172. defer ctx.Close()
  6173. err := target.UnmarshalBinaryWithContext(ctx)
  6174. if err != nil {
  6175. return err
  6176. }
  6177. return nil
  6178. }
  6179. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  6180. // the Owner type
  6181. func (target *Owner) UnmarshalBinaryFromReader(reader io.Reader) error {
  6182. ctx := NewDecodingContextFromReader(reader)
  6183. defer ctx.Close()
  6184. err := target.UnmarshalBinaryWithContext(ctx)
  6185. if err != nil {
  6186. return err
  6187. }
  6188. return nil
  6189. }
  6190. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6191. // the Owner type
  6192. func (target *Owner) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6193. // panics are recovered and propagated as errors
  6194. defer func() {
  6195. if r := recover(); r != nil {
  6196. if e, ok := r.(error); ok {
  6197. err = e
  6198. } else if s, ok := r.(string); ok {
  6199. err = fmt.Errorf("unexpected panic: %s", s)
  6200. } else {
  6201. err = fmt.Errorf("unexpected panic: %+v", r)
  6202. }
  6203. }
  6204. }()
  6205. buff := ctx.Buffer
  6206. version := buff.ReadUInt8()
  6207. if version > DefaultCodecVersion {
  6208. return fmt.Errorf("Invalid Version Unmarshalling Owner. Expected %d or less, got %d", DefaultCodecVersion, version)
  6209. }
  6210. var b string
  6211. if ctx.IsStringTable() {
  6212. c := buff.ReadInt() // read string index
  6213. b = ctx.Table.At(c)
  6214. } else {
  6215. b = buff.ReadString() // read string
  6216. }
  6217. a := b
  6218. target.UID = a
  6219. d := buff.ReadBool() // read bool
  6220. target.Controller = d
  6221. // --- [begin][read][alias](OwnerKind) ---
  6222. var e string
  6223. var g string
  6224. if ctx.IsStringTable() {
  6225. h := buff.ReadInt() // read string index
  6226. g = ctx.Table.At(h)
  6227. } else {
  6228. g = buff.ReadString() // read string
  6229. }
  6230. f := g
  6231. e = f
  6232. target.Kind = OwnerKind(e)
  6233. // --- [end][read][alias](OwnerKind) ---
  6234. return nil
  6235. }
  6236. //--------------------------------------------------------------------------
  6237. // PersistentVolume
  6238. //--------------------------------------------------------------------------
  6239. // MarshalBinary serializes the internal properties of this PersistentVolume instance
  6240. // into a byte array
  6241. func (target *PersistentVolume) MarshalBinary() (data []byte, err error) {
  6242. ctx := NewEncodingContext(nil)
  6243. e := target.MarshalBinaryWithContext(ctx)
  6244. if e != nil {
  6245. return nil, e
  6246. }
  6247. return ctx.ToBytes(), nil
  6248. }
  6249. // MarshalBinary serializes the internal properties of this PersistentVolume instance
  6250. // into an io.Writer.
  6251. func (target *PersistentVolume) MarshalBinaryTo(writer io.Writer) error {
  6252. buff := util.NewBufferFromWriter(writer)
  6253. defer buff.Flush()
  6254. ctx := NewEncodingContextFromBuffer(buff, nil)
  6255. return target.MarshalBinaryWithContext(ctx)
  6256. }
  6257. // MarshalBinaryWithContext serializes the internal properties of this PersistentVolume instance
  6258. // into a byte array leveraging a predefined context.
  6259. func (target *PersistentVolume) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6260. // panics are recovered and propagated as errors
  6261. defer func() {
  6262. if r := recover(); r != nil {
  6263. if e, ok := r.(error); ok {
  6264. err = e
  6265. } else if s, ok := r.(string); ok {
  6266. err = fmt.Errorf("unexpected panic: %s", s)
  6267. } else {
  6268. err = fmt.Errorf("unexpected panic: %+v", r)
  6269. }
  6270. }
  6271. }()
  6272. buff := ctx.Buffer
  6273. buff.WriteUInt8(DefaultCodecVersion) // version
  6274. if ctx.IsStringTable() {
  6275. a := ctx.Table.AddOrGet(target.UID)
  6276. buff.WriteInt(a) // write table index
  6277. } else {
  6278. buff.WriteString(target.UID) // write string
  6279. }
  6280. if ctx.IsStringTable() {
  6281. b := ctx.Table.AddOrGet(target.Name)
  6282. buff.WriteInt(b) // write table index
  6283. } else {
  6284. buff.WriteString(target.Name) // write string
  6285. }
  6286. if ctx.IsStringTable() {
  6287. c := ctx.Table.AddOrGet(target.StorageClass)
  6288. buff.WriteInt(c) // write table index
  6289. } else {
  6290. buff.WriteString(target.StorageClass) // write string
  6291. }
  6292. if ctx.IsStringTable() {
  6293. d := ctx.Table.AddOrGet(target.ProviderID)
  6294. buff.WriteInt(d) // write table index
  6295. } else {
  6296. buff.WriteString(target.ProviderID) // write string
  6297. }
  6298. buff.WriteFloat64(target.SizeBytes) // write float64
  6299. // --- [begin][write][reference](time.Time) ---
  6300. e, errA := target.Start.MarshalBinary()
  6301. if errA != nil {
  6302. return errA
  6303. }
  6304. buff.WriteInt(len(e))
  6305. buff.WriteBytes(e)
  6306. // --- [end][write][reference](time.Time) ---
  6307. // --- [begin][write][reference](time.Time) ---
  6308. f, errB := target.End.MarshalBinary()
  6309. if errB != nil {
  6310. return errB
  6311. }
  6312. buff.WriteInt(len(f))
  6313. buff.WriteBytes(f)
  6314. // --- [end][write][reference](time.Time) ---
  6315. return nil
  6316. }
  6317. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6318. // the PersistentVolume type
  6319. func (target *PersistentVolume) UnmarshalBinary(data []byte) error {
  6320. ctx := NewDecodingContextFromBytes(data)
  6321. defer ctx.Close()
  6322. err := target.UnmarshalBinaryWithContext(ctx)
  6323. if err != nil {
  6324. return err
  6325. }
  6326. return nil
  6327. }
  6328. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  6329. // the PersistentVolume type
  6330. func (target *PersistentVolume) UnmarshalBinaryFromReader(reader io.Reader) error {
  6331. ctx := NewDecodingContextFromReader(reader)
  6332. defer ctx.Close()
  6333. err := target.UnmarshalBinaryWithContext(ctx)
  6334. if err != nil {
  6335. return err
  6336. }
  6337. return nil
  6338. }
  6339. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6340. // the PersistentVolume type
  6341. func (target *PersistentVolume) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6342. // panics are recovered and propagated as errors
  6343. defer func() {
  6344. if r := recover(); r != nil {
  6345. if e, ok := r.(error); ok {
  6346. err = e
  6347. } else if s, ok := r.(string); ok {
  6348. err = fmt.Errorf("unexpected panic: %s", s)
  6349. } else {
  6350. err = fmt.Errorf("unexpected panic: %+v", r)
  6351. }
  6352. }
  6353. }()
  6354. buff := ctx.Buffer
  6355. version := buff.ReadUInt8()
  6356. if version > DefaultCodecVersion {
  6357. return fmt.Errorf("Invalid Version Unmarshalling PersistentVolume. Expected %d or less, got %d", DefaultCodecVersion, version)
  6358. }
  6359. var b string
  6360. if ctx.IsStringTable() {
  6361. c := buff.ReadInt() // read string index
  6362. b = ctx.Table.At(c)
  6363. } else {
  6364. b = buff.ReadString() // read string
  6365. }
  6366. a := b
  6367. target.UID = a
  6368. var e string
  6369. if ctx.IsStringTable() {
  6370. f := buff.ReadInt() // read string index
  6371. e = ctx.Table.At(f)
  6372. } else {
  6373. e = buff.ReadString() // read string
  6374. }
  6375. d := e
  6376. target.Name = d
  6377. var h string
  6378. if ctx.IsStringTable() {
  6379. l := buff.ReadInt() // read string index
  6380. h = ctx.Table.At(l)
  6381. } else {
  6382. h = buff.ReadString() // read string
  6383. }
  6384. g := h
  6385. target.StorageClass = g
  6386. var n string
  6387. if ctx.IsStringTable() {
  6388. o := buff.ReadInt() // read string index
  6389. n = ctx.Table.At(o)
  6390. } else {
  6391. n = buff.ReadString() // read string
  6392. }
  6393. m := n
  6394. target.ProviderID = m
  6395. p := buff.ReadFloat64() // read float64
  6396. target.SizeBytes = p
  6397. // --- [begin][read][reference](time.Time) ---
  6398. q := new(time.Time)
  6399. r := buff.ReadInt() // byte array length
  6400. s := buff.ReadBytes(r)
  6401. errA := q.UnmarshalBinary(s)
  6402. if errA != nil {
  6403. return errA
  6404. }
  6405. target.Start = *q
  6406. // --- [end][read][reference](time.Time) ---
  6407. // --- [begin][read][reference](time.Time) ---
  6408. t := new(time.Time)
  6409. u := buff.ReadInt() // byte array length
  6410. w := buff.ReadBytes(u)
  6411. errB := t.UnmarshalBinary(w)
  6412. if errB != nil {
  6413. return errB
  6414. }
  6415. target.End = *t
  6416. // --- [end][read][reference](time.Time) ---
  6417. return nil
  6418. }
  6419. //--------------------------------------------------------------------------
  6420. // PersistentVolumeClaim
  6421. //--------------------------------------------------------------------------
  6422. // MarshalBinary serializes the internal properties of this PersistentVolumeClaim instance
  6423. // into a byte array
  6424. func (target *PersistentVolumeClaim) MarshalBinary() (data []byte, err error) {
  6425. ctx := NewEncodingContext(nil)
  6426. e := target.MarshalBinaryWithContext(ctx)
  6427. if e != nil {
  6428. return nil, e
  6429. }
  6430. return ctx.ToBytes(), nil
  6431. }
  6432. // MarshalBinary serializes the internal properties of this PersistentVolumeClaim instance
  6433. // into an io.Writer.
  6434. func (target *PersistentVolumeClaim) MarshalBinaryTo(writer io.Writer) error {
  6435. buff := util.NewBufferFromWriter(writer)
  6436. defer buff.Flush()
  6437. ctx := NewEncodingContextFromBuffer(buff, nil)
  6438. return target.MarshalBinaryWithContext(ctx)
  6439. }
  6440. // MarshalBinaryWithContext serializes the internal properties of this PersistentVolumeClaim instance
  6441. // into a byte array leveraging a predefined context.
  6442. func (target *PersistentVolumeClaim) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6443. // panics are recovered and propagated as errors
  6444. defer func() {
  6445. if r := recover(); r != nil {
  6446. if e, ok := r.(error); ok {
  6447. err = e
  6448. } else if s, ok := r.(string); ok {
  6449. err = fmt.Errorf("unexpected panic: %s", s)
  6450. } else {
  6451. err = fmt.Errorf("unexpected panic: %+v", r)
  6452. }
  6453. }
  6454. }()
  6455. buff := ctx.Buffer
  6456. buff.WriteUInt8(DefaultCodecVersion) // version
  6457. if ctx.IsStringTable() {
  6458. a := ctx.Table.AddOrGet(target.UID)
  6459. buff.WriteInt(a) // write table index
  6460. } else {
  6461. buff.WriteString(target.UID) // write string
  6462. }
  6463. if ctx.IsStringTable() {
  6464. b := ctx.Table.AddOrGet(target.NamespaceUID)
  6465. buff.WriteInt(b) // write table index
  6466. } else {
  6467. buff.WriteString(target.NamespaceUID) // write string
  6468. }
  6469. if ctx.IsStringTable() {
  6470. c := ctx.Table.AddOrGet(target.Name)
  6471. buff.WriteInt(c) // write table index
  6472. } else {
  6473. buff.WriteString(target.Name) // write string
  6474. }
  6475. if ctx.IsStringTable() {
  6476. d := ctx.Table.AddOrGet(target.PersistentVolumeUID)
  6477. buff.WriteInt(d) // write table index
  6478. } else {
  6479. buff.WriteString(target.PersistentVolumeUID) // write string
  6480. }
  6481. if ctx.IsStringTable() {
  6482. e := ctx.Table.AddOrGet(target.StorageClass)
  6483. buff.WriteInt(e) // write table index
  6484. } else {
  6485. buff.WriteString(target.StorageClass) // write string
  6486. }
  6487. // --- [begin][write][reference](time.Time) ---
  6488. f, errA := target.Start.MarshalBinary()
  6489. if errA != nil {
  6490. return errA
  6491. }
  6492. buff.WriteInt(len(f))
  6493. buff.WriteBytes(f)
  6494. // --- [end][write][reference](time.Time) ---
  6495. // --- [begin][write][reference](time.Time) ---
  6496. g, errB := target.End.MarshalBinary()
  6497. if errB != nil {
  6498. return errB
  6499. }
  6500. buff.WriteInt(len(g))
  6501. buff.WriteBytes(g)
  6502. // --- [end][write][reference](time.Time) ---
  6503. buff.WriteFloat64(target.RequestedBytes) // write float64
  6504. buff.WriteFloat64(target.UsageBytesAvg) // write float64
  6505. buff.WriteFloat64(target.UsageBytesMax) // write float64
  6506. return nil
  6507. }
  6508. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6509. // the PersistentVolumeClaim type
  6510. func (target *PersistentVolumeClaim) UnmarshalBinary(data []byte) error {
  6511. ctx := NewDecodingContextFromBytes(data)
  6512. defer ctx.Close()
  6513. err := target.UnmarshalBinaryWithContext(ctx)
  6514. if err != nil {
  6515. return err
  6516. }
  6517. return nil
  6518. }
  6519. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  6520. // the PersistentVolumeClaim type
  6521. func (target *PersistentVolumeClaim) UnmarshalBinaryFromReader(reader io.Reader) error {
  6522. ctx := NewDecodingContextFromReader(reader)
  6523. defer ctx.Close()
  6524. err := target.UnmarshalBinaryWithContext(ctx)
  6525. if err != nil {
  6526. return err
  6527. }
  6528. return nil
  6529. }
  6530. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6531. // the PersistentVolumeClaim type
  6532. func (target *PersistentVolumeClaim) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6533. // panics are recovered and propagated as errors
  6534. defer func() {
  6535. if r := recover(); r != nil {
  6536. if e, ok := r.(error); ok {
  6537. err = e
  6538. } else if s, ok := r.(string); ok {
  6539. err = fmt.Errorf("unexpected panic: %s", s)
  6540. } else {
  6541. err = fmt.Errorf("unexpected panic: %+v", r)
  6542. }
  6543. }
  6544. }()
  6545. buff := ctx.Buffer
  6546. version := buff.ReadUInt8()
  6547. if version > DefaultCodecVersion {
  6548. return fmt.Errorf("Invalid Version Unmarshalling PersistentVolumeClaim. Expected %d or less, got %d", DefaultCodecVersion, version)
  6549. }
  6550. var b string
  6551. if ctx.IsStringTable() {
  6552. c := buff.ReadInt() // read string index
  6553. b = ctx.Table.At(c)
  6554. } else {
  6555. b = buff.ReadString() // read string
  6556. }
  6557. a := b
  6558. target.UID = a
  6559. var e string
  6560. if ctx.IsStringTable() {
  6561. f := buff.ReadInt() // read string index
  6562. e = ctx.Table.At(f)
  6563. } else {
  6564. e = buff.ReadString() // read string
  6565. }
  6566. d := e
  6567. target.NamespaceUID = d
  6568. var h string
  6569. if ctx.IsStringTable() {
  6570. l := buff.ReadInt() // read string index
  6571. h = ctx.Table.At(l)
  6572. } else {
  6573. h = buff.ReadString() // read string
  6574. }
  6575. g := h
  6576. target.Name = g
  6577. var n string
  6578. if ctx.IsStringTable() {
  6579. o := buff.ReadInt() // read string index
  6580. n = ctx.Table.At(o)
  6581. } else {
  6582. n = buff.ReadString() // read string
  6583. }
  6584. m := n
  6585. target.PersistentVolumeUID = m
  6586. var q string
  6587. if ctx.IsStringTable() {
  6588. r := buff.ReadInt() // read string index
  6589. q = ctx.Table.At(r)
  6590. } else {
  6591. q = buff.ReadString() // read string
  6592. }
  6593. p := q
  6594. target.StorageClass = p
  6595. // --- [begin][read][reference](time.Time) ---
  6596. s := new(time.Time)
  6597. t := buff.ReadInt() // byte array length
  6598. u := buff.ReadBytes(t)
  6599. errA := s.UnmarshalBinary(u)
  6600. if errA != nil {
  6601. return errA
  6602. }
  6603. target.Start = *s
  6604. // --- [end][read][reference](time.Time) ---
  6605. // --- [begin][read][reference](time.Time) ---
  6606. w := new(time.Time)
  6607. x := buff.ReadInt() // byte array length
  6608. y := buff.ReadBytes(x)
  6609. errB := w.UnmarshalBinary(y)
  6610. if errB != nil {
  6611. return errB
  6612. }
  6613. target.End = *w
  6614. // --- [end][read][reference](time.Time) ---
  6615. aa := buff.ReadFloat64() // read float64
  6616. target.RequestedBytes = aa
  6617. bb := buff.ReadFloat64() // read float64
  6618. target.UsageBytesAvg = bb
  6619. cc := buff.ReadFloat64() // read float64
  6620. target.UsageBytesMax = cc
  6621. return nil
  6622. }
  6623. //--------------------------------------------------------------------------
  6624. // Pod
  6625. //--------------------------------------------------------------------------
  6626. // MarshalBinary serializes the internal properties of this Pod instance
  6627. // into a byte array
  6628. func (target *Pod) MarshalBinary() (data []byte, err error) {
  6629. ctx := NewEncodingContext(nil)
  6630. e := target.MarshalBinaryWithContext(ctx)
  6631. if e != nil {
  6632. return nil, e
  6633. }
  6634. return ctx.ToBytes(), nil
  6635. }
  6636. // MarshalBinary serializes the internal properties of this Pod instance
  6637. // into an io.Writer.
  6638. func (target *Pod) MarshalBinaryTo(writer io.Writer) error {
  6639. buff := util.NewBufferFromWriter(writer)
  6640. defer buff.Flush()
  6641. ctx := NewEncodingContextFromBuffer(buff, nil)
  6642. return target.MarshalBinaryWithContext(ctx)
  6643. }
  6644. // MarshalBinaryWithContext serializes the internal properties of this Pod instance
  6645. // into a byte array leveraging a predefined context.
  6646. func (target *Pod) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6647. // panics are recovered and propagated as errors
  6648. defer func() {
  6649. if r := recover(); r != nil {
  6650. if e, ok := r.(error); ok {
  6651. err = e
  6652. } else if s, ok := r.(string); ok {
  6653. err = fmt.Errorf("unexpected panic: %s", s)
  6654. } else {
  6655. err = fmt.Errorf("unexpected panic: %+v", r)
  6656. }
  6657. }
  6658. }()
  6659. buff := ctx.Buffer
  6660. buff.WriteUInt8(DefaultCodecVersion) // version
  6661. if ctx.IsStringTable() {
  6662. a := ctx.Table.AddOrGet(target.UID)
  6663. buff.WriteInt(a) // write table index
  6664. } else {
  6665. buff.WriteString(target.UID) // write string
  6666. }
  6667. if ctx.IsStringTable() {
  6668. b := ctx.Table.AddOrGet(target.NamespaceUID)
  6669. buff.WriteInt(b) // write table index
  6670. } else {
  6671. buff.WriteString(target.NamespaceUID) // write string
  6672. }
  6673. if ctx.IsStringTable() {
  6674. c := ctx.Table.AddOrGet(target.NodeUID)
  6675. buff.WriteInt(c) // write table index
  6676. } else {
  6677. buff.WriteString(target.NodeUID) // write string
  6678. }
  6679. if ctx.IsStringTable() {
  6680. d := ctx.Table.AddOrGet(target.Name)
  6681. buff.WriteInt(d) // write table index
  6682. } else {
  6683. buff.WriteString(target.Name) // write string
  6684. }
  6685. if target.Owners == nil {
  6686. buff.WriteUInt8(uint8(0)) // write nil byte
  6687. } else {
  6688. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6689. // --- [begin][write][slice]([]Owner) ---
  6690. buff.WriteInt(len(target.Owners)) // slice length
  6691. for i := range target.Owners {
  6692. // --- [begin][write][struct](Owner) ---
  6693. buff.WriteInt(0) // [compatibility, unused]
  6694. errA := target.Owners[i].MarshalBinaryWithContext(ctx)
  6695. if errA != nil {
  6696. return errA
  6697. }
  6698. // --- [end][write][struct](Owner) ---
  6699. }
  6700. // --- [end][write][slice]([]Owner) ---
  6701. }
  6702. if target.PVCVolumes == nil {
  6703. buff.WriteUInt8(uint8(0)) // write nil byte
  6704. } else {
  6705. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6706. // --- [begin][write][slice]([]PodPVCVolume) ---
  6707. buff.WriteInt(len(target.PVCVolumes)) // slice length
  6708. for j := range target.PVCVolumes {
  6709. // --- [begin][write][struct](PodPVCVolume) ---
  6710. buff.WriteInt(0) // [compatibility, unused]
  6711. errB := target.PVCVolumes[j].MarshalBinaryWithContext(ctx)
  6712. if errB != nil {
  6713. return errB
  6714. }
  6715. // --- [end][write][struct](PodPVCVolume) ---
  6716. }
  6717. // --- [end][write][slice]([]PodPVCVolume) ---
  6718. }
  6719. if target.Labels == nil {
  6720. buff.WriteUInt8(uint8(0)) // write nil byte
  6721. } else {
  6722. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6723. // --- [begin][write][map](map[string]string) ---
  6724. buff.WriteInt(len(target.Labels)) // map length
  6725. for v, z := range target.Labels {
  6726. if ctx.IsStringTable() {
  6727. e := ctx.Table.AddOrGet(v)
  6728. buff.WriteInt(e) // write table index
  6729. } else {
  6730. buff.WriteString(v) // write string
  6731. }
  6732. if ctx.IsStringTable() {
  6733. f := ctx.Table.AddOrGet(z)
  6734. buff.WriteInt(f) // write table index
  6735. } else {
  6736. buff.WriteString(z) // write string
  6737. }
  6738. }
  6739. // --- [end][write][map](map[string]string) ---
  6740. }
  6741. if target.Annotations == nil {
  6742. buff.WriteUInt8(uint8(0)) // write nil byte
  6743. } else {
  6744. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6745. // --- [begin][write][map](map[string]string) ---
  6746. buff.WriteInt(len(target.Annotations)) // map length
  6747. for vv, zz := range target.Annotations {
  6748. if ctx.IsStringTable() {
  6749. g := ctx.Table.AddOrGet(vv)
  6750. buff.WriteInt(g) // write table index
  6751. } else {
  6752. buff.WriteString(vv) // write string
  6753. }
  6754. if ctx.IsStringTable() {
  6755. h := ctx.Table.AddOrGet(zz)
  6756. buff.WriteInt(h) // write table index
  6757. } else {
  6758. buff.WriteString(zz) // write string
  6759. }
  6760. }
  6761. // --- [end][write][map](map[string]string) ---
  6762. }
  6763. if target.NetworkTrafficDetails == nil {
  6764. buff.WriteUInt8(uint8(0)) // write nil byte
  6765. } else {
  6766. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6767. // --- [begin][write][slice]([]NetworkTrafficDetail) ---
  6768. buff.WriteInt(len(target.NetworkTrafficDetails)) // slice length
  6769. for ii := range target.NetworkTrafficDetails {
  6770. // --- [begin][write][struct](NetworkTrafficDetail) ---
  6771. buff.WriteInt(0) // [compatibility, unused]
  6772. errC := target.NetworkTrafficDetails[ii].MarshalBinaryWithContext(ctx)
  6773. if errC != nil {
  6774. return errC
  6775. }
  6776. // --- [end][write][struct](NetworkTrafficDetail) ---
  6777. }
  6778. // --- [end][write][slice]([]NetworkTrafficDetail) ---
  6779. }
  6780. // --- [begin][write][reference](time.Time) ---
  6781. l, errD := target.Start.MarshalBinary()
  6782. if errD != nil {
  6783. return errD
  6784. }
  6785. buff.WriteInt(len(l))
  6786. buff.WriteBytes(l)
  6787. // --- [end][write][reference](time.Time) ---
  6788. // --- [begin][write][reference](time.Time) ---
  6789. m, errE := target.End.MarshalBinary()
  6790. if errE != nil {
  6791. return errE
  6792. }
  6793. buff.WriteInt(len(m))
  6794. buff.WriteBytes(m)
  6795. // --- [end][write][reference](time.Time) ---
  6796. return nil
  6797. }
  6798. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6799. // the Pod type
  6800. func (target *Pod) UnmarshalBinary(data []byte) error {
  6801. ctx := NewDecodingContextFromBytes(data)
  6802. defer ctx.Close()
  6803. err := target.UnmarshalBinaryWithContext(ctx)
  6804. if err != nil {
  6805. return err
  6806. }
  6807. return nil
  6808. }
  6809. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  6810. // the Pod type
  6811. func (target *Pod) UnmarshalBinaryFromReader(reader io.Reader) error {
  6812. ctx := NewDecodingContextFromReader(reader)
  6813. defer ctx.Close()
  6814. err := target.UnmarshalBinaryWithContext(ctx)
  6815. if err != nil {
  6816. return err
  6817. }
  6818. return nil
  6819. }
  6820. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6821. // the Pod type
  6822. func (target *Pod) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6823. // panics are recovered and propagated as errors
  6824. defer func() {
  6825. if r := recover(); r != nil {
  6826. if e, ok := r.(error); ok {
  6827. err = e
  6828. } else if s, ok := r.(string); ok {
  6829. err = fmt.Errorf("unexpected panic: %s", s)
  6830. } else {
  6831. err = fmt.Errorf("unexpected panic: %+v", r)
  6832. }
  6833. }
  6834. }()
  6835. buff := ctx.Buffer
  6836. version := buff.ReadUInt8()
  6837. if version > DefaultCodecVersion {
  6838. return fmt.Errorf("Invalid Version Unmarshalling Pod. Expected %d or less, got %d", DefaultCodecVersion, version)
  6839. }
  6840. var b string
  6841. if ctx.IsStringTable() {
  6842. c := buff.ReadInt() // read string index
  6843. b = ctx.Table.At(c)
  6844. } else {
  6845. b = buff.ReadString() // read string
  6846. }
  6847. a := b
  6848. target.UID = a
  6849. var e string
  6850. if ctx.IsStringTable() {
  6851. f := buff.ReadInt() // read string index
  6852. e = ctx.Table.At(f)
  6853. } else {
  6854. e = buff.ReadString() // read string
  6855. }
  6856. d := e
  6857. target.NamespaceUID = d
  6858. var h string
  6859. if ctx.IsStringTable() {
  6860. l := buff.ReadInt() // read string index
  6861. h = ctx.Table.At(l)
  6862. } else {
  6863. h = buff.ReadString() // read string
  6864. }
  6865. g := h
  6866. target.NodeUID = g
  6867. var n string
  6868. if ctx.IsStringTable() {
  6869. o := buff.ReadInt() // read string index
  6870. n = ctx.Table.At(o)
  6871. } else {
  6872. n = buff.ReadString() // read string
  6873. }
  6874. m := n
  6875. target.Name = m
  6876. if buff.ReadUInt8() == uint8(0) {
  6877. target.Owners = nil
  6878. } else {
  6879. // --- [begin][read][slice]([]Owner) ---
  6880. q := buff.ReadInt() // slice len
  6881. p := make([]Owner, q)
  6882. for i := range q {
  6883. // --- [begin][read][struct](Owner) ---
  6884. s := new(Owner)
  6885. buff.ReadInt() // [compatibility, unused]
  6886. errA := s.UnmarshalBinaryWithContext(ctx)
  6887. if errA != nil {
  6888. return errA
  6889. }
  6890. r := *s
  6891. // --- [end][read][struct](Owner) ---
  6892. p[i] = r
  6893. }
  6894. target.Owners = p
  6895. // --- [end][read][slice]([]Owner) ---
  6896. }
  6897. if buff.ReadUInt8() == uint8(0) {
  6898. target.PVCVolumes = nil
  6899. } else {
  6900. // --- [begin][read][slice]([]PodPVCVolume) ---
  6901. u := buff.ReadInt() // slice len
  6902. t := make([]PodPVCVolume, u)
  6903. for j := range u {
  6904. // --- [begin][read][struct](PodPVCVolume) ---
  6905. x := new(PodPVCVolume)
  6906. buff.ReadInt() // [compatibility, unused]
  6907. errB := x.UnmarshalBinaryWithContext(ctx)
  6908. if errB != nil {
  6909. return errB
  6910. }
  6911. w := *x
  6912. // --- [end][read][struct](PodPVCVolume) ---
  6913. t[j] = w
  6914. }
  6915. target.PVCVolumes = t
  6916. // --- [end][read][slice]([]PodPVCVolume) ---
  6917. }
  6918. if buff.ReadUInt8() == uint8(0) {
  6919. target.Labels = nil
  6920. } else {
  6921. // --- [begin][read][map](map[string]string) ---
  6922. aa := buff.ReadInt() // map len
  6923. y := make(map[string]string, aa)
  6924. for range aa {
  6925. var v string
  6926. var cc string
  6927. if ctx.IsStringTable() {
  6928. dd := buff.ReadInt() // read string index
  6929. cc = ctx.Table.At(dd)
  6930. } else {
  6931. cc = buff.ReadString() // read string
  6932. }
  6933. bb := cc
  6934. v = bb
  6935. var z string
  6936. var ff string
  6937. if ctx.IsStringTable() {
  6938. gg := buff.ReadInt() // read string index
  6939. ff = ctx.Table.At(gg)
  6940. } else {
  6941. ff = buff.ReadString() // read string
  6942. }
  6943. ee := ff
  6944. z = ee
  6945. y[v] = z
  6946. }
  6947. target.Labels = y
  6948. // --- [end][read][map](map[string]string) ---
  6949. }
  6950. if buff.ReadUInt8() == uint8(0) {
  6951. target.Annotations = nil
  6952. } else {
  6953. // --- [begin][read][map](map[string]string) ---
  6954. ll := buff.ReadInt() // map len
  6955. hh := make(map[string]string, ll)
  6956. for range ll {
  6957. var vv string
  6958. var nn string
  6959. if ctx.IsStringTable() {
  6960. oo := buff.ReadInt() // read string index
  6961. nn = ctx.Table.At(oo)
  6962. } else {
  6963. nn = buff.ReadString() // read string
  6964. }
  6965. mm := nn
  6966. vv = mm
  6967. var zz string
  6968. var qq string
  6969. if ctx.IsStringTable() {
  6970. rr := buff.ReadInt() // read string index
  6971. qq = ctx.Table.At(rr)
  6972. } else {
  6973. qq = buff.ReadString() // read string
  6974. }
  6975. pp := qq
  6976. zz = pp
  6977. hh[vv] = zz
  6978. }
  6979. target.Annotations = hh
  6980. // --- [end][read][map](map[string]string) ---
  6981. }
  6982. if buff.ReadUInt8() == uint8(0) {
  6983. target.NetworkTrafficDetails = nil
  6984. } else {
  6985. // --- [begin][read][slice]([]NetworkTrafficDetail) ---
  6986. tt := buff.ReadInt() // slice len
  6987. ss := make([]NetworkTrafficDetail, tt)
  6988. for ii := range tt {
  6989. // --- [begin][read][struct](NetworkTrafficDetail) ---
  6990. ww := new(NetworkTrafficDetail)
  6991. buff.ReadInt() // [compatibility, unused]
  6992. errC := ww.UnmarshalBinaryWithContext(ctx)
  6993. if errC != nil {
  6994. return errC
  6995. }
  6996. uu := *ww
  6997. // --- [end][read][struct](NetworkTrafficDetail) ---
  6998. ss[ii] = uu
  6999. }
  7000. target.NetworkTrafficDetails = ss
  7001. // --- [end][read][slice]([]NetworkTrafficDetail) ---
  7002. }
  7003. // --- [begin][read][reference](time.Time) ---
  7004. xx := new(time.Time)
  7005. yy := buff.ReadInt() // byte array length
  7006. aaa := buff.ReadBytes(yy)
  7007. errD := xx.UnmarshalBinary(aaa)
  7008. if errD != nil {
  7009. return errD
  7010. }
  7011. target.Start = *xx
  7012. // --- [end][read][reference](time.Time) ---
  7013. // --- [begin][read][reference](time.Time) ---
  7014. bbb := new(time.Time)
  7015. ccc := buff.ReadInt() // byte array length
  7016. ddd := buff.ReadBytes(ccc)
  7017. errE := bbb.UnmarshalBinary(ddd)
  7018. if errE != nil {
  7019. return errE
  7020. }
  7021. target.End = *bbb
  7022. // --- [end][read][reference](time.Time) ---
  7023. return nil
  7024. }
  7025. //--------------------------------------------------------------------------
  7026. // PodPVCVolume
  7027. //--------------------------------------------------------------------------
  7028. // MarshalBinary serializes the internal properties of this PodPVCVolume instance
  7029. // into a byte array
  7030. func (target *PodPVCVolume) MarshalBinary() (data []byte, err error) {
  7031. ctx := NewEncodingContext(nil)
  7032. e := target.MarshalBinaryWithContext(ctx)
  7033. if e != nil {
  7034. return nil, e
  7035. }
  7036. return ctx.ToBytes(), nil
  7037. }
  7038. // MarshalBinary serializes the internal properties of this PodPVCVolume instance
  7039. // into an io.Writer.
  7040. func (target *PodPVCVolume) MarshalBinaryTo(writer io.Writer) error {
  7041. buff := util.NewBufferFromWriter(writer)
  7042. defer buff.Flush()
  7043. ctx := NewEncodingContextFromBuffer(buff, nil)
  7044. return target.MarshalBinaryWithContext(ctx)
  7045. }
  7046. // MarshalBinaryWithContext serializes the internal properties of this PodPVCVolume instance
  7047. // into a byte array leveraging a predefined context.
  7048. func (target *PodPVCVolume) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  7049. // panics are recovered and propagated as errors
  7050. defer func() {
  7051. if r := recover(); r != nil {
  7052. if e, ok := r.(error); ok {
  7053. err = e
  7054. } else if s, ok := r.(string); ok {
  7055. err = fmt.Errorf("unexpected panic: %s", s)
  7056. } else {
  7057. err = fmt.Errorf("unexpected panic: %+v", r)
  7058. }
  7059. }
  7060. }()
  7061. buff := ctx.Buffer
  7062. buff.WriteUInt8(DefaultCodecVersion) // version
  7063. if ctx.IsStringTable() {
  7064. a := ctx.Table.AddOrGet(target.Name)
  7065. buff.WriteInt(a) // write table index
  7066. } else {
  7067. buff.WriteString(target.Name) // write string
  7068. }
  7069. if ctx.IsStringTable() {
  7070. b := ctx.Table.AddOrGet(target.PersistentVolumeClaimUID)
  7071. buff.WriteInt(b) // write table index
  7072. } else {
  7073. buff.WriteString(target.PersistentVolumeClaimUID) // write string
  7074. }
  7075. return nil
  7076. }
  7077. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7078. // the PodPVCVolume type
  7079. func (target *PodPVCVolume) UnmarshalBinary(data []byte) error {
  7080. ctx := NewDecodingContextFromBytes(data)
  7081. defer ctx.Close()
  7082. err := target.UnmarshalBinaryWithContext(ctx)
  7083. if err != nil {
  7084. return err
  7085. }
  7086. return nil
  7087. }
  7088. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  7089. // the PodPVCVolume type
  7090. func (target *PodPVCVolume) UnmarshalBinaryFromReader(reader io.Reader) error {
  7091. ctx := NewDecodingContextFromReader(reader)
  7092. defer ctx.Close()
  7093. err := target.UnmarshalBinaryWithContext(ctx)
  7094. if err != nil {
  7095. return err
  7096. }
  7097. return nil
  7098. }
  7099. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7100. // the PodPVCVolume type
  7101. func (target *PodPVCVolume) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7102. // panics are recovered and propagated as errors
  7103. defer func() {
  7104. if r := recover(); r != nil {
  7105. if e, ok := r.(error); ok {
  7106. err = e
  7107. } else if s, ok := r.(string); ok {
  7108. err = fmt.Errorf("unexpected panic: %s", s)
  7109. } else {
  7110. err = fmt.Errorf("unexpected panic: %+v", r)
  7111. }
  7112. }
  7113. }()
  7114. buff := ctx.Buffer
  7115. version := buff.ReadUInt8()
  7116. if version > DefaultCodecVersion {
  7117. return fmt.Errorf("Invalid Version Unmarshalling PodPVCVolume. Expected %d or less, got %d", DefaultCodecVersion, version)
  7118. }
  7119. var b string
  7120. if ctx.IsStringTable() {
  7121. c := buff.ReadInt() // read string index
  7122. b = ctx.Table.At(c)
  7123. } else {
  7124. b = buff.ReadString() // read string
  7125. }
  7126. a := b
  7127. target.Name = a
  7128. var e string
  7129. if ctx.IsStringTable() {
  7130. f := buff.ReadInt() // read string index
  7131. e = ctx.Table.At(f)
  7132. } else {
  7133. e = buff.ReadString() // read string
  7134. }
  7135. d := e
  7136. target.PersistentVolumeClaimUID = d
  7137. return nil
  7138. }
  7139. //--------------------------------------------------------------------------
  7140. // ReplicaSet
  7141. //--------------------------------------------------------------------------
  7142. // MarshalBinary serializes the internal properties of this ReplicaSet instance
  7143. // into a byte array
  7144. func (target *ReplicaSet) MarshalBinary() (data []byte, err error) {
  7145. ctx := NewEncodingContext(nil)
  7146. e := target.MarshalBinaryWithContext(ctx)
  7147. if e != nil {
  7148. return nil, e
  7149. }
  7150. return ctx.ToBytes(), nil
  7151. }
  7152. // MarshalBinary serializes the internal properties of this ReplicaSet instance
  7153. // into an io.Writer.
  7154. func (target *ReplicaSet) MarshalBinaryTo(writer io.Writer) error {
  7155. buff := util.NewBufferFromWriter(writer)
  7156. defer buff.Flush()
  7157. ctx := NewEncodingContextFromBuffer(buff, nil)
  7158. return target.MarshalBinaryWithContext(ctx)
  7159. }
  7160. // MarshalBinaryWithContext serializes the internal properties of this ReplicaSet instance
  7161. // into a byte array leveraging a predefined context.
  7162. func (target *ReplicaSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  7163. // panics are recovered and propagated as errors
  7164. defer func() {
  7165. if r := recover(); r != nil {
  7166. if e, ok := r.(error); ok {
  7167. err = e
  7168. } else if s, ok := r.(string); ok {
  7169. err = fmt.Errorf("unexpected panic: %s", s)
  7170. } else {
  7171. err = fmt.Errorf("unexpected panic: %+v", r)
  7172. }
  7173. }
  7174. }()
  7175. buff := ctx.Buffer
  7176. buff.WriteUInt8(DefaultCodecVersion) // version
  7177. if ctx.IsStringTable() {
  7178. a := ctx.Table.AddOrGet(target.UID)
  7179. buff.WriteInt(a) // write table index
  7180. } else {
  7181. buff.WriteString(target.UID) // write string
  7182. }
  7183. if ctx.IsStringTable() {
  7184. b := ctx.Table.AddOrGet(target.NamespaceUID)
  7185. buff.WriteInt(b) // write table index
  7186. } else {
  7187. buff.WriteString(target.NamespaceUID) // write string
  7188. }
  7189. if ctx.IsStringTable() {
  7190. c := ctx.Table.AddOrGet(target.Name)
  7191. buff.WriteInt(c) // write table index
  7192. } else {
  7193. buff.WriteString(target.Name) // write string
  7194. }
  7195. if target.Owners == nil {
  7196. buff.WriteUInt8(uint8(0)) // write nil byte
  7197. } else {
  7198. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7199. // --- [begin][write][slice]([]Owner) ---
  7200. buff.WriteInt(len(target.Owners)) // slice length
  7201. for i := range target.Owners {
  7202. // --- [begin][write][struct](Owner) ---
  7203. buff.WriteInt(0) // [compatibility, unused]
  7204. errA := target.Owners[i].MarshalBinaryWithContext(ctx)
  7205. if errA != nil {
  7206. return errA
  7207. }
  7208. // --- [end][write][struct](Owner) ---
  7209. }
  7210. // --- [end][write][slice]([]Owner) ---
  7211. }
  7212. if target.Labels == nil {
  7213. buff.WriteUInt8(uint8(0)) // write nil byte
  7214. } else {
  7215. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7216. // --- [begin][write][map](map[string]string) ---
  7217. buff.WriteInt(len(target.Labels)) // map length
  7218. for v, z := range target.Labels {
  7219. if ctx.IsStringTable() {
  7220. d := ctx.Table.AddOrGet(v)
  7221. buff.WriteInt(d) // write table index
  7222. } else {
  7223. buff.WriteString(v) // write string
  7224. }
  7225. if ctx.IsStringTable() {
  7226. e := ctx.Table.AddOrGet(z)
  7227. buff.WriteInt(e) // write table index
  7228. } else {
  7229. buff.WriteString(z) // write string
  7230. }
  7231. }
  7232. // --- [end][write][map](map[string]string) ---
  7233. }
  7234. if target.Annotations == nil {
  7235. buff.WriteUInt8(uint8(0)) // write nil byte
  7236. } else {
  7237. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7238. // --- [begin][write][map](map[string]string) ---
  7239. buff.WriteInt(len(target.Annotations)) // map length
  7240. for vv, zz := range target.Annotations {
  7241. if ctx.IsStringTable() {
  7242. f := ctx.Table.AddOrGet(vv)
  7243. buff.WriteInt(f) // write table index
  7244. } else {
  7245. buff.WriteString(vv) // write string
  7246. }
  7247. if ctx.IsStringTable() {
  7248. g := ctx.Table.AddOrGet(zz)
  7249. buff.WriteInt(g) // write table index
  7250. } else {
  7251. buff.WriteString(zz) // write string
  7252. }
  7253. }
  7254. // --- [end][write][map](map[string]string) ---
  7255. }
  7256. // --- [begin][write][reference](time.Time) ---
  7257. h, errB := target.Start.MarshalBinary()
  7258. if errB != nil {
  7259. return errB
  7260. }
  7261. buff.WriteInt(len(h))
  7262. buff.WriteBytes(h)
  7263. // --- [end][write][reference](time.Time) ---
  7264. // --- [begin][write][reference](time.Time) ---
  7265. l, errC := target.End.MarshalBinary()
  7266. if errC != nil {
  7267. return errC
  7268. }
  7269. buff.WriteInt(len(l))
  7270. buff.WriteBytes(l)
  7271. // --- [end][write][reference](time.Time) ---
  7272. return nil
  7273. }
  7274. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7275. // the ReplicaSet type
  7276. func (target *ReplicaSet) UnmarshalBinary(data []byte) error {
  7277. ctx := NewDecodingContextFromBytes(data)
  7278. defer ctx.Close()
  7279. err := target.UnmarshalBinaryWithContext(ctx)
  7280. if err != nil {
  7281. return err
  7282. }
  7283. return nil
  7284. }
  7285. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  7286. // the ReplicaSet type
  7287. func (target *ReplicaSet) UnmarshalBinaryFromReader(reader io.Reader) error {
  7288. ctx := NewDecodingContextFromReader(reader)
  7289. defer ctx.Close()
  7290. err := target.UnmarshalBinaryWithContext(ctx)
  7291. if err != nil {
  7292. return err
  7293. }
  7294. return nil
  7295. }
  7296. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7297. // the ReplicaSet type
  7298. func (target *ReplicaSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7299. // panics are recovered and propagated as errors
  7300. defer func() {
  7301. if r := recover(); r != nil {
  7302. if e, ok := r.(error); ok {
  7303. err = e
  7304. } else if s, ok := r.(string); ok {
  7305. err = fmt.Errorf("unexpected panic: %s", s)
  7306. } else {
  7307. err = fmt.Errorf("unexpected panic: %+v", r)
  7308. }
  7309. }
  7310. }()
  7311. buff := ctx.Buffer
  7312. version := buff.ReadUInt8()
  7313. if version > DefaultCodecVersion {
  7314. return fmt.Errorf("Invalid Version Unmarshalling ReplicaSet. Expected %d or less, got %d", DefaultCodecVersion, version)
  7315. }
  7316. var b string
  7317. if ctx.IsStringTable() {
  7318. c := buff.ReadInt() // read string index
  7319. b = ctx.Table.At(c)
  7320. } else {
  7321. b = buff.ReadString() // read string
  7322. }
  7323. a := b
  7324. target.UID = a
  7325. var e string
  7326. if ctx.IsStringTable() {
  7327. f := buff.ReadInt() // read string index
  7328. e = ctx.Table.At(f)
  7329. } else {
  7330. e = buff.ReadString() // read string
  7331. }
  7332. d := e
  7333. target.NamespaceUID = d
  7334. var h string
  7335. if ctx.IsStringTable() {
  7336. l := buff.ReadInt() // read string index
  7337. h = ctx.Table.At(l)
  7338. } else {
  7339. h = buff.ReadString() // read string
  7340. }
  7341. g := h
  7342. target.Name = g
  7343. if buff.ReadUInt8() == uint8(0) {
  7344. target.Owners = nil
  7345. } else {
  7346. // --- [begin][read][slice]([]Owner) ---
  7347. n := buff.ReadInt() // slice len
  7348. m := make([]Owner, n)
  7349. for i := range n {
  7350. // --- [begin][read][struct](Owner) ---
  7351. p := new(Owner)
  7352. buff.ReadInt() // [compatibility, unused]
  7353. errA := p.UnmarshalBinaryWithContext(ctx)
  7354. if errA != nil {
  7355. return errA
  7356. }
  7357. o := *p
  7358. // --- [end][read][struct](Owner) ---
  7359. m[i] = o
  7360. }
  7361. target.Owners = m
  7362. // --- [end][read][slice]([]Owner) ---
  7363. }
  7364. if buff.ReadUInt8() == uint8(0) {
  7365. target.Labels = nil
  7366. } else {
  7367. // --- [begin][read][map](map[string]string) ---
  7368. r := buff.ReadInt() // map len
  7369. q := make(map[string]string, r)
  7370. for range r {
  7371. var v string
  7372. var t string
  7373. if ctx.IsStringTable() {
  7374. u := buff.ReadInt() // read string index
  7375. t = ctx.Table.At(u)
  7376. } else {
  7377. t = buff.ReadString() // read string
  7378. }
  7379. s := t
  7380. v = s
  7381. var z string
  7382. var x string
  7383. if ctx.IsStringTable() {
  7384. y := buff.ReadInt() // read string index
  7385. x = ctx.Table.At(y)
  7386. } else {
  7387. x = buff.ReadString() // read string
  7388. }
  7389. w := x
  7390. z = w
  7391. q[v] = z
  7392. }
  7393. target.Labels = q
  7394. // --- [end][read][map](map[string]string) ---
  7395. }
  7396. if buff.ReadUInt8() == uint8(0) {
  7397. target.Annotations = nil
  7398. } else {
  7399. // --- [begin][read][map](map[string]string) ---
  7400. bb := buff.ReadInt() // map len
  7401. aa := make(map[string]string, bb)
  7402. for range bb {
  7403. var vv string
  7404. var dd string
  7405. if ctx.IsStringTable() {
  7406. ee := buff.ReadInt() // read string index
  7407. dd = ctx.Table.At(ee)
  7408. } else {
  7409. dd = buff.ReadString() // read string
  7410. }
  7411. cc := dd
  7412. vv = cc
  7413. var zz string
  7414. var gg string
  7415. if ctx.IsStringTable() {
  7416. hh := buff.ReadInt() // read string index
  7417. gg = ctx.Table.At(hh)
  7418. } else {
  7419. gg = buff.ReadString() // read string
  7420. }
  7421. ff := gg
  7422. zz = ff
  7423. aa[vv] = zz
  7424. }
  7425. target.Annotations = aa
  7426. // --- [end][read][map](map[string]string) ---
  7427. }
  7428. // --- [begin][read][reference](time.Time) ---
  7429. ll := new(time.Time)
  7430. mm := buff.ReadInt() // byte array length
  7431. nn := buff.ReadBytes(mm)
  7432. errB := ll.UnmarshalBinary(nn)
  7433. if errB != nil {
  7434. return errB
  7435. }
  7436. target.Start = *ll
  7437. // --- [end][read][reference](time.Time) ---
  7438. // --- [begin][read][reference](time.Time) ---
  7439. oo := new(time.Time)
  7440. pp := buff.ReadInt() // byte array length
  7441. qq := buff.ReadBytes(pp)
  7442. errC := oo.UnmarshalBinary(qq)
  7443. if errC != nil {
  7444. return errC
  7445. }
  7446. target.End = *oo
  7447. // --- [end][read][reference](time.Time) ---
  7448. return nil
  7449. }
  7450. //--------------------------------------------------------------------------
  7451. // ResourceQuantity
  7452. //--------------------------------------------------------------------------
  7453. // MarshalBinary serializes the internal properties of this ResourceQuantity instance
  7454. // into a byte array
  7455. func (target *ResourceQuantity) MarshalBinary() (data []byte, err error) {
  7456. ctx := NewEncodingContext(nil)
  7457. e := target.MarshalBinaryWithContext(ctx)
  7458. if e != nil {
  7459. return nil, e
  7460. }
  7461. return ctx.ToBytes(), nil
  7462. }
  7463. // MarshalBinary serializes the internal properties of this ResourceQuantity instance
  7464. // into an io.Writer.
  7465. func (target *ResourceQuantity) MarshalBinaryTo(writer io.Writer) error {
  7466. buff := util.NewBufferFromWriter(writer)
  7467. defer buff.Flush()
  7468. ctx := NewEncodingContextFromBuffer(buff, nil)
  7469. return target.MarshalBinaryWithContext(ctx)
  7470. }
  7471. // MarshalBinaryWithContext serializes the internal properties of this ResourceQuantity instance
  7472. // into a byte array leveraging a predefined context.
  7473. func (target *ResourceQuantity) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  7474. // panics are recovered and propagated as errors
  7475. defer func() {
  7476. if r := recover(); r != nil {
  7477. if e, ok := r.(error); ok {
  7478. err = e
  7479. } else if s, ok := r.(string); ok {
  7480. err = fmt.Errorf("unexpected panic: %s", s)
  7481. } else {
  7482. err = fmt.Errorf("unexpected panic: %+v", r)
  7483. }
  7484. }
  7485. }()
  7486. buff := ctx.Buffer
  7487. buff.WriteUInt8(DefaultCodecVersion) // version
  7488. // --- [begin][write][alias](Resource) ---
  7489. if ctx.IsStringTable() {
  7490. a := ctx.Table.AddOrGet(string(target.Resource))
  7491. buff.WriteInt(a) // write table index
  7492. } else {
  7493. buff.WriteString(string(target.Resource)) // write string
  7494. }
  7495. // --- [end][write][alias](Resource) ---
  7496. // --- [begin][write][alias](Unit) ---
  7497. if ctx.IsStringTable() {
  7498. b := ctx.Table.AddOrGet(string(target.Unit))
  7499. buff.WriteInt(b) // write table index
  7500. } else {
  7501. buff.WriteString(string(target.Unit)) // write string
  7502. }
  7503. // --- [end][write][alias](Unit) ---
  7504. // --- [begin][write][alias](Stats) ---
  7505. if map[StatType]float64(target.Values) == nil {
  7506. buff.WriteUInt8(uint8(0)) // write nil byte
  7507. } else {
  7508. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7509. // --- [begin][write][map](map[StatType]float64) ---
  7510. buff.WriteInt(len(map[StatType]float64(target.Values))) // map length
  7511. for v, z := range map[StatType]float64(target.Values) {
  7512. // --- [begin][write][alias](StatType) ---
  7513. if ctx.IsStringTable() {
  7514. c := ctx.Table.AddOrGet(string(v))
  7515. buff.WriteInt(c) // write table index
  7516. } else {
  7517. buff.WriteString(string(v)) // write string
  7518. }
  7519. // --- [end][write][alias](StatType) ---
  7520. buff.WriteFloat64(z) // write float64
  7521. }
  7522. // --- [end][write][map](map[StatType]float64) ---
  7523. }
  7524. // --- [end][write][alias](Stats) ---
  7525. return nil
  7526. }
  7527. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7528. // the ResourceQuantity type
  7529. func (target *ResourceQuantity) UnmarshalBinary(data []byte) error {
  7530. ctx := NewDecodingContextFromBytes(data)
  7531. defer ctx.Close()
  7532. err := target.UnmarshalBinaryWithContext(ctx)
  7533. if err != nil {
  7534. return err
  7535. }
  7536. return nil
  7537. }
  7538. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  7539. // the ResourceQuantity type
  7540. func (target *ResourceQuantity) UnmarshalBinaryFromReader(reader io.Reader) error {
  7541. ctx := NewDecodingContextFromReader(reader)
  7542. defer ctx.Close()
  7543. err := target.UnmarshalBinaryWithContext(ctx)
  7544. if err != nil {
  7545. return err
  7546. }
  7547. return nil
  7548. }
  7549. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7550. // the ResourceQuantity type
  7551. func (target *ResourceQuantity) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7552. // panics are recovered and propagated as errors
  7553. defer func() {
  7554. if r := recover(); r != nil {
  7555. if e, ok := r.(error); ok {
  7556. err = e
  7557. } else if s, ok := r.(string); ok {
  7558. err = fmt.Errorf("unexpected panic: %s", s)
  7559. } else {
  7560. err = fmt.Errorf("unexpected panic: %+v", r)
  7561. }
  7562. }
  7563. }()
  7564. buff := ctx.Buffer
  7565. version := buff.ReadUInt8()
  7566. if version > DefaultCodecVersion {
  7567. return fmt.Errorf("Invalid Version Unmarshalling ResourceQuantity. Expected %d or less, got %d", DefaultCodecVersion, version)
  7568. }
  7569. // field version check
  7570. if uint8(1) <= version {
  7571. // --- [begin][read][alias](Resource) ---
  7572. var a string
  7573. var c string
  7574. if ctx.IsStringTable() {
  7575. d := buff.ReadInt() // read string index
  7576. c = ctx.Table.At(d)
  7577. } else {
  7578. c = buff.ReadString() // read string
  7579. }
  7580. b := c
  7581. a = b
  7582. target.Resource = Resource(a)
  7583. // --- [end][read][alias](Resource) ---
  7584. } else {
  7585. }
  7586. // field version check
  7587. if uint8(1) <= version {
  7588. // --- [begin][read][alias](Unit) ---
  7589. var e string
  7590. var g string
  7591. if ctx.IsStringTable() {
  7592. h := buff.ReadInt() // read string index
  7593. g = ctx.Table.At(h)
  7594. } else {
  7595. g = buff.ReadString() // read string
  7596. }
  7597. f := g
  7598. e = f
  7599. target.Unit = Unit(e)
  7600. // --- [end][read][alias](Unit) ---
  7601. } else {
  7602. }
  7603. // field version check
  7604. if uint8(1) <= version {
  7605. // --- [begin][read][alias](Stats) ---
  7606. var l map[StatType]float64
  7607. if buff.ReadUInt8() == uint8(0) {
  7608. l = nil
  7609. } else {
  7610. // --- [begin][read][map](map[StatType]float64) ---
  7611. n := buff.ReadInt() // map len
  7612. m := make(map[StatType]float64, n)
  7613. for range n {
  7614. // --- [begin][read][alias](StatType) ---
  7615. var o string
  7616. var q string
  7617. if ctx.IsStringTable() {
  7618. r := buff.ReadInt() // read string index
  7619. q = ctx.Table.At(r)
  7620. } else {
  7621. q = buff.ReadString() // read string
  7622. }
  7623. p := q
  7624. o = p
  7625. v := StatType(o)
  7626. // --- [end][read][alias](StatType) ---
  7627. var z float64
  7628. s := buff.ReadFloat64() // read float64
  7629. z = s
  7630. m[v] = z
  7631. }
  7632. l = m
  7633. // --- [end][read][map](map[StatType]float64) ---
  7634. }
  7635. target.Values = Stats(l)
  7636. // --- [end][read][alias](Stats) ---
  7637. } else {
  7638. }
  7639. return nil
  7640. }
  7641. //--------------------------------------------------------------------------
  7642. // ResourceQuota
  7643. //--------------------------------------------------------------------------
  7644. // MarshalBinary serializes the internal properties of this ResourceQuota instance
  7645. // into a byte array
  7646. func (target *ResourceQuota) MarshalBinary() (data []byte, err error) {
  7647. ctx := NewEncodingContext(nil)
  7648. e := target.MarshalBinaryWithContext(ctx)
  7649. if e != nil {
  7650. return nil, e
  7651. }
  7652. return ctx.ToBytes(), nil
  7653. }
  7654. // MarshalBinary serializes the internal properties of this ResourceQuota instance
  7655. // into an io.Writer.
  7656. func (target *ResourceQuota) MarshalBinaryTo(writer io.Writer) error {
  7657. buff := util.NewBufferFromWriter(writer)
  7658. defer buff.Flush()
  7659. ctx := NewEncodingContextFromBuffer(buff, nil)
  7660. return target.MarshalBinaryWithContext(ctx)
  7661. }
  7662. // MarshalBinaryWithContext serializes the internal properties of this ResourceQuota instance
  7663. // into a byte array leveraging a predefined context.
  7664. func (target *ResourceQuota) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  7665. // panics are recovered and propagated as errors
  7666. defer func() {
  7667. if r := recover(); r != nil {
  7668. if e, ok := r.(error); ok {
  7669. err = e
  7670. } else if s, ok := r.(string); ok {
  7671. err = fmt.Errorf("unexpected panic: %s", s)
  7672. } else {
  7673. err = fmt.Errorf("unexpected panic: %+v", r)
  7674. }
  7675. }
  7676. }()
  7677. buff := ctx.Buffer
  7678. buff.WriteUInt8(DefaultCodecVersion) // version
  7679. if ctx.IsStringTable() {
  7680. a := ctx.Table.AddOrGet(target.UID)
  7681. buff.WriteInt(a) // write table index
  7682. } else {
  7683. buff.WriteString(target.UID) // write string
  7684. }
  7685. if ctx.IsStringTable() {
  7686. b := ctx.Table.AddOrGet(target.NamespaceUID)
  7687. buff.WriteInt(b) // write table index
  7688. } else {
  7689. buff.WriteString(target.NamespaceUID) // write string
  7690. }
  7691. if ctx.IsStringTable() {
  7692. c := ctx.Table.AddOrGet(target.Name)
  7693. buff.WriteInt(c) // write table index
  7694. } else {
  7695. buff.WriteString(target.Name) // write string
  7696. }
  7697. if target.Spec == nil {
  7698. buff.WriteUInt8(uint8(0)) // write nil byte
  7699. } else {
  7700. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7701. // --- [begin][write][struct](ResourceQuotaSpec) ---
  7702. buff.WriteInt(0) // [compatibility, unused]
  7703. errA := target.Spec.MarshalBinaryWithContext(ctx)
  7704. if errA != nil {
  7705. return errA
  7706. }
  7707. // --- [end][write][struct](ResourceQuotaSpec) ---
  7708. }
  7709. if target.Status == nil {
  7710. buff.WriteUInt8(uint8(0)) // write nil byte
  7711. } else {
  7712. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7713. // --- [begin][write][struct](ResourceQuotaStatus) ---
  7714. buff.WriteInt(0) // [compatibility, unused]
  7715. errB := target.Status.MarshalBinaryWithContext(ctx)
  7716. if errB != nil {
  7717. return errB
  7718. }
  7719. // --- [end][write][struct](ResourceQuotaStatus) ---
  7720. }
  7721. // --- [begin][write][reference](time.Time) ---
  7722. d, errC := target.Start.MarshalBinary()
  7723. if errC != nil {
  7724. return errC
  7725. }
  7726. buff.WriteInt(len(d))
  7727. buff.WriteBytes(d)
  7728. // --- [end][write][reference](time.Time) ---
  7729. // --- [begin][write][reference](time.Time) ---
  7730. e, errD := target.End.MarshalBinary()
  7731. if errD != nil {
  7732. return errD
  7733. }
  7734. buff.WriteInt(len(e))
  7735. buff.WriteBytes(e)
  7736. // --- [end][write][reference](time.Time) ---
  7737. return nil
  7738. }
  7739. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7740. // the ResourceQuota type
  7741. func (target *ResourceQuota) UnmarshalBinary(data []byte) error {
  7742. ctx := NewDecodingContextFromBytes(data)
  7743. defer ctx.Close()
  7744. err := target.UnmarshalBinaryWithContext(ctx)
  7745. if err != nil {
  7746. return err
  7747. }
  7748. return nil
  7749. }
  7750. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  7751. // the ResourceQuota type
  7752. func (target *ResourceQuota) UnmarshalBinaryFromReader(reader io.Reader) error {
  7753. ctx := NewDecodingContextFromReader(reader)
  7754. defer ctx.Close()
  7755. err := target.UnmarshalBinaryWithContext(ctx)
  7756. if err != nil {
  7757. return err
  7758. }
  7759. return nil
  7760. }
  7761. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7762. // the ResourceQuota type
  7763. func (target *ResourceQuota) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7764. // panics are recovered and propagated as errors
  7765. defer func() {
  7766. if r := recover(); r != nil {
  7767. if e, ok := r.(error); ok {
  7768. err = e
  7769. } else if s, ok := r.(string); ok {
  7770. err = fmt.Errorf("unexpected panic: %s", s)
  7771. } else {
  7772. err = fmt.Errorf("unexpected panic: %+v", r)
  7773. }
  7774. }
  7775. }()
  7776. buff := ctx.Buffer
  7777. version := buff.ReadUInt8()
  7778. if version > DefaultCodecVersion {
  7779. return fmt.Errorf("Invalid Version Unmarshalling ResourceQuota. Expected %d or less, got %d", DefaultCodecVersion, version)
  7780. }
  7781. // field version check
  7782. if uint8(1) <= version {
  7783. var b string
  7784. if ctx.IsStringTable() {
  7785. c := buff.ReadInt() // read string index
  7786. b = ctx.Table.At(c)
  7787. } else {
  7788. b = buff.ReadString() // read string
  7789. }
  7790. a := b
  7791. target.UID = a
  7792. } else {
  7793. target.UID = "" // default
  7794. }
  7795. // field version check
  7796. if uint8(1) <= version {
  7797. var e string
  7798. if ctx.IsStringTable() {
  7799. f := buff.ReadInt() // read string index
  7800. e = ctx.Table.At(f)
  7801. } else {
  7802. e = buff.ReadString() // read string
  7803. }
  7804. d := e
  7805. target.NamespaceUID = d
  7806. } else {
  7807. target.NamespaceUID = "" // default
  7808. }
  7809. // field version check
  7810. if uint8(1) <= version {
  7811. var h string
  7812. if ctx.IsStringTable() {
  7813. l := buff.ReadInt() // read string index
  7814. h = ctx.Table.At(l)
  7815. } else {
  7816. h = buff.ReadString() // read string
  7817. }
  7818. g := h
  7819. target.Name = g
  7820. } else {
  7821. target.Name = "" // default
  7822. }
  7823. // field version check
  7824. if uint8(1) <= version {
  7825. if buff.ReadUInt8() == uint8(0) {
  7826. target.Spec = nil
  7827. } else {
  7828. // --- [begin][read][struct](ResourceQuotaSpec) ---
  7829. m := new(ResourceQuotaSpec)
  7830. buff.ReadInt() // [compatibility, unused]
  7831. errA := m.UnmarshalBinaryWithContext(ctx)
  7832. if errA != nil {
  7833. return errA
  7834. }
  7835. target.Spec = m
  7836. // --- [end][read][struct](ResourceQuotaSpec) ---
  7837. }
  7838. } else {
  7839. target.Spec = nil
  7840. }
  7841. // field version check
  7842. if uint8(1) <= version {
  7843. if buff.ReadUInt8() == uint8(0) {
  7844. target.Status = nil
  7845. } else {
  7846. // --- [begin][read][struct](ResourceQuotaStatus) ---
  7847. n := new(ResourceQuotaStatus)
  7848. buff.ReadInt() // [compatibility, unused]
  7849. errB := n.UnmarshalBinaryWithContext(ctx)
  7850. if errB != nil {
  7851. return errB
  7852. }
  7853. target.Status = n
  7854. // --- [end][read][struct](ResourceQuotaStatus) ---
  7855. }
  7856. } else {
  7857. target.Status = nil
  7858. }
  7859. // field version check
  7860. if uint8(1) <= version {
  7861. // --- [begin][read][reference](time.Time) ---
  7862. o := new(time.Time)
  7863. p := buff.ReadInt() // byte array length
  7864. q := buff.ReadBytes(p)
  7865. errC := o.UnmarshalBinary(q)
  7866. if errC != nil {
  7867. return errC
  7868. }
  7869. target.Start = *o
  7870. // --- [end][read][reference](time.Time) ---
  7871. } else {
  7872. }
  7873. // field version check
  7874. if uint8(1) <= version {
  7875. // --- [begin][read][reference](time.Time) ---
  7876. r := new(time.Time)
  7877. s := buff.ReadInt() // byte array length
  7878. t := buff.ReadBytes(s)
  7879. errD := r.UnmarshalBinary(t)
  7880. if errD != nil {
  7881. return errD
  7882. }
  7883. target.End = *r
  7884. // --- [end][read][reference](time.Time) ---
  7885. } else {
  7886. }
  7887. return nil
  7888. }
  7889. //--------------------------------------------------------------------------
  7890. // ResourceQuotaSpec
  7891. //--------------------------------------------------------------------------
  7892. // MarshalBinary serializes the internal properties of this ResourceQuotaSpec instance
  7893. // into a byte array
  7894. func (target *ResourceQuotaSpec) MarshalBinary() (data []byte, err error) {
  7895. ctx := NewEncodingContext(nil)
  7896. e := target.MarshalBinaryWithContext(ctx)
  7897. if e != nil {
  7898. return nil, e
  7899. }
  7900. return ctx.ToBytes(), nil
  7901. }
  7902. // MarshalBinary serializes the internal properties of this ResourceQuotaSpec instance
  7903. // into an io.Writer.
  7904. func (target *ResourceQuotaSpec) MarshalBinaryTo(writer io.Writer) error {
  7905. buff := util.NewBufferFromWriter(writer)
  7906. defer buff.Flush()
  7907. ctx := NewEncodingContextFromBuffer(buff, nil)
  7908. return target.MarshalBinaryWithContext(ctx)
  7909. }
  7910. // MarshalBinaryWithContext serializes the internal properties of this ResourceQuotaSpec instance
  7911. // into a byte array leveraging a predefined context.
  7912. func (target *ResourceQuotaSpec) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  7913. // panics are recovered and propagated as errors
  7914. defer func() {
  7915. if r := recover(); r != nil {
  7916. if e, ok := r.(error); ok {
  7917. err = e
  7918. } else if s, ok := r.(string); ok {
  7919. err = fmt.Errorf("unexpected panic: %s", s)
  7920. } else {
  7921. err = fmt.Errorf("unexpected panic: %+v", r)
  7922. }
  7923. }
  7924. }()
  7925. buff := ctx.Buffer
  7926. buff.WriteUInt8(DefaultCodecVersion) // version
  7927. if target.Hard == nil {
  7928. buff.WriteUInt8(uint8(0)) // write nil byte
  7929. } else {
  7930. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7931. // --- [begin][write][struct](ResourceQuotaSpecHard) ---
  7932. buff.WriteInt(0) // [compatibility, unused]
  7933. errA := target.Hard.MarshalBinaryWithContext(ctx)
  7934. if errA != nil {
  7935. return errA
  7936. }
  7937. // --- [end][write][struct](ResourceQuotaSpecHard) ---
  7938. }
  7939. return nil
  7940. }
  7941. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7942. // the ResourceQuotaSpec type
  7943. func (target *ResourceQuotaSpec) UnmarshalBinary(data []byte) error {
  7944. ctx := NewDecodingContextFromBytes(data)
  7945. defer ctx.Close()
  7946. err := target.UnmarshalBinaryWithContext(ctx)
  7947. if err != nil {
  7948. return err
  7949. }
  7950. return nil
  7951. }
  7952. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  7953. // the ResourceQuotaSpec type
  7954. func (target *ResourceQuotaSpec) UnmarshalBinaryFromReader(reader io.Reader) error {
  7955. ctx := NewDecodingContextFromReader(reader)
  7956. defer ctx.Close()
  7957. err := target.UnmarshalBinaryWithContext(ctx)
  7958. if err != nil {
  7959. return err
  7960. }
  7961. return nil
  7962. }
  7963. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7964. // the ResourceQuotaSpec type
  7965. func (target *ResourceQuotaSpec) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7966. // panics are recovered and propagated as errors
  7967. defer func() {
  7968. if r := recover(); r != nil {
  7969. if e, ok := r.(error); ok {
  7970. err = e
  7971. } else if s, ok := r.(string); ok {
  7972. err = fmt.Errorf("unexpected panic: %s", s)
  7973. } else {
  7974. err = fmt.Errorf("unexpected panic: %+v", r)
  7975. }
  7976. }
  7977. }()
  7978. buff := ctx.Buffer
  7979. version := buff.ReadUInt8()
  7980. if version > DefaultCodecVersion {
  7981. return fmt.Errorf("Invalid Version Unmarshalling ResourceQuotaSpec. Expected %d or less, got %d", DefaultCodecVersion, version)
  7982. }
  7983. // field version check
  7984. if uint8(1) <= version {
  7985. if buff.ReadUInt8() == uint8(0) {
  7986. target.Hard = nil
  7987. } else {
  7988. // --- [begin][read][struct](ResourceQuotaSpecHard) ---
  7989. a := new(ResourceQuotaSpecHard)
  7990. buff.ReadInt() // [compatibility, unused]
  7991. errA := a.UnmarshalBinaryWithContext(ctx)
  7992. if errA != nil {
  7993. return errA
  7994. }
  7995. target.Hard = a
  7996. // --- [end][read][struct](ResourceQuotaSpecHard) ---
  7997. }
  7998. } else {
  7999. target.Hard = nil
  8000. }
  8001. return nil
  8002. }
  8003. //--------------------------------------------------------------------------
  8004. // ResourceQuotaSpecHard
  8005. //--------------------------------------------------------------------------
  8006. // MarshalBinary serializes the internal properties of this ResourceQuotaSpecHard instance
  8007. // into a byte array
  8008. func (target *ResourceQuotaSpecHard) MarshalBinary() (data []byte, err error) {
  8009. ctx := NewEncodingContext(nil)
  8010. e := target.MarshalBinaryWithContext(ctx)
  8011. if e != nil {
  8012. return nil, e
  8013. }
  8014. return ctx.ToBytes(), nil
  8015. }
  8016. // MarshalBinary serializes the internal properties of this ResourceQuotaSpecHard instance
  8017. // into an io.Writer.
  8018. func (target *ResourceQuotaSpecHard) MarshalBinaryTo(writer io.Writer) error {
  8019. buff := util.NewBufferFromWriter(writer)
  8020. defer buff.Flush()
  8021. ctx := NewEncodingContextFromBuffer(buff, nil)
  8022. return target.MarshalBinaryWithContext(ctx)
  8023. }
  8024. // MarshalBinaryWithContext serializes the internal properties of this ResourceQuotaSpecHard instance
  8025. // into a byte array leveraging a predefined context.
  8026. func (target *ResourceQuotaSpecHard) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  8027. // panics are recovered and propagated as errors
  8028. defer func() {
  8029. if r := recover(); r != nil {
  8030. if e, ok := r.(error); ok {
  8031. err = e
  8032. } else if s, ok := r.(string); ok {
  8033. err = fmt.Errorf("unexpected panic: %s", s)
  8034. } else {
  8035. err = fmt.Errorf("unexpected panic: %+v", r)
  8036. }
  8037. }
  8038. }()
  8039. buff := ctx.Buffer
  8040. buff.WriteUInt8(DefaultCodecVersion) // version
  8041. // --- [begin][write][alias](ResourceQuantities) ---
  8042. if map[Resource]ResourceQuantity(target.Requests) == nil {
  8043. buff.WriteUInt8(uint8(0)) // write nil byte
  8044. } else {
  8045. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8046. // --- [begin][write][map](map[Resource]ResourceQuantity) ---
  8047. buff.WriteInt(len(map[Resource]ResourceQuantity(target.Requests))) // map length
  8048. for v, z := range map[Resource]ResourceQuantity(target.Requests) {
  8049. // --- [begin][write][alias](Resource) ---
  8050. if ctx.IsStringTable() {
  8051. a := ctx.Table.AddOrGet(string(v))
  8052. buff.WriteInt(a) // write table index
  8053. } else {
  8054. buff.WriteString(string(v)) // write string
  8055. }
  8056. // --- [end][write][alias](Resource) ---
  8057. // --- [begin][write][struct](ResourceQuantity) ---
  8058. buff.WriteInt(0) // [compatibility, unused]
  8059. errA := z.MarshalBinaryWithContext(ctx)
  8060. if errA != nil {
  8061. return errA
  8062. }
  8063. // --- [end][write][struct](ResourceQuantity) ---
  8064. }
  8065. // --- [end][write][map](map[Resource]ResourceQuantity) ---
  8066. }
  8067. // --- [end][write][alias](ResourceQuantities) ---
  8068. // --- [begin][write][alias](ResourceQuantities) ---
  8069. if map[Resource]ResourceQuantity(target.Limits) == nil {
  8070. buff.WriteUInt8(uint8(0)) // write nil byte
  8071. } else {
  8072. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8073. // --- [begin][write][map](map[Resource]ResourceQuantity) ---
  8074. buff.WriteInt(len(map[Resource]ResourceQuantity(target.Limits))) // map length
  8075. for vv, zz := range map[Resource]ResourceQuantity(target.Limits) {
  8076. // --- [begin][write][alias](Resource) ---
  8077. if ctx.IsStringTable() {
  8078. b := ctx.Table.AddOrGet(string(vv))
  8079. buff.WriteInt(b) // write table index
  8080. } else {
  8081. buff.WriteString(string(vv)) // write string
  8082. }
  8083. // --- [end][write][alias](Resource) ---
  8084. // --- [begin][write][struct](ResourceQuantity) ---
  8085. buff.WriteInt(0) // [compatibility, unused]
  8086. errB := zz.MarshalBinaryWithContext(ctx)
  8087. if errB != nil {
  8088. return errB
  8089. }
  8090. // --- [end][write][struct](ResourceQuantity) ---
  8091. }
  8092. // --- [end][write][map](map[Resource]ResourceQuantity) ---
  8093. }
  8094. // --- [end][write][alias](ResourceQuantities) ---
  8095. return nil
  8096. }
  8097. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  8098. // the ResourceQuotaSpecHard type
  8099. func (target *ResourceQuotaSpecHard) UnmarshalBinary(data []byte) error {
  8100. ctx := NewDecodingContextFromBytes(data)
  8101. defer ctx.Close()
  8102. err := target.UnmarshalBinaryWithContext(ctx)
  8103. if err != nil {
  8104. return err
  8105. }
  8106. return nil
  8107. }
  8108. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  8109. // the ResourceQuotaSpecHard type
  8110. func (target *ResourceQuotaSpecHard) UnmarshalBinaryFromReader(reader io.Reader) error {
  8111. ctx := NewDecodingContextFromReader(reader)
  8112. defer ctx.Close()
  8113. err := target.UnmarshalBinaryWithContext(ctx)
  8114. if err != nil {
  8115. return err
  8116. }
  8117. return nil
  8118. }
  8119. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  8120. // the ResourceQuotaSpecHard type
  8121. func (target *ResourceQuotaSpecHard) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  8122. // panics are recovered and propagated as errors
  8123. defer func() {
  8124. if r := recover(); r != nil {
  8125. if e, ok := r.(error); ok {
  8126. err = e
  8127. } else if s, ok := r.(string); ok {
  8128. err = fmt.Errorf("unexpected panic: %s", s)
  8129. } else {
  8130. err = fmt.Errorf("unexpected panic: %+v", r)
  8131. }
  8132. }
  8133. }()
  8134. buff := ctx.Buffer
  8135. version := buff.ReadUInt8()
  8136. if version > DefaultCodecVersion {
  8137. return fmt.Errorf("Invalid Version Unmarshalling ResourceQuotaSpecHard. Expected %d or less, got %d", DefaultCodecVersion, version)
  8138. }
  8139. // field version check
  8140. if uint8(1) <= version {
  8141. // --- [begin][read][alias](ResourceQuantities) ---
  8142. var a map[Resource]ResourceQuantity
  8143. if buff.ReadUInt8() == uint8(0) {
  8144. a = nil
  8145. } else {
  8146. // --- [begin][read][map](map[Resource]ResourceQuantity) ---
  8147. c := buff.ReadInt() // map len
  8148. b := make(map[Resource]ResourceQuantity, c)
  8149. for range c {
  8150. // --- [begin][read][alias](Resource) ---
  8151. var d string
  8152. var f string
  8153. if ctx.IsStringTable() {
  8154. g := buff.ReadInt() // read string index
  8155. f = ctx.Table.At(g)
  8156. } else {
  8157. f = buff.ReadString() // read string
  8158. }
  8159. e := f
  8160. d = e
  8161. v := Resource(d)
  8162. // --- [end][read][alias](Resource) ---
  8163. // --- [begin][read][struct](ResourceQuantity) ---
  8164. h := new(ResourceQuantity)
  8165. buff.ReadInt() // [compatibility, unused]
  8166. errA := h.UnmarshalBinaryWithContext(ctx)
  8167. if errA != nil {
  8168. return errA
  8169. }
  8170. z := *h
  8171. // --- [end][read][struct](ResourceQuantity) ---
  8172. b[v] = z
  8173. }
  8174. a = b
  8175. // --- [end][read][map](map[Resource]ResourceQuantity) ---
  8176. }
  8177. target.Requests = ResourceQuantities(a)
  8178. // --- [end][read][alias](ResourceQuantities) ---
  8179. } else {
  8180. }
  8181. // field version check
  8182. if uint8(1) <= version {
  8183. // --- [begin][read][alias](ResourceQuantities) ---
  8184. var l map[Resource]ResourceQuantity
  8185. if buff.ReadUInt8() == uint8(0) {
  8186. l = nil
  8187. } else {
  8188. // --- [begin][read][map](map[Resource]ResourceQuantity) ---
  8189. n := buff.ReadInt() // map len
  8190. m := make(map[Resource]ResourceQuantity, n)
  8191. for range n {
  8192. // --- [begin][read][alias](Resource) ---
  8193. var o string
  8194. var q string
  8195. if ctx.IsStringTable() {
  8196. r := buff.ReadInt() // read string index
  8197. q = ctx.Table.At(r)
  8198. } else {
  8199. q = buff.ReadString() // read string
  8200. }
  8201. p := q
  8202. o = p
  8203. vv := Resource(o)
  8204. // --- [end][read][alias](Resource) ---
  8205. // --- [begin][read][struct](ResourceQuantity) ---
  8206. s := new(ResourceQuantity)
  8207. buff.ReadInt() // [compatibility, unused]
  8208. errB := s.UnmarshalBinaryWithContext(ctx)
  8209. if errB != nil {
  8210. return errB
  8211. }
  8212. zz := *s
  8213. // --- [end][read][struct](ResourceQuantity) ---
  8214. m[vv] = zz
  8215. }
  8216. l = m
  8217. // --- [end][read][map](map[Resource]ResourceQuantity) ---
  8218. }
  8219. target.Limits = ResourceQuantities(l)
  8220. // --- [end][read][alias](ResourceQuantities) ---
  8221. } else {
  8222. }
  8223. return nil
  8224. }
  8225. //--------------------------------------------------------------------------
  8226. // ResourceQuotaStatus
  8227. //--------------------------------------------------------------------------
  8228. // MarshalBinary serializes the internal properties of this ResourceQuotaStatus instance
  8229. // into a byte array
  8230. func (target *ResourceQuotaStatus) MarshalBinary() (data []byte, err error) {
  8231. ctx := NewEncodingContext(nil)
  8232. e := target.MarshalBinaryWithContext(ctx)
  8233. if e != nil {
  8234. return nil, e
  8235. }
  8236. return ctx.ToBytes(), nil
  8237. }
  8238. // MarshalBinary serializes the internal properties of this ResourceQuotaStatus instance
  8239. // into an io.Writer.
  8240. func (target *ResourceQuotaStatus) MarshalBinaryTo(writer io.Writer) error {
  8241. buff := util.NewBufferFromWriter(writer)
  8242. defer buff.Flush()
  8243. ctx := NewEncodingContextFromBuffer(buff, nil)
  8244. return target.MarshalBinaryWithContext(ctx)
  8245. }
  8246. // MarshalBinaryWithContext serializes the internal properties of this ResourceQuotaStatus instance
  8247. // into a byte array leveraging a predefined context.
  8248. func (target *ResourceQuotaStatus) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  8249. // panics are recovered and propagated as errors
  8250. defer func() {
  8251. if r := recover(); r != nil {
  8252. if e, ok := r.(error); ok {
  8253. err = e
  8254. } else if s, ok := r.(string); ok {
  8255. err = fmt.Errorf("unexpected panic: %s", s)
  8256. } else {
  8257. err = fmt.Errorf("unexpected panic: %+v", r)
  8258. }
  8259. }
  8260. }()
  8261. buff := ctx.Buffer
  8262. buff.WriteUInt8(DefaultCodecVersion) // version
  8263. if target.Used == nil {
  8264. buff.WriteUInt8(uint8(0)) // write nil byte
  8265. } else {
  8266. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8267. // --- [begin][write][struct](ResourceQuotaStatusUsed) ---
  8268. buff.WriteInt(0) // [compatibility, unused]
  8269. errA := target.Used.MarshalBinaryWithContext(ctx)
  8270. if errA != nil {
  8271. return errA
  8272. }
  8273. // --- [end][write][struct](ResourceQuotaStatusUsed) ---
  8274. }
  8275. return nil
  8276. }
  8277. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  8278. // the ResourceQuotaStatus type
  8279. func (target *ResourceQuotaStatus) UnmarshalBinary(data []byte) error {
  8280. ctx := NewDecodingContextFromBytes(data)
  8281. defer ctx.Close()
  8282. err := target.UnmarshalBinaryWithContext(ctx)
  8283. if err != nil {
  8284. return err
  8285. }
  8286. return nil
  8287. }
  8288. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  8289. // the ResourceQuotaStatus type
  8290. func (target *ResourceQuotaStatus) UnmarshalBinaryFromReader(reader io.Reader) error {
  8291. ctx := NewDecodingContextFromReader(reader)
  8292. defer ctx.Close()
  8293. err := target.UnmarshalBinaryWithContext(ctx)
  8294. if err != nil {
  8295. return err
  8296. }
  8297. return nil
  8298. }
  8299. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  8300. // the ResourceQuotaStatus type
  8301. func (target *ResourceQuotaStatus) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  8302. // panics are recovered and propagated as errors
  8303. defer func() {
  8304. if r := recover(); r != nil {
  8305. if e, ok := r.(error); ok {
  8306. err = e
  8307. } else if s, ok := r.(string); ok {
  8308. err = fmt.Errorf("unexpected panic: %s", s)
  8309. } else {
  8310. err = fmt.Errorf("unexpected panic: %+v", r)
  8311. }
  8312. }
  8313. }()
  8314. buff := ctx.Buffer
  8315. version := buff.ReadUInt8()
  8316. if version > DefaultCodecVersion {
  8317. return fmt.Errorf("Invalid Version Unmarshalling ResourceQuotaStatus. Expected %d or less, got %d", DefaultCodecVersion, version)
  8318. }
  8319. // field version check
  8320. if uint8(1) <= version {
  8321. if buff.ReadUInt8() == uint8(0) {
  8322. target.Used = nil
  8323. } else {
  8324. // --- [begin][read][struct](ResourceQuotaStatusUsed) ---
  8325. a := new(ResourceQuotaStatusUsed)
  8326. buff.ReadInt() // [compatibility, unused]
  8327. errA := a.UnmarshalBinaryWithContext(ctx)
  8328. if errA != nil {
  8329. return errA
  8330. }
  8331. target.Used = a
  8332. // --- [end][read][struct](ResourceQuotaStatusUsed) ---
  8333. }
  8334. } else {
  8335. target.Used = nil
  8336. }
  8337. return nil
  8338. }
  8339. //--------------------------------------------------------------------------
  8340. // ResourceQuotaStatusUsed
  8341. //--------------------------------------------------------------------------
  8342. // MarshalBinary serializes the internal properties of this ResourceQuotaStatusUsed instance
  8343. // into a byte array
  8344. func (target *ResourceQuotaStatusUsed) MarshalBinary() (data []byte, err error) {
  8345. ctx := NewEncodingContext(nil)
  8346. e := target.MarshalBinaryWithContext(ctx)
  8347. if e != nil {
  8348. return nil, e
  8349. }
  8350. return ctx.ToBytes(), nil
  8351. }
  8352. // MarshalBinary serializes the internal properties of this ResourceQuotaStatusUsed instance
  8353. // into an io.Writer.
  8354. func (target *ResourceQuotaStatusUsed) MarshalBinaryTo(writer io.Writer) error {
  8355. buff := util.NewBufferFromWriter(writer)
  8356. defer buff.Flush()
  8357. ctx := NewEncodingContextFromBuffer(buff, nil)
  8358. return target.MarshalBinaryWithContext(ctx)
  8359. }
  8360. // MarshalBinaryWithContext serializes the internal properties of this ResourceQuotaStatusUsed instance
  8361. // into a byte array leveraging a predefined context.
  8362. func (target *ResourceQuotaStatusUsed) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  8363. // panics are recovered and propagated as errors
  8364. defer func() {
  8365. if r := recover(); r != nil {
  8366. if e, ok := r.(error); ok {
  8367. err = e
  8368. } else if s, ok := r.(string); ok {
  8369. err = fmt.Errorf("unexpected panic: %s", s)
  8370. } else {
  8371. err = fmt.Errorf("unexpected panic: %+v", r)
  8372. }
  8373. }
  8374. }()
  8375. buff := ctx.Buffer
  8376. buff.WriteUInt8(DefaultCodecVersion) // version
  8377. // --- [begin][write][alias](ResourceQuantities) ---
  8378. if map[Resource]ResourceQuantity(target.Requests) == nil {
  8379. buff.WriteUInt8(uint8(0)) // write nil byte
  8380. } else {
  8381. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8382. // --- [begin][write][map](map[Resource]ResourceQuantity) ---
  8383. buff.WriteInt(len(map[Resource]ResourceQuantity(target.Requests))) // map length
  8384. for v, z := range map[Resource]ResourceQuantity(target.Requests) {
  8385. // --- [begin][write][alias](Resource) ---
  8386. if ctx.IsStringTable() {
  8387. a := ctx.Table.AddOrGet(string(v))
  8388. buff.WriteInt(a) // write table index
  8389. } else {
  8390. buff.WriteString(string(v)) // write string
  8391. }
  8392. // --- [end][write][alias](Resource) ---
  8393. // --- [begin][write][struct](ResourceQuantity) ---
  8394. buff.WriteInt(0) // [compatibility, unused]
  8395. errA := z.MarshalBinaryWithContext(ctx)
  8396. if errA != nil {
  8397. return errA
  8398. }
  8399. // --- [end][write][struct](ResourceQuantity) ---
  8400. }
  8401. // --- [end][write][map](map[Resource]ResourceQuantity) ---
  8402. }
  8403. // --- [end][write][alias](ResourceQuantities) ---
  8404. // --- [begin][write][alias](ResourceQuantities) ---
  8405. if map[Resource]ResourceQuantity(target.Limits) == nil {
  8406. buff.WriteUInt8(uint8(0)) // write nil byte
  8407. } else {
  8408. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8409. // --- [begin][write][map](map[Resource]ResourceQuantity) ---
  8410. buff.WriteInt(len(map[Resource]ResourceQuantity(target.Limits))) // map length
  8411. for vv, zz := range map[Resource]ResourceQuantity(target.Limits) {
  8412. // --- [begin][write][alias](Resource) ---
  8413. if ctx.IsStringTable() {
  8414. b := ctx.Table.AddOrGet(string(vv))
  8415. buff.WriteInt(b) // write table index
  8416. } else {
  8417. buff.WriteString(string(vv)) // write string
  8418. }
  8419. // --- [end][write][alias](Resource) ---
  8420. // --- [begin][write][struct](ResourceQuantity) ---
  8421. buff.WriteInt(0) // [compatibility, unused]
  8422. errB := zz.MarshalBinaryWithContext(ctx)
  8423. if errB != nil {
  8424. return errB
  8425. }
  8426. // --- [end][write][struct](ResourceQuantity) ---
  8427. }
  8428. // --- [end][write][map](map[Resource]ResourceQuantity) ---
  8429. }
  8430. // --- [end][write][alias](ResourceQuantities) ---
  8431. return nil
  8432. }
  8433. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  8434. // the ResourceQuotaStatusUsed type
  8435. func (target *ResourceQuotaStatusUsed) UnmarshalBinary(data []byte) error {
  8436. ctx := NewDecodingContextFromBytes(data)
  8437. defer ctx.Close()
  8438. err := target.UnmarshalBinaryWithContext(ctx)
  8439. if err != nil {
  8440. return err
  8441. }
  8442. return nil
  8443. }
  8444. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  8445. // the ResourceQuotaStatusUsed type
  8446. func (target *ResourceQuotaStatusUsed) UnmarshalBinaryFromReader(reader io.Reader) error {
  8447. ctx := NewDecodingContextFromReader(reader)
  8448. defer ctx.Close()
  8449. err := target.UnmarshalBinaryWithContext(ctx)
  8450. if err != nil {
  8451. return err
  8452. }
  8453. return nil
  8454. }
  8455. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  8456. // the ResourceQuotaStatusUsed type
  8457. func (target *ResourceQuotaStatusUsed) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  8458. // panics are recovered and propagated as errors
  8459. defer func() {
  8460. if r := recover(); r != nil {
  8461. if e, ok := r.(error); ok {
  8462. err = e
  8463. } else if s, ok := r.(string); ok {
  8464. err = fmt.Errorf("unexpected panic: %s", s)
  8465. } else {
  8466. err = fmt.Errorf("unexpected panic: %+v", r)
  8467. }
  8468. }
  8469. }()
  8470. buff := ctx.Buffer
  8471. version := buff.ReadUInt8()
  8472. if version > DefaultCodecVersion {
  8473. return fmt.Errorf("Invalid Version Unmarshalling ResourceQuotaStatusUsed. Expected %d or less, got %d", DefaultCodecVersion, version)
  8474. }
  8475. // field version check
  8476. if uint8(1) <= version {
  8477. // --- [begin][read][alias](ResourceQuantities) ---
  8478. var a map[Resource]ResourceQuantity
  8479. if buff.ReadUInt8() == uint8(0) {
  8480. a = nil
  8481. } else {
  8482. // --- [begin][read][map](map[Resource]ResourceQuantity) ---
  8483. c := buff.ReadInt() // map len
  8484. b := make(map[Resource]ResourceQuantity, c)
  8485. for range c {
  8486. // --- [begin][read][alias](Resource) ---
  8487. var d string
  8488. var f string
  8489. if ctx.IsStringTable() {
  8490. g := buff.ReadInt() // read string index
  8491. f = ctx.Table.At(g)
  8492. } else {
  8493. f = buff.ReadString() // read string
  8494. }
  8495. e := f
  8496. d = e
  8497. v := Resource(d)
  8498. // --- [end][read][alias](Resource) ---
  8499. // --- [begin][read][struct](ResourceQuantity) ---
  8500. h := new(ResourceQuantity)
  8501. buff.ReadInt() // [compatibility, unused]
  8502. errA := h.UnmarshalBinaryWithContext(ctx)
  8503. if errA != nil {
  8504. return errA
  8505. }
  8506. z := *h
  8507. // --- [end][read][struct](ResourceQuantity) ---
  8508. b[v] = z
  8509. }
  8510. a = b
  8511. // --- [end][read][map](map[Resource]ResourceQuantity) ---
  8512. }
  8513. target.Requests = ResourceQuantities(a)
  8514. // --- [end][read][alias](ResourceQuantities) ---
  8515. } else {
  8516. }
  8517. // field version check
  8518. if uint8(1) <= version {
  8519. // --- [begin][read][alias](ResourceQuantities) ---
  8520. var l map[Resource]ResourceQuantity
  8521. if buff.ReadUInt8() == uint8(0) {
  8522. l = nil
  8523. } else {
  8524. // --- [begin][read][map](map[Resource]ResourceQuantity) ---
  8525. n := buff.ReadInt() // map len
  8526. m := make(map[Resource]ResourceQuantity, n)
  8527. for range n {
  8528. // --- [begin][read][alias](Resource) ---
  8529. var o string
  8530. var q string
  8531. if ctx.IsStringTable() {
  8532. r := buff.ReadInt() // read string index
  8533. q = ctx.Table.At(r)
  8534. } else {
  8535. q = buff.ReadString() // read string
  8536. }
  8537. p := q
  8538. o = p
  8539. vv := Resource(o)
  8540. // --- [end][read][alias](Resource) ---
  8541. // --- [begin][read][struct](ResourceQuantity) ---
  8542. s := new(ResourceQuantity)
  8543. buff.ReadInt() // [compatibility, unused]
  8544. errB := s.UnmarshalBinaryWithContext(ctx)
  8545. if errB != nil {
  8546. return errB
  8547. }
  8548. zz := *s
  8549. // --- [end][read][struct](ResourceQuantity) ---
  8550. m[vv] = zz
  8551. }
  8552. l = m
  8553. // --- [end][read][map](map[Resource]ResourceQuantity) ---
  8554. }
  8555. target.Limits = ResourceQuantities(l)
  8556. // --- [end][read][alias](ResourceQuantities) ---
  8557. } else {
  8558. }
  8559. return nil
  8560. }
  8561. //--------------------------------------------------------------------------
  8562. // Service
  8563. //--------------------------------------------------------------------------
  8564. // MarshalBinary serializes the internal properties of this Service instance
  8565. // into a byte array
  8566. func (target *Service) MarshalBinary() (data []byte, err error) {
  8567. ctx := NewEncodingContext(nil)
  8568. e := target.MarshalBinaryWithContext(ctx)
  8569. if e != nil {
  8570. return nil, e
  8571. }
  8572. return ctx.ToBytes(), nil
  8573. }
  8574. // MarshalBinary serializes the internal properties of this Service instance
  8575. // into an io.Writer.
  8576. func (target *Service) MarshalBinaryTo(writer io.Writer) error {
  8577. buff := util.NewBufferFromWriter(writer)
  8578. defer buff.Flush()
  8579. ctx := NewEncodingContextFromBuffer(buff, nil)
  8580. return target.MarshalBinaryWithContext(ctx)
  8581. }
  8582. // MarshalBinaryWithContext serializes the internal properties of this Service instance
  8583. // into a byte array leveraging a predefined context.
  8584. func (target *Service) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  8585. // panics are recovered and propagated as errors
  8586. defer func() {
  8587. if r := recover(); r != nil {
  8588. if e, ok := r.(error); ok {
  8589. err = e
  8590. } else if s, ok := r.(string); ok {
  8591. err = fmt.Errorf("unexpected panic: %s", s)
  8592. } else {
  8593. err = fmt.Errorf("unexpected panic: %+v", r)
  8594. }
  8595. }
  8596. }()
  8597. buff := ctx.Buffer
  8598. buff.WriteUInt8(DefaultCodecVersion) // version
  8599. if ctx.IsStringTable() {
  8600. a := ctx.Table.AddOrGet(target.UID)
  8601. buff.WriteInt(a) // write table index
  8602. } else {
  8603. buff.WriteString(target.UID) // write string
  8604. }
  8605. if ctx.IsStringTable() {
  8606. b := ctx.Table.AddOrGet(target.NamespaceUID)
  8607. buff.WriteInt(b) // write table index
  8608. } else {
  8609. buff.WriteString(target.NamespaceUID) // write string
  8610. }
  8611. if ctx.IsStringTable() {
  8612. c := ctx.Table.AddOrGet(target.Name)
  8613. buff.WriteInt(c) // write table index
  8614. } else {
  8615. buff.WriteString(target.Name) // write string
  8616. }
  8617. // --- [begin][write][alias](ServiceType) ---
  8618. if ctx.IsStringTable() {
  8619. d := ctx.Table.AddOrGet(string(target.Type))
  8620. buff.WriteInt(d) // write table index
  8621. } else {
  8622. buff.WriteString(string(target.Type)) // write string
  8623. }
  8624. // --- [end][write][alias](ServiceType) ---
  8625. // --- [begin][write][reference](time.Time) ---
  8626. e, errA := target.Start.MarshalBinary()
  8627. if errA != nil {
  8628. return errA
  8629. }
  8630. buff.WriteInt(len(e))
  8631. buff.WriteBytes(e)
  8632. // --- [end][write][reference](time.Time) ---
  8633. // --- [begin][write][reference](time.Time) ---
  8634. f, errB := target.End.MarshalBinary()
  8635. if errB != nil {
  8636. return errB
  8637. }
  8638. buff.WriteInt(len(f))
  8639. buff.WriteBytes(f)
  8640. // --- [end][write][reference](time.Time) ---
  8641. if target.Selector == nil {
  8642. buff.WriteUInt8(uint8(0)) // write nil byte
  8643. } else {
  8644. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8645. // --- [begin][write][map](map[string]string) ---
  8646. buff.WriteInt(len(target.Selector)) // map length
  8647. for v, z := range target.Selector {
  8648. if ctx.IsStringTable() {
  8649. g := ctx.Table.AddOrGet(v)
  8650. buff.WriteInt(g) // write table index
  8651. } else {
  8652. buff.WriteString(v) // write string
  8653. }
  8654. if ctx.IsStringTable() {
  8655. h := ctx.Table.AddOrGet(z)
  8656. buff.WriteInt(h) // write table index
  8657. } else {
  8658. buff.WriteString(z) // write string
  8659. }
  8660. }
  8661. // --- [end][write][map](map[string]string) ---
  8662. }
  8663. if ctx.IsStringTable() {
  8664. l := ctx.Table.AddOrGet(target.LBIngressAddress)
  8665. buff.WriteInt(l) // write table index
  8666. } else {
  8667. buff.WriteString(target.LBIngressAddress) // write string
  8668. }
  8669. return nil
  8670. }
  8671. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  8672. // the Service type
  8673. func (target *Service) UnmarshalBinary(data []byte) error {
  8674. ctx := NewDecodingContextFromBytes(data)
  8675. defer ctx.Close()
  8676. err := target.UnmarshalBinaryWithContext(ctx)
  8677. if err != nil {
  8678. return err
  8679. }
  8680. return nil
  8681. }
  8682. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  8683. // the Service type
  8684. func (target *Service) UnmarshalBinaryFromReader(reader io.Reader) error {
  8685. ctx := NewDecodingContextFromReader(reader)
  8686. defer ctx.Close()
  8687. err := target.UnmarshalBinaryWithContext(ctx)
  8688. if err != nil {
  8689. return err
  8690. }
  8691. return nil
  8692. }
  8693. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  8694. // the Service type
  8695. func (target *Service) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  8696. // panics are recovered and propagated as errors
  8697. defer func() {
  8698. if r := recover(); r != nil {
  8699. if e, ok := r.(error); ok {
  8700. err = e
  8701. } else if s, ok := r.(string); ok {
  8702. err = fmt.Errorf("unexpected panic: %s", s)
  8703. } else {
  8704. err = fmt.Errorf("unexpected panic: %+v", r)
  8705. }
  8706. }
  8707. }()
  8708. buff := ctx.Buffer
  8709. version := buff.ReadUInt8()
  8710. if version > DefaultCodecVersion {
  8711. return fmt.Errorf("Invalid Version Unmarshalling Service. Expected %d or less, got %d", DefaultCodecVersion, version)
  8712. }
  8713. var b string
  8714. if ctx.IsStringTable() {
  8715. c := buff.ReadInt() // read string index
  8716. b = ctx.Table.At(c)
  8717. } else {
  8718. b = buff.ReadString() // read string
  8719. }
  8720. a := b
  8721. target.UID = a
  8722. var e string
  8723. if ctx.IsStringTable() {
  8724. f := buff.ReadInt() // read string index
  8725. e = ctx.Table.At(f)
  8726. } else {
  8727. e = buff.ReadString() // read string
  8728. }
  8729. d := e
  8730. target.NamespaceUID = d
  8731. var h string
  8732. if ctx.IsStringTable() {
  8733. l := buff.ReadInt() // read string index
  8734. h = ctx.Table.At(l)
  8735. } else {
  8736. h = buff.ReadString() // read string
  8737. }
  8738. g := h
  8739. target.Name = g
  8740. // --- [begin][read][alias](ServiceType) ---
  8741. var m string
  8742. var o string
  8743. if ctx.IsStringTable() {
  8744. p := buff.ReadInt() // read string index
  8745. o = ctx.Table.At(p)
  8746. } else {
  8747. o = buff.ReadString() // read string
  8748. }
  8749. n := o
  8750. m = n
  8751. target.Type = ServiceType(m)
  8752. // --- [end][read][alias](ServiceType) ---
  8753. // --- [begin][read][reference](time.Time) ---
  8754. q := new(time.Time)
  8755. r := buff.ReadInt() // byte array length
  8756. s := buff.ReadBytes(r)
  8757. errA := q.UnmarshalBinary(s)
  8758. if errA != nil {
  8759. return errA
  8760. }
  8761. target.Start = *q
  8762. // --- [end][read][reference](time.Time) ---
  8763. // --- [begin][read][reference](time.Time) ---
  8764. t := new(time.Time)
  8765. u := buff.ReadInt() // byte array length
  8766. w := buff.ReadBytes(u)
  8767. errB := t.UnmarshalBinary(w)
  8768. if errB != nil {
  8769. return errB
  8770. }
  8771. target.End = *t
  8772. // --- [end][read][reference](time.Time) ---
  8773. if buff.ReadUInt8() == uint8(0) {
  8774. target.Selector = nil
  8775. } else {
  8776. // --- [begin][read][map](map[string]string) ---
  8777. y := buff.ReadInt() // map len
  8778. x := make(map[string]string, y)
  8779. for range y {
  8780. var v string
  8781. var bb string
  8782. if ctx.IsStringTable() {
  8783. cc := buff.ReadInt() // read string index
  8784. bb = ctx.Table.At(cc)
  8785. } else {
  8786. bb = buff.ReadString() // read string
  8787. }
  8788. aa := bb
  8789. v = aa
  8790. var z string
  8791. var ee string
  8792. if ctx.IsStringTable() {
  8793. ff := buff.ReadInt() // read string index
  8794. ee = ctx.Table.At(ff)
  8795. } else {
  8796. ee = buff.ReadString() // read string
  8797. }
  8798. dd := ee
  8799. z = dd
  8800. x[v] = z
  8801. }
  8802. target.Selector = x
  8803. // --- [end][read][map](map[string]string) ---
  8804. }
  8805. var hh string
  8806. if ctx.IsStringTable() {
  8807. ll := buff.ReadInt() // read string index
  8808. hh = ctx.Table.At(ll)
  8809. } else {
  8810. hh = buff.ReadString() // read string
  8811. }
  8812. gg := hh
  8813. target.LBIngressAddress = gg
  8814. return nil
  8815. }
  8816. //--------------------------------------------------------------------------
  8817. // StatefulSet
  8818. //--------------------------------------------------------------------------
  8819. // MarshalBinary serializes the internal properties of this StatefulSet instance
  8820. // into a byte array
  8821. func (target *StatefulSet) MarshalBinary() (data []byte, err error) {
  8822. ctx := NewEncodingContext(nil)
  8823. e := target.MarshalBinaryWithContext(ctx)
  8824. if e != nil {
  8825. return nil, e
  8826. }
  8827. return ctx.ToBytes(), nil
  8828. }
  8829. // MarshalBinary serializes the internal properties of this StatefulSet instance
  8830. // into an io.Writer.
  8831. func (target *StatefulSet) MarshalBinaryTo(writer io.Writer) error {
  8832. buff := util.NewBufferFromWriter(writer)
  8833. defer buff.Flush()
  8834. ctx := NewEncodingContextFromBuffer(buff, nil)
  8835. return target.MarshalBinaryWithContext(ctx)
  8836. }
  8837. // MarshalBinaryWithContext serializes the internal properties of this StatefulSet instance
  8838. // into a byte array leveraging a predefined context.
  8839. func (target *StatefulSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  8840. // panics are recovered and propagated as errors
  8841. defer func() {
  8842. if r := recover(); r != nil {
  8843. if e, ok := r.(error); ok {
  8844. err = e
  8845. } else if s, ok := r.(string); ok {
  8846. err = fmt.Errorf("unexpected panic: %s", s)
  8847. } else {
  8848. err = fmt.Errorf("unexpected panic: %+v", r)
  8849. }
  8850. }
  8851. }()
  8852. buff := ctx.Buffer
  8853. buff.WriteUInt8(DefaultCodecVersion) // version
  8854. if ctx.IsStringTable() {
  8855. a := ctx.Table.AddOrGet(target.UID)
  8856. buff.WriteInt(a) // write table index
  8857. } else {
  8858. buff.WriteString(target.UID) // write string
  8859. }
  8860. if ctx.IsStringTable() {
  8861. b := ctx.Table.AddOrGet(target.NamespaceUID)
  8862. buff.WriteInt(b) // write table index
  8863. } else {
  8864. buff.WriteString(target.NamespaceUID) // write string
  8865. }
  8866. if ctx.IsStringTable() {
  8867. c := ctx.Table.AddOrGet(target.Name)
  8868. buff.WriteInt(c) // write table index
  8869. } else {
  8870. buff.WriteString(target.Name) // write string
  8871. }
  8872. if target.Labels == nil {
  8873. buff.WriteUInt8(uint8(0)) // write nil byte
  8874. } else {
  8875. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8876. // --- [begin][write][map](map[string]string) ---
  8877. buff.WriteInt(len(target.Labels)) // map length
  8878. for v, z := range target.Labels {
  8879. if ctx.IsStringTable() {
  8880. d := ctx.Table.AddOrGet(v)
  8881. buff.WriteInt(d) // write table index
  8882. } else {
  8883. buff.WriteString(v) // write string
  8884. }
  8885. if ctx.IsStringTable() {
  8886. e := ctx.Table.AddOrGet(z)
  8887. buff.WriteInt(e) // write table index
  8888. } else {
  8889. buff.WriteString(z) // write string
  8890. }
  8891. }
  8892. // --- [end][write][map](map[string]string) ---
  8893. }
  8894. if target.Annotations == nil {
  8895. buff.WriteUInt8(uint8(0)) // write nil byte
  8896. } else {
  8897. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8898. // --- [begin][write][map](map[string]string) ---
  8899. buff.WriteInt(len(target.Annotations)) // map length
  8900. for vv, zz := range target.Annotations {
  8901. if ctx.IsStringTable() {
  8902. f := ctx.Table.AddOrGet(vv)
  8903. buff.WriteInt(f) // write table index
  8904. } else {
  8905. buff.WriteString(vv) // write string
  8906. }
  8907. if ctx.IsStringTable() {
  8908. g := ctx.Table.AddOrGet(zz)
  8909. buff.WriteInt(g) // write table index
  8910. } else {
  8911. buff.WriteString(zz) // write string
  8912. }
  8913. }
  8914. // --- [end][write][map](map[string]string) ---
  8915. }
  8916. if target.MatchLabels == nil {
  8917. buff.WriteUInt8(uint8(0)) // write nil byte
  8918. } else {
  8919. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8920. // --- [begin][write][map](map[string]string) ---
  8921. buff.WriteInt(len(target.MatchLabels)) // map length
  8922. for vvv, zzz := range target.MatchLabels {
  8923. if ctx.IsStringTable() {
  8924. h := ctx.Table.AddOrGet(vvv)
  8925. buff.WriteInt(h) // write table index
  8926. } else {
  8927. buff.WriteString(vvv) // write string
  8928. }
  8929. if ctx.IsStringTable() {
  8930. l := ctx.Table.AddOrGet(zzz)
  8931. buff.WriteInt(l) // write table index
  8932. } else {
  8933. buff.WriteString(zzz) // write string
  8934. }
  8935. }
  8936. // --- [end][write][map](map[string]string) ---
  8937. }
  8938. // --- [begin][write][reference](time.Time) ---
  8939. m, errA := target.Start.MarshalBinary()
  8940. if errA != nil {
  8941. return errA
  8942. }
  8943. buff.WriteInt(len(m))
  8944. buff.WriteBytes(m)
  8945. // --- [end][write][reference](time.Time) ---
  8946. // --- [begin][write][reference](time.Time) ---
  8947. n, errB := target.End.MarshalBinary()
  8948. if errB != nil {
  8949. return errB
  8950. }
  8951. buff.WriteInt(len(n))
  8952. buff.WriteBytes(n)
  8953. // --- [end][write][reference](time.Time) ---
  8954. return nil
  8955. }
  8956. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  8957. // the StatefulSet type
  8958. func (target *StatefulSet) UnmarshalBinary(data []byte) error {
  8959. ctx := NewDecodingContextFromBytes(data)
  8960. defer ctx.Close()
  8961. err := target.UnmarshalBinaryWithContext(ctx)
  8962. if err != nil {
  8963. return err
  8964. }
  8965. return nil
  8966. }
  8967. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  8968. // the StatefulSet type
  8969. func (target *StatefulSet) UnmarshalBinaryFromReader(reader io.Reader) error {
  8970. ctx := NewDecodingContextFromReader(reader)
  8971. defer ctx.Close()
  8972. err := target.UnmarshalBinaryWithContext(ctx)
  8973. if err != nil {
  8974. return err
  8975. }
  8976. return nil
  8977. }
  8978. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  8979. // the StatefulSet type
  8980. func (target *StatefulSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  8981. // panics are recovered and propagated as errors
  8982. defer func() {
  8983. if r := recover(); r != nil {
  8984. if e, ok := r.(error); ok {
  8985. err = e
  8986. } else if s, ok := r.(string); ok {
  8987. err = fmt.Errorf("unexpected panic: %s", s)
  8988. } else {
  8989. err = fmt.Errorf("unexpected panic: %+v", r)
  8990. }
  8991. }
  8992. }()
  8993. buff := ctx.Buffer
  8994. version := buff.ReadUInt8()
  8995. if version > DefaultCodecVersion {
  8996. return fmt.Errorf("Invalid Version Unmarshalling StatefulSet. Expected %d or less, got %d", DefaultCodecVersion, version)
  8997. }
  8998. var b string
  8999. if ctx.IsStringTable() {
  9000. c := buff.ReadInt() // read string index
  9001. b = ctx.Table.At(c)
  9002. } else {
  9003. b = buff.ReadString() // read string
  9004. }
  9005. a := b
  9006. target.UID = a
  9007. var e string
  9008. if ctx.IsStringTable() {
  9009. f := buff.ReadInt() // read string index
  9010. e = ctx.Table.At(f)
  9011. } else {
  9012. e = buff.ReadString() // read string
  9013. }
  9014. d := e
  9015. target.NamespaceUID = d
  9016. var h string
  9017. if ctx.IsStringTable() {
  9018. l := buff.ReadInt() // read string index
  9019. h = ctx.Table.At(l)
  9020. } else {
  9021. h = buff.ReadString() // read string
  9022. }
  9023. g := h
  9024. target.Name = g
  9025. if buff.ReadUInt8() == uint8(0) {
  9026. target.Labels = nil
  9027. } else {
  9028. // --- [begin][read][map](map[string]string) ---
  9029. n := buff.ReadInt() // map len
  9030. m := make(map[string]string, n)
  9031. for range n {
  9032. var v string
  9033. var p string
  9034. if ctx.IsStringTable() {
  9035. q := buff.ReadInt() // read string index
  9036. p = ctx.Table.At(q)
  9037. } else {
  9038. p = buff.ReadString() // read string
  9039. }
  9040. o := p
  9041. v = o
  9042. var z string
  9043. var s string
  9044. if ctx.IsStringTable() {
  9045. t := buff.ReadInt() // read string index
  9046. s = ctx.Table.At(t)
  9047. } else {
  9048. s = buff.ReadString() // read string
  9049. }
  9050. r := s
  9051. z = r
  9052. m[v] = z
  9053. }
  9054. target.Labels = m
  9055. // --- [end][read][map](map[string]string) ---
  9056. }
  9057. if buff.ReadUInt8() == uint8(0) {
  9058. target.Annotations = nil
  9059. } else {
  9060. // --- [begin][read][map](map[string]string) ---
  9061. w := buff.ReadInt() // map len
  9062. u := make(map[string]string, w)
  9063. for range w {
  9064. var vv string
  9065. var y string
  9066. if ctx.IsStringTable() {
  9067. aa := buff.ReadInt() // read string index
  9068. y = ctx.Table.At(aa)
  9069. } else {
  9070. y = buff.ReadString() // read string
  9071. }
  9072. x := y
  9073. vv = x
  9074. var zz string
  9075. var cc string
  9076. if ctx.IsStringTable() {
  9077. dd := buff.ReadInt() // read string index
  9078. cc = ctx.Table.At(dd)
  9079. } else {
  9080. cc = buff.ReadString() // read string
  9081. }
  9082. bb := cc
  9083. zz = bb
  9084. u[vv] = zz
  9085. }
  9086. target.Annotations = u
  9087. // --- [end][read][map](map[string]string) ---
  9088. }
  9089. if buff.ReadUInt8() == uint8(0) {
  9090. target.MatchLabels = nil
  9091. } else {
  9092. // --- [begin][read][map](map[string]string) ---
  9093. ff := buff.ReadInt() // map len
  9094. ee := make(map[string]string, ff)
  9095. for range ff {
  9096. var vvv string
  9097. var hh string
  9098. if ctx.IsStringTable() {
  9099. ll := buff.ReadInt() // read string index
  9100. hh = ctx.Table.At(ll)
  9101. } else {
  9102. hh = buff.ReadString() // read string
  9103. }
  9104. gg := hh
  9105. vvv = gg
  9106. var zzz string
  9107. var nn string
  9108. if ctx.IsStringTable() {
  9109. oo := buff.ReadInt() // read string index
  9110. nn = ctx.Table.At(oo)
  9111. } else {
  9112. nn = buff.ReadString() // read string
  9113. }
  9114. mm := nn
  9115. zzz = mm
  9116. ee[vvv] = zzz
  9117. }
  9118. target.MatchLabels = ee
  9119. // --- [end][read][map](map[string]string) ---
  9120. }
  9121. // --- [begin][read][reference](time.Time) ---
  9122. pp := new(time.Time)
  9123. qq := buff.ReadInt() // byte array length
  9124. rr := buff.ReadBytes(qq)
  9125. errA := pp.UnmarshalBinary(rr)
  9126. if errA != nil {
  9127. return errA
  9128. }
  9129. target.Start = *pp
  9130. // --- [end][read][reference](time.Time) ---
  9131. // --- [begin][read][reference](time.Time) ---
  9132. ss := new(time.Time)
  9133. tt := buff.ReadInt() // byte array length
  9134. uu := buff.ReadBytes(tt)
  9135. errB := ss.UnmarshalBinary(uu)
  9136. if errB != nil {
  9137. return errB
  9138. }
  9139. target.End = *ss
  9140. // --- [end][read][reference](time.Time) ---
  9141. return nil
  9142. }
  9143. //--------------------------------------------------------------------------
  9144. // Window
  9145. //--------------------------------------------------------------------------
  9146. // MarshalBinary serializes the internal properties of this Window instance
  9147. // into a byte array
  9148. func (target *Window) MarshalBinary() (data []byte, err error) {
  9149. ctx := NewEncodingContext(nil)
  9150. e := target.MarshalBinaryWithContext(ctx)
  9151. if e != nil {
  9152. return nil, e
  9153. }
  9154. return ctx.ToBytes(), nil
  9155. }
  9156. // MarshalBinary serializes the internal properties of this Window instance
  9157. // into an io.Writer.
  9158. func (target *Window) MarshalBinaryTo(writer io.Writer) error {
  9159. buff := util.NewBufferFromWriter(writer)
  9160. defer buff.Flush()
  9161. ctx := NewEncodingContextFromBuffer(buff, nil)
  9162. return target.MarshalBinaryWithContext(ctx)
  9163. }
  9164. // MarshalBinaryWithContext serializes the internal properties of this Window instance
  9165. // into a byte array leveraging a predefined context.
  9166. func (target *Window) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  9167. // panics are recovered and propagated as errors
  9168. defer func() {
  9169. if r := recover(); r != nil {
  9170. if e, ok := r.(error); ok {
  9171. err = e
  9172. } else if s, ok := r.(string); ok {
  9173. err = fmt.Errorf("unexpected panic: %s", s)
  9174. } else {
  9175. err = fmt.Errorf("unexpected panic: %+v", r)
  9176. }
  9177. }
  9178. }()
  9179. buff := ctx.Buffer
  9180. buff.WriteUInt8(DefaultCodecVersion) // version
  9181. // --- [begin][write][reference](time.Time) ---
  9182. a, errA := target.Start.MarshalBinary()
  9183. if errA != nil {
  9184. return errA
  9185. }
  9186. buff.WriteInt(len(a))
  9187. buff.WriteBytes(a)
  9188. // --- [end][write][reference](time.Time) ---
  9189. // --- [begin][write][reference](time.Time) ---
  9190. b, errB := target.End.MarshalBinary()
  9191. if errB != nil {
  9192. return errB
  9193. }
  9194. buff.WriteInt(len(b))
  9195. buff.WriteBytes(b)
  9196. // --- [end][write][reference](time.Time) ---
  9197. return nil
  9198. }
  9199. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  9200. // the Window type
  9201. func (target *Window) UnmarshalBinary(data []byte) error {
  9202. ctx := NewDecodingContextFromBytes(data)
  9203. defer ctx.Close()
  9204. err := target.UnmarshalBinaryWithContext(ctx)
  9205. if err != nil {
  9206. return err
  9207. }
  9208. return nil
  9209. }
  9210. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  9211. // the Window type
  9212. func (target *Window) UnmarshalBinaryFromReader(reader io.Reader) error {
  9213. ctx := NewDecodingContextFromReader(reader)
  9214. defer ctx.Close()
  9215. err := target.UnmarshalBinaryWithContext(ctx)
  9216. if err != nil {
  9217. return err
  9218. }
  9219. return nil
  9220. }
  9221. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  9222. // the Window type
  9223. func (target *Window) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  9224. // panics are recovered and propagated as errors
  9225. defer func() {
  9226. if r := recover(); r != nil {
  9227. if e, ok := r.(error); ok {
  9228. err = e
  9229. } else if s, ok := r.(string); ok {
  9230. err = fmt.Errorf("unexpected panic: %s", s)
  9231. } else {
  9232. err = fmt.Errorf("unexpected panic: %+v", r)
  9233. }
  9234. }
  9235. }()
  9236. buff := ctx.Buffer
  9237. version := buff.ReadUInt8()
  9238. if version > DefaultCodecVersion {
  9239. return fmt.Errorf("Invalid Version Unmarshalling Window. Expected %d or less, got %d", DefaultCodecVersion, version)
  9240. }
  9241. // field version check
  9242. if uint8(1) <= version {
  9243. // --- [begin][read][reference](time.Time) ---
  9244. a := new(time.Time)
  9245. b := buff.ReadInt() // byte array length
  9246. c := buff.ReadBytes(b)
  9247. errA := a.UnmarshalBinary(c)
  9248. if errA != nil {
  9249. return errA
  9250. }
  9251. target.Start = *a
  9252. // --- [end][read][reference](time.Time) ---
  9253. } else {
  9254. }
  9255. // field version check
  9256. if uint8(1) <= version {
  9257. // --- [begin][read][reference](time.Time) ---
  9258. d := new(time.Time)
  9259. e := buff.ReadInt() // byte array length
  9260. f := buff.ReadBytes(e)
  9261. errB := d.UnmarshalBinary(f)
  9262. if errB != nil {
  9263. return errB
  9264. }
  9265. target.End = *d
  9266. // --- [end][read][reference](time.Time) ---
  9267. } else {
  9268. }
  9269. return nil
  9270. }