kubemodel_codecs.go 262 KB

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