kubemodel_codecs.go 272 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // DO NOT MODIFY
  4. //
  5. // ┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻
  6. //
  7. //
  8. // This source file was automatically generated by bingen.
  9. //
  10. ////////////////////////////////////////////////////////////////////////////////
  11. package kubemodel
  12. import (
  13. "cmp"
  14. "fmt"
  15. "github.com/opencost/opencost/core/pkg/model/shared"
  16. "io"
  17. "iter"
  18. "os"
  19. "reflect"
  20. "slices"
  21. "strings"
  22. "sync"
  23. "time"
  24. "unsafe"
  25. util "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.CPUCoreAllocationAvg) // write float64
  1006. buff.WriteFloat64(target.CPUCoreUsageAvg) // write float64
  1007. buff.WriteFloat64(target.CPUCoreUsageMax) // write float64
  1008. buff.WriteFloat64(target.RAMBytesAllocationAvg) // 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.CPUCoreAllocationAvg = 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.RAMBytesAllocationAvg = 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. return nil
  3609. }
  3610. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  3611. // the KubeModelSet type
  3612. func (target *KubeModelSet) UnmarshalBinary(data []byte) error {
  3613. ctx := NewDecodingContextFromBytes(data)
  3614. defer ctx.Close()
  3615. err := target.UnmarshalBinaryWithContext(ctx)
  3616. if err != nil {
  3617. return err
  3618. }
  3619. return nil
  3620. }
  3621. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  3622. // the KubeModelSet type
  3623. func (target *KubeModelSet) UnmarshalBinaryFromReader(reader io.Reader) error {
  3624. ctx := NewDecodingContextFromReader(reader)
  3625. defer ctx.Close()
  3626. err := target.UnmarshalBinaryWithContext(ctx)
  3627. if err != nil {
  3628. return err
  3629. }
  3630. return nil
  3631. }
  3632. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  3633. // the KubeModelSet type
  3634. func (target *KubeModelSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  3635. // panics are recovered and propagated as errors
  3636. defer func() {
  3637. if r := recover(); r != nil {
  3638. if e, ok := r.(error); ok {
  3639. err = e
  3640. } else if s, ok := r.(string); ok {
  3641. err = fmt.Errorf("unexpected panic: %s", s)
  3642. } else {
  3643. err = fmt.Errorf("unexpected panic: %+v", r)
  3644. }
  3645. }
  3646. }()
  3647. buff := ctx.Buffer
  3648. version := buff.ReadUInt8()
  3649. if version > DefaultCodecVersion {
  3650. return fmt.Errorf("Invalid Version Unmarshalling KubeModelSet. Expected %d or less, got %d", DefaultCodecVersion, version)
  3651. }
  3652. // field version check
  3653. if uint8(1) <= version {
  3654. if buff.ReadUInt8() == uint8(0) {
  3655. target.Metadata = nil
  3656. } else {
  3657. // --- [begin][read][struct](Metadata) ---
  3658. a := new(Metadata)
  3659. buff.ReadInt() // [compatibility, unused]
  3660. errA := a.UnmarshalBinaryWithContext(ctx)
  3661. if errA != nil {
  3662. return errA
  3663. }
  3664. target.Metadata = a
  3665. // --- [end][read][struct](Metadata) ---
  3666. }
  3667. } else {
  3668. target.Metadata = nil
  3669. }
  3670. // field version check
  3671. if uint8(1) <= version {
  3672. // --- [begin][read][struct](Window) ---
  3673. b := new(Window)
  3674. buff.ReadInt() // [compatibility, unused]
  3675. errB := b.UnmarshalBinaryWithContext(ctx)
  3676. if errB != nil {
  3677. return errB
  3678. }
  3679. target.Window = *b
  3680. // --- [end][read][struct](Window) ---
  3681. } else {
  3682. }
  3683. // field version check
  3684. if uint8(1) <= version {
  3685. if buff.ReadUInt8() == uint8(0) {
  3686. target.Cluster = nil
  3687. } else {
  3688. // --- [begin][read][struct](Cluster) ---
  3689. c := new(Cluster)
  3690. buff.ReadInt() // [compatibility, unused]
  3691. errC := c.UnmarshalBinaryWithContext(ctx)
  3692. if errC != nil {
  3693. return errC
  3694. }
  3695. target.Cluster = c
  3696. // --- [end][read][struct](Cluster) ---
  3697. }
  3698. } else {
  3699. target.Cluster = nil
  3700. }
  3701. // field version check
  3702. if uint8(1) <= version {
  3703. if buff.ReadUInt8() == uint8(0) {
  3704. target.Namespaces = nil
  3705. } else {
  3706. // --- [begin][read][map](map[string]*Namespace) ---
  3707. e := buff.ReadInt() // map len
  3708. d := make(map[string]*Namespace, e)
  3709. for range e {
  3710. var v string
  3711. var g string
  3712. if ctx.IsStringTable() {
  3713. h := buff.ReadInt() // read string index
  3714. g = ctx.Table.At(h)
  3715. } else {
  3716. g = buff.ReadString() // read string
  3717. }
  3718. f := g
  3719. v = f
  3720. var z *Namespace
  3721. if buff.ReadUInt8() == uint8(0) {
  3722. z = nil
  3723. } else {
  3724. // --- [begin][read][struct](Namespace) ---
  3725. l := new(Namespace)
  3726. buff.ReadInt() // [compatibility, unused]
  3727. errD := l.UnmarshalBinaryWithContext(ctx)
  3728. if errD != nil {
  3729. return errD
  3730. }
  3731. z = l
  3732. // --- [end][read][struct](Namespace) ---
  3733. }
  3734. d[v] = z
  3735. }
  3736. target.Namespaces = d
  3737. // --- [end][read][map](map[string]*Namespace) ---
  3738. }
  3739. } else {
  3740. target.Namespaces = nil
  3741. }
  3742. // field version check
  3743. if uint8(1) <= version {
  3744. if buff.ReadUInt8() == uint8(0) {
  3745. target.ResourceQuotas = nil
  3746. } else {
  3747. // --- [begin][read][map](map[string]*ResourceQuota) ---
  3748. n := buff.ReadInt() // map len
  3749. m := make(map[string]*ResourceQuota, n)
  3750. for range n {
  3751. var vv string
  3752. var p string
  3753. if ctx.IsStringTable() {
  3754. q := buff.ReadInt() // read string index
  3755. p = ctx.Table.At(q)
  3756. } else {
  3757. p = buff.ReadString() // read string
  3758. }
  3759. o := p
  3760. vv = o
  3761. var zz *ResourceQuota
  3762. if buff.ReadUInt8() == uint8(0) {
  3763. zz = nil
  3764. } else {
  3765. // --- [begin][read][struct](ResourceQuota) ---
  3766. r := new(ResourceQuota)
  3767. buff.ReadInt() // [compatibility, unused]
  3768. errE := r.UnmarshalBinaryWithContext(ctx)
  3769. if errE != nil {
  3770. return errE
  3771. }
  3772. zz = r
  3773. // --- [end][read][struct](ResourceQuota) ---
  3774. }
  3775. m[vv] = zz
  3776. }
  3777. target.ResourceQuotas = m
  3778. // --- [end][read][map](map[string]*ResourceQuota) ---
  3779. }
  3780. } else {
  3781. target.ResourceQuotas = nil
  3782. }
  3783. // field version check
  3784. if uint8(2) <= version {
  3785. if buff.ReadUInt8() == uint8(0) {
  3786. target.Services = nil
  3787. } else {
  3788. // --- [begin][read][map](map[string]*Service) ---
  3789. t := buff.ReadInt() // map len
  3790. s := make(map[string]*Service, t)
  3791. for range t {
  3792. var vvv string
  3793. var w string
  3794. if ctx.IsStringTable() {
  3795. x := buff.ReadInt() // read string index
  3796. w = ctx.Table.At(x)
  3797. } else {
  3798. w = buff.ReadString() // read string
  3799. }
  3800. u := w
  3801. vvv = u
  3802. var zzz *Service
  3803. if buff.ReadUInt8() == uint8(0) {
  3804. zzz = nil
  3805. } else {
  3806. // --- [begin][read][struct](Service) ---
  3807. y := new(Service)
  3808. buff.ReadInt() // [compatibility, unused]
  3809. errF := y.UnmarshalBinaryWithContext(ctx)
  3810. if errF != nil {
  3811. return errF
  3812. }
  3813. zzz = y
  3814. // --- [end][read][struct](Service) ---
  3815. }
  3816. s[vvv] = zzz
  3817. }
  3818. target.Services = s
  3819. // --- [end][read][map](map[string]*Service) ---
  3820. }
  3821. } else {
  3822. target.Services = nil
  3823. }
  3824. // field version check
  3825. if uint8(2) <= version {
  3826. if buff.ReadUInt8() == uint8(0) {
  3827. target.Deployments = nil
  3828. } else {
  3829. // --- [begin][read][map](map[string]*Deployment) ---
  3830. bb := buff.ReadInt() // map len
  3831. aa := make(map[string]*Deployment, bb)
  3832. for range bb {
  3833. var vvvv string
  3834. var dd string
  3835. if ctx.IsStringTable() {
  3836. ee := buff.ReadInt() // read string index
  3837. dd = ctx.Table.At(ee)
  3838. } else {
  3839. dd = buff.ReadString() // read string
  3840. }
  3841. cc := dd
  3842. vvvv = cc
  3843. var zzzz *Deployment
  3844. if buff.ReadUInt8() == uint8(0) {
  3845. zzzz = nil
  3846. } else {
  3847. // --- [begin][read][struct](Deployment) ---
  3848. ff := new(Deployment)
  3849. buff.ReadInt() // [compatibility, unused]
  3850. errG := ff.UnmarshalBinaryWithContext(ctx)
  3851. if errG != nil {
  3852. return errG
  3853. }
  3854. zzzz = ff
  3855. // --- [end][read][struct](Deployment) ---
  3856. }
  3857. aa[vvvv] = zzzz
  3858. }
  3859. target.Deployments = aa
  3860. // --- [end][read][map](map[string]*Deployment) ---
  3861. }
  3862. } else {
  3863. target.Deployments = nil
  3864. }
  3865. // field version check
  3866. if uint8(2) <= version {
  3867. if buff.ReadUInt8() == uint8(0) {
  3868. target.StatefulSets = nil
  3869. } else {
  3870. // --- [begin][read][map](map[string]*StatefulSet) ---
  3871. hh := buff.ReadInt() // map len
  3872. gg := make(map[string]*StatefulSet, hh)
  3873. for range hh {
  3874. var vvvvv string
  3875. var mm string
  3876. if ctx.IsStringTable() {
  3877. nn := buff.ReadInt() // read string index
  3878. mm = ctx.Table.At(nn)
  3879. } else {
  3880. mm = buff.ReadString() // read string
  3881. }
  3882. ll := mm
  3883. vvvvv = ll
  3884. var zzzzz *StatefulSet
  3885. if buff.ReadUInt8() == uint8(0) {
  3886. zzzzz = nil
  3887. } else {
  3888. // --- [begin][read][struct](StatefulSet) ---
  3889. oo := new(StatefulSet)
  3890. buff.ReadInt() // [compatibility, unused]
  3891. errH := oo.UnmarshalBinaryWithContext(ctx)
  3892. if errH != nil {
  3893. return errH
  3894. }
  3895. zzzzz = oo
  3896. // --- [end][read][struct](StatefulSet) ---
  3897. }
  3898. gg[vvvvv] = zzzzz
  3899. }
  3900. target.StatefulSets = gg
  3901. // --- [end][read][map](map[string]*StatefulSet) ---
  3902. }
  3903. } else {
  3904. target.StatefulSets = nil
  3905. }
  3906. // field version check
  3907. if uint8(2) <= version {
  3908. if buff.ReadUInt8() == uint8(0) {
  3909. target.DaemonSets = nil
  3910. } else {
  3911. // --- [begin][read][map](map[string]*DaemonSet) ---
  3912. qq := buff.ReadInt() // map len
  3913. pp := make(map[string]*DaemonSet, qq)
  3914. for range qq {
  3915. var vvvvvv string
  3916. var ss string
  3917. if ctx.IsStringTable() {
  3918. tt := buff.ReadInt() // read string index
  3919. ss = ctx.Table.At(tt)
  3920. } else {
  3921. ss = buff.ReadString() // read string
  3922. }
  3923. rr := ss
  3924. vvvvvv = rr
  3925. var zzzzzz *DaemonSet
  3926. if buff.ReadUInt8() == uint8(0) {
  3927. zzzzzz = nil
  3928. } else {
  3929. // --- [begin][read][struct](DaemonSet) ---
  3930. uu := new(DaemonSet)
  3931. buff.ReadInt() // [compatibility, unused]
  3932. errI := uu.UnmarshalBinaryWithContext(ctx)
  3933. if errI != nil {
  3934. return errI
  3935. }
  3936. zzzzzz = uu
  3937. // --- [end][read][struct](DaemonSet) ---
  3938. }
  3939. pp[vvvvvv] = zzzzzz
  3940. }
  3941. target.DaemonSets = pp
  3942. // --- [end][read][map](map[string]*DaemonSet) ---
  3943. }
  3944. } else {
  3945. target.DaemonSets = nil
  3946. }
  3947. // field version check
  3948. if uint8(2) <= version {
  3949. if buff.ReadUInt8() == uint8(0) {
  3950. target.Jobs = nil
  3951. } else {
  3952. // --- [begin][read][map](map[string]*Job) ---
  3953. xx := buff.ReadInt() // map len
  3954. ww := make(map[string]*Job, xx)
  3955. for range xx {
  3956. var vvvvvvv string
  3957. var aaa string
  3958. if ctx.IsStringTable() {
  3959. bbb := buff.ReadInt() // read string index
  3960. aaa = ctx.Table.At(bbb)
  3961. } else {
  3962. aaa = buff.ReadString() // read string
  3963. }
  3964. yy := aaa
  3965. vvvvvvv = yy
  3966. var zzzzzzz *Job
  3967. if buff.ReadUInt8() == uint8(0) {
  3968. zzzzzzz = nil
  3969. } else {
  3970. // --- [begin][read][struct](Job) ---
  3971. ccc := new(Job)
  3972. buff.ReadInt() // [compatibility, unused]
  3973. errJ := ccc.UnmarshalBinaryWithContext(ctx)
  3974. if errJ != nil {
  3975. return errJ
  3976. }
  3977. zzzzzzz = ccc
  3978. // --- [end][read][struct](Job) ---
  3979. }
  3980. ww[vvvvvvv] = zzzzzzz
  3981. }
  3982. target.Jobs = ww
  3983. // --- [end][read][map](map[string]*Job) ---
  3984. }
  3985. } else {
  3986. target.Jobs = nil
  3987. }
  3988. // field version check
  3989. if uint8(2) <= version {
  3990. if buff.ReadUInt8() == uint8(0) {
  3991. target.CronJobs = nil
  3992. } else {
  3993. // --- [begin][read][map](map[string]*CronJob) ---
  3994. eee := buff.ReadInt() // map len
  3995. ddd := make(map[string]*CronJob, eee)
  3996. for range eee {
  3997. var vvvvvvvv string
  3998. var ggg string
  3999. if ctx.IsStringTable() {
  4000. hhh := buff.ReadInt() // read string index
  4001. ggg = ctx.Table.At(hhh)
  4002. } else {
  4003. ggg = buff.ReadString() // read string
  4004. }
  4005. fff := ggg
  4006. vvvvvvvv = fff
  4007. var zzzzzzzz *CronJob
  4008. if buff.ReadUInt8() == uint8(0) {
  4009. zzzzzzzz = nil
  4010. } else {
  4011. // --- [begin][read][struct](CronJob) ---
  4012. lll := new(CronJob)
  4013. buff.ReadInt() // [compatibility, unused]
  4014. errK := lll.UnmarshalBinaryWithContext(ctx)
  4015. if errK != nil {
  4016. return errK
  4017. }
  4018. zzzzzzzz = lll
  4019. // --- [end][read][struct](CronJob) ---
  4020. }
  4021. ddd[vvvvvvvv] = zzzzzzzz
  4022. }
  4023. target.CronJobs = ddd
  4024. // --- [end][read][map](map[string]*CronJob) ---
  4025. }
  4026. } else {
  4027. target.CronJobs = nil
  4028. }
  4029. // field version check
  4030. if uint8(2) <= version {
  4031. if buff.ReadUInt8() == uint8(0) {
  4032. target.ReplicaSets = nil
  4033. } else {
  4034. // --- [begin][read][map](map[string]*ReplicaSet) ---
  4035. nnn := buff.ReadInt() // map len
  4036. mmm := make(map[string]*ReplicaSet, nnn)
  4037. for range nnn {
  4038. var vvvvvvvvv string
  4039. var ppp string
  4040. if ctx.IsStringTable() {
  4041. qqq := buff.ReadInt() // read string index
  4042. ppp = ctx.Table.At(qqq)
  4043. } else {
  4044. ppp = buff.ReadString() // read string
  4045. }
  4046. ooo := ppp
  4047. vvvvvvvvv = ooo
  4048. var zzzzzzzzz *ReplicaSet
  4049. if buff.ReadUInt8() == uint8(0) {
  4050. zzzzzzzzz = nil
  4051. } else {
  4052. // --- [begin][read][struct](ReplicaSet) ---
  4053. rrr := new(ReplicaSet)
  4054. buff.ReadInt() // [compatibility, unused]
  4055. errL := rrr.UnmarshalBinaryWithContext(ctx)
  4056. if errL != nil {
  4057. return errL
  4058. }
  4059. zzzzzzzzz = rrr
  4060. // --- [end][read][struct](ReplicaSet) ---
  4061. }
  4062. mmm[vvvvvvvvv] = zzzzzzzzz
  4063. }
  4064. target.ReplicaSets = mmm
  4065. // --- [end][read][map](map[string]*ReplicaSet) ---
  4066. }
  4067. } else {
  4068. target.ReplicaSets = nil
  4069. }
  4070. // field version check
  4071. if uint8(2) <= version {
  4072. if buff.ReadUInt8() == uint8(0) {
  4073. target.Nodes = nil
  4074. } else {
  4075. // --- [begin][read][map](map[string]*Node) ---
  4076. ttt := buff.ReadInt() // map len
  4077. sss := make(map[string]*Node, ttt)
  4078. for range ttt {
  4079. var vvvvvvvvvv string
  4080. var www string
  4081. if ctx.IsStringTable() {
  4082. xxx := buff.ReadInt() // read string index
  4083. www = ctx.Table.At(xxx)
  4084. } else {
  4085. www = buff.ReadString() // read string
  4086. }
  4087. uuu := www
  4088. vvvvvvvvvv = uuu
  4089. var zzzzzzzzzz *Node
  4090. if buff.ReadUInt8() == uint8(0) {
  4091. zzzzzzzzzz = nil
  4092. } else {
  4093. // --- [begin][read][struct](Node) ---
  4094. yyy := new(Node)
  4095. buff.ReadInt() // [compatibility, unused]
  4096. errM := yyy.UnmarshalBinaryWithContext(ctx)
  4097. if errM != nil {
  4098. return errM
  4099. }
  4100. zzzzzzzzzz = yyy
  4101. // --- [end][read][struct](Node) ---
  4102. }
  4103. sss[vvvvvvvvvv] = zzzzzzzzzz
  4104. }
  4105. target.Nodes = sss
  4106. // --- [end][read][map](map[string]*Node) ---
  4107. }
  4108. } else {
  4109. target.Nodes = nil
  4110. }
  4111. // field version check
  4112. if uint8(2) <= version {
  4113. if buff.ReadUInt8() == uint8(0) {
  4114. target.PersistentVolumes = nil
  4115. } else {
  4116. // --- [begin][read][map](map[string]*PersistentVolume) ---
  4117. bbbb := buff.ReadInt() // map len
  4118. aaaa := make(map[string]*PersistentVolume, bbbb)
  4119. for range bbbb {
  4120. var vvvvvvvvvvv string
  4121. var dddd string
  4122. if ctx.IsStringTable() {
  4123. eeee := buff.ReadInt() // read string index
  4124. dddd = ctx.Table.At(eeee)
  4125. } else {
  4126. dddd = buff.ReadString() // read string
  4127. }
  4128. cccc := dddd
  4129. vvvvvvvvvvv = cccc
  4130. var zzzzzzzzzzz *PersistentVolume
  4131. if buff.ReadUInt8() == uint8(0) {
  4132. zzzzzzzzzzz = nil
  4133. } else {
  4134. // --- [begin][read][struct](PersistentVolume) ---
  4135. ffff := new(PersistentVolume)
  4136. buff.ReadInt() // [compatibility, unused]
  4137. errN := ffff.UnmarshalBinaryWithContext(ctx)
  4138. if errN != nil {
  4139. return errN
  4140. }
  4141. zzzzzzzzzzz = ffff
  4142. // --- [end][read][struct](PersistentVolume) ---
  4143. }
  4144. aaaa[vvvvvvvvvvv] = zzzzzzzzzzz
  4145. }
  4146. target.PersistentVolumes = aaaa
  4147. // --- [end][read][map](map[string]*PersistentVolume) ---
  4148. }
  4149. } else {
  4150. target.PersistentVolumes = nil
  4151. }
  4152. // field version check
  4153. if uint8(2) <= version {
  4154. if buff.ReadUInt8() == uint8(0) {
  4155. target.PersistentVolumeClaims = nil
  4156. } else {
  4157. // --- [begin][read][map](map[string]*PersistentVolumeClaim) ---
  4158. hhhh := buff.ReadInt() // map len
  4159. gggg := make(map[string]*PersistentVolumeClaim, hhhh)
  4160. for range hhhh {
  4161. var vvvvvvvvvvvv string
  4162. var mmmm string
  4163. if ctx.IsStringTable() {
  4164. nnnn := buff.ReadInt() // read string index
  4165. mmmm = ctx.Table.At(nnnn)
  4166. } else {
  4167. mmmm = buff.ReadString() // read string
  4168. }
  4169. llll := mmmm
  4170. vvvvvvvvvvvv = llll
  4171. var zzzzzzzzzzzz *PersistentVolumeClaim
  4172. if buff.ReadUInt8() == uint8(0) {
  4173. zzzzzzzzzzzz = nil
  4174. } else {
  4175. // --- [begin][read][struct](PersistentVolumeClaim) ---
  4176. oooo := new(PersistentVolumeClaim)
  4177. buff.ReadInt() // [compatibility, unused]
  4178. errO := oooo.UnmarshalBinaryWithContext(ctx)
  4179. if errO != nil {
  4180. return errO
  4181. }
  4182. zzzzzzzzzzzz = oooo
  4183. // --- [end][read][struct](PersistentVolumeClaim) ---
  4184. }
  4185. gggg[vvvvvvvvvvvv] = zzzzzzzzzzzz
  4186. }
  4187. target.PersistentVolumeClaims = gggg
  4188. // --- [end][read][map](map[string]*PersistentVolumeClaim) ---
  4189. }
  4190. } else {
  4191. target.PersistentVolumeClaims = nil
  4192. }
  4193. // field version check
  4194. if uint8(2) <= version {
  4195. if buff.ReadUInt8() == uint8(0) {
  4196. target.Pods = nil
  4197. } else {
  4198. // --- [begin][read][map](map[string]*Pod) ---
  4199. qqqq := buff.ReadInt() // map len
  4200. pppp := make(map[string]*Pod, qqqq)
  4201. for range qqqq {
  4202. var vvvvvvvvvvvvv string
  4203. var ssss string
  4204. if ctx.IsStringTable() {
  4205. tttt := buff.ReadInt() // read string index
  4206. ssss = ctx.Table.At(tttt)
  4207. } else {
  4208. ssss = buff.ReadString() // read string
  4209. }
  4210. rrrr := ssss
  4211. vvvvvvvvvvvvv = rrrr
  4212. var zzzzzzzzzzzzz *Pod
  4213. if buff.ReadUInt8() == uint8(0) {
  4214. zzzzzzzzzzzzz = nil
  4215. } else {
  4216. // --- [begin][read][struct](Pod) ---
  4217. uuuu := new(Pod)
  4218. buff.ReadInt() // [compatibility, unused]
  4219. errP := uuuu.UnmarshalBinaryWithContext(ctx)
  4220. if errP != nil {
  4221. return errP
  4222. }
  4223. zzzzzzzzzzzzz = uuuu
  4224. // --- [end][read][struct](Pod) ---
  4225. }
  4226. pppp[vvvvvvvvvvvvv] = zzzzzzzzzzzzz
  4227. }
  4228. target.Pods = pppp
  4229. // --- [end][read][map](map[string]*Pod) ---
  4230. }
  4231. } else {
  4232. target.Pods = nil
  4233. }
  4234. // field version check
  4235. if uint8(2) <= version {
  4236. if buff.ReadUInt8() == uint8(0) {
  4237. target.Containers = nil
  4238. } else {
  4239. // --- [begin][read][map](map[string]*Container) ---
  4240. xxxx := buff.ReadInt() // map len
  4241. wwww := make(map[string]*Container, xxxx)
  4242. for range xxxx {
  4243. var vvvvvvvvvvvvvv string
  4244. var aaaaa string
  4245. if ctx.IsStringTable() {
  4246. bbbbb := buff.ReadInt() // read string index
  4247. aaaaa = ctx.Table.At(bbbbb)
  4248. } else {
  4249. aaaaa = buff.ReadString() // read string
  4250. }
  4251. yyyy := aaaaa
  4252. vvvvvvvvvvvvvv = yyyy
  4253. var zzzzzzzzzzzzzz *Container
  4254. if buff.ReadUInt8() == uint8(0) {
  4255. zzzzzzzzzzzzzz = nil
  4256. } else {
  4257. // --- [begin][read][struct](Container) ---
  4258. ccccc := new(Container)
  4259. buff.ReadInt() // [compatibility, unused]
  4260. errQ := ccccc.UnmarshalBinaryWithContext(ctx)
  4261. if errQ != nil {
  4262. return errQ
  4263. }
  4264. zzzzzzzzzzzzzz = ccccc
  4265. // --- [end][read][struct](Container) ---
  4266. }
  4267. wwww[vvvvvvvvvvvvvv] = zzzzzzzzzzzzzz
  4268. }
  4269. target.Containers = wwww
  4270. // --- [end][read][map](map[string]*Container) ---
  4271. }
  4272. } else {
  4273. target.Containers = nil
  4274. }
  4275. return nil
  4276. }
  4277. //--------------------------------------------------------------------------
  4278. // KubeModelSetStream
  4279. //--------------------------------------------------------------------------
  4280. // KubeModelSetStream is a single use field stream for the contents of an KubeModelSet instance. Instead of creating an instance and populating
  4281. // the fields on that instance, we provide a streaming iterator which yields (BingenFieldInfo, *BingenValue) tuples for each
  4282. // streamable element. All slices and maps will be flattened one depth and each element streamed individually.
  4283. type KubeModelSetStream struct {
  4284. reader io.Reader
  4285. ctx *DecodingContext
  4286. err error
  4287. }
  4288. // Closes closes the internal io.Reader used to read and parse the KubeModelSet fields.
  4289. // This should be called once the stream is no longer needed.
  4290. func (stream *KubeModelSetStream) Close() {
  4291. if closer, ok := stream.reader.(io.Closer); ok {
  4292. closer.Close()
  4293. }
  4294. stream.ctx.Close()
  4295. }
  4296. // Error returns an error if one occurred during the process of streaming the KubeModelSet
  4297. // This can be checked after iterating through the Stream().
  4298. func (stream *KubeModelSetStream) Error() error {
  4299. return stream.err
  4300. }
  4301. // NewKubeModelSetStream creates a new KubeModelSetStream, which uses the io.Reader data to stream all internal fields of an KubeModelSet instance
  4302. func NewKubeModelSetStream(reader io.Reader) BingenStream {
  4303. ctx := NewDecodingContextFromReader(reader)
  4304. return &KubeModelSetStream{
  4305. ctx: ctx,
  4306. reader: reader,
  4307. }
  4308. }
  4309. // Stream returns the iterator which will stream each field of the target type.
  4310. func (stream *KubeModelSetStream) Stream() iter.Seq2[BingenFieldInfo, *BingenValue] {
  4311. return func(yield func(BingenFieldInfo, *BingenValue) bool) {
  4312. var fi BingenFieldInfo
  4313. ctx := stream.ctx
  4314. buff := ctx.Buffer
  4315. version := buff.ReadUInt8()
  4316. if version > DefaultCodecVersion {
  4317. stream.err = fmt.Errorf("Invalid Version Unmarshalling KubeModelSet. Expected %d or less, got %d", DefaultCodecVersion, version)
  4318. return
  4319. }
  4320. fi = BingenFieldInfo{
  4321. Type: reflect.TypeFor[*Metadata](),
  4322. Name: "Metadata",
  4323. }
  4324. // field version check
  4325. if uint8(1) <= version {
  4326. if buff.ReadUInt8() == uint8(0) {
  4327. if !yield(fi, nil) {
  4328. return
  4329. }
  4330. } else {
  4331. // --- [begin][read][struct](Metadata) ---
  4332. b := new(Metadata)
  4333. buff.ReadInt() // [compatibility, unused]
  4334. errA := b.UnmarshalBinaryWithContext(ctx)
  4335. if errA != nil {
  4336. stream.err = errA
  4337. return
  4338. }
  4339. a := b
  4340. // --- [end][read][struct](Metadata) ---
  4341. if !yield(fi, singleV(a)) {
  4342. return
  4343. }
  4344. }
  4345. } else {
  4346. if !yield(fi, nil) {
  4347. return
  4348. }
  4349. }
  4350. fi = BingenFieldInfo{
  4351. Type: reflect.TypeFor[Window](),
  4352. Name: "Window",
  4353. }
  4354. // field version check
  4355. if uint8(1) <= version {
  4356. // --- [begin][read][struct](Window) ---
  4357. d := new(Window)
  4358. buff.ReadInt() // [compatibility, unused]
  4359. errB := d.UnmarshalBinaryWithContext(ctx)
  4360. if errB != nil {
  4361. stream.err = errB
  4362. return
  4363. }
  4364. c := *d
  4365. // --- [end][read][struct](Window) ---
  4366. if !yield(fi, singleV(c)) {
  4367. return
  4368. }
  4369. } else {
  4370. }
  4371. fi = BingenFieldInfo{
  4372. Type: reflect.TypeFor[*Cluster](),
  4373. Name: "Cluster",
  4374. }
  4375. // field version check
  4376. if uint8(1) <= version {
  4377. if buff.ReadUInt8() == uint8(0) {
  4378. if !yield(fi, nil) {
  4379. return
  4380. }
  4381. } else {
  4382. // --- [begin][read][struct](Cluster) ---
  4383. f := new(Cluster)
  4384. buff.ReadInt() // [compatibility, unused]
  4385. errC := f.UnmarshalBinaryWithContext(ctx)
  4386. if errC != nil {
  4387. stream.err = errC
  4388. return
  4389. }
  4390. e := f
  4391. // --- [end][read][struct](Cluster) ---
  4392. if !yield(fi, singleV(e)) {
  4393. return
  4394. }
  4395. }
  4396. } else {
  4397. if !yield(fi, nil) {
  4398. return
  4399. }
  4400. }
  4401. fi = BingenFieldInfo{
  4402. Type: reflect.TypeFor[map[string]*Namespace](),
  4403. Name: "Namespaces",
  4404. }
  4405. // field version check
  4406. if uint8(1) <= version {
  4407. if buff.ReadUInt8() == uint8(0) {
  4408. if !yield(fi, nil) {
  4409. return
  4410. }
  4411. } else {
  4412. // --- [begin][read][streaming-map](map[string]*Namespace) ---
  4413. g := buff.ReadInt() // map len
  4414. for range g {
  4415. var v string
  4416. var l string
  4417. if ctx.IsStringTable() {
  4418. m := buff.ReadInt() // read string index
  4419. l = ctx.Table.At(m)
  4420. } else {
  4421. l = buff.ReadString() // read string
  4422. }
  4423. h := l
  4424. v = h
  4425. var z *Namespace
  4426. if buff.ReadUInt8() == uint8(0) {
  4427. z = nil
  4428. } else {
  4429. // --- [begin][read][struct](Namespace) ---
  4430. n := new(Namespace)
  4431. buff.ReadInt() // [compatibility, unused]
  4432. errD := n.UnmarshalBinaryWithContext(ctx)
  4433. if errD != nil {
  4434. stream.err = errD
  4435. return
  4436. }
  4437. z = n
  4438. // --- [end][read][struct](Namespace) ---
  4439. }
  4440. if !yield(fi, pairV(v, z)) {
  4441. return
  4442. }
  4443. }
  4444. // --- [end][read][streaming-map](map[string]*Namespace) ---
  4445. }
  4446. } else {
  4447. if !yield(fi, nil) {
  4448. return
  4449. }
  4450. }
  4451. fi = BingenFieldInfo{
  4452. Type: reflect.TypeFor[map[string]*ResourceQuota](),
  4453. Name: "ResourceQuotas",
  4454. }
  4455. // field version check
  4456. if uint8(1) <= version {
  4457. if buff.ReadUInt8() == uint8(0) {
  4458. if !yield(fi, nil) {
  4459. return
  4460. }
  4461. } else {
  4462. // --- [begin][read][streaming-map](map[string]*ResourceQuota) ---
  4463. o := buff.ReadInt() // map len
  4464. for range o {
  4465. var vv string
  4466. var q string
  4467. if ctx.IsStringTable() {
  4468. r := buff.ReadInt() // read string index
  4469. q = ctx.Table.At(r)
  4470. } else {
  4471. q = buff.ReadString() // read string
  4472. }
  4473. p := q
  4474. vv = p
  4475. var zz *ResourceQuota
  4476. if buff.ReadUInt8() == uint8(0) {
  4477. zz = nil
  4478. } else {
  4479. // --- [begin][read][struct](ResourceQuota) ---
  4480. s := new(ResourceQuota)
  4481. buff.ReadInt() // [compatibility, unused]
  4482. errE := s.UnmarshalBinaryWithContext(ctx)
  4483. if errE != nil {
  4484. stream.err = errE
  4485. return
  4486. }
  4487. zz = s
  4488. // --- [end][read][struct](ResourceQuota) ---
  4489. }
  4490. if !yield(fi, pairV(vv, zz)) {
  4491. return
  4492. }
  4493. }
  4494. // --- [end][read][streaming-map](map[string]*ResourceQuota) ---
  4495. }
  4496. } else {
  4497. if !yield(fi, nil) {
  4498. return
  4499. }
  4500. }
  4501. fi = BingenFieldInfo{
  4502. Type: reflect.TypeFor[map[string]*Service](),
  4503. Name: "Services",
  4504. }
  4505. // field version check
  4506. if uint8(2) <= version {
  4507. if buff.ReadUInt8() == uint8(0) {
  4508. if !yield(fi, nil) {
  4509. return
  4510. }
  4511. } else {
  4512. // --- [begin][read][streaming-map](map[string]*Service) ---
  4513. t := buff.ReadInt() // map len
  4514. for range t {
  4515. var vvv string
  4516. var w string
  4517. if ctx.IsStringTable() {
  4518. x := buff.ReadInt() // read string index
  4519. w = ctx.Table.At(x)
  4520. } else {
  4521. w = buff.ReadString() // read string
  4522. }
  4523. u := w
  4524. vvv = u
  4525. var zzz *Service
  4526. if buff.ReadUInt8() == uint8(0) {
  4527. zzz = nil
  4528. } else {
  4529. // --- [begin][read][struct](Service) ---
  4530. y := new(Service)
  4531. buff.ReadInt() // [compatibility, unused]
  4532. errF := y.UnmarshalBinaryWithContext(ctx)
  4533. if errF != nil {
  4534. stream.err = errF
  4535. return
  4536. }
  4537. zzz = y
  4538. // --- [end][read][struct](Service) ---
  4539. }
  4540. if !yield(fi, pairV(vvv, zzz)) {
  4541. return
  4542. }
  4543. }
  4544. // --- [end][read][streaming-map](map[string]*Service) ---
  4545. }
  4546. } else {
  4547. if !yield(fi, nil) {
  4548. return
  4549. }
  4550. }
  4551. fi = BingenFieldInfo{
  4552. Type: reflect.TypeFor[map[string]*Deployment](),
  4553. Name: "Deployments",
  4554. }
  4555. // field version check
  4556. if uint8(2) <= version {
  4557. if buff.ReadUInt8() == uint8(0) {
  4558. if !yield(fi, nil) {
  4559. return
  4560. }
  4561. } else {
  4562. // --- [begin][read][streaming-map](map[string]*Deployment) ---
  4563. aa := buff.ReadInt() // map len
  4564. for range aa {
  4565. var vvvv string
  4566. var cc string
  4567. if ctx.IsStringTable() {
  4568. dd := buff.ReadInt() // read string index
  4569. cc = ctx.Table.At(dd)
  4570. } else {
  4571. cc = buff.ReadString() // read string
  4572. }
  4573. bb := cc
  4574. vvvv = bb
  4575. var zzzz *Deployment
  4576. if buff.ReadUInt8() == uint8(0) {
  4577. zzzz = nil
  4578. } else {
  4579. // --- [begin][read][struct](Deployment) ---
  4580. ee := new(Deployment)
  4581. buff.ReadInt() // [compatibility, unused]
  4582. errG := ee.UnmarshalBinaryWithContext(ctx)
  4583. if errG != nil {
  4584. stream.err = errG
  4585. return
  4586. }
  4587. zzzz = ee
  4588. // --- [end][read][struct](Deployment) ---
  4589. }
  4590. if !yield(fi, pairV(vvvv, zzzz)) {
  4591. return
  4592. }
  4593. }
  4594. // --- [end][read][streaming-map](map[string]*Deployment) ---
  4595. }
  4596. } else {
  4597. if !yield(fi, nil) {
  4598. return
  4599. }
  4600. }
  4601. fi = BingenFieldInfo{
  4602. Type: reflect.TypeFor[map[string]*StatefulSet](),
  4603. Name: "StatefulSets",
  4604. }
  4605. // field version check
  4606. if uint8(2) <= version {
  4607. if buff.ReadUInt8() == uint8(0) {
  4608. if !yield(fi, nil) {
  4609. return
  4610. }
  4611. } else {
  4612. // --- [begin][read][streaming-map](map[string]*StatefulSet) ---
  4613. ff := buff.ReadInt() // map len
  4614. for range ff {
  4615. var vvvvv string
  4616. var hh string
  4617. if ctx.IsStringTable() {
  4618. ll := buff.ReadInt() // read string index
  4619. hh = ctx.Table.At(ll)
  4620. } else {
  4621. hh = buff.ReadString() // read string
  4622. }
  4623. gg := hh
  4624. vvvvv = gg
  4625. var zzzzz *StatefulSet
  4626. if buff.ReadUInt8() == uint8(0) {
  4627. zzzzz = nil
  4628. } else {
  4629. // --- [begin][read][struct](StatefulSet) ---
  4630. mm := new(StatefulSet)
  4631. buff.ReadInt() // [compatibility, unused]
  4632. errH := mm.UnmarshalBinaryWithContext(ctx)
  4633. if errH != nil {
  4634. stream.err = errH
  4635. return
  4636. }
  4637. zzzzz = mm
  4638. // --- [end][read][struct](StatefulSet) ---
  4639. }
  4640. if !yield(fi, pairV(vvvvv, zzzzz)) {
  4641. return
  4642. }
  4643. }
  4644. // --- [end][read][streaming-map](map[string]*StatefulSet) ---
  4645. }
  4646. } else {
  4647. if !yield(fi, nil) {
  4648. return
  4649. }
  4650. }
  4651. fi = BingenFieldInfo{
  4652. Type: reflect.TypeFor[map[string]*DaemonSet](),
  4653. Name: "DaemonSets",
  4654. }
  4655. // field version check
  4656. if uint8(2) <= version {
  4657. if buff.ReadUInt8() == uint8(0) {
  4658. if !yield(fi, nil) {
  4659. return
  4660. }
  4661. } else {
  4662. // --- [begin][read][streaming-map](map[string]*DaemonSet) ---
  4663. nn := buff.ReadInt() // map len
  4664. for range nn {
  4665. var vvvvvv string
  4666. var pp string
  4667. if ctx.IsStringTable() {
  4668. qq := buff.ReadInt() // read string index
  4669. pp = ctx.Table.At(qq)
  4670. } else {
  4671. pp = buff.ReadString() // read string
  4672. }
  4673. oo := pp
  4674. vvvvvv = oo
  4675. var zzzzzz *DaemonSet
  4676. if buff.ReadUInt8() == uint8(0) {
  4677. zzzzzz = nil
  4678. } else {
  4679. // --- [begin][read][struct](DaemonSet) ---
  4680. rr := new(DaemonSet)
  4681. buff.ReadInt() // [compatibility, unused]
  4682. errI := rr.UnmarshalBinaryWithContext(ctx)
  4683. if errI != nil {
  4684. stream.err = errI
  4685. return
  4686. }
  4687. zzzzzz = rr
  4688. // --- [end][read][struct](DaemonSet) ---
  4689. }
  4690. if !yield(fi, pairV(vvvvvv, zzzzzz)) {
  4691. return
  4692. }
  4693. }
  4694. // --- [end][read][streaming-map](map[string]*DaemonSet) ---
  4695. }
  4696. } else {
  4697. if !yield(fi, nil) {
  4698. return
  4699. }
  4700. }
  4701. fi = BingenFieldInfo{
  4702. Type: reflect.TypeFor[map[string]*Job](),
  4703. Name: "Jobs",
  4704. }
  4705. // field version check
  4706. if uint8(2) <= version {
  4707. if buff.ReadUInt8() == uint8(0) {
  4708. if !yield(fi, nil) {
  4709. return
  4710. }
  4711. } else {
  4712. // --- [begin][read][streaming-map](map[string]*Job) ---
  4713. ss := buff.ReadInt() // map len
  4714. for range ss {
  4715. var vvvvvvv string
  4716. var uu string
  4717. if ctx.IsStringTable() {
  4718. ww := buff.ReadInt() // read string index
  4719. uu = ctx.Table.At(ww)
  4720. } else {
  4721. uu = buff.ReadString() // read string
  4722. }
  4723. tt := uu
  4724. vvvvvvv = tt
  4725. var zzzzzzz *Job
  4726. if buff.ReadUInt8() == uint8(0) {
  4727. zzzzzzz = nil
  4728. } else {
  4729. // --- [begin][read][struct](Job) ---
  4730. xx := new(Job)
  4731. buff.ReadInt() // [compatibility, unused]
  4732. errJ := xx.UnmarshalBinaryWithContext(ctx)
  4733. if errJ != nil {
  4734. stream.err = errJ
  4735. return
  4736. }
  4737. zzzzzzz = xx
  4738. // --- [end][read][struct](Job) ---
  4739. }
  4740. if !yield(fi, pairV(vvvvvvv, zzzzzzz)) {
  4741. return
  4742. }
  4743. }
  4744. // --- [end][read][streaming-map](map[string]*Job) ---
  4745. }
  4746. } else {
  4747. if !yield(fi, nil) {
  4748. return
  4749. }
  4750. }
  4751. fi = BingenFieldInfo{
  4752. Type: reflect.TypeFor[map[string]*CronJob](),
  4753. Name: "CronJobs",
  4754. }
  4755. // field version check
  4756. if uint8(2) <= version {
  4757. if buff.ReadUInt8() == uint8(0) {
  4758. if !yield(fi, nil) {
  4759. return
  4760. }
  4761. } else {
  4762. // --- [begin][read][streaming-map](map[string]*CronJob) ---
  4763. yy := buff.ReadInt() // map len
  4764. for range yy {
  4765. var vvvvvvvv string
  4766. var bbb string
  4767. if ctx.IsStringTable() {
  4768. ccc := buff.ReadInt() // read string index
  4769. bbb = ctx.Table.At(ccc)
  4770. } else {
  4771. bbb = buff.ReadString() // read string
  4772. }
  4773. aaa := bbb
  4774. vvvvvvvv = aaa
  4775. var zzzzzzzz *CronJob
  4776. if buff.ReadUInt8() == uint8(0) {
  4777. zzzzzzzz = nil
  4778. } else {
  4779. // --- [begin][read][struct](CronJob) ---
  4780. ddd := new(CronJob)
  4781. buff.ReadInt() // [compatibility, unused]
  4782. errK := ddd.UnmarshalBinaryWithContext(ctx)
  4783. if errK != nil {
  4784. stream.err = errK
  4785. return
  4786. }
  4787. zzzzzzzz = ddd
  4788. // --- [end][read][struct](CronJob) ---
  4789. }
  4790. if !yield(fi, pairV(vvvvvvvv, zzzzzzzz)) {
  4791. return
  4792. }
  4793. }
  4794. // --- [end][read][streaming-map](map[string]*CronJob) ---
  4795. }
  4796. } else {
  4797. if !yield(fi, nil) {
  4798. return
  4799. }
  4800. }
  4801. fi = BingenFieldInfo{
  4802. Type: reflect.TypeFor[map[string]*ReplicaSet](),
  4803. Name: "ReplicaSets",
  4804. }
  4805. // field version check
  4806. if uint8(2) <= version {
  4807. if buff.ReadUInt8() == uint8(0) {
  4808. if !yield(fi, nil) {
  4809. return
  4810. }
  4811. } else {
  4812. // --- [begin][read][streaming-map](map[string]*ReplicaSet) ---
  4813. eee := buff.ReadInt() // map len
  4814. for range eee {
  4815. var vvvvvvvvv string
  4816. var ggg string
  4817. if ctx.IsStringTable() {
  4818. hhh := buff.ReadInt() // read string index
  4819. ggg = ctx.Table.At(hhh)
  4820. } else {
  4821. ggg = buff.ReadString() // read string
  4822. }
  4823. fff := ggg
  4824. vvvvvvvvv = fff
  4825. var zzzzzzzzz *ReplicaSet
  4826. if buff.ReadUInt8() == uint8(0) {
  4827. zzzzzzzzz = nil
  4828. } else {
  4829. // --- [begin][read][struct](ReplicaSet) ---
  4830. lll := new(ReplicaSet)
  4831. buff.ReadInt() // [compatibility, unused]
  4832. errL := lll.UnmarshalBinaryWithContext(ctx)
  4833. if errL != nil {
  4834. stream.err = errL
  4835. return
  4836. }
  4837. zzzzzzzzz = lll
  4838. // --- [end][read][struct](ReplicaSet) ---
  4839. }
  4840. if !yield(fi, pairV(vvvvvvvvv, zzzzzzzzz)) {
  4841. return
  4842. }
  4843. }
  4844. // --- [end][read][streaming-map](map[string]*ReplicaSet) ---
  4845. }
  4846. } else {
  4847. if !yield(fi, nil) {
  4848. return
  4849. }
  4850. }
  4851. fi = BingenFieldInfo{
  4852. Type: reflect.TypeFor[map[string]*Node](),
  4853. Name: "Nodes",
  4854. }
  4855. // field version check
  4856. if uint8(2) <= version {
  4857. if buff.ReadUInt8() == uint8(0) {
  4858. if !yield(fi, nil) {
  4859. return
  4860. }
  4861. } else {
  4862. // --- [begin][read][streaming-map](map[string]*Node) ---
  4863. mmm := buff.ReadInt() // map len
  4864. for range mmm {
  4865. var vvvvvvvvvv string
  4866. var ooo string
  4867. if ctx.IsStringTable() {
  4868. ppp := buff.ReadInt() // read string index
  4869. ooo = ctx.Table.At(ppp)
  4870. } else {
  4871. ooo = buff.ReadString() // read string
  4872. }
  4873. nnn := ooo
  4874. vvvvvvvvvv = nnn
  4875. var zzzzzzzzzz *Node
  4876. if buff.ReadUInt8() == uint8(0) {
  4877. zzzzzzzzzz = nil
  4878. } else {
  4879. // --- [begin][read][struct](Node) ---
  4880. qqq := new(Node)
  4881. buff.ReadInt() // [compatibility, unused]
  4882. errM := qqq.UnmarshalBinaryWithContext(ctx)
  4883. if errM != nil {
  4884. stream.err = errM
  4885. return
  4886. }
  4887. zzzzzzzzzz = qqq
  4888. // --- [end][read][struct](Node) ---
  4889. }
  4890. if !yield(fi, pairV(vvvvvvvvvv, zzzzzzzzzz)) {
  4891. return
  4892. }
  4893. }
  4894. // --- [end][read][streaming-map](map[string]*Node) ---
  4895. }
  4896. } else {
  4897. if !yield(fi, nil) {
  4898. return
  4899. }
  4900. }
  4901. fi = BingenFieldInfo{
  4902. Type: reflect.TypeFor[map[string]*PersistentVolume](),
  4903. Name: "PersistentVolumes",
  4904. }
  4905. // field version check
  4906. if uint8(2) <= version {
  4907. if buff.ReadUInt8() == uint8(0) {
  4908. if !yield(fi, nil) {
  4909. return
  4910. }
  4911. } else {
  4912. // --- [begin][read][streaming-map](map[string]*PersistentVolume) ---
  4913. rrr := buff.ReadInt() // map len
  4914. for range rrr {
  4915. var vvvvvvvvvvv string
  4916. var ttt string
  4917. if ctx.IsStringTable() {
  4918. uuu := buff.ReadInt() // read string index
  4919. ttt = ctx.Table.At(uuu)
  4920. } else {
  4921. ttt = buff.ReadString() // read string
  4922. }
  4923. sss := ttt
  4924. vvvvvvvvvvv = sss
  4925. var zzzzzzzzzzz *PersistentVolume
  4926. if buff.ReadUInt8() == uint8(0) {
  4927. zzzzzzzzzzz = nil
  4928. } else {
  4929. // --- [begin][read][struct](PersistentVolume) ---
  4930. www := new(PersistentVolume)
  4931. buff.ReadInt() // [compatibility, unused]
  4932. errN := www.UnmarshalBinaryWithContext(ctx)
  4933. if errN != nil {
  4934. stream.err = errN
  4935. return
  4936. }
  4937. zzzzzzzzzzz = www
  4938. // --- [end][read][struct](PersistentVolume) ---
  4939. }
  4940. if !yield(fi, pairV(vvvvvvvvvvv, zzzzzzzzzzz)) {
  4941. return
  4942. }
  4943. }
  4944. // --- [end][read][streaming-map](map[string]*PersistentVolume) ---
  4945. }
  4946. } else {
  4947. if !yield(fi, nil) {
  4948. return
  4949. }
  4950. }
  4951. fi = BingenFieldInfo{
  4952. Type: reflect.TypeFor[map[string]*PersistentVolumeClaim](),
  4953. Name: "PersistentVolumeClaims",
  4954. }
  4955. // field version check
  4956. if uint8(2) <= version {
  4957. if buff.ReadUInt8() == uint8(0) {
  4958. if !yield(fi, nil) {
  4959. return
  4960. }
  4961. } else {
  4962. // --- [begin][read][streaming-map](map[string]*PersistentVolumeClaim) ---
  4963. xxx := buff.ReadInt() // map len
  4964. for range xxx {
  4965. var vvvvvvvvvvvv string
  4966. var aaaa string
  4967. if ctx.IsStringTable() {
  4968. bbbb := buff.ReadInt() // read string index
  4969. aaaa = ctx.Table.At(bbbb)
  4970. } else {
  4971. aaaa = buff.ReadString() // read string
  4972. }
  4973. yyy := aaaa
  4974. vvvvvvvvvvvv = yyy
  4975. var zzzzzzzzzzzz *PersistentVolumeClaim
  4976. if buff.ReadUInt8() == uint8(0) {
  4977. zzzzzzzzzzzz = nil
  4978. } else {
  4979. // --- [begin][read][struct](PersistentVolumeClaim) ---
  4980. cccc := new(PersistentVolumeClaim)
  4981. buff.ReadInt() // [compatibility, unused]
  4982. errO := cccc.UnmarshalBinaryWithContext(ctx)
  4983. if errO != nil {
  4984. stream.err = errO
  4985. return
  4986. }
  4987. zzzzzzzzzzzz = cccc
  4988. // --- [end][read][struct](PersistentVolumeClaim) ---
  4989. }
  4990. if !yield(fi, pairV(vvvvvvvvvvvv, zzzzzzzzzzzz)) {
  4991. return
  4992. }
  4993. }
  4994. // --- [end][read][streaming-map](map[string]*PersistentVolumeClaim) ---
  4995. }
  4996. } else {
  4997. if !yield(fi, nil) {
  4998. return
  4999. }
  5000. }
  5001. fi = BingenFieldInfo{
  5002. Type: reflect.TypeFor[map[string]*Pod](),
  5003. Name: "Pods",
  5004. }
  5005. // field version check
  5006. if uint8(2) <= version {
  5007. if buff.ReadUInt8() == uint8(0) {
  5008. if !yield(fi, nil) {
  5009. return
  5010. }
  5011. } else {
  5012. // --- [begin][read][streaming-map](map[string]*Pod) ---
  5013. dddd := buff.ReadInt() // map len
  5014. for range dddd {
  5015. var vvvvvvvvvvvvv string
  5016. var ffff string
  5017. if ctx.IsStringTable() {
  5018. gggg := buff.ReadInt() // read string index
  5019. ffff = ctx.Table.At(gggg)
  5020. } else {
  5021. ffff = buff.ReadString() // read string
  5022. }
  5023. eeee := ffff
  5024. vvvvvvvvvvvvv = eeee
  5025. var zzzzzzzzzzzzz *Pod
  5026. if buff.ReadUInt8() == uint8(0) {
  5027. zzzzzzzzzzzzz = nil
  5028. } else {
  5029. // --- [begin][read][struct](Pod) ---
  5030. hhhh := new(Pod)
  5031. buff.ReadInt() // [compatibility, unused]
  5032. errP := hhhh.UnmarshalBinaryWithContext(ctx)
  5033. if errP != nil {
  5034. stream.err = errP
  5035. return
  5036. }
  5037. zzzzzzzzzzzzz = hhhh
  5038. // --- [end][read][struct](Pod) ---
  5039. }
  5040. if !yield(fi, pairV(vvvvvvvvvvvvv, zzzzzzzzzzzzz)) {
  5041. return
  5042. }
  5043. }
  5044. // --- [end][read][streaming-map](map[string]*Pod) ---
  5045. }
  5046. } else {
  5047. if !yield(fi, nil) {
  5048. return
  5049. }
  5050. }
  5051. fi = BingenFieldInfo{
  5052. Type: reflect.TypeFor[map[string]*Container](),
  5053. Name: "Containers",
  5054. }
  5055. // field version check
  5056. if uint8(2) <= version {
  5057. if buff.ReadUInt8() == uint8(0) {
  5058. if !yield(fi, nil) {
  5059. return
  5060. }
  5061. } else {
  5062. // --- [begin][read][streaming-map](map[string]*Container) ---
  5063. llll := buff.ReadInt() // map len
  5064. for range llll {
  5065. var vvvvvvvvvvvvvv string
  5066. var nnnn string
  5067. if ctx.IsStringTable() {
  5068. oooo := buff.ReadInt() // read string index
  5069. nnnn = ctx.Table.At(oooo)
  5070. } else {
  5071. nnnn = buff.ReadString() // read string
  5072. }
  5073. mmmm := nnnn
  5074. vvvvvvvvvvvvvv = mmmm
  5075. var zzzzzzzzzzzzzz *Container
  5076. if buff.ReadUInt8() == uint8(0) {
  5077. zzzzzzzzzzzzzz = nil
  5078. } else {
  5079. // --- [begin][read][struct](Container) ---
  5080. pppp := new(Container)
  5081. buff.ReadInt() // [compatibility, unused]
  5082. errQ := pppp.UnmarshalBinaryWithContext(ctx)
  5083. if errQ != nil {
  5084. stream.err = errQ
  5085. return
  5086. }
  5087. zzzzzzzzzzzzzz = pppp
  5088. // --- [end][read][struct](Container) ---
  5089. }
  5090. if !yield(fi, pairV(vvvvvvvvvvvvvv, zzzzzzzzzzzzzz)) {
  5091. return
  5092. }
  5093. }
  5094. // --- [end][read][streaming-map](map[string]*Container) ---
  5095. }
  5096. } else {
  5097. if !yield(fi, nil) {
  5098. return
  5099. }
  5100. }
  5101. }
  5102. }
  5103. //--------------------------------------------------------------------------
  5104. // Metadata
  5105. //--------------------------------------------------------------------------
  5106. // MarshalBinary serializes the internal properties of this Metadata instance
  5107. // into a byte array
  5108. func (target *Metadata) MarshalBinary() (data []byte, err error) {
  5109. ctx := NewEncodingContext(nil)
  5110. e := target.MarshalBinaryWithContext(ctx)
  5111. if e != nil {
  5112. return nil, e
  5113. }
  5114. return ctx.ToBytes(), nil
  5115. }
  5116. // MarshalBinary serializes the internal properties of this Metadata instance
  5117. // into an io.Writer.
  5118. func (target *Metadata) MarshalBinaryTo(writer io.Writer) error {
  5119. buff := util.NewBufferFromWriter(writer)
  5120. defer buff.Flush()
  5121. ctx := NewEncodingContextFromBuffer(buff, nil)
  5122. return target.MarshalBinaryWithContext(ctx)
  5123. }
  5124. // MarshalBinaryWithContext serializes the internal properties of this Metadata instance
  5125. // into a byte array leveraging a predefined context.
  5126. func (target *Metadata) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5127. // panics are recovered and propagated as errors
  5128. defer func() {
  5129. if r := recover(); r != nil {
  5130. if e, ok := r.(error); ok {
  5131. err = e
  5132. } else if s, ok := r.(string); ok {
  5133. err = fmt.Errorf("unexpected panic: %s", s)
  5134. } else {
  5135. err = fmt.Errorf("unexpected panic: %+v", r)
  5136. }
  5137. }
  5138. }()
  5139. buff := ctx.Buffer
  5140. buff.WriteUInt8(DefaultCodecVersion) // version
  5141. // --- [begin][write][reference](time.Time) ---
  5142. a, errA := target.CreatedAt.MarshalBinary()
  5143. if errA != nil {
  5144. return errA
  5145. }
  5146. buff.WriteInt(len(a))
  5147. buff.WriteBytes(a)
  5148. // --- [end][write][reference](time.Time) ---
  5149. // --- [begin][write][reference](time.Time) ---
  5150. b, errB := target.CompletedAt.MarshalBinary()
  5151. if errB != nil {
  5152. return errB
  5153. }
  5154. buff.WriteInt(len(b))
  5155. buff.WriteBytes(b)
  5156. // --- [end][write][reference](time.Time) ---
  5157. buff.WriteInt(target.ObjectCount) // write int
  5158. if target.Diagnostics == nil {
  5159. buff.WriteUInt8(uint8(0)) // write nil byte
  5160. } else {
  5161. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5162. // --- [begin][write][slice]([]Diagnostic) ---
  5163. buff.WriteInt(len(target.Diagnostics)) // slice length
  5164. for i := range target.Diagnostics {
  5165. // --- [begin][write][struct](Diagnostic) ---
  5166. buff.WriteInt(0) // [compatibility, unused]
  5167. errC := target.Diagnostics[i].MarshalBinaryWithContext(ctx)
  5168. if errC != nil {
  5169. return errC
  5170. }
  5171. // --- [end][write][struct](Diagnostic) ---
  5172. }
  5173. // --- [end][write][slice]([]Diagnostic) ---
  5174. }
  5175. // --- [begin][write][alias](DiagnosticLevel) ---
  5176. buff.WriteInt(int(target.DiagnosticLevel)) // write int
  5177. // --- [end][write][alias](DiagnosticLevel) ---
  5178. return nil
  5179. }
  5180. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5181. // the Metadata type
  5182. func (target *Metadata) UnmarshalBinary(data []byte) error {
  5183. ctx := NewDecodingContextFromBytes(data)
  5184. defer ctx.Close()
  5185. err := target.UnmarshalBinaryWithContext(ctx)
  5186. if err != nil {
  5187. return err
  5188. }
  5189. return nil
  5190. }
  5191. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  5192. // the Metadata type
  5193. func (target *Metadata) UnmarshalBinaryFromReader(reader io.Reader) error {
  5194. ctx := NewDecodingContextFromReader(reader)
  5195. defer ctx.Close()
  5196. err := target.UnmarshalBinaryWithContext(ctx)
  5197. if err != nil {
  5198. return err
  5199. }
  5200. return nil
  5201. }
  5202. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5203. // the Metadata type
  5204. func (target *Metadata) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5205. // panics are recovered and propagated as errors
  5206. defer func() {
  5207. if r := recover(); r != nil {
  5208. if e, ok := r.(error); ok {
  5209. err = e
  5210. } else if s, ok := r.(string); ok {
  5211. err = fmt.Errorf("unexpected panic: %s", s)
  5212. } else {
  5213. err = fmt.Errorf("unexpected panic: %+v", r)
  5214. }
  5215. }
  5216. }()
  5217. buff := ctx.Buffer
  5218. version := buff.ReadUInt8()
  5219. if version > DefaultCodecVersion {
  5220. return fmt.Errorf("Invalid Version Unmarshalling Metadata. Expected %d or less, got %d", DefaultCodecVersion, version)
  5221. }
  5222. // field version check
  5223. if uint8(1) <= version {
  5224. // --- [begin][read][reference](time.Time) ---
  5225. a := new(time.Time)
  5226. b := buff.ReadInt() // byte array length
  5227. c := buff.ReadBytes(b)
  5228. errA := a.UnmarshalBinary(c)
  5229. if errA != nil {
  5230. return errA
  5231. }
  5232. target.CreatedAt = *a
  5233. // --- [end][read][reference](time.Time) ---
  5234. } else {
  5235. }
  5236. // field version check
  5237. if uint8(1) <= version {
  5238. // --- [begin][read][reference](time.Time) ---
  5239. d := new(time.Time)
  5240. e := buff.ReadInt() // byte array length
  5241. f := buff.ReadBytes(e)
  5242. errB := d.UnmarshalBinary(f)
  5243. if errB != nil {
  5244. return errB
  5245. }
  5246. target.CompletedAt = *d
  5247. // --- [end][read][reference](time.Time) ---
  5248. } else {
  5249. }
  5250. // field version check
  5251. if uint8(1) <= version {
  5252. g := buff.ReadInt() // read int
  5253. target.ObjectCount = g
  5254. } else {
  5255. target.ObjectCount = int(0) // default
  5256. }
  5257. // field version check
  5258. if uint8(1) <= version {
  5259. if buff.ReadUInt8() == uint8(0) {
  5260. target.Diagnostics = nil
  5261. } else {
  5262. // --- [begin][read][slice]([]Diagnostic) ---
  5263. l := buff.ReadInt() // slice len
  5264. h := make([]Diagnostic, l)
  5265. for i := range l {
  5266. // --- [begin][read][struct](Diagnostic) ---
  5267. n := new(Diagnostic)
  5268. buff.ReadInt() // [compatibility, unused]
  5269. errC := n.UnmarshalBinaryWithContext(ctx)
  5270. if errC != nil {
  5271. return errC
  5272. }
  5273. m := *n
  5274. // --- [end][read][struct](Diagnostic) ---
  5275. h[i] = m
  5276. }
  5277. target.Diagnostics = h
  5278. // --- [end][read][slice]([]Diagnostic) ---
  5279. }
  5280. } else {
  5281. target.Diagnostics = nil
  5282. }
  5283. // field version check
  5284. if uint8(1) <= version {
  5285. // --- [begin][read][alias](DiagnosticLevel) ---
  5286. var o int
  5287. p := buff.ReadInt() // read int
  5288. o = p
  5289. target.DiagnosticLevel = DiagnosticLevel(o)
  5290. // --- [end][read][alias](DiagnosticLevel) ---
  5291. } else {
  5292. }
  5293. return nil
  5294. }
  5295. //--------------------------------------------------------------------------
  5296. // Namespace
  5297. //--------------------------------------------------------------------------
  5298. // MarshalBinary serializes the internal properties of this Namespace instance
  5299. // into a byte array
  5300. func (target *Namespace) MarshalBinary() (data []byte, err error) {
  5301. ctx := NewEncodingContext(nil)
  5302. e := target.MarshalBinaryWithContext(ctx)
  5303. if e != nil {
  5304. return nil, e
  5305. }
  5306. return ctx.ToBytes(), nil
  5307. }
  5308. // MarshalBinary serializes the internal properties of this Namespace instance
  5309. // into an io.Writer.
  5310. func (target *Namespace) MarshalBinaryTo(writer io.Writer) error {
  5311. buff := util.NewBufferFromWriter(writer)
  5312. defer buff.Flush()
  5313. ctx := NewEncodingContextFromBuffer(buff, nil)
  5314. return target.MarshalBinaryWithContext(ctx)
  5315. }
  5316. // MarshalBinaryWithContext serializes the internal properties of this Namespace instance
  5317. // into a byte array leveraging a predefined context.
  5318. func (target *Namespace) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5319. // panics are recovered and propagated as errors
  5320. defer func() {
  5321. if r := recover(); r != nil {
  5322. if e, ok := r.(error); ok {
  5323. err = e
  5324. } else if s, ok := r.(string); ok {
  5325. err = fmt.Errorf("unexpected panic: %s", s)
  5326. } else {
  5327. err = fmt.Errorf("unexpected panic: %+v", r)
  5328. }
  5329. }
  5330. }()
  5331. buff := ctx.Buffer
  5332. buff.WriteUInt8(DefaultCodecVersion) // version
  5333. if ctx.IsStringTable() {
  5334. a := ctx.Table.AddOrGet(target.UID)
  5335. buff.WriteInt(a) // write table index
  5336. } else {
  5337. buff.WriteString(target.UID) // write string
  5338. }
  5339. if ctx.IsStringTable() {
  5340. b := ctx.Table.AddOrGet(target.bingenPlaceHolder)
  5341. buff.WriteInt(b) // write table index
  5342. } else {
  5343. buff.WriteString(target.bingenPlaceHolder) // write string
  5344. }
  5345. if ctx.IsStringTable() {
  5346. c := ctx.Table.AddOrGet(target.Name)
  5347. buff.WriteInt(c) // write table index
  5348. } else {
  5349. buff.WriteString(target.Name) // write string
  5350. }
  5351. if target.Labels == nil {
  5352. buff.WriteUInt8(uint8(0)) // write nil byte
  5353. } else {
  5354. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5355. // --- [begin][write][map](map[string]string) ---
  5356. buff.WriteInt(len(target.Labels)) // map length
  5357. for v, z := range target.Labels {
  5358. if ctx.IsStringTable() {
  5359. d := ctx.Table.AddOrGet(v)
  5360. buff.WriteInt(d) // write table index
  5361. } else {
  5362. buff.WriteString(v) // write string
  5363. }
  5364. if ctx.IsStringTable() {
  5365. e := ctx.Table.AddOrGet(z)
  5366. buff.WriteInt(e) // write table index
  5367. } else {
  5368. buff.WriteString(z) // write string
  5369. }
  5370. }
  5371. // --- [end][write][map](map[string]string) ---
  5372. }
  5373. if target.Annotations == nil {
  5374. buff.WriteUInt8(uint8(0)) // write nil byte
  5375. } else {
  5376. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5377. // --- [begin][write][map](map[string]string) ---
  5378. buff.WriteInt(len(target.Annotations)) // map length
  5379. for vv, zz := range target.Annotations {
  5380. if ctx.IsStringTable() {
  5381. f := ctx.Table.AddOrGet(vv)
  5382. buff.WriteInt(f) // write table index
  5383. } else {
  5384. buff.WriteString(vv) // write string
  5385. }
  5386. if ctx.IsStringTable() {
  5387. g := ctx.Table.AddOrGet(zz)
  5388. buff.WriteInt(g) // write table index
  5389. } else {
  5390. buff.WriteString(zz) // write string
  5391. }
  5392. }
  5393. // --- [end][write][map](map[string]string) ---
  5394. }
  5395. // --- [begin][write][reference](time.Time) ---
  5396. h, errA := target.Start.MarshalBinary()
  5397. if errA != nil {
  5398. return errA
  5399. }
  5400. buff.WriteInt(len(h))
  5401. buff.WriteBytes(h)
  5402. // --- [end][write][reference](time.Time) ---
  5403. // --- [begin][write][reference](time.Time) ---
  5404. l, errB := target.End.MarshalBinary()
  5405. if errB != nil {
  5406. return errB
  5407. }
  5408. buff.WriteInt(len(l))
  5409. buff.WriteBytes(l)
  5410. // --- [end][write][reference](time.Time) ---
  5411. return nil
  5412. }
  5413. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5414. // the Namespace type
  5415. func (target *Namespace) UnmarshalBinary(data []byte) error {
  5416. ctx := NewDecodingContextFromBytes(data)
  5417. defer ctx.Close()
  5418. err := target.UnmarshalBinaryWithContext(ctx)
  5419. if err != nil {
  5420. return err
  5421. }
  5422. return nil
  5423. }
  5424. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  5425. // the Namespace type
  5426. func (target *Namespace) UnmarshalBinaryFromReader(reader io.Reader) error {
  5427. ctx := NewDecodingContextFromReader(reader)
  5428. defer ctx.Close()
  5429. err := target.UnmarshalBinaryWithContext(ctx)
  5430. if err != nil {
  5431. return err
  5432. }
  5433. return nil
  5434. }
  5435. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5436. // the Namespace type
  5437. func (target *Namespace) UnmarshalBinaryWithContext(ctx *DecodingContext) (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. version := buff.ReadUInt8()
  5452. if version > DefaultCodecVersion {
  5453. return fmt.Errorf("Invalid Version Unmarshalling Namespace. Expected %d or less, got %d", DefaultCodecVersion, version)
  5454. }
  5455. // field version check
  5456. if uint8(1) <= version {
  5457. var b string
  5458. if ctx.IsStringTable() {
  5459. c := buff.ReadInt() // read string index
  5460. b = ctx.Table.At(c)
  5461. } else {
  5462. b = buff.ReadString() // read string
  5463. }
  5464. a := b
  5465. target.UID = a
  5466. } else {
  5467. target.UID = "" // default
  5468. }
  5469. // field version check
  5470. if uint8(1) <= version {
  5471. var e string
  5472. if ctx.IsStringTable() {
  5473. f := buff.ReadInt() // read string index
  5474. e = ctx.Table.At(f)
  5475. } else {
  5476. e = buff.ReadString() // read string
  5477. }
  5478. d := e
  5479. target.bingenPlaceHolder = d
  5480. } else {
  5481. target.bingenPlaceHolder = "" // default
  5482. }
  5483. // field version check
  5484. if uint8(1) <= version {
  5485. var h string
  5486. if ctx.IsStringTable() {
  5487. l := buff.ReadInt() // read string index
  5488. h = ctx.Table.At(l)
  5489. } else {
  5490. h = buff.ReadString() // read string
  5491. }
  5492. g := h
  5493. target.Name = g
  5494. } else {
  5495. target.Name = "" // default
  5496. }
  5497. // field version check
  5498. if uint8(1) <= version {
  5499. if buff.ReadUInt8() == uint8(0) {
  5500. target.Labels = nil
  5501. } else {
  5502. // --- [begin][read][map](map[string]string) ---
  5503. n := buff.ReadInt() // map len
  5504. m := make(map[string]string, n)
  5505. for range n {
  5506. var v string
  5507. var p string
  5508. if ctx.IsStringTable() {
  5509. q := buff.ReadInt() // read string index
  5510. p = ctx.Table.At(q)
  5511. } else {
  5512. p = buff.ReadString() // read string
  5513. }
  5514. o := p
  5515. v = o
  5516. var z string
  5517. var s string
  5518. if ctx.IsStringTable() {
  5519. t := buff.ReadInt() // read string index
  5520. s = ctx.Table.At(t)
  5521. } else {
  5522. s = buff.ReadString() // read string
  5523. }
  5524. r := s
  5525. z = r
  5526. m[v] = z
  5527. }
  5528. target.Labels = m
  5529. // --- [end][read][map](map[string]string) ---
  5530. }
  5531. } else {
  5532. target.Labels = nil
  5533. }
  5534. // field version check
  5535. if uint8(1) <= version {
  5536. if buff.ReadUInt8() == uint8(0) {
  5537. target.Annotations = nil
  5538. } else {
  5539. // --- [begin][read][map](map[string]string) ---
  5540. w := buff.ReadInt() // map len
  5541. u := make(map[string]string, w)
  5542. for range w {
  5543. var vv string
  5544. var y string
  5545. if ctx.IsStringTable() {
  5546. aa := buff.ReadInt() // read string index
  5547. y = ctx.Table.At(aa)
  5548. } else {
  5549. y = buff.ReadString() // read string
  5550. }
  5551. x := y
  5552. vv = x
  5553. var zz string
  5554. var cc string
  5555. if ctx.IsStringTable() {
  5556. dd := buff.ReadInt() // read string index
  5557. cc = ctx.Table.At(dd)
  5558. } else {
  5559. cc = buff.ReadString() // read string
  5560. }
  5561. bb := cc
  5562. zz = bb
  5563. u[vv] = zz
  5564. }
  5565. target.Annotations = u
  5566. // --- [end][read][map](map[string]string) ---
  5567. }
  5568. } else {
  5569. target.Annotations = nil
  5570. }
  5571. // field version check
  5572. if uint8(1) <= version {
  5573. // --- [begin][read][reference](time.Time) ---
  5574. ee := new(time.Time)
  5575. ff := buff.ReadInt() // byte array length
  5576. gg := buff.ReadBytes(ff)
  5577. errA := ee.UnmarshalBinary(gg)
  5578. if errA != nil {
  5579. return errA
  5580. }
  5581. target.Start = *ee
  5582. // --- [end][read][reference](time.Time) ---
  5583. } else {
  5584. }
  5585. // field version check
  5586. if uint8(1) <= version {
  5587. // --- [begin][read][reference](time.Time) ---
  5588. hh := new(time.Time)
  5589. ll := buff.ReadInt() // byte array length
  5590. mm := buff.ReadBytes(ll)
  5591. errB := hh.UnmarshalBinary(mm)
  5592. if errB != nil {
  5593. return errB
  5594. }
  5595. target.End = *hh
  5596. // --- [end][read][reference](time.Time) ---
  5597. } else {
  5598. }
  5599. return nil
  5600. }
  5601. //--------------------------------------------------------------------------
  5602. // NetworkTrafficDetail
  5603. //--------------------------------------------------------------------------
  5604. // MarshalBinary serializes the internal properties of this NetworkTrafficDetail instance
  5605. // into a byte array
  5606. func (target *NetworkTrafficDetail) MarshalBinary() (data []byte, err error) {
  5607. ctx := NewEncodingContext(nil)
  5608. e := target.MarshalBinaryWithContext(ctx)
  5609. if e != nil {
  5610. return nil, e
  5611. }
  5612. return ctx.ToBytes(), nil
  5613. }
  5614. // MarshalBinary serializes the internal properties of this NetworkTrafficDetail instance
  5615. // into an io.Writer.
  5616. func (target *NetworkTrafficDetail) MarshalBinaryTo(writer io.Writer) error {
  5617. buff := util.NewBufferFromWriter(writer)
  5618. defer buff.Flush()
  5619. ctx := NewEncodingContextFromBuffer(buff, nil)
  5620. return target.MarshalBinaryWithContext(ctx)
  5621. }
  5622. // MarshalBinaryWithContext serializes the internal properties of this NetworkTrafficDetail instance
  5623. // into a byte array leveraging a predefined context.
  5624. func (target *NetworkTrafficDetail) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5625. // panics are recovered and propagated as errors
  5626. defer func() {
  5627. if r := recover(); r != nil {
  5628. if e, ok := r.(error); ok {
  5629. err = e
  5630. } else if s, ok := r.(string); ok {
  5631. err = fmt.Errorf("unexpected panic: %s", s)
  5632. } else {
  5633. err = fmt.Errorf("unexpected panic: %+v", r)
  5634. }
  5635. }
  5636. }()
  5637. buff := ctx.Buffer
  5638. buff.WriteUInt8(DefaultCodecVersion) // version
  5639. if ctx.IsStringTable() {
  5640. a := ctx.Table.AddOrGet(target.PodUID)
  5641. buff.WriteInt(a) // write table index
  5642. } else {
  5643. buff.WriteString(target.PodUID) // write string
  5644. }
  5645. if ctx.IsStringTable() {
  5646. b := ctx.Table.AddOrGet(target.Endpoint)
  5647. buff.WriteInt(b) // write table index
  5648. } else {
  5649. buff.WriteString(target.Endpoint) // write string
  5650. }
  5651. // --- [begin][write][alias](TrafficDirection) ---
  5652. if ctx.IsStringTable() {
  5653. c := ctx.Table.AddOrGet(string(target.TrafficDirection))
  5654. buff.WriteInt(c) // write table index
  5655. } else {
  5656. buff.WriteString(string(target.TrafficDirection)) // write string
  5657. }
  5658. // --- [end][write][alias](TrafficDirection) ---
  5659. // --- [begin][write][alias](TrafficType) ---
  5660. if ctx.IsStringTable() {
  5661. d := ctx.Table.AddOrGet(string(target.TrafficType))
  5662. buff.WriteInt(d) // write table index
  5663. } else {
  5664. buff.WriteString(string(target.TrafficType)) // write string
  5665. }
  5666. // --- [end][write][alias](TrafficType) ---
  5667. buff.WriteBool(target.IsNatGateway) // write bool
  5668. buff.WriteFloat64(target.Bytes) // write float64
  5669. return nil
  5670. }
  5671. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5672. // the NetworkTrafficDetail type
  5673. func (target *NetworkTrafficDetail) UnmarshalBinary(data []byte) error {
  5674. ctx := NewDecodingContextFromBytes(data)
  5675. defer ctx.Close()
  5676. err := target.UnmarshalBinaryWithContext(ctx)
  5677. if err != nil {
  5678. return err
  5679. }
  5680. return nil
  5681. }
  5682. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  5683. // the NetworkTrafficDetail type
  5684. func (target *NetworkTrafficDetail) UnmarshalBinaryFromReader(reader io.Reader) error {
  5685. ctx := NewDecodingContextFromReader(reader)
  5686. defer ctx.Close()
  5687. err := target.UnmarshalBinaryWithContext(ctx)
  5688. if err != nil {
  5689. return err
  5690. }
  5691. return nil
  5692. }
  5693. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5694. // the NetworkTrafficDetail type
  5695. func (target *NetworkTrafficDetail) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5696. // panics are recovered and propagated as errors
  5697. defer func() {
  5698. if r := recover(); r != nil {
  5699. if e, ok := r.(error); ok {
  5700. err = e
  5701. } else if s, ok := r.(string); ok {
  5702. err = fmt.Errorf("unexpected panic: %s", s)
  5703. } else {
  5704. err = fmt.Errorf("unexpected panic: %+v", r)
  5705. }
  5706. }
  5707. }()
  5708. buff := ctx.Buffer
  5709. version := buff.ReadUInt8()
  5710. if version > DefaultCodecVersion {
  5711. return fmt.Errorf("Invalid Version Unmarshalling NetworkTrafficDetail. Expected %d or less, got %d", DefaultCodecVersion, version)
  5712. }
  5713. var b string
  5714. if ctx.IsStringTable() {
  5715. c := buff.ReadInt() // read string index
  5716. b = ctx.Table.At(c)
  5717. } else {
  5718. b = buff.ReadString() // read string
  5719. }
  5720. a := b
  5721. target.PodUID = a
  5722. var e string
  5723. if ctx.IsStringTable() {
  5724. f := buff.ReadInt() // read string index
  5725. e = ctx.Table.At(f)
  5726. } else {
  5727. e = buff.ReadString() // read string
  5728. }
  5729. d := e
  5730. target.Endpoint = d
  5731. // --- [begin][read][alias](TrafficDirection) ---
  5732. var g string
  5733. var l string
  5734. if ctx.IsStringTable() {
  5735. m := buff.ReadInt() // read string index
  5736. l = ctx.Table.At(m)
  5737. } else {
  5738. l = buff.ReadString() // read string
  5739. }
  5740. h := l
  5741. g = h
  5742. target.TrafficDirection = TrafficDirection(g)
  5743. // --- [end][read][alias](TrafficDirection) ---
  5744. // --- [begin][read][alias](TrafficType) ---
  5745. var n string
  5746. var p string
  5747. if ctx.IsStringTable() {
  5748. q := buff.ReadInt() // read string index
  5749. p = ctx.Table.At(q)
  5750. } else {
  5751. p = buff.ReadString() // read string
  5752. }
  5753. o := p
  5754. n = o
  5755. target.TrafficType = TrafficType(n)
  5756. // --- [end][read][alias](TrafficType) ---
  5757. r := buff.ReadBool() // read bool
  5758. target.IsNatGateway = r
  5759. s := buff.ReadFloat64() // read float64
  5760. target.Bytes = s
  5761. return nil
  5762. }
  5763. //--------------------------------------------------------------------------
  5764. // Node
  5765. //--------------------------------------------------------------------------
  5766. // MarshalBinary serializes the internal properties of this Node instance
  5767. // into a byte array
  5768. func (target *Node) MarshalBinary() (data []byte, err error) {
  5769. ctx := NewEncodingContext(nil)
  5770. e := target.MarshalBinaryWithContext(ctx)
  5771. if e != nil {
  5772. return nil, e
  5773. }
  5774. return ctx.ToBytes(), nil
  5775. }
  5776. // MarshalBinary serializes the internal properties of this Node instance
  5777. // into an io.Writer.
  5778. func (target *Node) MarshalBinaryTo(writer io.Writer) error {
  5779. buff := util.NewBufferFromWriter(writer)
  5780. defer buff.Flush()
  5781. ctx := NewEncodingContextFromBuffer(buff, nil)
  5782. return target.MarshalBinaryWithContext(ctx)
  5783. }
  5784. // MarshalBinaryWithContext serializes the internal properties of this Node instance
  5785. // into a byte array leveraging a predefined context.
  5786. func (target *Node) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5787. // panics are recovered and propagated as errors
  5788. defer func() {
  5789. if r := recover(); r != nil {
  5790. if e, ok := r.(error); ok {
  5791. err = e
  5792. } else if s, ok := r.(string); ok {
  5793. err = fmt.Errorf("unexpected panic: %s", s)
  5794. } else {
  5795. err = fmt.Errorf("unexpected panic: %+v", r)
  5796. }
  5797. }
  5798. }()
  5799. buff := ctx.Buffer
  5800. buff.WriteUInt8(DefaultCodecVersion) // version
  5801. if ctx.IsStringTable() {
  5802. a := ctx.Table.AddOrGet(target.UID)
  5803. buff.WriteInt(a) // write table index
  5804. } else {
  5805. buff.WriteString(target.UID) // write string
  5806. }
  5807. if ctx.IsStringTable() {
  5808. b := ctx.Table.AddOrGet(target.ProviderID)
  5809. buff.WriteInt(b) // write table index
  5810. } else {
  5811. buff.WriteString(target.ProviderID) // write string
  5812. }
  5813. if ctx.IsStringTable() {
  5814. c := ctx.Table.AddOrGet(target.Name)
  5815. buff.WriteInt(c) // write table index
  5816. } else {
  5817. buff.WriteString(target.Name) // write string
  5818. }
  5819. if target.Labels == nil {
  5820. buff.WriteUInt8(uint8(0)) // write nil byte
  5821. } else {
  5822. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5823. // --- [begin][write][map](map[string]string) ---
  5824. buff.WriteInt(len(target.Labels)) // map length
  5825. for v, z := range target.Labels {
  5826. if ctx.IsStringTable() {
  5827. d := ctx.Table.AddOrGet(v)
  5828. buff.WriteInt(d) // write table index
  5829. } else {
  5830. buff.WriteString(v) // write string
  5831. }
  5832. if ctx.IsStringTable() {
  5833. e := ctx.Table.AddOrGet(z)
  5834. buff.WriteInt(e) // write table index
  5835. } else {
  5836. buff.WriteString(z) // write string
  5837. }
  5838. }
  5839. // --- [end][write][map](map[string]string) ---
  5840. }
  5841. // --- [begin][write][alias](ResourceQuantities) ---
  5842. if map[Resource]ResourceQuantity(target.ResourceCapacities) == nil {
  5843. buff.WriteUInt8(uint8(0)) // write nil byte
  5844. } else {
  5845. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5846. // --- [begin][write][map](map[Resource]ResourceQuantity) ---
  5847. buff.WriteInt(len(map[Resource]ResourceQuantity(target.ResourceCapacities))) // map length
  5848. for vv, zz := range map[Resource]ResourceQuantity(target.ResourceCapacities) {
  5849. // --- [begin][write][alias](Resource) ---
  5850. if ctx.IsStringTable() {
  5851. f := ctx.Table.AddOrGet(string(vv))
  5852. buff.WriteInt(f) // write table index
  5853. } else {
  5854. buff.WriteString(string(vv)) // write string
  5855. }
  5856. // --- [end][write][alias](Resource) ---
  5857. // --- [begin][write][struct](ResourceQuantity) ---
  5858. buff.WriteInt(0) // [compatibility, unused]
  5859. errA := zz.MarshalBinaryWithContext(ctx)
  5860. if errA != nil {
  5861. return errA
  5862. }
  5863. // --- [end][write][struct](ResourceQuantity) ---
  5864. }
  5865. // --- [end][write][map](map[Resource]ResourceQuantity) ---
  5866. }
  5867. // --- [end][write][alias](ResourceQuantities) ---
  5868. // --- [begin][write][alias](ResourceQuantities) ---
  5869. if map[Resource]ResourceQuantity(target.ResourcesAllocatable) == nil {
  5870. buff.WriteUInt8(uint8(0)) // write nil byte
  5871. } else {
  5872. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5873. // --- [begin][write][map](map[Resource]ResourceQuantity) ---
  5874. buff.WriteInt(len(map[Resource]ResourceQuantity(target.ResourcesAllocatable))) // map length
  5875. for vvv, zzz := range map[Resource]ResourceQuantity(target.ResourcesAllocatable) {
  5876. // --- [begin][write][alias](Resource) ---
  5877. if ctx.IsStringTable() {
  5878. g := ctx.Table.AddOrGet(string(vvv))
  5879. buff.WriteInt(g) // write table index
  5880. } else {
  5881. buff.WriteString(string(vvv)) // write string
  5882. }
  5883. // --- [end][write][alias](Resource) ---
  5884. // --- [begin][write][struct](ResourceQuantity) ---
  5885. buff.WriteInt(0) // [compatibility, unused]
  5886. errB := zzz.MarshalBinaryWithContext(ctx)
  5887. if errB != nil {
  5888. return errB
  5889. }
  5890. // --- [end][write][struct](ResourceQuantity) ---
  5891. }
  5892. // --- [end][write][map](map[Resource]ResourceQuantity) ---
  5893. }
  5894. // --- [end][write][alias](ResourceQuantities) ---
  5895. // --- [begin][write][struct](FileSystem) ---
  5896. buff.WriteInt(0) // [compatibility, unused]
  5897. errC := target.FileSystem.MarshalBinaryWithContext(ctx)
  5898. if errC != nil {
  5899. return errC
  5900. }
  5901. // --- [end][write][struct](FileSystem) ---
  5902. // --- [begin][write][reference](time.Time) ---
  5903. h, errD := target.Start.MarshalBinary()
  5904. if errD != nil {
  5905. return errD
  5906. }
  5907. buff.WriteInt(len(h))
  5908. buff.WriteBytes(h)
  5909. // --- [end][write][reference](time.Time) ---
  5910. // --- [begin][write][reference](time.Time) ---
  5911. l, errE := target.End.MarshalBinary()
  5912. if errE != nil {
  5913. return errE
  5914. }
  5915. buff.WriteInt(len(l))
  5916. buff.WriteBytes(l)
  5917. // --- [end][write][reference](time.Time) ---
  5918. return nil
  5919. }
  5920. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5921. // the Node type
  5922. func (target *Node) UnmarshalBinary(data []byte) error {
  5923. ctx := NewDecodingContextFromBytes(data)
  5924. defer ctx.Close()
  5925. err := target.UnmarshalBinaryWithContext(ctx)
  5926. if err != nil {
  5927. return err
  5928. }
  5929. return nil
  5930. }
  5931. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  5932. // the Node type
  5933. func (target *Node) UnmarshalBinaryFromReader(reader io.Reader) error {
  5934. ctx := NewDecodingContextFromReader(reader)
  5935. defer ctx.Close()
  5936. err := target.UnmarshalBinaryWithContext(ctx)
  5937. if err != nil {
  5938. return err
  5939. }
  5940. return nil
  5941. }
  5942. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5943. // the Node type
  5944. func (target *Node) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5945. // panics are recovered and propagated as errors
  5946. defer func() {
  5947. if r := recover(); r != nil {
  5948. if e, ok := r.(error); ok {
  5949. err = e
  5950. } else if s, ok := r.(string); ok {
  5951. err = fmt.Errorf("unexpected panic: %s", s)
  5952. } else {
  5953. err = fmt.Errorf("unexpected panic: %+v", r)
  5954. }
  5955. }
  5956. }()
  5957. buff := ctx.Buffer
  5958. version := buff.ReadUInt8()
  5959. if version > DefaultCodecVersion {
  5960. return fmt.Errorf("Invalid Version Unmarshalling Node. Expected %d or less, got %d", DefaultCodecVersion, version)
  5961. }
  5962. var b string
  5963. if ctx.IsStringTable() {
  5964. c := buff.ReadInt() // read string index
  5965. b = ctx.Table.At(c)
  5966. } else {
  5967. b = buff.ReadString() // read string
  5968. }
  5969. a := b
  5970. target.UID = a
  5971. var e string
  5972. if ctx.IsStringTable() {
  5973. f := buff.ReadInt() // read string index
  5974. e = ctx.Table.At(f)
  5975. } else {
  5976. e = buff.ReadString() // read string
  5977. }
  5978. d := e
  5979. target.ProviderID = d
  5980. var h string
  5981. if ctx.IsStringTable() {
  5982. l := buff.ReadInt() // read string index
  5983. h = ctx.Table.At(l)
  5984. } else {
  5985. h = buff.ReadString() // read string
  5986. }
  5987. g := h
  5988. target.Name = g
  5989. if buff.ReadUInt8() == uint8(0) {
  5990. target.Labels = nil
  5991. } else {
  5992. // --- [begin][read][map](map[string]string) ---
  5993. n := buff.ReadInt() // map len
  5994. m := make(map[string]string, n)
  5995. for range n {
  5996. var v string
  5997. var p string
  5998. if ctx.IsStringTable() {
  5999. q := buff.ReadInt() // read string index
  6000. p = ctx.Table.At(q)
  6001. } else {
  6002. p = buff.ReadString() // read string
  6003. }
  6004. o := p
  6005. v = o
  6006. var z string
  6007. var s string
  6008. if ctx.IsStringTable() {
  6009. t := buff.ReadInt() // read string index
  6010. s = ctx.Table.At(t)
  6011. } else {
  6012. s = buff.ReadString() // read string
  6013. }
  6014. r := s
  6015. z = r
  6016. m[v] = z
  6017. }
  6018. target.Labels = m
  6019. // --- [end][read][map](map[string]string) ---
  6020. }
  6021. // --- [begin][read][alias](ResourceQuantities) ---
  6022. var u map[Resource]ResourceQuantity
  6023. if buff.ReadUInt8() == uint8(0) {
  6024. u = nil
  6025. } else {
  6026. // --- [begin][read][map](map[Resource]ResourceQuantity) ---
  6027. x := buff.ReadInt() // map len
  6028. w := make(map[Resource]ResourceQuantity, x)
  6029. for range x {
  6030. // --- [begin][read][alias](Resource) ---
  6031. var y string
  6032. var bb string
  6033. if ctx.IsStringTable() {
  6034. cc := buff.ReadInt() // read string index
  6035. bb = ctx.Table.At(cc)
  6036. } else {
  6037. bb = buff.ReadString() // read string
  6038. }
  6039. aa := bb
  6040. y = aa
  6041. vv := Resource(y)
  6042. // --- [end][read][alias](Resource) ---
  6043. // --- [begin][read][struct](ResourceQuantity) ---
  6044. dd := new(ResourceQuantity)
  6045. buff.ReadInt() // [compatibility, unused]
  6046. errA := dd.UnmarshalBinaryWithContext(ctx)
  6047. if errA != nil {
  6048. return errA
  6049. }
  6050. zz := *dd
  6051. // --- [end][read][struct](ResourceQuantity) ---
  6052. w[vv] = zz
  6053. }
  6054. u = w
  6055. // --- [end][read][map](map[Resource]ResourceQuantity) ---
  6056. }
  6057. target.ResourceCapacities = ResourceQuantities(u)
  6058. // --- [end][read][alias](ResourceQuantities) ---
  6059. // --- [begin][read][alias](ResourceQuantities) ---
  6060. var ee map[Resource]ResourceQuantity
  6061. if buff.ReadUInt8() == uint8(0) {
  6062. ee = nil
  6063. } else {
  6064. // --- [begin][read][map](map[Resource]ResourceQuantity) ---
  6065. gg := buff.ReadInt() // map len
  6066. ff := make(map[Resource]ResourceQuantity, gg)
  6067. for range gg {
  6068. // --- [begin][read][alias](Resource) ---
  6069. var hh string
  6070. var mm string
  6071. if ctx.IsStringTable() {
  6072. nn := buff.ReadInt() // read string index
  6073. mm = ctx.Table.At(nn)
  6074. } else {
  6075. mm = buff.ReadString() // read string
  6076. }
  6077. ll := mm
  6078. hh = ll
  6079. vvv := Resource(hh)
  6080. // --- [end][read][alias](Resource) ---
  6081. // --- [begin][read][struct](ResourceQuantity) ---
  6082. oo := new(ResourceQuantity)
  6083. buff.ReadInt() // [compatibility, unused]
  6084. errB := oo.UnmarshalBinaryWithContext(ctx)
  6085. if errB != nil {
  6086. return errB
  6087. }
  6088. zzz := *oo
  6089. // --- [end][read][struct](ResourceQuantity) ---
  6090. ff[vvv] = zzz
  6091. }
  6092. ee = ff
  6093. // --- [end][read][map](map[Resource]ResourceQuantity) ---
  6094. }
  6095. target.ResourcesAllocatable = ResourceQuantities(ee)
  6096. // --- [end][read][alias](ResourceQuantities) ---
  6097. // --- [begin][read][struct](FileSystem) ---
  6098. pp := new(FileSystem)
  6099. buff.ReadInt() // [compatibility, unused]
  6100. errC := pp.UnmarshalBinaryWithContext(ctx)
  6101. if errC != nil {
  6102. return errC
  6103. }
  6104. target.FileSystem = *pp
  6105. // --- [end][read][struct](FileSystem) ---
  6106. // --- [begin][read][reference](time.Time) ---
  6107. qq := new(time.Time)
  6108. rr := buff.ReadInt() // byte array length
  6109. ss := buff.ReadBytes(rr)
  6110. errD := qq.UnmarshalBinary(ss)
  6111. if errD != nil {
  6112. return errD
  6113. }
  6114. target.Start = *qq
  6115. // --- [end][read][reference](time.Time) ---
  6116. // --- [begin][read][reference](time.Time) ---
  6117. tt := new(time.Time)
  6118. uu := buff.ReadInt() // byte array length
  6119. ww := buff.ReadBytes(uu)
  6120. errE := tt.UnmarshalBinary(ww)
  6121. if errE != nil {
  6122. return errE
  6123. }
  6124. target.End = *tt
  6125. // --- [end][read][reference](time.Time) ---
  6126. return nil
  6127. }
  6128. //--------------------------------------------------------------------------
  6129. // Owner
  6130. //--------------------------------------------------------------------------
  6131. // MarshalBinary serializes the internal properties of this Owner instance
  6132. // into a byte array
  6133. func (target *Owner) MarshalBinary() (data []byte, err error) {
  6134. ctx := NewEncodingContext(nil)
  6135. e := target.MarshalBinaryWithContext(ctx)
  6136. if e != nil {
  6137. return nil, e
  6138. }
  6139. return ctx.ToBytes(), nil
  6140. }
  6141. // MarshalBinary serializes the internal properties of this Owner instance
  6142. // into an io.Writer.
  6143. func (target *Owner) MarshalBinaryTo(writer io.Writer) error {
  6144. buff := util.NewBufferFromWriter(writer)
  6145. defer buff.Flush()
  6146. ctx := NewEncodingContextFromBuffer(buff, nil)
  6147. return target.MarshalBinaryWithContext(ctx)
  6148. }
  6149. // MarshalBinaryWithContext serializes the internal properties of this Owner instance
  6150. // into a byte array leveraging a predefined context.
  6151. func (target *Owner) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6152. // panics are recovered and propagated as errors
  6153. defer func() {
  6154. if r := recover(); r != nil {
  6155. if e, ok := r.(error); ok {
  6156. err = e
  6157. } else if s, ok := r.(string); ok {
  6158. err = fmt.Errorf("unexpected panic: %s", s)
  6159. } else {
  6160. err = fmt.Errorf("unexpected panic: %+v", r)
  6161. }
  6162. }
  6163. }()
  6164. buff := ctx.Buffer
  6165. buff.WriteUInt8(DefaultCodecVersion) // version
  6166. if ctx.IsStringTable() {
  6167. a := ctx.Table.AddOrGet(target.UID)
  6168. buff.WriteInt(a) // write table index
  6169. } else {
  6170. buff.WriteString(target.UID) // write string
  6171. }
  6172. buff.WriteBool(target.Controller) // write bool
  6173. // --- [begin][write][alias](OwnerKind) ---
  6174. if ctx.IsStringTable() {
  6175. b := ctx.Table.AddOrGet(string(target.Kind))
  6176. buff.WriteInt(b) // write table index
  6177. } else {
  6178. buff.WriteString(string(target.Kind)) // write string
  6179. }
  6180. // --- [end][write][alias](OwnerKind) ---
  6181. return nil
  6182. }
  6183. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6184. // the Owner type
  6185. func (target *Owner) UnmarshalBinary(data []byte) error {
  6186. ctx := NewDecodingContextFromBytes(data)
  6187. defer ctx.Close()
  6188. err := target.UnmarshalBinaryWithContext(ctx)
  6189. if err != nil {
  6190. return err
  6191. }
  6192. return nil
  6193. }
  6194. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  6195. // the Owner type
  6196. func (target *Owner) UnmarshalBinaryFromReader(reader io.Reader) error {
  6197. ctx := NewDecodingContextFromReader(reader)
  6198. defer ctx.Close()
  6199. err := target.UnmarshalBinaryWithContext(ctx)
  6200. if err != nil {
  6201. return err
  6202. }
  6203. return nil
  6204. }
  6205. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6206. // the Owner type
  6207. func (target *Owner) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6208. // panics are recovered and propagated as errors
  6209. defer func() {
  6210. if r := recover(); r != nil {
  6211. if e, ok := r.(error); ok {
  6212. err = e
  6213. } else if s, ok := r.(string); ok {
  6214. err = fmt.Errorf("unexpected panic: %s", s)
  6215. } else {
  6216. err = fmt.Errorf("unexpected panic: %+v", r)
  6217. }
  6218. }
  6219. }()
  6220. buff := ctx.Buffer
  6221. version := buff.ReadUInt8()
  6222. if version > DefaultCodecVersion {
  6223. return fmt.Errorf("Invalid Version Unmarshalling Owner. Expected %d or less, got %d", DefaultCodecVersion, version)
  6224. }
  6225. var b string
  6226. if ctx.IsStringTable() {
  6227. c := buff.ReadInt() // read string index
  6228. b = ctx.Table.At(c)
  6229. } else {
  6230. b = buff.ReadString() // read string
  6231. }
  6232. a := b
  6233. target.UID = a
  6234. d := buff.ReadBool() // read bool
  6235. target.Controller = d
  6236. // --- [begin][read][alias](OwnerKind) ---
  6237. var e string
  6238. var g string
  6239. if ctx.IsStringTable() {
  6240. h := buff.ReadInt() // read string index
  6241. g = ctx.Table.At(h)
  6242. } else {
  6243. g = buff.ReadString() // read string
  6244. }
  6245. f := g
  6246. e = f
  6247. target.Kind = OwnerKind(e)
  6248. // --- [end][read][alias](OwnerKind) ---
  6249. return nil
  6250. }
  6251. //--------------------------------------------------------------------------
  6252. // PersistentVolume
  6253. //--------------------------------------------------------------------------
  6254. // MarshalBinary serializes the internal properties of this PersistentVolume instance
  6255. // into a byte array
  6256. func (target *PersistentVolume) MarshalBinary() (data []byte, err error) {
  6257. ctx := NewEncodingContext(nil)
  6258. e := target.MarshalBinaryWithContext(ctx)
  6259. if e != nil {
  6260. return nil, e
  6261. }
  6262. return ctx.ToBytes(), nil
  6263. }
  6264. // MarshalBinary serializes the internal properties of this PersistentVolume instance
  6265. // into an io.Writer.
  6266. func (target *PersistentVolume) MarshalBinaryTo(writer io.Writer) error {
  6267. buff := util.NewBufferFromWriter(writer)
  6268. defer buff.Flush()
  6269. ctx := NewEncodingContextFromBuffer(buff, nil)
  6270. return target.MarshalBinaryWithContext(ctx)
  6271. }
  6272. // MarshalBinaryWithContext serializes the internal properties of this PersistentVolume instance
  6273. // into a byte array leveraging a predefined context.
  6274. func (target *PersistentVolume) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6275. // panics are recovered and propagated as errors
  6276. defer func() {
  6277. if r := recover(); r != nil {
  6278. if e, ok := r.(error); ok {
  6279. err = e
  6280. } else if s, ok := r.(string); ok {
  6281. err = fmt.Errorf("unexpected panic: %s", s)
  6282. } else {
  6283. err = fmt.Errorf("unexpected panic: %+v", r)
  6284. }
  6285. }
  6286. }()
  6287. buff := ctx.Buffer
  6288. buff.WriteUInt8(DefaultCodecVersion) // version
  6289. if ctx.IsStringTable() {
  6290. a := ctx.Table.AddOrGet(target.UID)
  6291. buff.WriteInt(a) // write table index
  6292. } else {
  6293. buff.WriteString(target.UID) // write string
  6294. }
  6295. if ctx.IsStringTable() {
  6296. b := ctx.Table.AddOrGet(target.Name)
  6297. buff.WriteInt(b) // write table index
  6298. } else {
  6299. buff.WriteString(target.Name) // write string
  6300. }
  6301. if ctx.IsStringTable() {
  6302. c := ctx.Table.AddOrGet(target.StorageClass)
  6303. buff.WriteInt(c) // write table index
  6304. } else {
  6305. buff.WriteString(target.StorageClass) // write string
  6306. }
  6307. if ctx.IsStringTable() {
  6308. d := ctx.Table.AddOrGet(target.CSIVolumeHandle)
  6309. buff.WriteInt(d) // write table index
  6310. } else {
  6311. buff.WriteString(target.CSIVolumeHandle) // write string
  6312. }
  6313. buff.WriteFloat64(target.SizeBytes) // write float64
  6314. // --- [begin][write][reference](time.Time) ---
  6315. e, errA := target.Start.MarshalBinary()
  6316. if errA != nil {
  6317. return errA
  6318. }
  6319. buff.WriteInt(len(e))
  6320. buff.WriteBytes(e)
  6321. // --- [end][write][reference](time.Time) ---
  6322. // --- [begin][write][reference](time.Time) ---
  6323. f, errB := target.End.MarshalBinary()
  6324. if errB != nil {
  6325. return errB
  6326. }
  6327. buff.WriteInt(len(f))
  6328. buff.WriteBytes(f)
  6329. // --- [end][write][reference](time.Time) ---
  6330. return nil
  6331. }
  6332. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6333. // the PersistentVolume type
  6334. func (target *PersistentVolume) UnmarshalBinary(data []byte) error {
  6335. ctx := NewDecodingContextFromBytes(data)
  6336. defer ctx.Close()
  6337. err := target.UnmarshalBinaryWithContext(ctx)
  6338. if err != nil {
  6339. return err
  6340. }
  6341. return nil
  6342. }
  6343. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  6344. // the PersistentVolume type
  6345. func (target *PersistentVolume) UnmarshalBinaryFromReader(reader io.Reader) error {
  6346. ctx := NewDecodingContextFromReader(reader)
  6347. defer ctx.Close()
  6348. err := target.UnmarshalBinaryWithContext(ctx)
  6349. if err != nil {
  6350. return err
  6351. }
  6352. return nil
  6353. }
  6354. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6355. // the PersistentVolume type
  6356. func (target *PersistentVolume) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6357. // panics are recovered and propagated as errors
  6358. defer func() {
  6359. if r := recover(); r != nil {
  6360. if e, ok := r.(error); ok {
  6361. err = e
  6362. } else if s, ok := r.(string); ok {
  6363. err = fmt.Errorf("unexpected panic: %s", s)
  6364. } else {
  6365. err = fmt.Errorf("unexpected panic: %+v", r)
  6366. }
  6367. }
  6368. }()
  6369. buff := ctx.Buffer
  6370. version := buff.ReadUInt8()
  6371. if version > DefaultCodecVersion {
  6372. return fmt.Errorf("Invalid Version Unmarshalling PersistentVolume. Expected %d or less, got %d", DefaultCodecVersion, version)
  6373. }
  6374. var b string
  6375. if ctx.IsStringTable() {
  6376. c := buff.ReadInt() // read string index
  6377. b = ctx.Table.At(c)
  6378. } else {
  6379. b = buff.ReadString() // read string
  6380. }
  6381. a := b
  6382. target.UID = a
  6383. var e string
  6384. if ctx.IsStringTable() {
  6385. f := buff.ReadInt() // read string index
  6386. e = ctx.Table.At(f)
  6387. } else {
  6388. e = buff.ReadString() // read string
  6389. }
  6390. d := e
  6391. target.Name = d
  6392. var h string
  6393. if ctx.IsStringTable() {
  6394. l := buff.ReadInt() // read string index
  6395. h = ctx.Table.At(l)
  6396. } else {
  6397. h = buff.ReadString() // read string
  6398. }
  6399. g := h
  6400. target.StorageClass = g
  6401. var n string
  6402. if ctx.IsStringTable() {
  6403. o := buff.ReadInt() // read string index
  6404. n = ctx.Table.At(o)
  6405. } else {
  6406. n = buff.ReadString() // read string
  6407. }
  6408. m := n
  6409. target.CSIVolumeHandle = m
  6410. p := buff.ReadFloat64() // read float64
  6411. target.SizeBytes = p
  6412. // --- [begin][read][reference](time.Time) ---
  6413. q := new(time.Time)
  6414. r := buff.ReadInt() // byte array length
  6415. s := buff.ReadBytes(r)
  6416. errA := q.UnmarshalBinary(s)
  6417. if errA != nil {
  6418. return errA
  6419. }
  6420. target.Start = *q
  6421. // --- [end][read][reference](time.Time) ---
  6422. // --- [begin][read][reference](time.Time) ---
  6423. t := new(time.Time)
  6424. u := buff.ReadInt() // byte array length
  6425. w := buff.ReadBytes(u)
  6426. errB := t.UnmarshalBinary(w)
  6427. if errB != nil {
  6428. return errB
  6429. }
  6430. target.End = *t
  6431. // --- [end][read][reference](time.Time) ---
  6432. return nil
  6433. }
  6434. //--------------------------------------------------------------------------
  6435. // PersistentVolumeClaim
  6436. //--------------------------------------------------------------------------
  6437. // MarshalBinary serializes the internal properties of this PersistentVolumeClaim instance
  6438. // into a byte array
  6439. func (target *PersistentVolumeClaim) MarshalBinary() (data []byte, err error) {
  6440. ctx := NewEncodingContext(nil)
  6441. e := target.MarshalBinaryWithContext(ctx)
  6442. if e != nil {
  6443. return nil, e
  6444. }
  6445. return ctx.ToBytes(), nil
  6446. }
  6447. // MarshalBinary serializes the internal properties of this PersistentVolumeClaim instance
  6448. // into an io.Writer.
  6449. func (target *PersistentVolumeClaim) MarshalBinaryTo(writer io.Writer) error {
  6450. buff := util.NewBufferFromWriter(writer)
  6451. defer buff.Flush()
  6452. ctx := NewEncodingContextFromBuffer(buff, nil)
  6453. return target.MarshalBinaryWithContext(ctx)
  6454. }
  6455. // MarshalBinaryWithContext serializes the internal properties of this PersistentVolumeClaim instance
  6456. // into a byte array leveraging a predefined context.
  6457. func (target *PersistentVolumeClaim) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6458. // panics are recovered and propagated as errors
  6459. defer func() {
  6460. if r := recover(); r != nil {
  6461. if e, ok := r.(error); ok {
  6462. err = e
  6463. } else if s, ok := r.(string); ok {
  6464. err = fmt.Errorf("unexpected panic: %s", s)
  6465. } else {
  6466. err = fmt.Errorf("unexpected panic: %+v", r)
  6467. }
  6468. }
  6469. }()
  6470. buff := ctx.Buffer
  6471. buff.WriteUInt8(DefaultCodecVersion) // version
  6472. if ctx.IsStringTable() {
  6473. a := ctx.Table.AddOrGet(target.UID)
  6474. buff.WriteInt(a) // write table index
  6475. } else {
  6476. buff.WriteString(target.UID) // write string
  6477. }
  6478. if ctx.IsStringTable() {
  6479. b := ctx.Table.AddOrGet(target.NamespaceUID)
  6480. buff.WriteInt(b) // write table index
  6481. } else {
  6482. buff.WriteString(target.NamespaceUID) // write string
  6483. }
  6484. if ctx.IsStringTable() {
  6485. c := ctx.Table.AddOrGet(target.Name)
  6486. buff.WriteInt(c) // write table index
  6487. } else {
  6488. buff.WriteString(target.Name) // write string
  6489. }
  6490. if ctx.IsStringTable() {
  6491. d := ctx.Table.AddOrGet(target.PersistentVolumeUID)
  6492. buff.WriteInt(d) // write table index
  6493. } else {
  6494. buff.WriteString(target.PersistentVolumeUID) // write string
  6495. }
  6496. if ctx.IsStringTable() {
  6497. e := ctx.Table.AddOrGet(target.StorageClass)
  6498. buff.WriteInt(e) // write table index
  6499. } else {
  6500. buff.WriteString(target.StorageClass) // write string
  6501. }
  6502. // --- [begin][write][reference](time.Time) ---
  6503. f, errA := target.Start.MarshalBinary()
  6504. if errA != nil {
  6505. return errA
  6506. }
  6507. buff.WriteInt(len(f))
  6508. buff.WriteBytes(f)
  6509. // --- [end][write][reference](time.Time) ---
  6510. // --- [begin][write][reference](time.Time) ---
  6511. g, errB := target.End.MarshalBinary()
  6512. if errB != nil {
  6513. return errB
  6514. }
  6515. buff.WriteInt(len(g))
  6516. buff.WriteBytes(g)
  6517. // --- [end][write][reference](time.Time) ---
  6518. buff.WriteFloat64(target.RequestedBytes) // write float64
  6519. buff.WriteFloat64(target.UsageBytesAvg) // write float64
  6520. buff.WriteFloat64(target.UsageBytesMax) // write float64
  6521. return nil
  6522. }
  6523. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6524. // the PersistentVolumeClaim type
  6525. func (target *PersistentVolumeClaim) UnmarshalBinary(data []byte) error {
  6526. ctx := NewDecodingContextFromBytes(data)
  6527. defer ctx.Close()
  6528. err := target.UnmarshalBinaryWithContext(ctx)
  6529. if err != nil {
  6530. return err
  6531. }
  6532. return nil
  6533. }
  6534. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  6535. // the PersistentVolumeClaim type
  6536. func (target *PersistentVolumeClaim) UnmarshalBinaryFromReader(reader io.Reader) error {
  6537. ctx := NewDecodingContextFromReader(reader)
  6538. defer ctx.Close()
  6539. err := target.UnmarshalBinaryWithContext(ctx)
  6540. if err != nil {
  6541. return err
  6542. }
  6543. return nil
  6544. }
  6545. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6546. // the PersistentVolumeClaim type
  6547. func (target *PersistentVolumeClaim) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6548. // panics are recovered and propagated as errors
  6549. defer func() {
  6550. if r := recover(); r != nil {
  6551. if e, ok := r.(error); ok {
  6552. err = e
  6553. } else if s, ok := r.(string); ok {
  6554. err = fmt.Errorf("unexpected panic: %s", s)
  6555. } else {
  6556. err = fmt.Errorf("unexpected panic: %+v", r)
  6557. }
  6558. }
  6559. }()
  6560. buff := ctx.Buffer
  6561. version := buff.ReadUInt8()
  6562. if version > DefaultCodecVersion {
  6563. return fmt.Errorf("Invalid Version Unmarshalling PersistentVolumeClaim. Expected %d or less, got %d", DefaultCodecVersion, version)
  6564. }
  6565. var b string
  6566. if ctx.IsStringTable() {
  6567. c := buff.ReadInt() // read string index
  6568. b = ctx.Table.At(c)
  6569. } else {
  6570. b = buff.ReadString() // read string
  6571. }
  6572. a := b
  6573. target.UID = a
  6574. var e string
  6575. if ctx.IsStringTable() {
  6576. f := buff.ReadInt() // read string index
  6577. e = ctx.Table.At(f)
  6578. } else {
  6579. e = buff.ReadString() // read string
  6580. }
  6581. d := e
  6582. target.NamespaceUID = d
  6583. var h string
  6584. if ctx.IsStringTable() {
  6585. l := buff.ReadInt() // read string index
  6586. h = ctx.Table.At(l)
  6587. } else {
  6588. h = buff.ReadString() // read string
  6589. }
  6590. g := h
  6591. target.Name = g
  6592. var n string
  6593. if ctx.IsStringTable() {
  6594. o := buff.ReadInt() // read string index
  6595. n = ctx.Table.At(o)
  6596. } else {
  6597. n = buff.ReadString() // read string
  6598. }
  6599. m := n
  6600. target.PersistentVolumeUID = m
  6601. var q string
  6602. if ctx.IsStringTable() {
  6603. r := buff.ReadInt() // read string index
  6604. q = ctx.Table.At(r)
  6605. } else {
  6606. q = buff.ReadString() // read string
  6607. }
  6608. p := q
  6609. target.StorageClass = p
  6610. // --- [begin][read][reference](time.Time) ---
  6611. s := new(time.Time)
  6612. t := buff.ReadInt() // byte array length
  6613. u := buff.ReadBytes(t)
  6614. errA := s.UnmarshalBinary(u)
  6615. if errA != nil {
  6616. return errA
  6617. }
  6618. target.Start = *s
  6619. // --- [end][read][reference](time.Time) ---
  6620. // --- [begin][read][reference](time.Time) ---
  6621. w := new(time.Time)
  6622. x := buff.ReadInt() // byte array length
  6623. y := buff.ReadBytes(x)
  6624. errB := w.UnmarshalBinary(y)
  6625. if errB != nil {
  6626. return errB
  6627. }
  6628. target.End = *w
  6629. // --- [end][read][reference](time.Time) ---
  6630. aa := buff.ReadFloat64() // read float64
  6631. target.RequestedBytes = aa
  6632. bb := buff.ReadFloat64() // read float64
  6633. target.UsageBytesAvg = bb
  6634. cc := buff.ReadFloat64() // read float64
  6635. target.UsageBytesMax = cc
  6636. return nil
  6637. }
  6638. //--------------------------------------------------------------------------
  6639. // Pod
  6640. //--------------------------------------------------------------------------
  6641. // MarshalBinary serializes the internal properties of this Pod instance
  6642. // into a byte array
  6643. func (target *Pod) MarshalBinary() (data []byte, err error) {
  6644. ctx := NewEncodingContext(nil)
  6645. e := target.MarshalBinaryWithContext(ctx)
  6646. if e != nil {
  6647. return nil, e
  6648. }
  6649. return ctx.ToBytes(), nil
  6650. }
  6651. // MarshalBinary serializes the internal properties of this Pod instance
  6652. // into an io.Writer.
  6653. func (target *Pod) MarshalBinaryTo(writer io.Writer) error {
  6654. buff := util.NewBufferFromWriter(writer)
  6655. defer buff.Flush()
  6656. ctx := NewEncodingContextFromBuffer(buff, nil)
  6657. return target.MarshalBinaryWithContext(ctx)
  6658. }
  6659. // MarshalBinaryWithContext serializes the internal properties of this Pod instance
  6660. // into a byte array leveraging a predefined context.
  6661. func (target *Pod) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6662. // panics are recovered and propagated as errors
  6663. defer func() {
  6664. if r := recover(); r != nil {
  6665. if e, ok := r.(error); ok {
  6666. err = e
  6667. } else if s, ok := r.(string); ok {
  6668. err = fmt.Errorf("unexpected panic: %s", s)
  6669. } else {
  6670. err = fmt.Errorf("unexpected panic: %+v", r)
  6671. }
  6672. }
  6673. }()
  6674. buff := ctx.Buffer
  6675. buff.WriteUInt8(DefaultCodecVersion) // version
  6676. if ctx.IsStringTable() {
  6677. a := ctx.Table.AddOrGet(target.UID)
  6678. buff.WriteInt(a) // write table index
  6679. } else {
  6680. buff.WriteString(target.UID) // write string
  6681. }
  6682. if ctx.IsStringTable() {
  6683. b := ctx.Table.AddOrGet(target.NamespaceUID)
  6684. buff.WriteInt(b) // write table index
  6685. } else {
  6686. buff.WriteString(target.NamespaceUID) // write string
  6687. }
  6688. if ctx.IsStringTable() {
  6689. c := ctx.Table.AddOrGet(target.NodeUID)
  6690. buff.WriteInt(c) // write table index
  6691. } else {
  6692. buff.WriteString(target.NodeUID) // write string
  6693. }
  6694. if ctx.IsStringTable() {
  6695. d := ctx.Table.AddOrGet(target.Name)
  6696. buff.WriteInt(d) // write table index
  6697. } else {
  6698. buff.WriteString(target.Name) // write string
  6699. }
  6700. if target.Owners == nil {
  6701. buff.WriteUInt8(uint8(0)) // write nil byte
  6702. } else {
  6703. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6704. // --- [begin][write][slice]([]Owner) ---
  6705. buff.WriteInt(len(target.Owners)) // slice length
  6706. for i := range target.Owners {
  6707. // --- [begin][write][struct](Owner) ---
  6708. buff.WriteInt(0) // [compatibility, unused]
  6709. errA := target.Owners[i].MarshalBinaryWithContext(ctx)
  6710. if errA != nil {
  6711. return errA
  6712. }
  6713. // --- [end][write][struct](Owner) ---
  6714. }
  6715. // --- [end][write][slice]([]Owner) ---
  6716. }
  6717. if target.PVCVolumes == nil {
  6718. buff.WriteUInt8(uint8(0)) // write nil byte
  6719. } else {
  6720. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6721. // --- [begin][write][slice]([]PodPVCVolume) ---
  6722. buff.WriteInt(len(target.PVCVolumes)) // slice length
  6723. for j := range target.PVCVolumes {
  6724. // --- [begin][write][struct](PodPVCVolume) ---
  6725. buff.WriteInt(0) // [compatibility, unused]
  6726. errB := target.PVCVolumes[j].MarshalBinaryWithContext(ctx)
  6727. if errB != nil {
  6728. return errB
  6729. }
  6730. // --- [end][write][struct](PodPVCVolume) ---
  6731. }
  6732. // --- [end][write][slice]([]PodPVCVolume) ---
  6733. }
  6734. if target.Labels == nil {
  6735. buff.WriteUInt8(uint8(0)) // write nil byte
  6736. } else {
  6737. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6738. // --- [begin][write][map](map[string]string) ---
  6739. buff.WriteInt(len(target.Labels)) // map length
  6740. for v, z := range target.Labels {
  6741. if ctx.IsStringTable() {
  6742. e := ctx.Table.AddOrGet(v)
  6743. buff.WriteInt(e) // write table index
  6744. } else {
  6745. buff.WriteString(v) // write string
  6746. }
  6747. if ctx.IsStringTable() {
  6748. f := ctx.Table.AddOrGet(z)
  6749. buff.WriteInt(f) // write table index
  6750. } else {
  6751. buff.WriteString(z) // write string
  6752. }
  6753. }
  6754. // --- [end][write][map](map[string]string) ---
  6755. }
  6756. if target.Annotations == nil {
  6757. buff.WriteUInt8(uint8(0)) // write nil byte
  6758. } else {
  6759. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6760. // --- [begin][write][map](map[string]string) ---
  6761. buff.WriteInt(len(target.Annotations)) // map length
  6762. for vv, zz := range target.Annotations {
  6763. if ctx.IsStringTable() {
  6764. g := ctx.Table.AddOrGet(vv)
  6765. buff.WriteInt(g) // write table index
  6766. } else {
  6767. buff.WriteString(vv) // write string
  6768. }
  6769. if ctx.IsStringTable() {
  6770. h := ctx.Table.AddOrGet(zz)
  6771. buff.WriteInt(h) // write table index
  6772. } else {
  6773. buff.WriteString(zz) // write string
  6774. }
  6775. }
  6776. // --- [end][write][map](map[string]string) ---
  6777. }
  6778. if target.NetworkTrafficDetails == nil {
  6779. buff.WriteUInt8(uint8(0)) // write nil byte
  6780. } else {
  6781. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6782. // --- [begin][write][slice]([]NetworkTrafficDetail) ---
  6783. buff.WriteInt(len(target.NetworkTrafficDetails)) // slice length
  6784. for ii := range target.NetworkTrafficDetails {
  6785. // --- [begin][write][struct](NetworkTrafficDetail) ---
  6786. buff.WriteInt(0) // [compatibility, unused]
  6787. errC := target.NetworkTrafficDetails[ii].MarshalBinaryWithContext(ctx)
  6788. if errC != nil {
  6789. return errC
  6790. }
  6791. // --- [end][write][struct](NetworkTrafficDetail) ---
  6792. }
  6793. // --- [end][write][slice]([]NetworkTrafficDetail) ---
  6794. }
  6795. // --- [begin][write][reference](time.Time) ---
  6796. l, errD := target.Start.MarshalBinary()
  6797. if errD != nil {
  6798. return errD
  6799. }
  6800. buff.WriteInt(len(l))
  6801. buff.WriteBytes(l)
  6802. // --- [end][write][reference](time.Time) ---
  6803. // --- [begin][write][reference](time.Time) ---
  6804. m, errE := target.End.MarshalBinary()
  6805. if errE != nil {
  6806. return errE
  6807. }
  6808. buff.WriteInt(len(m))
  6809. buff.WriteBytes(m)
  6810. // --- [end][write][reference](time.Time) ---
  6811. return nil
  6812. }
  6813. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6814. // the Pod type
  6815. func (target *Pod) UnmarshalBinary(data []byte) error {
  6816. ctx := NewDecodingContextFromBytes(data)
  6817. defer ctx.Close()
  6818. err := target.UnmarshalBinaryWithContext(ctx)
  6819. if err != nil {
  6820. return err
  6821. }
  6822. return nil
  6823. }
  6824. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  6825. // the Pod type
  6826. func (target *Pod) UnmarshalBinaryFromReader(reader io.Reader) error {
  6827. ctx := NewDecodingContextFromReader(reader)
  6828. defer ctx.Close()
  6829. err := target.UnmarshalBinaryWithContext(ctx)
  6830. if err != nil {
  6831. return err
  6832. }
  6833. return nil
  6834. }
  6835. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6836. // the Pod type
  6837. func (target *Pod) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6838. // panics are recovered and propagated as errors
  6839. defer func() {
  6840. if r := recover(); r != nil {
  6841. if e, ok := r.(error); ok {
  6842. err = e
  6843. } else if s, ok := r.(string); ok {
  6844. err = fmt.Errorf("unexpected panic: %s", s)
  6845. } else {
  6846. err = fmt.Errorf("unexpected panic: %+v", r)
  6847. }
  6848. }
  6849. }()
  6850. buff := ctx.Buffer
  6851. version := buff.ReadUInt8()
  6852. if version > DefaultCodecVersion {
  6853. return fmt.Errorf("Invalid Version Unmarshalling Pod. Expected %d or less, got %d", DefaultCodecVersion, version)
  6854. }
  6855. var b string
  6856. if ctx.IsStringTable() {
  6857. c := buff.ReadInt() // read string index
  6858. b = ctx.Table.At(c)
  6859. } else {
  6860. b = buff.ReadString() // read string
  6861. }
  6862. a := b
  6863. target.UID = a
  6864. var e string
  6865. if ctx.IsStringTable() {
  6866. f := buff.ReadInt() // read string index
  6867. e = ctx.Table.At(f)
  6868. } else {
  6869. e = buff.ReadString() // read string
  6870. }
  6871. d := e
  6872. target.NamespaceUID = d
  6873. var h string
  6874. if ctx.IsStringTable() {
  6875. l := buff.ReadInt() // read string index
  6876. h = ctx.Table.At(l)
  6877. } else {
  6878. h = buff.ReadString() // read string
  6879. }
  6880. g := h
  6881. target.NodeUID = g
  6882. var n string
  6883. if ctx.IsStringTable() {
  6884. o := buff.ReadInt() // read string index
  6885. n = ctx.Table.At(o)
  6886. } else {
  6887. n = buff.ReadString() // read string
  6888. }
  6889. m := n
  6890. target.Name = m
  6891. if buff.ReadUInt8() == uint8(0) {
  6892. target.Owners = nil
  6893. } else {
  6894. // --- [begin][read][slice]([]Owner) ---
  6895. q := buff.ReadInt() // slice len
  6896. p := make([]Owner, q)
  6897. for i := range q {
  6898. // --- [begin][read][struct](Owner) ---
  6899. s := new(Owner)
  6900. buff.ReadInt() // [compatibility, unused]
  6901. errA := s.UnmarshalBinaryWithContext(ctx)
  6902. if errA != nil {
  6903. return errA
  6904. }
  6905. r := *s
  6906. // --- [end][read][struct](Owner) ---
  6907. p[i] = r
  6908. }
  6909. target.Owners = p
  6910. // --- [end][read][slice]([]Owner) ---
  6911. }
  6912. if buff.ReadUInt8() == uint8(0) {
  6913. target.PVCVolumes = nil
  6914. } else {
  6915. // --- [begin][read][slice]([]PodPVCVolume) ---
  6916. u := buff.ReadInt() // slice len
  6917. t := make([]PodPVCVolume, u)
  6918. for j := range u {
  6919. // --- [begin][read][struct](PodPVCVolume) ---
  6920. x := new(PodPVCVolume)
  6921. buff.ReadInt() // [compatibility, unused]
  6922. errB := x.UnmarshalBinaryWithContext(ctx)
  6923. if errB != nil {
  6924. return errB
  6925. }
  6926. w := *x
  6927. // --- [end][read][struct](PodPVCVolume) ---
  6928. t[j] = w
  6929. }
  6930. target.PVCVolumes = t
  6931. // --- [end][read][slice]([]PodPVCVolume) ---
  6932. }
  6933. if buff.ReadUInt8() == uint8(0) {
  6934. target.Labels = nil
  6935. } else {
  6936. // --- [begin][read][map](map[string]string) ---
  6937. aa := buff.ReadInt() // map len
  6938. y := make(map[string]string, aa)
  6939. for range aa {
  6940. var v string
  6941. var cc string
  6942. if ctx.IsStringTable() {
  6943. dd := buff.ReadInt() // read string index
  6944. cc = ctx.Table.At(dd)
  6945. } else {
  6946. cc = buff.ReadString() // read string
  6947. }
  6948. bb := cc
  6949. v = bb
  6950. var z string
  6951. var ff string
  6952. if ctx.IsStringTable() {
  6953. gg := buff.ReadInt() // read string index
  6954. ff = ctx.Table.At(gg)
  6955. } else {
  6956. ff = buff.ReadString() // read string
  6957. }
  6958. ee := ff
  6959. z = ee
  6960. y[v] = z
  6961. }
  6962. target.Labels = y
  6963. // --- [end][read][map](map[string]string) ---
  6964. }
  6965. if buff.ReadUInt8() == uint8(0) {
  6966. target.Annotations = nil
  6967. } else {
  6968. // --- [begin][read][map](map[string]string) ---
  6969. ll := buff.ReadInt() // map len
  6970. hh := make(map[string]string, ll)
  6971. for range ll {
  6972. var vv string
  6973. var nn string
  6974. if ctx.IsStringTable() {
  6975. oo := buff.ReadInt() // read string index
  6976. nn = ctx.Table.At(oo)
  6977. } else {
  6978. nn = buff.ReadString() // read string
  6979. }
  6980. mm := nn
  6981. vv = mm
  6982. var zz string
  6983. var qq string
  6984. if ctx.IsStringTable() {
  6985. rr := buff.ReadInt() // read string index
  6986. qq = ctx.Table.At(rr)
  6987. } else {
  6988. qq = buff.ReadString() // read string
  6989. }
  6990. pp := qq
  6991. zz = pp
  6992. hh[vv] = zz
  6993. }
  6994. target.Annotations = hh
  6995. // --- [end][read][map](map[string]string) ---
  6996. }
  6997. if buff.ReadUInt8() == uint8(0) {
  6998. target.NetworkTrafficDetails = nil
  6999. } else {
  7000. // --- [begin][read][slice]([]NetworkTrafficDetail) ---
  7001. tt := buff.ReadInt() // slice len
  7002. ss := make([]NetworkTrafficDetail, tt)
  7003. for ii := range tt {
  7004. // --- [begin][read][struct](NetworkTrafficDetail) ---
  7005. ww := new(NetworkTrafficDetail)
  7006. buff.ReadInt() // [compatibility, unused]
  7007. errC := ww.UnmarshalBinaryWithContext(ctx)
  7008. if errC != nil {
  7009. return errC
  7010. }
  7011. uu := *ww
  7012. // --- [end][read][struct](NetworkTrafficDetail) ---
  7013. ss[ii] = uu
  7014. }
  7015. target.NetworkTrafficDetails = ss
  7016. // --- [end][read][slice]([]NetworkTrafficDetail) ---
  7017. }
  7018. // --- [begin][read][reference](time.Time) ---
  7019. xx := new(time.Time)
  7020. yy := buff.ReadInt() // byte array length
  7021. aaa := buff.ReadBytes(yy)
  7022. errD := xx.UnmarshalBinary(aaa)
  7023. if errD != nil {
  7024. return errD
  7025. }
  7026. target.Start = *xx
  7027. // --- [end][read][reference](time.Time) ---
  7028. // --- [begin][read][reference](time.Time) ---
  7029. bbb := new(time.Time)
  7030. ccc := buff.ReadInt() // byte array length
  7031. ddd := buff.ReadBytes(ccc)
  7032. errE := bbb.UnmarshalBinary(ddd)
  7033. if errE != nil {
  7034. return errE
  7035. }
  7036. target.End = *bbb
  7037. // --- [end][read][reference](time.Time) ---
  7038. return nil
  7039. }
  7040. //--------------------------------------------------------------------------
  7041. // PodPVCVolume
  7042. //--------------------------------------------------------------------------
  7043. // MarshalBinary serializes the internal properties of this PodPVCVolume instance
  7044. // into a byte array
  7045. func (target *PodPVCVolume) MarshalBinary() (data []byte, err error) {
  7046. ctx := NewEncodingContext(nil)
  7047. e := target.MarshalBinaryWithContext(ctx)
  7048. if e != nil {
  7049. return nil, e
  7050. }
  7051. return ctx.ToBytes(), nil
  7052. }
  7053. // MarshalBinary serializes the internal properties of this PodPVCVolume instance
  7054. // into an io.Writer.
  7055. func (target *PodPVCVolume) MarshalBinaryTo(writer io.Writer) error {
  7056. buff := util.NewBufferFromWriter(writer)
  7057. defer buff.Flush()
  7058. ctx := NewEncodingContextFromBuffer(buff, nil)
  7059. return target.MarshalBinaryWithContext(ctx)
  7060. }
  7061. // MarshalBinaryWithContext serializes the internal properties of this PodPVCVolume instance
  7062. // into a byte array leveraging a predefined context.
  7063. func (target *PodPVCVolume) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  7064. // panics are recovered and propagated as errors
  7065. defer func() {
  7066. if r := recover(); r != nil {
  7067. if e, ok := r.(error); ok {
  7068. err = e
  7069. } else if s, ok := r.(string); ok {
  7070. err = fmt.Errorf("unexpected panic: %s", s)
  7071. } else {
  7072. err = fmt.Errorf("unexpected panic: %+v", r)
  7073. }
  7074. }
  7075. }()
  7076. buff := ctx.Buffer
  7077. buff.WriteUInt8(DefaultCodecVersion) // version
  7078. if ctx.IsStringTable() {
  7079. a := ctx.Table.AddOrGet(target.Name)
  7080. buff.WriteInt(a) // write table index
  7081. } else {
  7082. buff.WriteString(target.Name) // write string
  7083. }
  7084. if ctx.IsStringTable() {
  7085. b := ctx.Table.AddOrGet(target.PersistentVolumeClaimUID)
  7086. buff.WriteInt(b) // write table index
  7087. } else {
  7088. buff.WriteString(target.PersistentVolumeClaimUID) // write string
  7089. }
  7090. return nil
  7091. }
  7092. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7093. // the PodPVCVolume type
  7094. func (target *PodPVCVolume) UnmarshalBinary(data []byte) error {
  7095. ctx := NewDecodingContextFromBytes(data)
  7096. defer ctx.Close()
  7097. err := target.UnmarshalBinaryWithContext(ctx)
  7098. if err != nil {
  7099. return err
  7100. }
  7101. return nil
  7102. }
  7103. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  7104. // the PodPVCVolume type
  7105. func (target *PodPVCVolume) UnmarshalBinaryFromReader(reader io.Reader) error {
  7106. ctx := NewDecodingContextFromReader(reader)
  7107. defer ctx.Close()
  7108. err := target.UnmarshalBinaryWithContext(ctx)
  7109. if err != nil {
  7110. return err
  7111. }
  7112. return nil
  7113. }
  7114. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7115. // the PodPVCVolume type
  7116. func (target *PodPVCVolume) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7117. // panics are recovered and propagated as errors
  7118. defer func() {
  7119. if r := recover(); r != nil {
  7120. if e, ok := r.(error); ok {
  7121. err = e
  7122. } else if s, ok := r.(string); ok {
  7123. err = fmt.Errorf("unexpected panic: %s", s)
  7124. } else {
  7125. err = fmt.Errorf("unexpected panic: %+v", r)
  7126. }
  7127. }
  7128. }()
  7129. buff := ctx.Buffer
  7130. version := buff.ReadUInt8()
  7131. if version > DefaultCodecVersion {
  7132. return fmt.Errorf("Invalid Version Unmarshalling PodPVCVolume. Expected %d or less, got %d", DefaultCodecVersion, version)
  7133. }
  7134. var b string
  7135. if ctx.IsStringTable() {
  7136. c := buff.ReadInt() // read string index
  7137. b = ctx.Table.At(c)
  7138. } else {
  7139. b = buff.ReadString() // read string
  7140. }
  7141. a := b
  7142. target.Name = a
  7143. var e string
  7144. if ctx.IsStringTable() {
  7145. f := buff.ReadInt() // read string index
  7146. e = ctx.Table.At(f)
  7147. } else {
  7148. e = buff.ReadString() // read string
  7149. }
  7150. d := e
  7151. target.PersistentVolumeClaimUID = d
  7152. return nil
  7153. }
  7154. //--------------------------------------------------------------------------
  7155. // ReplicaSet
  7156. //--------------------------------------------------------------------------
  7157. // MarshalBinary serializes the internal properties of this ReplicaSet instance
  7158. // into a byte array
  7159. func (target *ReplicaSet) MarshalBinary() (data []byte, err error) {
  7160. ctx := NewEncodingContext(nil)
  7161. e := target.MarshalBinaryWithContext(ctx)
  7162. if e != nil {
  7163. return nil, e
  7164. }
  7165. return ctx.ToBytes(), nil
  7166. }
  7167. // MarshalBinary serializes the internal properties of this ReplicaSet instance
  7168. // into an io.Writer.
  7169. func (target *ReplicaSet) MarshalBinaryTo(writer io.Writer) error {
  7170. buff := util.NewBufferFromWriter(writer)
  7171. defer buff.Flush()
  7172. ctx := NewEncodingContextFromBuffer(buff, nil)
  7173. return target.MarshalBinaryWithContext(ctx)
  7174. }
  7175. // MarshalBinaryWithContext serializes the internal properties of this ReplicaSet instance
  7176. // into a byte array leveraging a predefined context.
  7177. func (target *ReplicaSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  7178. // panics are recovered and propagated as errors
  7179. defer func() {
  7180. if r := recover(); r != nil {
  7181. if e, ok := r.(error); ok {
  7182. err = e
  7183. } else if s, ok := r.(string); ok {
  7184. err = fmt.Errorf("unexpected panic: %s", s)
  7185. } else {
  7186. err = fmt.Errorf("unexpected panic: %+v", r)
  7187. }
  7188. }
  7189. }()
  7190. buff := ctx.Buffer
  7191. buff.WriteUInt8(DefaultCodecVersion) // version
  7192. if ctx.IsStringTable() {
  7193. a := ctx.Table.AddOrGet(target.UID)
  7194. buff.WriteInt(a) // write table index
  7195. } else {
  7196. buff.WriteString(target.UID) // write string
  7197. }
  7198. if ctx.IsStringTable() {
  7199. b := ctx.Table.AddOrGet(target.NamespaceUID)
  7200. buff.WriteInt(b) // write table index
  7201. } else {
  7202. buff.WriteString(target.NamespaceUID) // write string
  7203. }
  7204. if ctx.IsStringTable() {
  7205. c := ctx.Table.AddOrGet(target.Name)
  7206. buff.WriteInt(c) // write table index
  7207. } else {
  7208. buff.WriteString(target.Name) // write string
  7209. }
  7210. if target.Owners == nil {
  7211. buff.WriteUInt8(uint8(0)) // write nil byte
  7212. } else {
  7213. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7214. // --- [begin][write][slice]([]Owner) ---
  7215. buff.WriteInt(len(target.Owners)) // slice length
  7216. for i := range target.Owners {
  7217. // --- [begin][write][struct](Owner) ---
  7218. buff.WriteInt(0) // [compatibility, unused]
  7219. errA := target.Owners[i].MarshalBinaryWithContext(ctx)
  7220. if errA != nil {
  7221. return errA
  7222. }
  7223. // --- [end][write][struct](Owner) ---
  7224. }
  7225. // --- [end][write][slice]([]Owner) ---
  7226. }
  7227. if target.Labels == nil {
  7228. buff.WriteUInt8(uint8(0)) // write nil byte
  7229. } else {
  7230. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7231. // --- [begin][write][map](map[string]string) ---
  7232. buff.WriteInt(len(target.Labels)) // map length
  7233. for v, z := range target.Labels {
  7234. if ctx.IsStringTable() {
  7235. d := ctx.Table.AddOrGet(v)
  7236. buff.WriteInt(d) // write table index
  7237. } else {
  7238. buff.WriteString(v) // write string
  7239. }
  7240. if ctx.IsStringTable() {
  7241. e := ctx.Table.AddOrGet(z)
  7242. buff.WriteInt(e) // write table index
  7243. } else {
  7244. buff.WriteString(z) // write string
  7245. }
  7246. }
  7247. // --- [end][write][map](map[string]string) ---
  7248. }
  7249. if target.Annotations == nil {
  7250. buff.WriteUInt8(uint8(0)) // write nil byte
  7251. } else {
  7252. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7253. // --- [begin][write][map](map[string]string) ---
  7254. buff.WriteInt(len(target.Annotations)) // map length
  7255. for vv, zz := range target.Annotations {
  7256. if ctx.IsStringTable() {
  7257. f := ctx.Table.AddOrGet(vv)
  7258. buff.WriteInt(f) // write table index
  7259. } else {
  7260. buff.WriteString(vv) // write string
  7261. }
  7262. if ctx.IsStringTable() {
  7263. g := ctx.Table.AddOrGet(zz)
  7264. buff.WriteInt(g) // write table index
  7265. } else {
  7266. buff.WriteString(zz) // write string
  7267. }
  7268. }
  7269. // --- [end][write][map](map[string]string) ---
  7270. }
  7271. // --- [begin][write][reference](time.Time) ---
  7272. h, errB := target.Start.MarshalBinary()
  7273. if errB != nil {
  7274. return errB
  7275. }
  7276. buff.WriteInt(len(h))
  7277. buff.WriteBytes(h)
  7278. // --- [end][write][reference](time.Time) ---
  7279. // --- [begin][write][reference](time.Time) ---
  7280. l, errC := target.End.MarshalBinary()
  7281. if errC != nil {
  7282. return errC
  7283. }
  7284. buff.WriteInt(len(l))
  7285. buff.WriteBytes(l)
  7286. // --- [end][write][reference](time.Time) ---
  7287. return nil
  7288. }
  7289. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7290. // the ReplicaSet type
  7291. func (target *ReplicaSet) UnmarshalBinary(data []byte) error {
  7292. ctx := NewDecodingContextFromBytes(data)
  7293. defer ctx.Close()
  7294. err := target.UnmarshalBinaryWithContext(ctx)
  7295. if err != nil {
  7296. return err
  7297. }
  7298. return nil
  7299. }
  7300. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  7301. // the ReplicaSet type
  7302. func (target *ReplicaSet) UnmarshalBinaryFromReader(reader io.Reader) error {
  7303. ctx := NewDecodingContextFromReader(reader)
  7304. defer ctx.Close()
  7305. err := target.UnmarshalBinaryWithContext(ctx)
  7306. if err != nil {
  7307. return err
  7308. }
  7309. return nil
  7310. }
  7311. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7312. // the ReplicaSet type
  7313. func (target *ReplicaSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7314. // panics are recovered and propagated as errors
  7315. defer func() {
  7316. if r := recover(); r != nil {
  7317. if e, ok := r.(error); ok {
  7318. err = e
  7319. } else if s, ok := r.(string); ok {
  7320. err = fmt.Errorf("unexpected panic: %s", s)
  7321. } else {
  7322. err = fmt.Errorf("unexpected panic: %+v", r)
  7323. }
  7324. }
  7325. }()
  7326. buff := ctx.Buffer
  7327. version := buff.ReadUInt8()
  7328. if version > DefaultCodecVersion {
  7329. return fmt.Errorf("Invalid Version Unmarshalling ReplicaSet. Expected %d or less, got %d", DefaultCodecVersion, version)
  7330. }
  7331. var b string
  7332. if ctx.IsStringTable() {
  7333. c := buff.ReadInt() // read string index
  7334. b = ctx.Table.At(c)
  7335. } else {
  7336. b = buff.ReadString() // read string
  7337. }
  7338. a := b
  7339. target.UID = a
  7340. var e string
  7341. if ctx.IsStringTable() {
  7342. f := buff.ReadInt() // read string index
  7343. e = ctx.Table.At(f)
  7344. } else {
  7345. e = buff.ReadString() // read string
  7346. }
  7347. d := e
  7348. target.NamespaceUID = d
  7349. var h string
  7350. if ctx.IsStringTable() {
  7351. l := buff.ReadInt() // read string index
  7352. h = ctx.Table.At(l)
  7353. } else {
  7354. h = buff.ReadString() // read string
  7355. }
  7356. g := h
  7357. target.Name = g
  7358. if buff.ReadUInt8() == uint8(0) {
  7359. target.Owners = nil
  7360. } else {
  7361. // --- [begin][read][slice]([]Owner) ---
  7362. n := buff.ReadInt() // slice len
  7363. m := make([]Owner, n)
  7364. for i := range n {
  7365. // --- [begin][read][struct](Owner) ---
  7366. p := new(Owner)
  7367. buff.ReadInt() // [compatibility, unused]
  7368. errA := p.UnmarshalBinaryWithContext(ctx)
  7369. if errA != nil {
  7370. return errA
  7371. }
  7372. o := *p
  7373. // --- [end][read][struct](Owner) ---
  7374. m[i] = o
  7375. }
  7376. target.Owners = m
  7377. // --- [end][read][slice]([]Owner) ---
  7378. }
  7379. if buff.ReadUInt8() == uint8(0) {
  7380. target.Labels = nil
  7381. } else {
  7382. // --- [begin][read][map](map[string]string) ---
  7383. r := buff.ReadInt() // map len
  7384. q := make(map[string]string, r)
  7385. for range r {
  7386. var v string
  7387. var t string
  7388. if ctx.IsStringTable() {
  7389. u := buff.ReadInt() // read string index
  7390. t = ctx.Table.At(u)
  7391. } else {
  7392. t = buff.ReadString() // read string
  7393. }
  7394. s := t
  7395. v = s
  7396. var z string
  7397. var x string
  7398. if ctx.IsStringTable() {
  7399. y := buff.ReadInt() // read string index
  7400. x = ctx.Table.At(y)
  7401. } else {
  7402. x = buff.ReadString() // read string
  7403. }
  7404. w := x
  7405. z = w
  7406. q[v] = z
  7407. }
  7408. target.Labels = q
  7409. // --- [end][read][map](map[string]string) ---
  7410. }
  7411. if buff.ReadUInt8() == uint8(0) {
  7412. target.Annotations = nil
  7413. } else {
  7414. // --- [begin][read][map](map[string]string) ---
  7415. bb := buff.ReadInt() // map len
  7416. aa := make(map[string]string, bb)
  7417. for range bb {
  7418. var vv string
  7419. var dd string
  7420. if ctx.IsStringTable() {
  7421. ee := buff.ReadInt() // read string index
  7422. dd = ctx.Table.At(ee)
  7423. } else {
  7424. dd = buff.ReadString() // read string
  7425. }
  7426. cc := dd
  7427. vv = cc
  7428. var zz string
  7429. var gg string
  7430. if ctx.IsStringTable() {
  7431. hh := buff.ReadInt() // read string index
  7432. gg = ctx.Table.At(hh)
  7433. } else {
  7434. gg = buff.ReadString() // read string
  7435. }
  7436. ff := gg
  7437. zz = ff
  7438. aa[vv] = zz
  7439. }
  7440. target.Annotations = aa
  7441. // --- [end][read][map](map[string]string) ---
  7442. }
  7443. // --- [begin][read][reference](time.Time) ---
  7444. ll := new(time.Time)
  7445. mm := buff.ReadInt() // byte array length
  7446. nn := buff.ReadBytes(mm)
  7447. errB := ll.UnmarshalBinary(nn)
  7448. if errB != nil {
  7449. return errB
  7450. }
  7451. target.Start = *ll
  7452. // --- [end][read][reference](time.Time) ---
  7453. // --- [begin][read][reference](time.Time) ---
  7454. oo := new(time.Time)
  7455. pp := buff.ReadInt() // byte array length
  7456. qq := buff.ReadBytes(pp)
  7457. errC := oo.UnmarshalBinary(qq)
  7458. if errC != nil {
  7459. return errC
  7460. }
  7461. target.End = *oo
  7462. // --- [end][read][reference](time.Time) ---
  7463. return nil
  7464. }
  7465. //--------------------------------------------------------------------------
  7466. // ResourceQuantity
  7467. //--------------------------------------------------------------------------
  7468. // MarshalBinary serializes the internal properties of this ResourceQuantity instance
  7469. // into a byte array
  7470. func (target *ResourceQuantity) MarshalBinary() (data []byte, err error) {
  7471. ctx := NewEncodingContext(nil)
  7472. e := target.MarshalBinaryWithContext(ctx)
  7473. if e != nil {
  7474. return nil, e
  7475. }
  7476. return ctx.ToBytes(), nil
  7477. }
  7478. // MarshalBinary serializes the internal properties of this ResourceQuantity instance
  7479. // into an io.Writer.
  7480. func (target *ResourceQuantity) MarshalBinaryTo(writer io.Writer) error {
  7481. buff := util.NewBufferFromWriter(writer)
  7482. defer buff.Flush()
  7483. ctx := NewEncodingContextFromBuffer(buff, nil)
  7484. return target.MarshalBinaryWithContext(ctx)
  7485. }
  7486. // MarshalBinaryWithContext serializes the internal properties of this ResourceQuantity instance
  7487. // into a byte array leveraging a predefined context.
  7488. func (target *ResourceQuantity) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  7489. // panics are recovered and propagated as errors
  7490. defer func() {
  7491. if r := recover(); r != nil {
  7492. if e, ok := r.(error); ok {
  7493. err = e
  7494. } else if s, ok := r.(string); ok {
  7495. err = fmt.Errorf("unexpected panic: %s", s)
  7496. } else {
  7497. err = fmt.Errorf("unexpected panic: %+v", r)
  7498. }
  7499. }
  7500. }()
  7501. buff := ctx.Buffer
  7502. buff.WriteUInt8(DefaultCodecVersion) // version
  7503. // --- [begin][write][alias](Resource) ---
  7504. if ctx.IsStringTable() {
  7505. a := ctx.Table.AddOrGet(string(target.Resource))
  7506. buff.WriteInt(a) // write table index
  7507. } else {
  7508. buff.WriteString(string(target.Resource)) // write string
  7509. }
  7510. // --- [end][write][alias](Resource) ---
  7511. // --- [begin][write][alias](Unit) ---
  7512. if ctx.IsStringTable() {
  7513. b := ctx.Table.AddOrGet(string(target.Unit))
  7514. buff.WriteInt(b) // write table index
  7515. } else {
  7516. buff.WriteString(string(target.Unit)) // write string
  7517. }
  7518. // --- [end][write][alias](Unit) ---
  7519. // --- [begin][write][alias](Stats) ---
  7520. if map[StatType]float64(target.Values) == nil {
  7521. buff.WriteUInt8(uint8(0)) // write nil byte
  7522. } else {
  7523. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7524. // --- [begin][write][map](map[StatType]float64) ---
  7525. buff.WriteInt(len(map[StatType]float64(target.Values))) // map length
  7526. for v, z := range map[StatType]float64(target.Values) {
  7527. // --- [begin][write][alias](StatType) ---
  7528. if ctx.IsStringTable() {
  7529. c := ctx.Table.AddOrGet(string(v))
  7530. buff.WriteInt(c) // write table index
  7531. } else {
  7532. buff.WriteString(string(v)) // write string
  7533. }
  7534. // --- [end][write][alias](StatType) ---
  7535. buff.WriteFloat64(z) // write float64
  7536. }
  7537. // --- [end][write][map](map[StatType]float64) ---
  7538. }
  7539. // --- [end][write][alias](Stats) ---
  7540. return nil
  7541. }
  7542. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7543. // the ResourceQuantity type
  7544. func (target *ResourceQuantity) UnmarshalBinary(data []byte) error {
  7545. ctx := NewDecodingContextFromBytes(data)
  7546. defer ctx.Close()
  7547. err := target.UnmarshalBinaryWithContext(ctx)
  7548. if err != nil {
  7549. return err
  7550. }
  7551. return nil
  7552. }
  7553. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  7554. // the ResourceQuantity type
  7555. func (target *ResourceQuantity) UnmarshalBinaryFromReader(reader io.Reader) error {
  7556. ctx := NewDecodingContextFromReader(reader)
  7557. defer ctx.Close()
  7558. err := target.UnmarshalBinaryWithContext(ctx)
  7559. if err != nil {
  7560. return err
  7561. }
  7562. return nil
  7563. }
  7564. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7565. // the ResourceQuantity type
  7566. func (target *ResourceQuantity) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7567. // panics are recovered and propagated as errors
  7568. defer func() {
  7569. if r := recover(); r != nil {
  7570. if e, ok := r.(error); ok {
  7571. err = e
  7572. } else if s, ok := r.(string); ok {
  7573. err = fmt.Errorf("unexpected panic: %s", s)
  7574. } else {
  7575. err = fmt.Errorf("unexpected panic: %+v", r)
  7576. }
  7577. }
  7578. }()
  7579. buff := ctx.Buffer
  7580. version := buff.ReadUInt8()
  7581. if version > DefaultCodecVersion {
  7582. return fmt.Errorf("Invalid Version Unmarshalling ResourceQuantity. Expected %d or less, got %d", DefaultCodecVersion, version)
  7583. }
  7584. // field version check
  7585. if uint8(1) <= version {
  7586. // --- [begin][read][alias](Resource) ---
  7587. var a string
  7588. var c string
  7589. if ctx.IsStringTable() {
  7590. d := buff.ReadInt() // read string index
  7591. c = ctx.Table.At(d)
  7592. } else {
  7593. c = buff.ReadString() // read string
  7594. }
  7595. b := c
  7596. a = b
  7597. target.Resource = Resource(a)
  7598. // --- [end][read][alias](Resource) ---
  7599. } else {
  7600. }
  7601. // field version check
  7602. if uint8(1) <= version {
  7603. // --- [begin][read][alias](Unit) ---
  7604. var e string
  7605. var g string
  7606. if ctx.IsStringTable() {
  7607. h := buff.ReadInt() // read string index
  7608. g = ctx.Table.At(h)
  7609. } else {
  7610. g = buff.ReadString() // read string
  7611. }
  7612. f := g
  7613. e = f
  7614. target.Unit = Unit(e)
  7615. // --- [end][read][alias](Unit) ---
  7616. } else {
  7617. }
  7618. // field version check
  7619. if uint8(1) <= version {
  7620. // --- [begin][read][alias](Stats) ---
  7621. var l map[StatType]float64
  7622. if buff.ReadUInt8() == uint8(0) {
  7623. l = nil
  7624. } else {
  7625. // --- [begin][read][map](map[StatType]float64) ---
  7626. n := buff.ReadInt() // map len
  7627. m := make(map[StatType]float64, n)
  7628. for range n {
  7629. // --- [begin][read][alias](StatType) ---
  7630. var o string
  7631. var q string
  7632. if ctx.IsStringTable() {
  7633. r := buff.ReadInt() // read string index
  7634. q = ctx.Table.At(r)
  7635. } else {
  7636. q = buff.ReadString() // read string
  7637. }
  7638. p := q
  7639. o = p
  7640. v := StatType(o)
  7641. // --- [end][read][alias](StatType) ---
  7642. var z float64
  7643. s := buff.ReadFloat64() // read float64
  7644. z = s
  7645. m[v] = z
  7646. }
  7647. l = m
  7648. // --- [end][read][map](map[StatType]float64) ---
  7649. }
  7650. target.Values = Stats(l)
  7651. // --- [end][read][alias](Stats) ---
  7652. } else {
  7653. }
  7654. return nil
  7655. }
  7656. //--------------------------------------------------------------------------
  7657. // ResourceQuota
  7658. //--------------------------------------------------------------------------
  7659. // MarshalBinary serializes the internal properties of this ResourceQuota instance
  7660. // into a byte array
  7661. func (target *ResourceQuota) MarshalBinary() (data []byte, err error) {
  7662. ctx := NewEncodingContext(nil)
  7663. e := target.MarshalBinaryWithContext(ctx)
  7664. if e != nil {
  7665. return nil, e
  7666. }
  7667. return ctx.ToBytes(), nil
  7668. }
  7669. // MarshalBinary serializes the internal properties of this ResourceQuota instance
  7670. // into an io.Writer.
  7671. func (target *ResourceQuota) MarshalBinaryTo(writer io.Writer) error {
  7672. buff := util.NewBufferFromWriter(writer)
  7673. defer buff.Flush()
  7674. ctx := NewEncodingContextFromBuffer(buff, nil)
  7675. return target.MarshalBinaryWithContext(ctx)
  7676. }
  7677. // MarshalBinaryWithContext serializes the internal properties of this ResourceQuota instance
  7678. // into a byte array leveraging a predefined context.
  7679. func (target *ResourceQuota) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  7680. // panics are recovered and propagated as errors
  7681. defer func() {
  7682. if r := recover(); r != nil {
  7683. if e, ok := r.(error); ok {
  7684. err = e
  7685. } else if s, ok := r.(string); ok {
  7686. err = fmt.Errorf("unexpected panic: %s", s)
  7687. } else {
  7688. err = fmt.Errorf("unexpected panic: %+v", r)
  7689. }
  7690. }
  7691. }()
  7692. buff := ctx.Buffer
  7693. buff.WriteUInt8(DefaultCodecVersion) // version
  7694. if ctx.IsStringTable() {
  7695. a := ctx.Table.AddOrGet(target.UID)
  7696. buff.WriteInt(a) // write table index
  7697. } else {
  7698. buff.WriteString(target.UID) // write string
  7699. }
  7700. if ctx.IsStringTable() {
  7701. b := ctx.Table.AddOrGet(target.NamespaceUID)
  7702. buff.WriteInt(b) // write table index
  7703. } else {
  7704. buff.WriteString(target.NamespaceUID) // write string
  7705. }
  7706. if ctx.IsStringTable() {
  7707. c := ctx.Table.AddOrGet(target.Name)
  7708. buff.WriteInt(c) // write table index
  7709. } else {
  7710. buff.WriteString(target.Name) // write string
  7711. }
  7712. if target.Spec == nil {
  7713. buff.WriteUInt8(uint8(0)) // write nil byte
  7714. } else {
  7715. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7716. // --- [begin][write][struct](ResourceQuotaSpec) ---
  7717. buff.WriteInt(0) // [compatibility, unused]
  7718. errA := target.Spec.MarshalBinaryWithContext(ctx)
  7719. if errA != nil {
  7720. return errA
  7721. }
  7722. // --- [end][write][struct](ResourceQuotaSpec) ---
  7723. }
  7724. if target.Status == nil {
  7725. buff.WriteUInt8(uint8(0)) // write nil byte
  7726. } else {
  7727. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7728. // --- [begin][write][struct](ResourceQuotaStatus) ---
  7729. buff.WriteInt(0) // [compatibility, unused]
  7730. errB := target.Status.MarshalBinaryWithContext(ctx)
  7731. if errB != nil {
  7732. return errB
  7733. }
  7734. // --- [end][write][struct](ResourceQuotaStatus) ---
  7735. }
  7736. // --- [begin][write][reference](time.Time) ---
  7737. d, errC := target.Start.MarshalBinary()
  7738. if errC != nil {
  7739. return errC
  7740. }
  7741. buff.WriteInt(len(d))
  7742. buff.WriteBytes(d)
  7743. // --- [end][write][reference](time.Time) ---
  7744. // --- [begin][write][reference](time.Time) ---
  7745. e, errD := target.End.MarshalBinary()
  7746. if errD != nil {
  7747. return errD
  7748. }
  7749. buff.WriteInt(len(e))
  7750. buff.WriteBytes(e)
  7751. // --- [end][write][reference](time.Time) ---
  7752. return nil
  7753. }
  7754. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7755. // the ResourceQuota type
  7756. func (target *ResourceQuota) UnmarshalBinary(data []byte) error {
  7757. ctx := NewDecodingContextFromBytes(data)
  7758. defer ctx.Close()
  7759. err := target.UnmarshalBinaryWithContext(ctx)
  7760. if err != nil {
  7761. return err
  7762. }
  7763. return nil
  7764. }
  7765. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  7766. // the ResourceQuota type
  7767. func (target *ResourceQuota) UnmarshalBinaryFromReader(reader io.Reader) error {
  7768. ctx := NewDecodingContextFromReader(reader)
  7769. defer ctx.Close()
  7770. err := target.UnmarshalBinaryWithContext(ctx)
  7771. if err != nil {
  7772. return err
  7773. }
  7774. return nil
  7775. }
  7776. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7777. // the ResourceQuota type
  7778. func (target *ResourceQuota) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7779. // panics are recovered and propagated as errors
  7780. defer func() {
  7781. if r := recover(); r != nil {
  7782. if e, ok := r.(error); ok {
  7783. err = e
  7784. } else if s, ok := r.(string); ok {
  7785. err = fmt.Errorf("unexpected panic: %s", s)
  7786. } else {
  7787. err = fmt.Errorf("unexpected panic: %+v", r)
  7788. }
  7789. }
  7790. }()
  7791. buff := ctx.Buffer
  7792. version := buff.ReadUInt8()
  7793. if version > DefaultCodecVersion {
  7794. return fmt.Errorf("Invalid Version Unmarshalling ResourceQuota. Expected %d or less, got %d", DefaultCodecVersion, version)
  7795. }
  7796. // field version check
  7797. if uint8(1) <= version {
  7798. var b string
  7799. if ctx.IsStringTable() {
  7800. c := buff.ReadInt() // read string index
  7801. b = ctx.Table.At(c)
  7802. } else {
  7803. b = buff.ReadString() // read string
  7804. }
  7805. a := b
  7806. target.UID = a
  7807. } else {
  7808. target.UID = "" // default
  7809. }
  7810. // field version check
  7811. if uint8(1) <= version {
  7812. var e string
  7813. if ctx.IsStringTable() {
  7814. f := buff.ReadInt() // read string index
  7815. e = ctx.Table.At(f)
  7816. } else {
  7817. e = buff.ReadString() // read string
  7818. }
  7819. d := e
  7820. target.NamespaceUID = d
  7821. } else {
  7822. target.NamespaceUID = "" // default
  7823. }
  7824. // field version check
  7825. if uint8(1) <= version {
  7826. var h string
  7827. if ctx.IsStringTable() {
  7828. l := buff.ReadInt() // read string index
  7829. h = ctx.Table.At(l)
  7830. } else {
  7831. h = buff.ReadString() // read string
  7832. }
  7833. g := h
  7834. target.Name = g
  7835. } else {
  7836. target.Name = "" // default
  7837. }
  7838. // field version check
  7839. if uint8(1) <= version {
  7840. if buff.ReadUInt8() == uint8(0) {
  7841. target.Spec = nil
  7842. } else {
  7843. // --- [begin][read][struct](ResourceQuotaSpec) ---
  7844. m := new(ResourceQuotaSpec)
  7845. buff.ReadInt() // [compatibility, unused]
  7846. errA := m.UnmarshalBinaryWithContext(ctx)
  7847. if errA != nil {
  7848. return errA
  7849. }
  7850. target.Spec = m
  7851. // --- [end][read][struct](ResourceQuotaSpec) ---
  7852. }
  7853. } else {
  7854. target.Spec = nil
  7855. }
  7856. // field version check
  7857. if uint8(1) <= version {
  7858. if buff.ReadUInt8() == uint8(0) {
  7859. target.Status = nil
  7860. } else {
  7861. // --- [begin][read][struct](ResourceQuotaStatus) ---
  7862. n := new(ResourceQuotaStatus)
  7863. buff.ReadInt() // [compatibility, unused]
  7864. errB := n.UnmarshalBinaryWithContext(ctx)
  7865. if errB != nil {
  7866. return errB
  7867. }
  7868. target.Status = n
  7869. // --- [end][read][struct](ResourceQuotaStatus) ---
  7870. }
  7871. } else {
  7872. target.Status = nil
  7873. }
  7874. // field version check
  7875. if uint8(1) <= version {
  7876. // --- [begin][read][reference](time.Time) ---
  7877. o := new(time.Time)
  7878. p := buff.ReadInt() // byte array length
  7879. q := buff.ReadBytes(p)
  7880. errC := o.UnmarshalBinary(q)
  7881. if errC != nil {
  7882. return errC
  7883. }
  7884. target.Start = *o
  7885. // --- [end][read][reference](time.Time) ---
  7886. } else {
  7887. }
  7888. // field version check
  7889. if uint8(1) <= version {
  7890. // --- [begin][read][reference](time.Time) ---
  7891. r := new(time.Time)
  7892. s := buff.ReadInt() // byte array length
  7893. t := buff.ReadBytes(s)
  7894. errD := r.UnmarshalBinary(t)
  7895. if errD != nil {
  7896. return errD
  7897. }
  7898. target.End = *r
  7899. // --- [end][read][reference](time.Time) ---
  7900. } else {
  7901. }
  7902. return nil
  7903. }
  7904. //--------------------------------------------------------------------------
  7905. // ResourceQuotaSpec
  7906. //--------------------------------------------------------------------------
  7907. // MarshalBinary serializes the internal properties of this ResourceQuotaSpec instance
  7908. // into a byte array
  7909. func (target *ResourceQuotaSpec) MarshalBinary() (data []byte, err error) {
  7910. ctx := NewEncodingContext(nil)
  7911. e := target.MarshalBinaryWithContext(ctx)
  7912. if e != nil {
  7913. return nil, e
  7914. }
  7915. return ctx.ToBytes(), nil
  7916. }
  7917. // MarshalBinary serializes the internal properties of this ResourceQuotaSpec instance
  7918. // into an io.Writer.
  7919. func (target *ResourceQuotaSpec) MarshalBinaryTo(writer io.Writer) error {
  7920. buff := util.NewBufferFromWriter(writer)
  7921. defer buff.Flush()
  7922. ctx := NewEncodingContextFromBuffer(buff, nil)
  7923. return target.MarshalBinaryWithContext(ctx)
  7924. }
  7925. // MarshalBinaryWithContext serializes the internal properties of this ResourceQuotaSpec instance
  7926. // into a byte array leveraging a predefined context.
  7927. func (target *ResourceQuotaSpec) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  7928. // panics are recovered and propagated as errors
  7929. defer func() {
  7930. if r := recover(); r != nil {
  7931. if e, ok := r.(error); ok {
  7932. err = e
  7933. } else if s, ok := r.(string); ok {
  7934. err = fmt.Errorf("unexpected panic: %s", s)
  7935. } else {
  7936. err = fmt.Errorf("unexpected panic: %+v", r)
  7937. }
  7938. }
  7939. }()
  7940. buff := ctx.Buffer
  7941. buff.WriteUInt8(DefaultCodecVersion) // version
  7942. if target.Hard == nil {
  7943. buff.WriteUInt8(uint8(0)) // write nil byte
  7944. } else {
  7945. buff.WriteUInt8(uint8(1)) // write non-nil byte
  7946. // --- [begin][write][struct](ResourceQuotaSpecHard) ---
  7947. buff.WriteInt(0) // [compatibility, unused]
  7948. errA := target.Hard.MarshalBinaryWithContext(ctx)
  7949. if errA != nil {
  7950. return errA
  7951. }
  7952. // --- [end][write][struct](ResourceQuotaSpecHard) ---
  7953. }
  7954. return nil
  7955. }
  7956. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  7957. // the ResourceQuotaSpec type
  7958. func (target *ResourceQuotaSpec) UnmarshalBinary(data []byte) error {
  7959. ctx := NewDecodingContextFromBytes(data)
  7960. defer ctx.Close()
  7961. err := target.UnmarshalBinaryWithContext(ctx)
  7962. if err != nil {
  7963. return err
  7964. }
  7965. return nil
  7966. }
  7967. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  7968. // the ResourceQuotaSpec type
  7969. func (target *ResourceQuotaSpec) UnmarshalBinaryFromReader(reader io.Reader) error {
  7970. ctx := NewDecodingContextFromReader(reader)
  7971. defer ctx.Close()
  7972. err := target.UnmarshalBinaryWithContext(ctx)
  7973. if err != nil {
  7974. return err
  7975. }
  7976. return nil
  7977. }
  7978. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  7979. // the ResourceQuotaSpec type
  7980. func (target *ResourceQuotaSpec) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  7981. // panics are recovered and propagated as errors
  7982. defer func() {
  7983. if r := recover(); r != nil {
  7984. if e, ok := r.(error); ok {
  7985. err = e
  7986. } else if s, ok := r.(string); ok {
  7987. err = fmt.Errorf("unexpected panic: %s", s)
  7988. } else {
  7989. err = fmt.Errorf("unexpected panic: %+v", r)
  7990. }
  7991. }
  7992. }()
  7993. buff := ctx.Buffer
  7994. version := buff.ReadUInt8()
  7995. if version > DefaultCodecVersion {
  7996. return fmt.Errorf("Invalid Version Unmarshalling ResourceQuotaSpec. Expected %d or less, got %d", DefaultCodecVersion, version)
  7997. }
  7998. // field version check
  7999. if uint8(1) <= version {
  8000. if buff.ReadUInt8() == uint8(0) {
  8001. target.Hard = nil
  8002. } else {
  8003. // --- [begin][read][struct](ResourceQuotaSpecHard) ---
  8004. a := new(ResourceQuotaSpecHard)
  8005. buff.ReadInt() // [compatibility, unused]
  8006. errA := a.UnmarshalBinaryWithContext(ctx)
  8007. if errA != nil {
  8008. return errA
  8009. }
  8010. target.Hard = a
  8011. // --- [end][read][struct](ResourceQuotaSpecHard) ---
  8012. }
  8013. } else {
  8014. target.Hard = nil
  8015. }
  8016. return nil
  8017. }
  8018. //--------------------------------------------------------------------------
  8019. // ResourceQuotaSpecHard
  8020. //--------------------------------------------------------------------------
  8021. // MarshalBinary serializes the internal properties of this ResourceQuotaSpecHard instance
  8022. // into a byte array
  8023. func (target *ResourceQuotaSpecHard) MarshalBinary() (data []byte, err error) {
  8024. ctx := NewEncodingContext(nil)
  8025. e := target.MarshalBinaryWithContext(ctx)
  8026. if e != nil {
  8027. return nil, e
  8028. }
  8029. return ctx.ToBytes(), nil
  8030. }
  8031. // MarshalBinary serializes the internal properties of this ResourceQuotaSpecHard instance
  8032. // into an io.Writer.
  8033. func (target *ResourceQuotaSpecHard) MarshalBinaryTo(writer io.Writer) error {
  8034. buff := util.NewBufferFromWriter(writer)
  8035. defer buff.Flush()
  8036. ctx := NewEncodingContextFromBuffer(buff, nil)
  8037. return target.MarshalBinaryWithContext(ctx)
  8038. }
  8039. // MarshalBinaryWithContext serializes the internal properties of this ResourceQuotaSpecHard instance
  8040. // into a byte array leveraging a predefined context.
  8041. func (target *ResourceQuotaSpecHard) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  8042. // panics are recovered and propagated as errors
  8043. defer func() {
  8044. if r := recover(); r != nil {
  8045. if e, ok := r.(error); ok {
  8046. err = e
  8047. } else if s, ok := r.(string); ok {
  8048. err = fmt.Errorf("unexpected panic: %s", s)
  8049. } else {
  8050. err = fmt.Errorf("unexpected panic: %+v", r)
  8051. }
  8052. }
  8053. }()
  8054. buff := ctx.Buffer
  8055. buff.WriteUInt8(DefaultCodecVersion) // version
  8056. // --- [begin][write][alias](ResourceQuantities) ---
  8057. if map[Resource]ResourceQuantity(target.Requests) == nil {
  8058. buff.WriteUInt8(uint8(0)) // write nil byte
  8059. } else {
  8060. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8061. // --- [begin][write][map](map[Resource]ResourceQuantity) ---
  8062. buff.WriteInt(len(map[Resource]ResourceQuantity(target.Requests))) // map length
  8063. for v, z := range map[Resource]ResourceQuantity(target.Requests) {
  8064. // --- [begin][write][alias](Resource) ---
  8065. if ctx.IsStringTable() {
  8066. a := ctx.Table.AddOrGet(string(v))
  8067. buff.WriteInt(a) // write table index
  8068. } else {
  8069. buff.WriteString(string(v)) // write string
  8070. }
  8071. // --- [end][write][alias](Resource) ---
  8072. // --- [begin][write][struct](ResourceQuantity) ---
  8073. buff.WriteInt(0) // [compatibility, unused]
  8074. errA := z.MarshalBinaryWithContext(ctx)
  8075. if errA != nil {
  8076. return errA
  8077. }
  8078. // --- [end][write][struct](ResourceQuantity) ---
  8079. }
  8080. // --- [end][write][map](map[Resource]ResourceQuantity) ---
  8081. }
  8082. // --- [end][write][alias](ResourceQuantities) ---
  8083. // --- [begin][write][alias](ResourceQuantities) ---
  8084. if map[Resource]ResourceQuantity(target.Limits) == nil {
  8085. buff.WriteUInt8(uint8(0)) // write nil byte
  8086. } else {
  8087. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8088. // --- [begin][write][map](map[Resource]ResourceQuantity) ---
  8089. buff.WriteInt(len(map[Resource]ResourceQuantity(target.Limits))) // map length
  8090. for vv, zz := range map[Resource]ResourceQuantity(target.Limits) {
  8091. // --- [begin][write][alias](Resource) ---
  8092. if ctx.IsStringTable() {
  8093. b := ctx.Table.AddOrGet(string(vv))
  8094. buff.WriteInt(b) // write table index
  8095. } else {
  8096. buff.WriteString(string(vv)) // write string
  8097. }
  8098. // --- [end][write][alias](Resource) ---
  8099. // --- [begin][write][struct](ResourceQuantity) ---
  8100. buff.WriteInt(0) // [compatibility, unused]
  8101. errB := zz.MarshalBinaryWithContext(ctx)
  8102. if errB != nil {
  8103. return errB
  8104. }
  8105. // --- [end][write][struct](ResourceQuantity) ---
  8106. }
  8107. // --- [end][write][map](map[Resource]ResourceQuantity) ---
  8108. }
  8109. // --- [end][write][alias](ResourceQuantities) ---
  8110. return nil
  8111. }
  8112. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  8113. // the ResourceQuotaSpecHard type
  8114. func (target *ResourceQuotaSpecHard) UnmarshalBinary(data []byte) error {
  8115. ctx := NewDecodingContextFromBytes(data)
  8116. defer ctx.Close()
  8117. err := target.UnmarshalBinaryWithContext(ctx)
  8118. if err != nil {
  8119. return err
  8120. }
  8121. return nil
  8122. }
  8123. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  8124. // the ResourceQuotaSpecHard type
  8125. func (target *ResourceQuotaSpecHard) UnmarshalBinaryFromReader(reader io.Reader) error {
  8126. ctx := NewDecodingContextFromReader(reader)
  8127. defer ctx.Close()
  8128. err := target.UnmarshalBinaryWithContext(ctx)
  8129. if err != nil {
  8130. return err
  8131. }
  8132. return nil
  8133. }
  8134. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  8135. // the ResourceQuotaSpecHard type
  8136. func (target *ResourceQuotaSpecHard) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  8137. // panics are recovered and propagated as errors
  8138. defer func() {
  8139. if r := recover(); r != nil {
  8140. if e, ok := r.(error); ok {
  8141. err = e
  8142. } else if s, ok := r.(string); ok {
  8143. err = fmt.Errorf("unexpected panic: %s", s)
  8144. } else {
  8145. err = fmt.Errorf("unexpected panic: %+v", r)
  8146. }
  8147. }
  8148. }()
  8149. buff := ctx.Buffer
  8150. version := buff.ReadUInt8()
  8151. if version > DefaultCodecVersion {
  8152. return fmt.Errorf("Invalid Version Unmarshalling ResourceQuotaSpecHard. Expected %d or less, got %d", DefaultCodecVersion, version)
  8153. }
  8154. // field version check
  8155. if uint8(1) <= version {
  8156. // --- [begin][read][alias](ResourceQuantities) ---
  8157. var a map[Resource]ResourceQuantity
  8158. if buff.ReadUInt8() == uint8(0) {
  8159. a = nil
  8160. } else {
  8161. // --- [begin][read][map](map[Resource]ResourceQuantity) ---
  8162. c := buff.ReadInt() // map len
  8163. b := make(map[Resource]ResourceQuantity, c)
  8164. for range c {
  8165. // --- [begin][read][alias](Resource) ---
  8166. var d string
  8167. var f string
  8168. if ctx.IsStringTable() {
  8169. g := buff.ReadInt() // read string index
  8170. f = ctx.Table.At(g)
  8171. } else {
  8172. f = buff.ReadString() // read string
  8173. }
  8174. e := f
  8175. d = e
  8176. v := Resource(d)
  8177. // --- [end][read][alias](Resource) ---
  8178. // --- [begin][read][struct](ResourceQuantity) ---
  8179. h := new(ResourceQuantity)
  8180. buff.ReadInt() // [compatibility, unused]
  8181. errA := h.UnmarshalBinaryWithContext(ctx)
  8182. if errA != nil {
  8183. return errA
  8184. }
  8185. z := *h
  8186. // --- [end][read][struct](ResourceQuantity) ---
  8187. b[v] = z
  8188. }
  8189. a = b
  8190. // --- [end][read][map](map[Resource]ResourceQuantity) ---
  8191. }
  8192. target.Requests = ResourceQuantities(a)
  8193. // --- [end][read][alias](ResourceQuantities) ---
  8194. } else {
  8195. }
  8196. // field version check
  8197. if uint8(1) <= version {
  8198. // --- [begin][read][alias](ResourceQuantities) ---
  8199. var l map[Resource]ResourceQuantity
  8200. if buff.ReadUInt8() == uint8(0) {
  8201. l = nil
  8202. } else {
  8203. // --- [begin][read][map](map[Resource]ResourceQuantity) ---
  8204. n := buff.ReadInt() // map len
  8205. m := make(map[Resource]ResourceQuantity, n)
  8206. for range n {
  8207. // --- [begin][read][alias](Resource) ---
  8208. var o string
  8209. var q string
  8210. if ctx.IsStringTable() {
  8211. r := buff.ReadInt() // read string index
  8212. q = ctx.Table.At(r)
  8213. } else {
  8214. q = buff.ReadString() // read string
  8215. }
  8216. p := q
  8217. o = p
  8218. vv := Resource(o)
  8219. // --- [end][read][alias](Resource) ---
  8220. // --- [begin][read][struct](ResourceQuantity) ---
  8221. s := new(ResourceQuantity)
  8222. buff.ReadInt() // [compatibility, unused]
  8223. errB := s.UnmarshalBinaryWithContext(ctx)
  8224. if errB != nil {
  8225. return errB
  8226. }
  8227. zz := *s
  8228. // --- [end][read][struct](ResourceQuantity) ---
  8229. m[vv] = zz
  8230. }
  8231. l = m
  8232. // --- [end][read][map](map[Resource]ResourceQuantity) ---
  8233. }
  8234. target.Limits = ResourceQuantities(l)
  8235. // --- [end][read][alias](ResourceQuantities) ---
  8236. } else {
  8237. }
  8238. return nil
  8239. }
  8240. //--------------------------------------------------------------------------
  8241. // ResourceQuotaStatus
  8242. //--------------------------------------------------------------------------
  8243. // MarshalBinary serializes the internal properties of this ResourceQuotaStatus instance
  8244. // into a byte array
  8245. func (target *ResourceQuotaStatus) MarshalBinary() (data []byte, err error) {
  8246. ctx := NewEncodingContext(nil)
  8247. e := target.MarshalBinaryWithContext(ctx)
  8248. if e != nil {
  8249. return nil, e
  8250. }
  8251. return ctx.ToBytes(), nil
  8252. }
  8253. // MarshalBinary serializes the internal properties of this ResourceQuotaStatus instance
  8254. // into an io.Writer.
  8255. func (target *ResourceQuotaStatus) MarshalBinaryTo(writer io.Writer) error {
  8256. buff := util.NewBufferFromWriter(writer)
  8257. defer buff.Flush()
  8258. ctx := NewEncodingContextFromBuffer(buff, nil)
  8259. return target.MarshalBinaryWithContext(ctx)
  8260. }
  8261. // MarshalBinaryWithContext serializes the internal properties of this ResourceQuotaStatus instance
  8262. // into a byte array leveraging a predefined context.
  8263. func (target *ResourceQuotaStatus) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  8264. // panics are recovered and propagated as errors
  8265. defer func() {
  8266. if r := recover(); r != nil {
  8267. if e, ok := r.(error); ok {
  8268. err = e
  8269. } else if s, ok := r.(string); ok {
  8270. err = fmt.Errorf("unexpected panic: %s", s)
  8271. } else {
  8272. err = fmt.Errorf("unexpected panic: %+v", r)
  8273. }
  8274. }
  8275. }()
  8276. buff := ctx.Buffer
  8277. buff.WriteUInt8(DefaultCodecVersion) // version
  8278. if target.Used == nil {
  8279. buff.WriteUInt8(uint8(0)) // write nil byte
  8280. } else {
  8281. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8282. // --- [begin][write][struct](ResourceQuotaStatusUsed) ---
  8283. buff.WriteInt(0) // [compatibility, unused]
  8284. errA := target.Used.MarshalBinaryWithContext(ctx)
  8285. if errA != nil {
  8286. return errA
  8287. }
  8288. // --- [end][write][struct](ResourceQuotaStatusUsed) ---
  8289. }
  8290. return nil
  8291. }
  8292. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  8293. // the ResourceQuotaStatus type
  8294. func (target *ResourceQuotaStatus) UnmarshalBinary(data []byte) error {
  8295. ctx := NewDecodingContextFromBytes(data)
  8296. defer ctx.Close()
  8297. err := target.UnmarshalBinaryWithContext(ctx)
  8298. if err != nil {
  8299. return err
  8300. }
  8301. return nil
  8302. }
  8303. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  8304. // the ResourceQuotaStatus type
  8305. func (target *ResourceQuotaStatus) UnmarshalBinaryFromReader(reader io.Reader) error {
  8306. ctx := NewDecodingContextFromReader(reader)
  8307. defer ctx.Close()
  8308. err := target.UnmarshalBinaryWithContext(ctx)
  8309. if err != nil {
  8310. return err
  8311. }
  8312. return nil
  8313. }
  8314. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  8315. // the ResourceQuotaStatus type
  8316. func (target *ResourceQuotaStatus) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  8317. // panics are recovered and propagated as errors
  8318. defer func() {
  8319. if r := recover(); r != nil {
  8320. if e, ok := r.(error); ok {
  8321. err = e
  8322. } else if s, ok := r.(string); ok {
  8323. err = fmt.Errorf("unexpected panic: %s", s)
  8324. } else {
  8325. err = fmt.Errorf("unexpected panic: %+v", r)
  8326. }
  8327. }
  8328. }()
  8329. buff := ctx.Buffer
  8330. version := buff.ReadUInt8()
  8331. if version > DefaultCodecVersion {
  8332. return fmt.Errorf("Invalid Version Unmarshalling ResourceQuotaStatus. Expected %d or less, got %d", DefaultCodecVersion, version)
  8333. }
  8334. // field version check
  8335. if uint8(1) <= version {
  8336. if buff.ReadUInt8() == uint8(0) {
  8337. target.Used = nil
  8338. } else {
  8339. // --- [begin][read][struct](ResourceQuotaStatusUsed) ---
  8340. a := new(ResourceQuotaStatusUsed)
  8341. buff.ReadInt() // [compatibility, unused]
  8342. errA := a.UnmarshalBinaryWithContext(ctx)
  8343. if errA != nil {
  8344. return errA
  8345. }
  8346. target.Used = a
  8347. // --- [end][read][struct](ResourceQuotaStatusUsed) ---
  8348. }
  8349. } else {
  8350. target.Used = nil
  8351. }
  8352. return nil
  8353. }
  8354. //--------------------------------------------------------------------------
  8355. // ResourceQuotaStatusUsed
  8356. //--------------------------------------------------------------------------
  8357. // MarshalBinary serializes the internal properties of this ResourceQuotaStatusUsed instance
  8358. // into a byte array
  8359. func (target *ResourceQuotaStatusUsed) MarshalBinary() (data []byte, err error) {
  8360. ctx := NewEncodingContext(nil)
  8361. e := target.MarshalBinaryWithContext(ctx)
  8362. if e != nil {
  8363. return nil, e
  8364. }
  8365. return ctx.ToBytes(), nil
  8366. }
  8367. // MarshalBinary serializes the internal properties of this ResourceQuotaStatusUsed instance
  8368. // into an io.Writer.
  8369. func (target *ResourceQuotaStatusUsed) MarshalBinaryTo(writer io.Writer) error {
  8370. buff := util.NewBufferFromWriter(writer)
  8371. defer buff.Flush()
  8372. ctx := NewEncodingContextFromBuffer(buff, nil)
  8373. return target.MarshalBinaryWithContext(ctx)
  8374. }
  8375. // MarshalBinaryWithContext serializes the internal properties of this ResourceQuotaStatusUsed instance
  8376. // into a byte array leveraging a predefined context.
  8377. func (target *ResourceQuotaStatusUsed) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  8378. // panics are recovered and propagated as errors
  8379. defer func() {
  8380. if r := recover(); r != nil {
  8381. if e, ok := r.(error); ok {
  8382. err = e
  8383. } else if s, ok := r.(string); ok {
  8384. err = fmt.Errorf("unexpected panic: %s", s)
  8385. } else {
  8386. err = fmt.Errorf("unexpected panic: %+v", r)
  8387. }
  8388. }
  8389. }()
  8390. buff := ctx.Buffer
  8391. buff.WriteUInt8(DefaultCodecVersion) // version
  8392. // --- [begin][write][alias](ResourceQuantities) ---
  8393. if map[Resource]ResourceQuantity(target.Requests) == nil {
  8394. buff.WriteUInt8(uint8(0)) // write nil byte
  8395. } else {
  8396. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8397. // --- [begin][write][map](map[Resource]ResourceQuantity) ---
  8398. buff.WriteInt(len(map[Resource]ResourceQuantity(target.Requests))) // map length
  8399. for v, z := range map[Resource]ResourceQuantity(target.Requests) {
  8400. // --- [begin][write][alias](Resource) ---
  8401. if ctx.IsStringTable() {
  8402. a := ctx.Table.AddOrGet(string(v))
  8403. buff.WriteInt(a) // write table index
  8404. } else {
  8405. buff.WriteString(string(v)) // write string
  8406. }
  8407. // --- [end][write][alias](Resource) ---
  8408. // --- [begin][write][struct](ResourceQuantity) ---
  8409. buff.WriteInt(0) // [compatibility, unused]
  8410. errA := z.MarshalBinaryWithContext(ctx)
  8411. if errA != nil {
  8412. return errA
  8413. }
  8414. // --- [end][write][struct](ResourceQuantity) ---
  8415. }
  8416. // --- [end][write][map](map[Resource]ResourceQuantity) ---
  8417. }
  8418. // --- [end][write][alias](ResourceQuantities) ---
  8419. // --- [begin][write][alias](ResourceQuantities) ---
  8420. if map[Resource]ResourceQuantity(target.Limits) == nil {
  8421. buff.WriteUInt8(uint8(0)) // write nil byte
  8422. } else {
  8423. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8424. // --- [begin][write][map](map[Resource]ResourceQuantity) ---
  8425. buff.WriteInt(len(map[Resource]ResourceQuantity(target.Limits))) // map length
  8426. for vv, zz := range map[Resource]ResourceQuantity(target.Limits) {
  8427. // --- [begin][write][alias](Resource) ---
  8428. if ctx.IsStringTable() {
  8429. b := ctx.Table.AddOrGet(string(vv))
  8430. buff.WriteInt(b) // write table index
  8431. } else {
  8432. buff.WriteString(string(vv)) // write string
  8433. }
  8434. // --- [end][write][alias](Resource) ---
  8435. // --- [begin][write][struct](ResourceQuantity) ---
  8436. buff.WriteInt(0) // [compatibility, unused]
  8437. errB := zz.MarshalBinaryWithContext(ctx)
  8438. if errB != nil {
  8439. return errB
  8440. }
  8441. // --- [end][write][struct](ResourceQuantity) ---
  8442. }
  8443. // --- [end][write][map](map[Resource]ResourceQuantity) ---
  8444. }
  8445. // --- [end][write][alias](ResourceQuantities) ---
  8446. return nil
  8447. }
  8448. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  8449. // the ResourceQuotaStatusUsed type
  8450. func (target *ResourceQuotaStatusUsed) UnmarshalBinary(data []byte) error {
  8451. ctx := NewDecodingContextFromBytes(data)
  8452. defer ctx.Close()
  8453. err := target.UnmarshalBinaryWithContext(ctx)
  8454. if err != nil {
  8455. return err
  8456. }
  8457. return nil
  8458. }
  8459. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  8460. // the ResourceQuotaStatusUsed type
  8461. func (target *ResourceQuotaStatusUsed) UnmarshalBinaryFromReader(reader io.Reader) error {
  8462. ctx := NewDecodingContextFromReader(reader)
  8463. defer ctx.Close()
  8464. err := target.UnmarshalBinaryWithContext(ctx)
  8465. if err != nil {
  8466. return err
  8467. }
  8468. return nil
  8469. }
  8470. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  8471. // the ResourceQuotaStatusUsed type
  8472. func (target *ResourceQuotaStatusUsed) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  8473. // panics are recovered and propagated as errors
  8474. defer func() {
  8475. if r := recover(); r != nil {
  8476. if e, ok := r.(error); ok {
  8477. err = e
  8478. } else if s, ok := r.(string); ok {
  8479. err = fmt.Errorf("unexpected panic: %s", s)
  8480. } else {
  8481. err = fmt.Errorf("unexpected panic: %+v", r)
  8482. }
  8483. }
  8484. }()
  8485. buff := ctx.Buffer
  8486. version := buff.ReadUInt8()
  8487. if version > DefaultCodecVersion {
  8488. return fmt.Errorf("Invalid Version Unmarshalling ResourceQuotaStatusUsed. Expected %d or less, got %d", DefaultCodecVersion, version)
  8489. }
  8490. // field version check
  8491. if uint8(1) <= version {
  8492. // --- [begin][read][alias](ResourceQuantities) ---
  8493. var a map[Resource]ResourceQuantity
  8494. if buff.ReadUInt8() == uint8(0) {
  8495. a = nil
  8496. } else {
  8497. // --- [begin][read][map](map[Resource]ResourceQuantity) ---
  8498. c := buff.ReadInt() // map len
  8499. b := make(map[Resource]ResourceQuantity, c)
  8500. for range c {
  8501. // --- [begin][read][alias](Resource) ---
  8502. var d string
  8503. var f string
  8504. if ctx.IsStringTable() {
  8505. g := buff.ReadInt() // read string index
  8506. f = ctx.Table.At(g)
  8507. } else {
  8508. f = buff.ReadString() // read string
  8509. }
  8510. e := f
  8511. d = e
  8512. v := Resource(d)
  8513. // --- [end][read][alias](Resource) ---
  8514. // --- [begin][read][struct](ResourceQuantity) ---
  8515. h := new(ResourceQuantity)
  8516. buff.ReadInt() // [compatibility, unused]
  8517. errA := h.UnmarshalBinaryWithContext(ctx)
  8518. if errA != nil {
  8519. return errA
  8520. }
  8521. z := *h
  8522. // --- [end][read][struct](ResourceQuantity) ---
  8523. b[v] = z
  8524. }
  8525. a = b
  8526. // --- [end][read][map](map[Resource]ResourceQuantity) ---
  8527. }
  8528. target.Requests = ResourceQuantities(a)
  8529. // --- [end][read][alias](ResourceQuantities) ---
  8530. } else {
  8531. }
  8532. // field version check
  8533. if uint8(1) <= version {
  8534. // --- [begin][read][alias](ResourceQuantities) ---
  8535. var l map[Resource]ResourceQuantity
  8536. if buff.ReadUInt8() == uint8(0) {
  8537. l = nil
  8538. } else {
  8539. // --- [begin][read][map](map[Resource]ResourceQuantity) ---
  8540. n := buff.ReadInt() // map len
  8541. m := make(map[Resource]ResourceQuantity, n)
  8542. for range n {
  8543. // --- [begin][read][alias](Resource) ---
  8544. var o string
  8545. var q string
  8546. if ctx.IsStringTable() {
  8547. r := buff.ReadInt() // read string index
  8548. q = ctx.Table.At(r)
  8549. } else {
  8550. q = buff.ReadString() // read string
  8551. }
  8552. p := q
  8553. o = p
  8554. vv := Resource(o)
  8555. // --- [end][read][alias](Resource) ---
  8556. // --- [begin][read][struct](ResourceQuantity) ---
  8557. s := new(ResourceQuantity)
  8558. buff.ReadInt() // [compatibility, unused]
  8559. errB := s.UnmarshalBinaryWithContext(ctx)
  8560. if errB != nil {
  8561. return errB
  8562. }
  8563. zz := *s
  8564. // --- [end][read][struct](ResourceQuantity) ---
  8565. m[vv] = zz
  8566. }
  8567. l = m
  8568. // --- [end][read][map](map[Resource]ResourceQuantity) ---
  8569. }
  8570. target.Limits = ResourceQuantities(l)
  8571. // --- [end][read][alias](ResourceQuantities) ---
  8572. } else {
  8573. }
  8574. return nil
  8575. }
  8576. //--------------------------------------------------------------------------
  8577. // Service
  8578. //--------------------------------------------------------------------------
  8579. // MarshalBinary serializes the internal properties of this Service instance
  8580. // into a byte array
  8581. func (target *Service) MarshalBinary() (data []byte, err error) {
  8582. ctx := NewEncodingContext(nil)
  8583. e := target.MarshalBinaryWithContext(ctx)
  8584. if e != nil {
  8585. return nil, e
  8586. }
  8587. return ctx.ToBytes(), nil
  8588. }
  8589. // MarshalBinary serializes the internal properties of this Service instance
  8590. // into an io.Writer.
  8591. func (target *Service) MarshalBinaryTo(writer io.Writer) error {
  8592. buff := util.NewBufferFromWriter(writer)
  8593. defer buff.Flush()
  8594. ctx := NewEncodingContextFromBuffer(buff, nil)
  8595. return target.MarshalBinaryWithContext(ctx)
  8596. }
  8597. // MarshalBinaryWithContext serializes the internal properties of this Service instance
  8598. // into a byte array leveraging a predefined context.
  8599. func (target *Service) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  8600. // panics are recovered and propagated as errors
  8601. defer func() {
  8602. if r := recover(); r != nil {
  8603. if e, ok := r.(error); ok {
  8604. err = e
  8605. } else if s, ok := r.(string); ok {
  8606. err = fmt.Errorf("unexpected panic: %s", s)
  8607. } else {
  8608. err = fmt.Errorf("unexpected panic: %+v", r)
  8609. }
  8610. }
  8611. }()
  8612. buff := ctx.Buffer
  8613. buff.WriteUInt8(DefaultCodecVersion) // version
  8614. if ctx.IsStringTable() {
  8615. a := ctx.Table.AddOrGet(target.UID)
  8616. buff.WriteInt(a) // write table index
  8617. } else {
  8618. buff.WriteString(target.UID) // write string
  8619. }
  8620. if ctx.IsStringTable() {
  8621. b := ctx.Table.AddOrGet(target.NamespaceUID)
  8622. buff.WriteInt(b) // write table index
  8623. } else {
  8624. buff.WriteString(target.NamespaceUID) // write string
  8625. }
  8626. if ctx.IsStringTable() {
  8627. c := ctx.Table.AddOrGet(target.Name)
  8628. buff.WriteInt(c) // write table index
  8629. } else {
  8630. buff.WriteString(target.Name) // write string
  8631. }
  8632. // --- [begin][write][alias](ServiceType) ---
  8633. if ctx.IsStringTable() {
  8634. d := ctx.Table.AddOrGet(string(target.Type))
  8635. buff.WriteInt(d) // write table index
  8636. } else {
  8637. buff.WriteString(string(target.Type)) // write string
  8638. }
  8639. // --- [end][write][alias](ServiceType) ---
  8640. // --- [begin][write][reference](time.Time) ---
  8641. e, errA := target.Start.MarshalBinary()
  8642. if errA != nil {
  8643. return errA
  8644. }
  8645. buff.WriteInt(len(e))
  8646. buff.WriteBytes(e)
  8647. // --- [end][write][reference](time.Time) ---
  8648. // --- [begin][write][reference](time.Time) ---
  8649. f, errB := target.End.MarshalBinary()
  8650. if errB != nil {
  8651. return errB
  8652. }
  8653. buff.WriteInt(len(f))
  8654. buff.WriteBytes(f)
  8655. // --- [end][write][reference](time.Time) ---
  8656. if target.Selector == nil {
  8657. buff.WriteUInt8(uint8(0)) // write nil byte
  8658. } else {
  8659. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8660. // --- [begin][write][map](map[string]string) ---
  8661. buff.WriteInt(len(target.Selector)) // map length
  8662. for v, z := range target.Selector {
  8663. if ctx.IsStringTable() {
  8664. g := ctx.Table.AddOrGet(v)
  8665. buff.WriteInt(g) // write table index
  8666. } else {
  8667. buff.WriteString(v) // write string
  8668. }
  8669. if ctx.IsStringTable() {
  8670. h := ctx.Table.AddOrGet(z)
  8671. buff.WriteInt(h) // write table index
  8672. } else {
  8673. buff.WriteString(z) // write string
  8674. }
  8675. }
  8676. // --- [end][write][map](map[string]string) ---
  8677. }
  8678. if ctx.IsStringTable() {
  8679. l := ctx.Table.AddOrGet(target.LBIngressAddress)
  8680. buff.WriteInt(l) // write table index
  8681. } else {
  8682. buff.WriteString(target.LBIngressAddress) // write string
  8683. }
  8684. return nil
  8685. }
  8686. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  8687. // the Service type
  8688. func (target *Service) UnmarshalBinary(data []byte) error {
  8689. ctx := NewDecodingContextFromBytes(data)
  8690. defer ctx.Close()
  8691. err := target.UnmarshalBinaryWithContext(ctx)
  8692. if err != nil {
  8693. return err
  8694. }
  8695. return nil
  8696. }
  8697. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  8698. // the Service type
  8699. func (target *Service) UnmarshalBinaryFromReader(reader io.Reader) error {
  8700. ctx := NewDecodingContextFromReader(reader)
  8701. defer ctx.Close()
  8702. err := target.UnmarshalBinaryWithContext(ctx)
  8703. if err != nil {
  8704. return err
  8705. }
  8706. return nil
  8707. }
  8708. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  8709. // the Service type
  8710. func (target *Service) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  8711. // panics are recovered and propagated as errors
  8712. defer func() {
  8713. if r := recover(); r != nil {
  8714. if e, ok := r.(error); ok {
  8715. err = e
  8716. } else if s, ok := r.(string); ok {
  8717. err = fmt.Errorf("unexpected panic: %s", s)
  8718. } else {
  8719. err = fmt.Errorf("unexpected panic: %+v", r)
  8720. }
  8721. }
  8722. }()
  8723. buff := ctx.Buffer
  8724. version := buff.ReadUInt8()
  8725. if version > DefaultCodecVersion {
  8726. return fmt.Errorf("Invalid Version Unmarshalling Service. Expected %d or less, got %d", DefaultCodecVersion, version)
  8727. }
  8728. var b string
  8729. if ctx.IsStringTable() {
  8730. c := buff.ReadInt() // read string index
  8731. b = ctx.Table.At(c)
  8732. } else {
  8733. b = buff.ReadString() // read string
  8734. }
  8735. a := b
  8736. target.UID = a
  8737. var e string
  8738. if ctx.IsStringTable() {
  8739. f := buff.ReadInt() // read string index
  8740. e = ctx.Table.At(f)
  8741. } else {
  8742. e = buff.ReadString() // read string
  8743. }
  8744. d := e
  8745. target.NamespaceUID = d
  8746. var h string
  8747. if ctx.IsStringTable() {
  8748. l := buff.ReadInt() // read string index
  8749. h = ctx.Table.At(l)
  8750. } else {
  8751. h = buff.ReadString() // read string
  8752. }
  8753. g := h
  8754. target.Name = g
  8755. // --- [begin][read][alias](ServiceType) ---
  8756. var m string
  8757. var o string
  8758. if ctx.IsStringTable() {
  8759. p := buff.ReadInt() // read string index
  8760. o = ctx.Table.At(p)
  8761. } else {
  8762. o = buff.ReadString() // read string
  8763. }
  8764. n := o
  8765. m = n
  8766. target.Type = ServiceType(m)
  8767. // --- [end][read][alias](ServiceType) ---
  8768. // --- [begin][read][reference](time.Time) ---
  8769. q := new(time.Time)
  8770. r := buff.ReadInt() // byte array length
  8771. s := buff.ReadBytes(r)
  8772. errA := q.UnmarshalBinary(s)
  8773. if errA != nil {
  8774. return errA
  8775. }
  8776. target.Start = *q
  8777. // --- [end][read][reference](time.Time) ---
  8778. // --- [begin][read][reference](time.Time) ---
  8779. t := new(time.Time)
  8780. u := buff.ReadInt() // byte array length
  8781. w := buff.ReadBytes(u)
  8782. errB := t.UnmarshalBinary(w)
  8783. if errB != nil {
  8784. return errB
  8785. }
  8786. target.End = *t
  8787. // --- [end][read][reference](time.Time) ---
  8788. if buff.ReadUInt8() == uint8(0) {
  8789. target.Selector = nil
  8790. } else {
  8791. // --- [begin][read][map](map[string]string) ---
  8792. y := buff.ReadInt() // map len
  8793. x := make(map[string]string, y)
  8794. for range y {
  8795. var v string
  8796. var bb string
  8797. if ctx.IsStringTable() {
  8798. cc := buff.ReadInt() // read string index
  8799. bb = ctx.Table.At(cc)
  8800. } else {
  8801. bb = buff.ReadString() // read string
  8802. }
  8803. aa := bb
  8804. v = aa
  8805. var z string
  8806. var ee string
  8807. if ctx.IsStringTable() {
  8808. ff := buff.ReadInt() // read string index
  8809. ee = ctx.Table.At(ff)
  8810. } else {
  8811. ee = buff.ReadString() // read string
  8812. }
  8813. dd := ee
  8814. z = dd
  8815. x[v] = z
  8816. }
  8817. target.Selector = x
  8818. // --- [end][read][map](map[string]string) ---
  8819. }
  8820. var hh string
  8821. if ctx.IsStringTable() {
  8822. ll := buff.ReadInt() // read string index
  8823. hh = ctx.Table.At(ll)
  8824. } else {
  8825. hh = buff.ReadString() // read string
  8826. }
  8827. gg := hh
  8828. target.LBIngressAddress = gg
  8829. return nil
  8830. }
  8831. //--------------------------------------------------------------------------
  8832. // StatefulSet
  8833. //--------------------------------------------------------------------------
  8834. // MarshalBinary serializes the internal properties of this StatefulSet instance
  8835. // into a byte array
  8836. func (target *StatefulSet) MarshalBinary() (data []byte, err error) {
  8837. ctx := NewEncodingContext(nil)
  8838. e := target.MarshalBinaryWithContext(ctx)
  8839. if e != nil {
  8840. return nil, e
  8841. }
  8842. return ctx.ToBytes(), nil
  8843. }
  8844. // MarshalBinary serializes the internal properties of this StatefulSet instance
  8845. // into an io.Writer.
  8846. func (target *StatefulSet) MarshalBinaryTo(writer io.Writer) error {
  8847. buff := util.NewBufferFromWriter(writer)
  8848. defer buff.Flush()
  8849. ctx := NewEncodingContextFromBuffer(buff, nil)
  8850. return target.MarshalBinaryWithContext(ctx)
  8851. }
  8852. // MarshalBinaryWithContext serializes the internal properties of this StatefulSet instance
  8853. // into a byte array leveraging a predefined context.
  8854. func (target *StatefulSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  8855. // panics are recovered and propagated as errors
  8856. defer func() {
  8857. if r := recover(); r != nil {
  8858. if e, ok := r.(error); ok {
  8859. err = e
  8860. } else if s, ok := r.(string); ok {
  8861. err = fmt.Errorf("unexpected panic: %s", s)
  8862. } else {
  8863. err = fmt.Errorf("unexpected panic: %+v", r)
  8864. }
  8865. }
  8866. }()
  8867. buff := ctx.Buffer
  8868. buff.WriteUInt8(DefaultCodecVersion) // version
  8869. if ctx.IsStringTable() {
  8870. a := ctx.Table.AddOrGet(target.UID)
  8871. buff.WriteInt(a) // write table index
  8872. } else {
  8873. buff.WriteString(target.UID) // write string
  8874. }
  8875. if ctx.IsStringTable() {
  8876. b := ctx.Table.AddOrGet(target.NamespaceUID)
  8877. buff.WriteInt(b) // write table index
  8878. } else {
  8879. buff.WriteString(target.NamespaceUID) // write string
  8880. }
  8881. if ctx.IsStringTable() {
  8882. c := ctx.Table.AddOrGet(target.Name)
  8883. buff.WriteInt(c) // write table index
  8884. } else {
  8885. buff.WriteString(target.Name) // write string
  8886. }
  8887. if target.Labels == nil {
  8888. buff.WriteUInt8(uint8(0)) // write nil byte
  8889. } else {
  8890. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8891. // --- [begin][write][map](map[string]string) ---
  8892. buff.WriteInt(len(target.Labels)) // map length
  8893. for v, z := range target.Labels {
  8894. if ctx.IsStringTable() {
  8895. d := ctx.Table.AddOrGet(v)
  8896. buff.WriteInt(d) // write table index
  8897. } else {
  8898. buff.WriteString(v) // write string
  8899. }
  8900. if ctx.IsStringTable() {
  8901. e := ctx.Table.AddOrGet(z)
  8902. buff.WriteInt(e) // write table index
  8903. } else {
  8904. buff.WriteString(z) // write string
  8905. }
  8906. }
  8907. // --- [end][write][map](map[string]string) ---
  8908. }
  8909. if target.Annotations == nil {
  8910. buff.WriteUInt8(uint8(0)) // write nil byte
  8911. } else {
  8912. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8913. // --- [begin][write][map](map[string]string) ---
  8914. buff.WriteInt(len(target.Annotations)) // map length
  8915. for vv, zz := range target.Annotations {
  8916. if ctx.IsStringTable() {
  8917. f := ctx.Table.AddOrGet(vv)
  8918. buff.WriteInt(f) // write table index
  8919. } else {
  8920. buff.WriteString(vv) // write string
  8921. }
  8922. if ctx.IsStringTable() {
  8923. g := ctx.Table.AddOrGet(zz)
  8924. buff.WriteInt(g) // write table index
  8925. } else {
  8926. buff.WriteString(zz) // write string
  8927. }
  8928. }
  8929. // --- [end][write][map](map[string]string) ---
  8930. }
  8931. if target.MatchLabels == nil {
  8932. buff.WriteUInt8(uint8(0)) // write nil byte
  8933. } else {
  8934. buff.WriteUInt8(uint8(1)) // write non-nil byte
  8935. // --- [begin][write][map](map[string]string) ---
  8936. buff.WriteInt(len(target.MatchLabels)) // map length
  8937. for vvv, zzz := range target.MatchLabels {
  8938. if ctx.IsStringTable() {
  8939. h := ctx.Table.AddOrGet(vvv)
  8940. buff.WriteInt(h) // write table index
  8941. } else {
  8942. buff.WriteString(vvv) // write string
  8943. }
  8944. if ctx.IsStringTable() {
  8945. l := ctx.Table.AddOrGet(zzz)
  8946. buff.WriteInt(l) // write table index
  8947. } else {
  8948. buff.WriteString(zzz) // write string
  8949. }
  8950. }
  8951. // --- [end][write][map](map[string]string) ---
  8952. }
  8953. // --- [begin][write][reference](time.Time) ---
  8954. m, errA := target.Start.MarshalBinary()
  8955. if errA != nil {
  8956. return errA
  8957. }
  8958. buff.WriteInt(len(m))
  8959. buff.WriteBytes(m)
  8960. // --- [end][write][reference](time.Time) ---
  8961. // --- [begin][write][reference](time.Time) ---
  8962. n, errB := target.End.MarshalBinary()
  8963. if errB != nil {
  8964. return errB
  8965. }
  8966. buff.WriteInt(len(n))
  8967. buff.WriteBytes(n)
  8968. // --- [end][write][reference](time.Time) ---
  8969. return nil
  8970. }
  8971. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  8972. // the StatefulSet type
  8973. func (target *StatefulSet) UnmarshalBinary(data []byte) error {
  8974. ctx := NewDecodingContextFromBytes(data)
  8975. defer ctx.Close()
  8976. err := target.UnmarshalBinaryWithContext(ctx)
  8977. if err != nil {
  8978. return err
  8979. }
  8980. return nil
  8981. }
  8982. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  8983. // the StatefulSet type
  8984. func (target *StatefulSet) UnmarshalBinaryFromReader(reader io.Reader) error {
  8985. ctx := NewDecodingContextFromReader(reader)
  8986. defer ctx.Close()
  8987. err := target.UnmarshalBinaryWithContext(ctx)
  8988. if err != nil {
  8989. return err
  8990. }
  8991. return nil
  8992. }
  8993. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  8994. // the StatefulSet type
  8995. func (target *StatefulSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  8996. // panics are recovered and propagated as errors
  8997. defer func() {
  8998. if r := recover(); r != nil {
  8999. if e, ok := r.(error); ok {
  9000. err = e
  9001. } else if s, ok := r.(string); ok {
  9002. err = fmt.Errorf("unexpected panic: %s", s)
  9003. } else {
  9004. err = fmt.Errorf("unexpected panic: %+v", r)
  9005. }
  9006. }
  9007. }()
  9008. buff := ctx.Buffer
  9009. version := buff.ReadUInt8()
  9010. if version > DefaultCodecVersion {
  9011. return fmt.Errorf("Invalid Version Unmarshalling StatefulSet. Expected %d or less, got %d", DefaultCodecVersion, version)
  9012. }
  9013. var b string
  9014. if ctx.IsStringTable() {
  9015. c := buff.ReadInt() // read string index
  9016. b = ctx.Table.At(c)
  9017. } else {
  9018. b = buff.ReadString() // read string
  9019. }
  9020. a := b
  9021. target.UID = a
  9022. var e string
  9023. if ctx.IsStringTable() {
  9024. f := buff.ReadInt() // read string index
  9025. e = ctx.Table.At(f)
  9026. } else {
  9027. e = buff.ReadString() // read string
  9028. }
  9029. d := e
  9030. target.NamespaceUID = d
  9031. var h string
  9032. if ctx.IsStringTable() {
  9033. l := buff.ReadInt() // read string index
  9034. h = ctx.Table.At(l)
  9035. } else {
  9036. h = buff.ReadString() // read string
  9037. }
  9038. g := h
  9039. target.Name = g
  9040. if buff.ReadUInt8() == uint8(0) {
  9041. target.Labels = nil
  9042. } else {
  9043. // --- [begin][read][map](map[string]string) ---
  9044. n := buff.ReadInt() // map len
  9045. m := make(map[string]string, n)
  9046. for range n {
  9047. var v string
  9048. var p string
  9049. if ctx.IsStringTable() {
  9050. q := buff.ReadInt() // read string index
  9051. p = ctx.Table.At(q)
  9052. } else {
  9053. p = buff.ReadString() // read string
  9054. }
  9055. o := p
  9056. v = o
  9057. var z string
  9058. var s string
  9059. if ctx.IsStringTable() {
  9060. t := buff.ReadInt() // read string index
  9061. s = ctx.Table.At(t)
  9062. } else {
  9063. s = buff.ReadString() // read string
  9064. }
  9065. r := s
  9066. z = r
  9067. m[v] = z
  9068. }
  9069. target.Labels = m
  9070. // --- [end][read][map](map[string]string) ---
  9071. }
  9072. if buff.ReadUInt8() == uint8(0) {
  9073. target.Annotations = nil
  9074. } else {
  9075. // --- [begin][read][map](map[string]string) ---
  9076. w := buff.ReadInt() // map len
  9077. u := make(map[string]string, w)
  9078. for range w {
  9079. var vv string
  9080. var y string
  9081. if ctx.IsStringTable() {
  9082. aa := buff.ReadInt() // read string index
  9083. y = ctx.Table.At(aa)
  9084. } else {
  9085. y = buff.ReadString() // read string
  9086. }
  9087. x := y
  9088. vv = x
  9089. var zz string
  9090. var cc string
  9091. if ctx.IsStringTable() {
  9092. dd := buff.ReadInt() // read string index
  9093. cc = ctx.Table.At(dd)
  9094. } else {
  9095. cc = buff.ReadString() // read string
  9096. }
  9097. bb := cc
  9098. zz = bb
  9099. u[vv] = zz
  9100. }
  9101. target.Annotations = u
  9102. // --- [end][read][map](map[string]string) ---
  9103. }
  9104. if buff.ReadUInt8() == uint8(0) {
  9105. target.MatchLabels = nil
  9106. } else {
  9107. // --- [begin][read][map](map[string]string) ---
  9108. ff := buff.ReadInt() // map len
  9109. ee := make(map[string]string, ff)
  9110. for range ff {
  9111. var vvv string
  9112. var hh string
  9113. if ctx.IsStringTable() {
  9114. ll := buff.ReadInt() // read string index
  9115. hh = ctx.Table.At(ll)
  9116. } else {
  9117. hh = buff.ReadString() // read string
  9118. }
  9119. gg := hh
  9120. vvv = gg
  9121. var zzz string
  9122. var nn string
  9123. if ctx.IsStringTable() {
  9124. oo := buff.ReadInt() // read string index
  9125. nn = ctx.Table.At(oo)
  9126. } else {
  9127. nn = buff.ReadString() // read string
  9128. }
  9129. mm := nn
  9130. zzz = mm
  9131. ee[vvv] = zzz
  9132. }
  9133. target.MatchLabels = ee
  9134. // --- [end][read][map](map[string]string) ---
  9135. }
  9136. // --- [begin][read][reference](time.Time) ---
  9137. pp := new(time.Time)
  9138. qq := buff.ReadInt() // byte array length
  9139. rr := buff.ReadBytes(qq)
  9140. errA := pp.UnmarshalBinary(rr)
  9141. if errA != nil {
  9142. return errA
  9143. }
  9144. target.Start = *pp
  9145. // --- [end][read][reference](time.Time) ---
  9146. // --- [begin][read][reference](time.Time) ---
  9147. ss := new(time.Time)
  9148. tt := buff.ReadInt() // byte array length
  9149. uu := buff.ReadBytes(tt)
  9150. errB := ss.UnmarshalBinary(uu)
  9151. if errB != nil {
  9152. return errB
  9153. }
  9154. target.End = *ss
  9155. // --- [end][read][reference](time.Time) ---
  9156. return nil
  9157. }
  9158. //--------------------------------------------------------------------------
  9159. // Window
  9160. //--------------------------------------------------------------------------
  9161. // MarshalBinary serializes the internal properties of this Window instance
  9162. // into a byte array
  9163. func (target *Window) MarshalBinary() (data []byte, err error) {
  9164. ctx := NewEncodingContext(nil)
  9165. e := target.MarshalBinaryWithContext(ctx)
  9166. if e != nil {
  9167. return nil, e
  9168. }
  9169. return ctx.ToBytes(), nil
  9170. }
  9171. // MarshalBinary serializes the internal properties of this Window instance
  9172. // into an io.Writer.
  9173. func (target *Window) MarshalBinaryTo(writer io.Writer) error {
  9174. buff := util.NewBufferFromWriter(writer)
  9175. defer buff.Flush()
  9176. ctx := NewEncodingContextFromBuffer(buff, nil)
  9177. return target.MarshalBinaryWithContext(ctx)
  9178. }
  9179. // MarshalBinaryWithContext serializes the internal properties of this Window instance
  9180. // into a byte array leveraging a predefined context.
  9181. func (target *Window) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  9182. // panics are recovered and propagated as errors
  9183. defer func() {
  9184. if r := recover(); r != nil {
  9185. if e, ok := r.(error); ok {
  9186. err = e
  9187. } else if s, ok := r.(string); ok {
  9188. err = fmt.Errorf("unexpected panic: %s", s)
  9189. } else {
  9190. err = fmt.Errorf("unexpected panic: %+v", r)
  9191. }
  9192. }
  9193. }()
  9194. buff := ctx.Buffer
  9195. buff.WriteUInt8(DefaultCodecVersion) // version
  9196. // --- [begin][write][reference](time.Time) ---
  9197. a, errA := target.Start.MarshalBinary()
  9198. if errA != nil {
  9199. return errA
  9200. }
  9201. buff.WriteInt(len(a))
  9202. buff.WriteBytes(a)
  9203. // --- [end][write][reference](time.Time) ---
  9204. // --- [begin][write][reference](time.Time) ---
  9205. b, errB := target.End.MarshalBinary()
  9206. if errB != nil {
  9207. return errB
  9208. }
  9209. buff.WriteInt(len(b))
  9210. buff.WriteBytes(b)
  9211. // --- [end][write][reference](time.Time) ---
  9212. return nil
  9213. }
  9214. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  9215. // the Window type
  9216. func (target *Window) UnmarshalBinary(data []byte) error {
  9217. ctx := NewDecodingContextFromBytes(data)
  9218. defer ctx.Close()
  9219. err := target.UnmarshalBinaryWithContext(ctx)
  9220. if err != nil {
  9221. return err
  9222. }
  9223. return nil
  9224. }
  9225. // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
  9226. // the Window type
  9227. func (target *Window) UnmarshalBinaryFromReader(reader io.Reader) error {
  9228. ctx := NewDecodingContextFromReader(reader)
  9229. defer ctx.Close()
  9230. err := target.UnmarshalBinaryWithContext(ctx)
  9231. if err != nil {
  9232. return err
  9233. }
  9234. return nil
  9235. }
  9236. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  9237. // the Window type
  9238. func (target *Window) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  9239. // panics are recovered and propagated as errors
  9240. defer func() {
  9241. if r := recover(); r != nil {
  9242. if e, ok := r.(error); ok {
  9243. err = e
  9244. } else if s, ok := r.(string); ok {
  9245. err = fmt.Errorf("unexpected panic: %s", s)
  9246. } else {
  9247. err = fmt.Errorf("unexpected panic: %+v", r)
  9248. }
  9249. }
  9250. }()
  9251. buff := ctx.Buffer
  9252. version := buff.ReadUInt8()
  9253. if version > DefaultCodecVersion {
  9254. return fmt.Errorf("Invalid Version Unmarshalling Window. Expected %d or less, got %d", DefaultCodecVersion, version)
  9255. }
  9256. // field version check
  9257. if uint8(1) <= version {
  9258. // --- [begin][read][reference](time.Time) ---
  9259. a := new(time.Time)
  9260. b := buff.ReadInt() // byte array length
  9261. c := buff.ReadBytes(b)
  9262. errA := a.UnmarshalBinary(c)
  9263. if errA != nil {
  9264. return errA
  9265. }
  9266. target.Start = *a
  9267. // --- [end][read][reference](time.Time) ---
  9268. } else {
  9269. }
  9270. // field version check
  9271. if uint8(1) <= version {
  9272. // --- [begin][read][reference](time.Time) ---
  9273. d := new(time.Time)
  9274. e := buff.ReadInt() // byte array length
  9275. f := buff.ReadBytes(e)
  9276. errB := d.UnmarshalBinary(f)
  9277. if errB != nil {
  9278. return errB
  9279. }
  9280. target.End = *d
  9281. // --- [end][read][reference](time.Time) ---
  9282. } else {
  9283. }
  9284. return nil
  9285. }