kubemodel_codecs.go 275 KB

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