kubemodel_codecs.go 273 KB

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