| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270 |
- ////////////////////////////////////////////////////////////////////////////////
- //
- // DO NOT MODIFY
- //
- // ┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻
- //
- //
- // This source file was automatically generated by bingen.
- //
- ////////////////////////////////////////////////////////////////////////////////
- package kubemodel
- import (
- "fmt"
- "github.com/opencost/opencost/core/pkg/model/shared"
- "io"
- "iter"
- "os"
- "reflect"
- "strings"
- "sync"
- "time"
- "unsafe"
- util "github.com/opencost/opencost/core/pkg/util"
- )
- const (
- // GeneratorPackageName is the package the generator is targetting
- GeneratorPackageName string = "kubemodel"
- // BinaryTagStringTable is written and/or read prior to the existence of a string
- // table (where each index is encoded as a string entry in the resource
- BinaryTagStringTable string = "BGST"
- // DefaultCodecVersion is used for any resources listed in the Default version set
- DefaultCodecVersion uint8 = 4
- )
- //--------------------------------------------------------------------------
- // Configuration
- //--------------------------------------------------------------------------
- var (
- bingenConfigLock sync.RWMutex
- bingenConfig *BingenConfiguration = DefaultBingenConfiguration()
- )
- // BingenConfiguration is used to set any custom configuration in the way files are encoded
- // or decoded.
- type BingenConfiguration struct {
- // FileBackedStringTableEnabled enables the use of file-backed string tables for streaming
- // bingen decoding.
- FileBackedStringTableEnabled bool
- // FileBackedStringTableDir is the directory to write the string table files for reading.
- FileBackedStringTableDir string
- }
- // DefaultBingenConfiguration creates the default implementation of the bingen configuration
- // and returns it.
- func DefaultBingenConfiguration() *BingenConfiguration {
- return &BingenConfiguration{
- FileBackedStringTableEnabled: false,
- FileBackedStringTableDir: os.TempDir(),
- }
- }
- // ConfigureBingen accepts a new *BingenConfiguration instance which updates the internal decoder
- // and encoder behavior.
- func ConfigureBingen(config *BingenConfiguration) {
- bingenConfigLock.Lock()
- defer bingenConfigLock.Unlock()
- if config == nil {
- config = DefaultBingenConfiguration()
- }
- bingenConfig = config
- }
- // IsBingenFileBackedStringTableEnabled accessor for file backed string table configuration
- func IsBingenFileBackedStringTableEnabled() bool {
- bingenConfigLock.RLock()
- defer bingenConfigLock.RUnlock()
- return bingenConfig.FileBackedStringTableEnabled
- }
- // BingenFileBackedStringTableDir returns the directory configured for file backed string tables.
- func BingenFileBackedStringTableDir() string {
- bingenConfigLock.RLock()
- defer bingenConfigLock.RUnlock()
- return bingenConfig.FileBackedStringTableDir
- }
- //--------------------------------------------------------------------------
- // Type Map
- //--------------------------------------------------------------------------
- // Generated type map for resolving interface implementations to to concrete types
- var typeMap map[string]reflect.Type = map[string]reflect.Type{
- "Cluster": reflect.TypeFor[Cluster](),
- "Container": reflect.TypeFor[Container](),
- "CronJob": reflect.TypeFor[CronJob](),
- "DCGMContainer": reflect.TypeFor[DCGMContainer](),
- "DCGMDevice": reflect.TypeFor[DCGMDevice](),
- "DCGMDeviceSaturation": reflect.TypeFor[DCGMDeviceSaturation](),
- "DCGMPod": reflect.TypeFor[DCGMPod](),
- "DaemonSet": reflect.TypeFor[DaemonSet](),
- "Deployment": reflect.TypeFor[Deployment](),
- "Diagnostic": reflect.TypeFor[Diagnostic](),
- "FileSystem": reflect.TypeFor[FileSystem](),
- "Job": reflect.TypeFor[Job](),
- "KubeModelSet": reflect.TypeFor[KubeModelSet](),
- "Metadata": reflect.TypeFor[Metadata](),
- "Namespace": reflect.TypeFor[Namespace](),
- "NetworkTrafficDetail": reflect.TypeFor[NetworkTrafficDetail](),
- "Node": reflect.TypeFor[Node](),
- "Owner": reflect.TypeFor[Owner](),
- "PersistentVolume": reflect.TypeFor[PersistentVolume](),
- "PersistentVolumeClaim": reflect.TypeFor[PersistentVolumeClaim](),
- "Pod": reflect.TypeFor[Pod](),
- "PodPVCVolume": reflect.TypeFor[PodPVCVolume](),
- "ReplicaSet": reflect.TypeFor[ReplicaSet](),
- "ResourceQuantity": reflect.TypeFor[ResourceQuantity](),
- "ResourceQuota": reflect.TypeFor[ResourceQuota](),
- "ResourceQuotaSpec": reflect.TypeFor[ResourceQuotaSpec](),
- "ResourceQuotaSpecHard": reflect.TypeFor[ResourceQuotaSpecHard](),
- "ResourceQuotaStatus": reflect.TypeFor[ResourceQuotaStatus](),
- "ResourceQuotaStatusUsed": reflect.TypeFor[ResourceQuotaStatusUsed](),
- "Service": reflect.TypeFor[Service](),
- "StatefulSet": reflect.TypeFor[StatefulSet](),
- "Window": reflect.TypeFor[Window](),
- }
- //--------------------------------------------------------------------------
- // Type Helpers
- //--------------------------------------------------------------------------
- // isBinaryTag returns true when the first bytes in the provided binary matches the tag
- func isBinaryTag(data []byte, tag string) bool {
- if len(data) < len(tag) {
- return false
- }
- return string(data[:len(tag)]) == tag
- }
- // isReaderBinaryTag is used to peek the header for an io.Reader Buffer
- func isReaderBinaryTag(buff *util.Buffer, tag string) bool {
- data, err := buff.Peek(len(tag))
- if err != nil && err != io.EOF {
- panic(fmt.Sprintf("called Peek() on a non buffered reader: %s", err))
- }
- if len(data) < len(tag) {
- return false
- }
- return string(data[:len(tag)]) == tag
- }
- // appendBytes combines a and b into a new byte array
- func appendBytes(a []byte, b []byte) []byte {
- al := len(a)
- bl := len(b)
- tl := al + bl
- // allocate a new byte array for the combined
- // use native copy for speedy byte copying
- result := make([]byte, tl)
- copy(result, a)
- copy(result[al:], b)
- return result
- }
- // typeToString determines the basic properties of the type, the qualifier, package path, and
- // type name, and returns the qualified type
- func typeToString(f interface{}) string {
- qual := ""
- t := reflect.TypeOf(f)
- if t.Kind() == reflect.Ptr {
- t = t.Elem()
- qual = "*"
- }
- return fmt.Sprintf("%s%s.%s", qual, t.PkgPath(), t.Name())
- }
- // resolveType uses the name of a type and returns the package, base type name, and whether
- // or not it's a pointer.
- func resolveType(t string) (pkg string, name string, isPtr bool) {
- isPtr = t[:1] == "*"
- if isPtr {
- t = t[1:]
- }
- slashIndex := strings.LastIndex(t, "/")
- if slashIndex >= 0 {
- t = t[slashIndex+1:]
- }
- parts := strings.Split(t, ".")
- if parts[0] == GeneratorPackageName {
- parts[0] = ""
- }
- pkg = parts[0]
- name = parts[1]
- return
- }
- //--------------------------------------------------------------------------
- // Stream Helpers
- //--------------------------------------------------------------------------
- // StreamFactoryFunc is an alias for a func that creates a BingenStream implementation.
- type StreamFactoryFunc func(io.Reader) BingenStream
- // Generated streamable factory map for finding the specific new stream methods
- // by T type
- var streamFactoryMap map[reflect.Type]StreamFactoryFunc = map[reflect.Type]StreamFactoryFunc{
- reflect.TypeFor[KubeModelSet](): NewKubeModelSetStream,
- }
- // NewStreamFor accepts an io.Reader, and returns a new BingenStream for the generic T
- // type provided _if_ it is a registered bingen type that is annotated as 'streamable'. See
- // the streamFactoryMap for generated type listings.
- func NewStreamFor[T any](reader io.Reader) (BingenStream, error) {
- typeKey := reflect.TypeFor[T]()
- factory, ok := streamFactoryMap[typeKey]
- if !ok {
- return nil, fmt.Errorf("the type: %s is not a registered bingen streamable type", typeKey.Name())
- }
- return factory(reader), nil
- }
- // BingenStream is the stream interface for all streamable types
- type BingenStream interface {
- // Stream returns the iterator which will stream each field of the target type and
- // return the field info as well as the value.
- Stream() iter.Seq2[BingenFieldInfo, *BingenValue]
- // Close will close any dynamic io.Reader used to stream in the fields
- Close()
- // Error returns an error if one occurred during the process of streaming the type's fields.
- // This can be checked after iterating through the Stream().
- Error() error
- }
- // BingenValue contains the value of a field as well as any index/key associated with that value.
- type BingenValue struct {
- Value any
- Index any
- }
- // IsNil is just a method accessor way to check to see if the value returned was nil
- func (bv *BingenValue) IsNil() bool {
- return bv == nil
- }
- // creates a single BingenValue instance without a key or index
- func singleV(value any) *BingenValue {
- return &BingenValue{
- Value: value,
- }
- }
- // creates a pair of key/index and value.
- func pairV(index any, value any) *BingenValue {
- return &BingenValue{
- Value: value,
- Index: index,
- }
- }
- // BingenFieldInfo contains the type of the field being streamed as well as the name of the field.
- type BingenFieldInfo struct {
- Type reflect.Type
- Name string
- }
- //--------------------------------------------------------------------------
- // String Table Writer
- //--------------------------------------------------------------------------
- // StringTableWriter maps strings to specific indices for encoding
- type StringTableWriter struct {
- l sync.Mutex
- indices map[string]int
- next int
- }
- // NewStringTableWriter Creates a new StringTableWriter instance with provided contents
- func NewStringTableWriter(contents ...string) *StringTableWriter {
- st := &StringTableWriter{
- indices: make(map[string]int, len(contents)),
- next: len(contents),
- }
- for i, entry := range contents {
- st.indices[entry] = i
- }
- return st
- }
- // AddOrGet atomically retrieves a string entry's index if it exist. Otherwise, it will
- // add the entry and return the index.
- func (st *StringTableWriter) AddOrGet(s string) int {
- st.l.Lock()
- defer st.l.Unlock()
- if ind, ok := st.indices[s]; ok {
- return ind
- }
- current := st.next
- st.next++
- st.indices[s] = current
- return current
- }
- // ToSlice Converts the contents to a string array for encoding.
- func (st *StringTableWriter) ToSlice() []string {
- st.l.Lock()
- defer st.l.Unlock()
- if st.next == 0 {
- return []string{}
- }
- sl := make([]string, st.next)
- for s, i := range st.indices {
- sl[i] = s
- }
- return sl
- }
- // ToBytes Converts the contents to a binary encoded representation
- func (st *StringTableWriter) ToBytes() []byte {
- buff := util.NewBuffer()
- buff.WriteBytes([]byte(BinaryTagStringTable)) // bingen table header
- strs := st.ToSlice()
- buff.WriteInt(len(strs)) // table length
- for _, s := range strs {
- buff.WriteString(s)
- }
- return buff.Bytes()
- }
- //--------------------------------------------------------------------------
- // String Table Reader
- //--------------------------------------------------------------------------
- // StringTableReader is the interface used to read the string table from the decoding.
- type StringTableReader interface {
- // At returns the string entry at a specific index, or panics on out of bounds.
- At(index int) string
- // Len returns the total number of strings loaded in the string table.
- Len() int
- // Close will clear the loaded table, and drop any external resources used.
- Close() error
- }
- // SliceStringTableReader is a basic pre-loaded []string that provides index-based access.
- // The cost of this implementation is holding all strings in memory, which provides faster
- // lookup performance at the expense of memory usage.
- type SliceStringTableReader struct {
- table []string
- }
- // NewSliceStringTableReaderFrom creates a new SliceStringTableReader instance loading
- // data directly from the buffer. The buffer's position should start at the table length.
- func NewSliceStringTableReaderFrom(buffer *util.Buffer) StringTableReader {
- // table length
- tl := buffer.ReadInt()
- var table []string
- if tl > 0 {
- table = make([]string, tl)
- for i := range tl {
- table[i] = buffer.ReadString()
- }
- }
- return &SliceStringTableReader{
- table: table,
- }
- }
- // At returns the string entry at a specific index, or panics on out of bounds.
- func (sstr *SliceStringTableReader) At(index int) string {
- if index < 0 || index >= len(sstr.table) {
- panic(fmt.Errorf("%s: string table index out of bounds: %d", GeneratorPackageName, index))
- }
- return sstr.table[index]
- }
- // Len returns the total number of strings loaded in the string table.
- func (sstr *SliceStringTableReader) Len() int {
- if sstr == nil {
- return 0
- }
- return len(sstr.table)
- }
- // Close for the slice tables just nils out the slice and returns
- func (sstr *SliceStringTableReader) Close() error {
- sstr.table = nil
- return nil
- }
- // fileStringRef maps a bingen string-table index to a payload stored in a temp file.
- type fileStringRef struct {
- off int64
- length int
- }
- // FileStringTableReader leverages a local file to write string table data for lookup. On
- // memory focused systems, this allows a slower parse with a significant decrease in memory
- // usage. This implementation is often pair with streaming readers for high throughput with
- // reduced memory usage.
- type FileStringTableReader struct {
- f *os.File
- refs []fileStringRef
- }
- // NewFileStringTableFromBuffer reads exactly tl length-prefixed (uint16) string payloads from buffer
- // and appends each payload to a new temp file. It does not retain full strings in memory.
- func NewFileStringTableReaderFrom(buffer *util.Buffer, dir string) StringTableReader {
- // helper func to cast a string in-place to a byte slice.
- // NOTE: Return value is READ-ONLY. DO NOT MODIFY!
- byteSliceFor := func(s string) []byte {
- return unsafe.Slice(unsafe.StringData(s), len(s))
- }
- err := os.MkdirAll(dir, 0755)
- if err != nil {
- panic(fmt.Errorf("%s: failed to create string table directory: %w", GeneratorPackageName, err))
- }
- f, err := os.CreateTemp(dir, fmt.Sprintf("%s-bgst-*", GeneratorPackageName))
- if err != nil {
- panic(fmt.Errorf("%s: failed to create string table file: %w", GeneratorPackageName, err))
- }
- var writeErr error
- defer func() {
- if writeErr != nil {
- _ = f.Close()
- }
- }()
- // table length
- tl := buffer.ReadInt()
- var refs []fileStringRef
- if tl > 0 {
- refs = make([]fileStringRef, tl)
- for i := range tl {
- payload := byteSliceFor(buffer.ReadString())
- var off int64
- if len(payload) > 0 {
- off, err = f.Seek(0, io.SeekEnd)
- if err != nil {
- writeErr = fmt.Errorf("%s: failed to seek string table file: %w", GeneratorPackageName, err)
- panic(writeErr)
- }
- if _, err := f.Write(payload); err != nil {
- writeErr = fmt.Errorf("%s: failed to write string table entry %d: %w", GeneratorPackageName, i, err)
- panic(writeErr)
- }
- }
- refs[i] = fileStringRef{
- off: off,
- length: len(payload),
- }
- }
- }
- return &FileStringTableReader{
- f: f,
- refs: refs,
- }
- }
- // At returns the string from the internal file using the reference's offset and length.
- func (fstr *FileStringTableReader) At(index int) string {
- if fstr == nil || fstr.f == nil {
- panic(fmt.Errorf("%s: failed to read file string table data", GeneratorPackageName))
- }
- if index < 0 || index >= len(fstr.refs) {
- panic(fmt.Errorf("%s: string table index out of bounds: %d", GeneratorPackageName, index))
- }
- ref := fstr.refs[index]
- if ref.length == 0 {
- return ""
- }
- b := make([]byte, ref.length)
- _, err := fstr.f.ReadAt(b, ref.off)
- if err != nil {
- return ""
- }
- // cast the allocated bytes to a string in-place, as we
- // were the ones that allocated the bytes
- return unsafe.String(unsafe.SliceData(b), len(b))
- }
- // Len returns the total number of strings loaded in the string table.
- func (fstr *FileStringTableReader) Len() int {
- if fstr == nil {
- return 0
- }
- return len(fstr.refs)
- }
- // Close for the file string table reader closes the file and deletes it.
- func (fstr *FileStringTableReader) Close() error {
- if fstr == nil || fstr.f == nil {
- return nil
- }
- path := fstr.f.Name()
- err := fstr.f.Close()
- fstr.f = nil
- fstr.refs = nil
- if path != "" {
- _ = os.Remove(path)
- }
- return err
- }
- //--------------------------------------------------------------------------
- // Codec Context
- //--------------------------------------------------------------------------
- // EncodingContext is a context object passed to the encoders to ensure reuse of buffer
- // and table data
- type EncodingContext struct {
- Buffer *util.Buffer
- Table *StringTableWriter
- }
- // IsStringTable returns true if the table is available
- func (ec *EncodingContext) IsStringTable() bool {
- return ec.Table != nil
- }
- // DecodingContext is a context object passed to the decoders to ensure parent objects
- // reuse as much data as possible
- type DecodingContext struct {
- Buffer *util.Buffer
- Table StringTableReader
- }
- // NewDecodingContextFromBytes creates a new DecodingContext instance using an byte slice
- func NewDecodingContextFromBytes(data []byte) *DecodingContext {
- var table StringTableReader
- buff := util.NewBufferFromBytes(data)
- // string table header validation
- if isBinaryTag(data, BinaryTagStringTable) {
- buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
- // always use a slice string table with a byte array since the
- // data is already in memory
- table = NewSliceStringTableReaderFrom(buff)
- }
- return &DecodingContext{
- Buffer: buff,
- Table: table,
- }
- }
- // NewDecodingContextFromReader creates a new DecodingContext instance using an io.Reader
- // implementation
- func NewDecodingContextFromReader(reader io.Reader) *DecodingContext {
- var table StringTableReader
- buff := util.NewBufferFromReader(reader)
- if isReaderBinaryTag(buff, BinaryTagStringTable) {
- buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
- // create correct string table implementation
- if IsBingenFileBackedStringTableEnabled() {
- table = NewFileStringTableReaderFrom(buff, BingenFileBackedStringTableDir())
- } else {
- table = NewSliceStringTableReaderFrom(buff)
- }
- }
- return &DecodingContext{
- Buffer: buff,
- Table: table,
- }
- }
- // IsStringTable returns true if the table is available
- func (dc *DecodingContext) IsStringTable() bool {
- return dc.Table != nil && dc.Table.Len() > 0
- }
- // Close will ensure that any string table resources and buffer resources are
- // cleaned up.
- func (dc *DecodingContext) Close() {
- if dc.Table != nil {
- _ = dc.Table.Close()
- dc.Table = nil
- }
- }
- //--------------------------------------------------------------------------
- // Binary Codec
- //--------------------------------------------------------------------------
- // BinEncoder is an encoding interface which defines a context based marshal contract.
- type BinEncoder interface {
- MarshalBinaryWithContext(*EncodingContext) error
- }
- // BinDecoder is a decoding interface which defines a context based unmarshal contract.
- type BinDecoder interface {
- UnmarshalBinaryWithContext(*DecodingContext) error
- }
- //--------------------------------------------------------------------------
- // Cluster
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Cluster instance
- // into a byte array
- func (target *Cluster) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this Cluster instance
- // into a byte array leveraging a predefined context.
- func (target *Cluster) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.UID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.UID) // write string
- }
- // --- [begin][write][alias](shared.Provider) ---
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(string(target.Provider))
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(string(target.Provider)) // write string
- }
- // --- [end][write][alias](shared.Provider) ---
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(target.Account)
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(target.Account) // write string
- }
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(target.Name)
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(target.Name) // write string
- }
- if ctx.IsStringTable() {
- e := ctx.Table.AddOrGet(target.Region)
- buff.WriteInt(e) // write table index
- } else {
- buff.WriteString(target.Region) // write string
- }
- // --- [begin][write][reference](time.Time) ---
- f, errA := target.Start.MarshalBinary()
- if errA != nil {
- return errA
- }
- buff.WriteInt(len(f))
- buff.WriteBytes(f)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- g, errB := target.End.MarshalBinary()
- if errB != nil {
- return errB
- }
- buff.WriteInt(len(g))
- buff.WriteBytes(g)
- // --- [end][write][reference](time.Time) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Cluster type
- func (target *Cluster) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the Cluster type
- func (target *Cluster) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the Cluster type
- func (target *Cluster) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling Cluster. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- // field version check
- if uint8(1) <= version {
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.UID = a
- } else {
- target.UID = "" // default
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][alias](shared.Provider) ---
- var d string
- var f string
- if ctx.IsStringTable() {
- g := buff.ReadInt() // read string index
- f = ctx.Table.At(g)
- } else {
- f = buff.ReadString() // read string
- }
- e := f
- d = e
- target.Provider = shared.Provider(d)
- // --- [end][read][alias](shared.Provider) ---
- } else {
- }
- // field version check
- if uint8(1) <= version {
- var l string
- if ctx.IsStringTable() {
- m := buff.ReadInt() // read string index
- l = ctx.Table.At(m)
- } else {
- l = buff.ReadString() // read string
- }
- h := l
- target.Account = h
- } else {
- target.Account = "" // default
- }
- // field version check
- if uint8(1) <= version {
- var o string
- if ctx.IsStringTable() {
- p := buff.ReadInt() // read string index
- o = ctx.Table.At(p)
- } else {
- o = buff.ReadString() // read string
- }
- n := o
- target.Name = n
- } else {
- target.Name = "" // default
- }
- // field version check
- if uint8(2) <= version {
- var r string
- if ctx.IsStringTable() {
- s := buff.ReadInt() // read string index
- r = ctx.Table.At(s)
- } else {
- r = buff.ReadString() // read string
- }
- q := r
- target.Region = q
- } else {
- target.Region = "" // default
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][reference](time.Time) ---
- t := new(time.Time)
- u := buff.ReadInt() // byte array length
- w := buff.ReadBytes(u)
- errA := t.UnmarshalBinary(w)
- if errA != nil {
- return errA
- }
- target.Start = *t
- // --- [end][read][reference](time.Time) ---
- } else {
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][reference](time.Time) ---
- x := new(time.Time)
- y := buff.ReadInt() // byte array length
- aa := buff.ReadBytes(y)
- errB := x.UnmarshalBinary(aa)
- if errB != nil {
- return errB
- }
- target.End = *x
- // --- [end][read][reference](time.Time) ---
- } else {
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // Container
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Container instance
- // into a byte array
- func (target *Container) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this Container instance
- // into a byte array leveraging a predefined context.
- func (target *Container) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.PodUID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.PodUID) // write string
- }
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.Name)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.Name) // write string
- }
- // --- [begin][write][alias](ResourceQuantities) ---
- if map[Resource]ResourceQuantity(target.ResourceRequests) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[Resource]ResourceQuantity) ---
- buff.WriteInt(len(map[Resource]ResourceQuantity(target.ResourceRequests))) // map length
- for v, z := range map[Resource]ResourceQuantity(target.ResourceRequests) {
- // --- [begin][write][alias](Resource) ---
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(string(v))
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(string(v)) // write string
- }
- // --- [end][write][alias](Resource) ---
- // --- [begin][write][struct](ResourceQuantity) ---
- buff.WriteInt(0) // [compatibility, unused]
- errA := z.MarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- // --- [end][write][struct](ResourceQuantity) ---
- }
- // --- [end][write][map](map[Resource]ResourceQuantity) ---
- }
- // --- [end][write][alias](ResourceQuantities) ---
- // --- [begin][write][alias](ResourceQuantities) ---
- if map[Resource]ResourceQuantity(target.ResourceLimits) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[Resource]ResourceQuantity) ---
- buff.WriteInt(len(map[Resource]ResourceQuantity(target.ResourceLimits))) // map length
- for vv, zz := range map[Resource]ResourceQuantity(target.ResourceLimits) {
- // --- [begin][write][alias](Resource) ---
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(string(vv))
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(string(vv)) // write string
- }
- // --- [end][write][alias](Resource) ---
- // --- [begin][write][struct](ResourceQuantity) ---
- buff.WriteInt(0) // [compatibility, unused]
- errB := zz.MarshalBinaryWithContext(ctx)
- if errB != nil {
- return errB
- }
- // --- [end][write][struct](ResourceQuantity) ---
- }
- // --- [end][write][map](map[Resource]ResourceQuantity) ---
- }
- // --- [end][write][alias](ResourceQuantities) ---
- buff.WriteFloat64(target.CPUCoresAllocated) // write float64
- buff.WriteFloat64(target.CPUCoreUsageAvg) // write float64
- buff.WriteFloat64(target.CPUCoreUsageMax) // write float64
- buff.WriteFloat64(target.RAMBytesAllocated) // write float64
- buff.WriteFloat64(target.RAMBytesUsageAvg) // write float64
- buff.WriteFloat64(target.RAMBytesUsageMax) // write float64
- // --- [begin][write][reference](time.Time) ---
- e, errC := target.Start.MarshalBinary()
- if errC != nil {
- return errC
- }
- buff.WriteInt(len(e))
- buff.WriteBytes(e)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- f, errD := target.End.MarshalBinary()
- if errD != nil {
- return errD
- }
- buff.WriteInt(len(f))
- buff.WriteBytes(f)
- // --- [end][write][reference](time.Time) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Container type
- func (target *Container) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the Container type
- func (target *Container) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the Container type
- func (target *Container) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling Container. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.PodUID = a
- var e string
- if ctx.IsStringTable() {
- f := buff.ReadInt() // read string index
- e = ctx.Table.At(f)
- } else {
- e = buff.ReadString() // read string
- }
- d := e
- target.Name = d
- // --- [begin][read][alias](ResourceQuantities) ---
- var g map[Resource]ResourceQuantity
- if buff.ReadUInt8() == uint8(0) {
- g = nil
- } else {
- // --- [begin][read][map](map[Resource]ResourceQuantity) ---
- l := buff.ReadInt() // map len
- h := make(map[Resource]ResourceQuantity, l)
- for range l {
- // --- [begin][read][alias](Resource) ---
- var m string
- var o string
- if ctx.IsStringTable() {
- p := buff.ReadInt() // read string index
- o = ctx.Table.At(p)
- } else {
- o = buff.ReadString() // read string
- }
- n := o
- m = n
- v := Resource(m)
- // --- [end][read][alias](Resource) ---
- // --- [begin][read][struct](ResourceQuantity) ---
- q := new(ResourceQuantity)
- buff.ReadInt() // [compatibility, unused]
- errA := q.UnmarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- z := *q
- // --- [end][read][struct](ResourceQuantity) ---
- h[v] = z
- }
- g = h
- // --- [end][read][map](map[Resource]ResourceQuantity) ---
- }
- target.ResourceRequests = ResourceQuantities(g)
- // --- [end][read][alias](ResourceQuantities) ---
- // --- [begin][read][alias](ResourceQuantities) ---
- var r map[Resource]ResourceQuantity
- if buff.ReadUInt8() == uint8(0) {
- r = nil
- } else {
- // --- [begin][read][map](map[Resource]ResourceQuantity) ---
- t := buff.ReadInt() // map len
- s := make(map[Resource]ResourceQuantity, t)
- for range t {
- // --- [begin][read][alias](Resource) ---
- var u string
- var x string
- if ctx.IsStringTable() {
- y := buff.ReadInt() // read string index
- x = ctx.Table.At(y)
- } else {
- x = buff.ReadString() // read string
- }
- w := x
- u = w
- vv := Resource(u)
- // --- [end][read][alias](Resource) ---
- // --- [begin][read][struct](ResourceQuantity) ---
- aa := new(ResourceQuantity)
- buff.ReadInt() // [compatibility, unused]
- errB := aa.UnmarshalBinaryWithContext(ctx)
- if errB != nil {
- return errB
- }
- zz := *aa
- // --- [end][read][struct](ResourceQuantity) ---
- s[vv] = zz
- }
- r = s
- // --- [end][read][map](map[Resource]ResourceQuantity) ---
- }
- target.ResourceLimits = ResourceQuantities(r)
- // --- [end][read][alias](ResourceQuantities) ---
- bb := buff.ReadFloat64() // read float64
- target.CPUCoresAllocated = bb
- cc := buff.ReadFloat64() // read float64
- target.CPUCoreUsageAvg = cc
- dd := buff.ReadFloat64() // read float64
- target.CPUCoreUsageMax = dd
- ee := buff.ReadFloat64() // read float64
- target.RAMBytesAllocated = ee
- ff := buff.ReadFloat64() // read float64
- target.RAMBytesUsageAvg = ff
- gg := buff.ReadFloat64() // read float64
- target.RAMBytesUsageMax = gg
- // --- [begin][read][reference](time.Time) ---
- hh := new(time.Time)
- ll := buff.ReadInt() // byte array length
- mm := buff.ReadBytes(ll)
- errC := hh.UnmarshalBinary(mm)
- if errC != nil {
- return errC
- }
- target.Start = *hh
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- nn := new(time.Time)
- oo := buff.ReadInt() // byte array length
- pp := buff.ReadBytes(oo)
- errD := nn.UnmarshalBinary(pp)
- if errD != nil {
- return errD
- }
- target.End = *nn
- // --- [end][read][reference](time.Time) ---
- return nil
- }
- //--------------------------------------------------------------------------
- // CronJob
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this CronJob instance
- // into a byte array
- func (target *CronJob) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this CronJob instance
- // into a byte array leveraging a predefined context.
- func (target *CronJob) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.UID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.UID) // write string
- }
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.NamespaceUID)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.NamespaceUID) // write string
- }
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(target.Name)
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(target.Name) // write string
- }
- if target.Labels == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Labels)) // map length
- for v, z := range target.Labels {
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(v)
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(v) // write string
- }
- if ctx.IsStringTable() {
- e := ctx.Table.AddOrGet(z)
- buff.WriteInt(e) // write table index
- } else {
- buff.WriteString(z) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- if target.Annotations == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Annotations)) // map length
- for vv, zz := range target.Annotations {
- if ctx.IsStringTable() {
- f := ctx.Table.AddOrGet(vv)
- buff.WriteInt(f) // write table index
- } else {
- buff.WriteString(vv) // write string
- }
- if ctx.IsStringTable() {
- g := ctx.Table.AddOrGet(zz)
- buff.WriteInt(g) // write table index
- } else {
- buff.WriteString(zz) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [begin][write][reference](time.Time) ---
- h, errA := target.Start.MarshalBinary()
- if errA != nil {
- return errA
- }
- buff.WriteInt(len(h))
- buff.WriteBytes(h)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- l, errB := target.End.MarshalBinary()
- if errB != nil {
- return errB
- }
- buff.WriteInt(len(l))
- buff.WriteBytes(l)
- // --- [end][write][reference](time.Time) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the CronJob type
- func (target *CronJob) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the CronJob type
- func (target *CronJob) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the CronJob type
- func (target *CronJob) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling CronJob. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.UID = a
- var e string
- if ctx.IsStringTable() {
- f := buff.ReadInt() // read string index
- e = ctx.Table.At(f)
- } else {
- e = buff.ReadString() // read string
- }
- d := e
- target.NamespaceUID = d
- var h string
- if ctx.IsStringTable() {
- l := buff.ReadInt() // read string index
- h = ctx.Table.At(l)
- } else {
- h = buff.ReadString() // read string
- }
- g := h
- target.Name = g
- if buff.ReadUInt8() == uint8(0) {
- target.Labels = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- n := buff.ReadInt() // map len
- m := make(map[string]string, n)
- for range n {
- var v string
- var p string
- if ctx.IsStringTable() {
- q := buff.ReadInt() // read string index
- p = ctx.Table.At(q)
- } else {
- p = buff.ReadString() // read string
- }
- o := p
- v = o
- var z string
- var s string
- if ctx.IsStringTable() {
- t := buff.ReadInt() // read string index
- s = ctx.Table.At(t)
- } else {
- s = buff.ReadString() // read string
- }
- r := s
- z = r
- m[v] = z
- }
- target.Labels = m
- // --- [end][read][map](map[string]string) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.Annotations = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- w := buff.ReadInt() // map len
- u := make(map[string]string, w)
- for range w {
- var vv string
- var y string
- if ctx.IsStringTable() {
- aa := buff.ReadInt() // read string index
- y = ctx.Table.At(aa)
- } else {
- y = buff.ReadString() // read string
- }
- x := y
- vv = x
- var zz string
- var cc string
- if ctx.IsStringTable() {
- dd := buff.ReadInt() // read string index
- cc = ctx.Table.At(dd)
- } else {
- cc = buff.ReadString() // read string
- }
- bb := cc
- zz = bb
- u[vv] = zz
- }
- target.Annotations = u
- // --- [end][read][map](map[string]string) ---
- }
- // --- [begin][read][reference](time.Time) ---
- ee := new(time.Time)
- ff := buff.ReadInt() // byte array length
- gg := buff.ReadBytes(ff)
- errA := ee.UnmarshalBinary(gg)
- if errA != nil {
- return errA
- }
- target.Start = *ee
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- hh := new(time.Time)
- ll := buff.ReadInt() // byte array length
- mm := buff.ReadBytes(ll)
- errB := hh.UnmarshalBinary(mm)
- if errB != nil {
- return errB
- }
- target.End = *hh
- // --- [end][read][reference](time.Time) ---
- return nil
- }
- //--------------------------------------------------------------------------
- // DCGMContainer
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this DCGMContainer instance
- // into a byte array
- func (target *DCGMContainer) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this DCGMContainer instance
- // into a byte array leveraging a predefined context.
- func (target *DCGMContainer) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- buff.WriteFloat64(target.UsageAvg) // write float64
- buff.WriteFloat64(target.UsageMax) // write float64
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the DCGMContainer type
- func (target *DCGMContainer) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the DCGMContainer type
- func (target *DCGMContainer) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the DCGMContainer type
- func (target *DCGMContainer) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling DCGMContainer. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- a := buff.ReadFloat64() // read float64
- target.UsageAvg = a
- b := buff.ReadFloat64() // read float64
- target.UsageMax = b
- return nil
- }
- //--------------------------------------------------------------------------
- // DCGMDevice
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this DCGMDevice instance
- // into a byte array
- func (target *DCGMDevice) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this DCGMDevice instance
- // into a byte array leveraging a predefined context.
- func (target *DCGMDevice) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.UUID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.UUID) // write string
- }
- // --- [begin][write][reference](time.Time) ---
- b, errA := target.Start.MarshalBinary()
- if errA != nil {
- return errA
- }
- buff.WriteInt(len(b))
- buff.WriteBytes(b)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- c, errB := target.End.MarshalBinary()
- if errB != nil {
- return errB
- }
- buff.WriteInt(len(c))
- buff.WriteBytes(c)
- // --- [end][write][reference](time.Time) ---
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(target.Device)
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(target.Device) // write string
- }
- if ctx.IsStringTable() {
- e := ctx.Table.AddOrGet(target.ModelName)
- buff.WriteInt(e) // write table index
- } else {
- buff.WriteString(target.ModelName) // write string
- }
- if target.PodUsages == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]DCGMPod) ---
- buff.WriteInt(len(target.PodUsages)) // map length
- for v, z := range target.PodUsages {
- if ctx.IsStringTable() {
- f := ctx.Table.AddOrGet(v)
- buff.WriteInt(f) // write table index
- } else {
- buff.WriteString(v) // write string
- }
- // --- [begin][write][struct](DCGMPod) ---
- buff.WriteInt(0) // [compatibility, unused]
- errC := z.MarshalBinaryWithContext(ctx)
- if errC != nil {
- return errC
- }
- // --- [end][write][struct](DCGMPod) ---
- }
- // --- [end][write][map](map[string]DCGMPod) ---
- }
- if target.Saturation == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](DCGMDeviceSaturation) ---
- buff.WriteInt(0) // [compatibility, unused]
- errD := target.Saturation.MarshalBinaryWithContext(ctx)
- if errD != nil {
- return errD
- }
- // --- [end][write][struct](DCGMDeviceSaturation) ---
- }
- buff.WriteFloat64(target.PowerWatts) // write float64
- buff.WriteFloat64(target.TemperatureCelsius) // write float64
- buff.WriteFloat64(target.ComputeUtilizationAvg) // write float64
- buff.WriteFloat64(target.ComputeUtilizationMax) // write float64
- buff.WriteFloat64(target.MemoryUsedBytesAvg) // write float64
- buff.WriteFloat64(target.MemoryUsedBytesMax) // write float64
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the DCGMDevice type
- func (target *DCGMDevice) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the DCGMDevice type
- func (target *DCGMDevice) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the DCGMDevice type
- func (target *DCGMDevice) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling DCGMDevice. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.UUID = a
- // --- [begin][read][reference](time.Time) ---
- d := new(time.Time)
- e := buff.ReadInt() // byte array length
- f := buff.ReadBytes(e)
- errA := d.UnmarshalBinary(f)
- if errA != nil {
- return errA
- }
- target.Start = *d
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- g := new(time.Time)
- h := buff.ReadInt() // byte array length
- l := buff.ReadBytes(h)
- errB := g.UnmarshalBinary(l)
- if errB != nil {
- return errB
- }
- target.End = *g
- // --- [end][read][reference](time.Time) ---
- var n string
- if ctx.IsStringTable() {
- o := buff.ReadInt() // read string index
- n = ctx.Table.At(o)
- } else {
- n = buff.ReadString() // read string
- }
- m := n
- target.Device = m
- var q string
- if ctx.IsStringTable() {
- r := buff.ReadInt() // read string index
- q = ctx.Table.At(r)
- } else {
- q = buff.ReadString() // read string
- }
- p := q
- target.ModelName = p
- if buff.ReadUInt8() == uint8(0) {
- target.PodUsages = nil
- } else {
- // --- [begin][read][map](map[string]DCGMPod) ---
- t := buff.ReadInt() // map len
- s := make(map[string]DCGMPod, t)
- for range t {
- var v string
- var w string
- if ctx.IsStringTable() {
- x := buff.ReadInt() // read string index
- w = ctx.Table.At(x)
- } else {
- w = buff.ReadString() // read string
- }
- u := w
- v = u
- // --- [begin][read][struct](DCGMPod) ---
- y := new(DCGMPod)
- buff.ReadInt() // [compatibility, unused]
- errC := y.UnmarshalBinaryWithContext(ctx)
- if errC != nil {
- return errC
- }
- z := *y
- // --- [end][read][struct](DCGMPod) ---
- s[v] = z
- }
- target.PodUsages = s
- // --- [end][read][map](map[string]DCGMPod) ---
- }
- // field version check
- if uint8(3) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Saturation = nil
- } else {
- // --- [begin][read][struct](DCGMDeviceSaturation) ---
- aa := new(DCGMDeviceSaturation)
- buff.ReadInt() // [compatibility, unused]
- errD := aa.UnmarshalBinaryWithContext(ctx)
- if errD != nil {
- return errD
- }
- target.Saturation = aa
- // --- [end][read][struct](DCGMDeviceSaturation) ---
- }
- } else {
- target.Saturation = nil
- }
- // field version check
- if uint8(4) <= version {
- bb := buff.ReadFloat64() // read float64
- target.PowerWatts = bb
- } else {
- target.PowerWatts = float64(0) // default
- }
- // field version check
- if uint8(4) <= version {
- cc := buff.ReadFloat64() // read float64
- target.TemperatureCelsius = cc
- } else {
- target.TemperatureCelsius = float64(0) // default
- }
- // field version check
- if uint8(4) <= version {
- dd := buff.ReadFloat64() // read float64
- target.ComputeUtilizationAvg = dd
- } else {
- target.ComputeUtilizationAvg = float64(0) // default
- }
- // field version check
- if uint8(4) <= version {
- ee := buff.ReadFloat64() // read float64
- target.ComputeUtilizationMax = ee
- } else {
- target.ComputeUtilizationMax = float64(0) // default
- }
- // field version check
- if uint8(4) <= version {
- ff := buff.ReadFloat64() // read float64
- target.MemoryUsedBytesAvg = ff
- } else {
- target.MemoryUsedBytesAvg = float64(0) // default
- }
- // field version check
- if uint8(4) <= version {
- gg := buff.ReadFloat64() // read float64
- target.MemoryUsedBytesMax = gg
- } else {
- target.MemoryUsedBytesMax = float64(0) // default
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // DCGMDeviceSaturation
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this DCGMDeviceSaturation instance
- // into a byte array
- func (target *DCGMDeviceSaturation) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this DCGMDeviceSaturation instance
- // into a byte array leveraging a predefined context.
- func (target *DCGMDeviceSaturation) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if target.ThrottleViolationRatios == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]float64) ---
- buff.WriteInt(len(target.ThrottleViolationRatios)) // map length
- for v, z := range target.ThrottleViolationRatios {
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(v)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(v) // write string
- }
- buff.WriteFloat64(z) // write float64
- }
- // --- [end][write][map](map[string]float64) ---
- }
- if target.ThrottleReasonRatios == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]float64) ---
- buff.WriteInt(len(target.ThrottleReasonRatios)) // map length
- for vv, zz := range target.ThrottleReasonRatios {
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(vv)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(vv) // write string
- }
- buff.WriteFloat64(zz) // write float64
- }
- // --- [end][write][map](map[string]float64) ---
- }
- if target.MemoryUsedRatioAvg == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- buff.WriteFloat64(*target.MemoryUsedRatioAvg) // write float64
- }
- if target.MemoryUsedRatioMax == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- buff.WriteFloat64(*target.MemoryUsedRatioMax) // write float64
- }
- if target.MemoryPressureRatio == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- buff.WriteFloat64(*target.MemoryPressureRatio) // write float64
- }
- if target.XIDErrorCount == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- buff.WriteFloat64(*target.XIDErrorCount) // write float64
- }
- if target.DRAMActiveAvg == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- buff.WriteFloat64(*target.DRAMActiveAvg) // write float64
- }
- if target.DRAMActiveMax == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- buff.WriteFloat64(*target.DRAMActiveMax) // write float64
- }
- if target.SMActiveAvg == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- buff.WriteFloat64(*target.SMActiveAvg) // write float64
- }
- if target.SMOccupancyAvg == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- buff.WriteFloat64(*target.SMOccupancyAvg) // write float64
- }
- if target.PCIeTxBytesAvg == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- buff.WriteFloat64(*target.PCIeTxBytesAvg) // write float64
- }
- if target.PCIeRxBytesAvg == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- buff.WriteFloat64(*target.PCIeRxBytesAvg) // write float64
- }
- if target.NVLinkTxBytesAvg == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- buff.WriteFloat64(*target.NVLinkTxBytesAvg) // write float64
- }
- if target.NVLinkRxBytesAvg == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- buff.WriteFloat64(*target.NVLinkRxBytesAvg) // write float64
- }
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the DCGMDeviceSaturation type
- func (target *DCGMDeviceSaturation) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the DCGMDeviceSaturation type
- func (target *DCGMDeviceSaturation) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the DCGMDeviceSaturation type
- func (target *DCGMDeviceSaturation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling DCGMDeviceSaturation. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- if buff.ReadUInt8() == uint8(0) {
- target.ThrottleViolationRatios = nil
- } else {
- // --- [begin][read][map](map[string]float64) ---
- b := buff.ReadInt() // map len
- a := make(map[string]float64, b)
- for range b {
- var v string
- var d string
- if ctx.IsStringTable() {
- e := buff.ReadInt() // read string index
- d = ctx.Table.At(e)
- } else {
- d = buff.ReadString() // read string
- }
- c := d
- v = c
- var z float64
- f := buff.ReadFloat64() // read float64
- z = f
- a[v] = z
- }
- target.ThrottleViolationRatios = a
- // --- [end][read][map](map[string]float64) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.ThrottleReasonRatios = nil
- } else {
- // --- [begin][read][map](map[string]float64) ---
- h := buff.ReadInt() // map len
- g := make(map[string]float64, h)
- for range h {
- var vv string
- var m string
- if ctx.IsStringTable() {
- n := buff.ReadInt() // read string index
- m = ctx.Table.At(n)
- } else {
- m = buff.ReadString() // read string
- }
- l := m
- vv = l
- var zz float64
- o := buff.ReadFloat64() // read float64
- zz = o
- g[vv] = zz
- }
- target.ThrottleReasonRatios = g
- // --- [end][read][map](map[string]float64) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.MemoryUsedRatioAvg = nil
- } else {
- p := buff.ReadFloat64() // read float64
- target.MemoryUsedRatioAvg = &p
- }
- if buff.ReadUInt8() == uint8(0) {
- target.MemoryUsedRatioMax = nil
- } else {
- q := buff.ReadFloat64() // read float64
- target.MemoryUsedRatioMax = &q
- }
- if buff.ReadUInt8() == uint8(0) {
- target.MemoryPressureRatio = nil
- } else {
- r := buff.ReadFloat64() // read float64
- target.MemoryPressureRatio = &r
- }
- if buff.ReadUInt8() == uint8(0) {
- target.XIDErrorCount = nil
- } else {
- s := buff.ReadFloat64() // read float64
- target.XIDErrorCount = &s
- }
- if buff.ReadUInt8() == uint8(0) {
- target.DRAMActiveAvg = nil
- } else {
- t := buff.ReadFloat64() // read float64
- target.DRAMActiveAvg = &t
- }
- if buff.ReadUInt8() == uint8(0) {
- target.DRAMActiveMax = nil
- } else {
- u := buff.ReadFloat64() // read float64
- target.DRAMActiveMax = &u
- }
- if buff.ReadUInt8() == uint8(0) {
- target.SMActiveAvg = nil
- } else {
- w := buff.ReadFloat64() // read float64
- target.SMActiveAvg = &w
- }
- if buff.ReadUInt8() == uint8(0) {
- target.SMOccupancyAvg = nil
- } else {
- x := buff.ReadFloat64() // read float64
- target.SMOccupancyAvg = &x
- }
- if buff.ReadUInt8() == uint8(0) {
- target.PCIeTxBytesAvg = nil
- } else {
- y := buff.ReadFloat64() // read float64
- target.PCIeTxBytesAvg = &y
- }
- if buff.ReadUInt8() == uint8(0) {
- target.PCIeRxBytesAvg = nil
- } else {
- aa := buff.ReadFloat64() // read float64
- target.PCIeRxBytesAvg = &aa
- }
- if buff.ReadUInt8() == uint8(0) {
- target.NVLinkTxBytesAvg = nil
- } else {
- bb := buff.ReadFloat64() // read float64
- target.NVLinkTxBytesAvg = &bb
- }
- if buff.ReadUInt8() == uint8(0) {
- target.NVLinkRxBytesAvg = nil
- } else {
- cc := buff.ReadFloat64() // read float64
- target.NVLinkRxBytesAvg = &cc
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // DCGMPod
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this DCGMPod instance
- // into a byte array
- func (target *DCGMPod) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this DCGMPod instance
- // into a byte array leveraging a predefined context.
- func (target *DCGMPod) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if target.ContainerUsages == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]DCGMContainer) ---
- buff.WriteInt(len(target.ContainerUsages)) // map length
- for v, z := range target.ContainerUsages {
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(v)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(v) // write string
- }
- // --- [begin][write][struct](DCGMContainer) ---
- buff.WriteInt(0) // [compatibility, unused]
- errA := z.MarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- // --- [end][write][struct](DCGMContainer) ---
- }
- // --- [end][write][map](map[string]DCGMContainer) ---
- }
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the DCGMPod type
- func (target *DCGMPod) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the DCGMPod type
- func (target *DCGMPod) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the DCGMPod type
- func (target *DCGMPod) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling DCGMPod. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- if buff.ReadUInt8() == uint8(0) {
- target.ContainerUsages = nil
- } else {
- // --- [begin][read][map](map[string]DCGMContainer) ---
- b := buff.ReadInt() // map len
- a := make(map[string]DCGMContainer, b)
- for range b {
- var v string
- var d string
- if ctx.IsStringTable() {
- e := buff.ReadInt() // read string index
- d = ctx.Table.At(e)
- } else {
- d = buff.ReadString() // read string
- }
- c := d
- v = c
- // --- [begin][read][struct](DCGMContainer) ---
- f := new(DCGMContainer)
- buff.ReadInt() // [compatibility, unused]
- errA := f.UnmarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- z := *f
- // --- [end][read][struct](DCGMContainer) ---
- a[v] = z
- }
- target.ContainerUsages = a
- // --- [end][read][map](map[string]DCGMContainer) ---
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // DaemonSet
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this DaemonSet instance
- // into a byte array
- func (target *DaemonSet) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this DaemonSet instance
- // into a byte array leveraging a predefined context.
- func (target *DaemonSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.UID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.UID) // write string
- }
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.NamespaceUID)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.NamespaceUID) // write string
- }
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(target.Name)
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(target.Name) // write string
- }
- if target.Labels == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Labels)) // map length
- for v, z := range target.Labels {
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(v)
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(v) // write string
- }
- if ctx.IsStringTable() {
- e := ctx.Table.AddOrGet(z)
- buff.WriteInt(e) // write table index
- } else {
- buff.WriteString(z) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- if target.Annotations == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Annotations)) // map length
- for vv, zz := range target.Annotations {
- if ctx.IsStringTable() {
- f := ctx.Table.AddOrGet(vv)
- buff.WriteInt(f) // write table index
- } else {
- buff.WriteString(vv) // write string
- }
- if ctx.IsStringTable() {
- g := ctx.Table.AddOrGet(zz)
- buff.WriteInt(g) // write table index
- } else {
- buff.WriteString(zz) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- if target.DevicePluginInfo == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.DevicePluginInfo)) // map length
- for vvv, zzz := range target.DevicePluginInfo {
- if ctx.IsStringTable() {
- h := ctx.Table.AddOrGet(vvv)
- buff.WriteInt(h) // write table index
- } else {
- buff.WriteString(vvv) // write string
- }
- if ctx.IsStringTable() {
- l := ctx.Table.AddOrGet(zzz)
- buff.WriteInt(l) // write table index
- } else {
- buff.WriteString(zzz) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [begin][write][reference](time.Time) ---
- m, errA := target.Start.MarshalBinary()
- if errA != nil {
- return errA
- }
- buff.WriteInt(len(m))
- buff.WriteBytes(m)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- n, errB := target.End.MarshalBinary()
- if errB != nil {
- return errB
- }
- buff.WriteInt(len(n))
- buff.WriteBytes(n)
- // --- [end][write][reference](time.Time) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the DaemonSet type
- func (target *DaemonSet) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the DaemonSet type
- func (target *DaemonSet) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the DaemonSet type
- func (target *DaemonSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling DaemonSet. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.UID = a
- var e string
- if ctx.IsStringTable() {
- f := buff.ReadInt() // read string index
- e = ctx.Table.At(f)
- } else {
- e = buff.ReadString() // read string
- }
- d := e
- target.NamespaceUID = d
- var h string
- if ctx.IsStringTable() {
- l := buff.ReadInt() // read string index
- h = ctx.Table.At(l)
- } else {
- h = buff.ReadString() // read string
- }
- g := h
- target.Name = g
- if buff.ReadUInt8() == uint8(0) {
- target.Labels = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- n := buff.ReadInt() // map len
- m := make(map[string]string, n)
- for range n {
- var v string
- var p string
- if ctx.IsStringTable() {
- q := buff.ReadInt() // read string index
- p = ctx.Table.At(q)
- } else {
- p = buff.ReadString() // read string
- }
- o := p
- v = o
- var z string
- var s string
- if ctx.IsStringTable() {
- t := buff.ReadInt() // read string index
- s = ctx.Table.At(t)
- } else {
- s = buff.ReadString() // read string
- }
- r := s
- z = r
- m[v] = z
- }
- target.Labels = m
- // --- [end][read][map](map[string]string) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.Annotations = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- w := buff.ReadInt() // map len
- u := make(map[string]string, w)
- for range w {
- var vv string
- var y string
- if ctx.IsStringTable() {
- aa := buff.ReadInt() // read string index
- y = ctx.Table.At(aa)
- } else {
- y = buff.ReadString() // read string
- }
- x := y
- vv = x
- var zz string
- var cc string
- if ctx.IsStringTable() {
- dd := buff.ReadInt() // read string index
- cc = ctx.Table.At(dd)
- } else {
- cc = buff.ReadString() // read string
- }
- bb := cc
- zz = bb
- u[vv] = zz
- }
- target.Annotations = u
- // --- [end][read][map](map[string]string) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.DevicePluginInfo = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- ff := buff.ReadInt() // map len
- ee := make(map[string]string, ff)
- for range ff {
- var vvv string
- var hh string
- if ctx.IsStringTable() {
- ll := buff.ReadInt() // read string index
- hh = ctx.Table.At(ll)
- } else {
- hh = buff.ReadString() // read string
- }
- gg := hh
- vvv = gg
- var zzz string
- var nn string
- if ctx.IsStringTable() {
- oo := buff.ReadInt() // read string index
- nn = ctx.Table.At(oo)
- } else {
- nn = buff.ReadString() // read string
- }
- mm := nn
- zzz = mm
- ee[vvv] = zzz
- }
- target.DevicePluginInfo = ee
- // --- [end][read][map](map[string]string) ---
- }
- // --- [begin][read][reference](time.Time) ---
- pp := new(time.Time)
- qq := buff.ReadInt() // byte array length
- rr := buff.ReadBytes(qq)
- errA := pp.UnmarshalBinary(rr)
- if errA != nil {
- return errA
- }
- target.Start = *pp
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- ss := new(time.Time)
- tt := buff.ReadInt() // byte array length
- uu := buff.ReadBytes(tt)
- errB := ss.UnmarshalBinary(uu)
- if errB != nil {
- return errB
- }
- target.End = *ss
- // --- [end][read][reference](time.Time) ---
- return nil
- }
- //--------------------------------------------------------------------------
- // Deployment
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Deployment instance
- // into a byte array
- func (target *Deployment) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this Deployment instance
- // into a byte array leveraging a predefined context.
- func (target *Deployment) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.UID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.UID) // write string
- }
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.NamespaceUID)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.NamespaceUID) // write string
- }
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(target.Name)
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(target.Name) // write string
- }
- if target.Labels == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Labels)) // map length
- for v, z := range target.Labels {
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(v)
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(v) // write string
- }
- if ctx.IsStringTable() {
- e := ctx.Table.AddOrGet(z)
- buff.WriteInt(e) // write table index
- } else {
- buff.WriteString(z) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- if target.Annotations == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Annotations)) // map length
- for vv, zz := range target.Annotations {
- if ctx.IsStringTable() {
- f := ctx.Table.AddOrGet(vv)
- buff.WriteInt(f) // write table index
- } else {
- buff.WriteString(vv) // write string
- }
- if ctx.IsStringTable() {
- g := ctx.Table.AddOrGet(zz)
- buff.WriteInt(g) // write table index
- } else {
- buff.WriteString(zz) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- if target.MatchLabels == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.MatchLabels)) // map length
- for vvv, zzz := range target.MatchLabels {
- if ctx.IsStringTable() {
- h := ctx.Table.AddOrGet(vvv)
- buff.WriteInt(h) // write table index
- } else {
- buff.WriteString(vvv) // write string
- }
- if ctx.IsStringTable() {
- l := ctx.Table.AddOrGet(zzz)
- buff.WriteInt(l) // write table index
- } else {
- buff.WriteString(zzz) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [begin][write][reference](time.Time) ---
- m, errA := target.Start.MarshalBinary()
- if errA != nil {
- return errA
- }
- buff.WriteInt(len(m))
- buff.WriteBytes(m)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- n, errB := target.End.MarshalBinary()
- if errB != nil {
- return errB
- }
- buff.WriteInt(len(n))
- buff.WriteBytes(n)
- // --- [end][write][reference](time.Time) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Deployment type
- func (target *Deployment) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the Deployment type
- func (target *Deployment) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the Deployment type
- func (target *Deployment) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling Deployment. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.UID = a
- var e string
- if ctx.IsStringTable() {
- f := buff.ReadInt() // read string index
- e = ctx.Table.At(f)
- } else {
- e = buff.ReadString() // read string
- }
- d := e
- target.NamespaceUID = d
- var h string
- if ctx.IsStringTable() {
- l := buff.ReadInt() // read string index
- h = ctx.Table.At(l)
- } else {
- h = buff.ReadString() // read string
- }
- g := h
- target.Name = g
- if buff.ReadUInt8() == uint8(0) {
- target.Labels = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- n := buff.ReadInt() // map len
- m := make(map[string]string, n)
- for range n {
- var v string
- var p string
- if ctx.IsStringTable() {
- q := buff.ReadInt() // read string index
- p = ctx.Table.At(q)
- } else {
- p = buff.ReadString() // read string
- }
- o := p
- v = o
- var z string
- var s string
- if ctx.IsStringTable() {
- t := buff.ReadInt() // read string index
- s = ctx.Table.At(t)
- } else {
- s = buff.ReadString() // read string
- }
- r := s
- z = r
- m[v] = z
- }
- target.Labels = m
- // --- [end][read][map](map[string]string) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.Annotations = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- w := buff.ReadInt() // map len
- u := make(map[string]string, w)
- for range w {
- var vv string
- var y string
- if ctx.IsStringTable() {
- aa := buff.ReadInt() // read string index
- y = ctx.Table.At(aa)
- } else {
- y = buff.ReadString() // read string
- }
- x := y
- vv = x
- var zz string
- var cc string
- if ctx.IsStringTable() {
- dd := buff.ReadInt() // read string index
- cc = ctx.Table.At(dd)
- } else {
- cc = buff.ReadString() // read string
- }
- bb := cc
- zz = bb
- u[vv] = zz
- }
- target.Annotations = u
- // --- [end][read][map](map[string]string) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.MatchLabels = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- ff := buff.ReadInt() // map len
- ee := make(map[string]string, ff)
- for range ff {
- var vvv string
- var hh string
- if ctx.IsStringTable() {
- ll := buff.ReadInt() // read string index
- hh = ctx.Table.At(ll)
- } else {
- hh = buff.ReadString() // read string
- }
- gg := hh
- vvv = gg
- var zzz string
- var nn string
- if ctx.IsStringTable() {
- oo := buff.ReadInt() // read string index
- nn = ctx.Table.At(oo)
- } else {
- nn = buff.ReadString() // read string
- }
- mm := nn
- zzz = mm
- ee[vvv] = zzz
- }
- target.MatchLabels = ee
- // --- [end][read][map](map[string]string) ---
- }
- // --- [begin][read][reference](time.Time) ---
- pp := new(time.Time)
- qq := buff.ReadInt() // byte array length
- rr := buff.ReadBytes(qq)
- errA := pp.UnmarshalBinary(rr)
- if errA != nil {
- return errA
- }
- target.Start = *pp
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- ss := new(time.Time)
- tt := buff.ReadInt() // byte array length
- uu := buff.ReadBytes(tt)
- errB := ss.UnmarshalBinary(uu)
- if errB != nil {
- return errB
- }
- target.End = *ss
- // --- [end][read][reference](time.Time) ---
- return nil
- }
- //--------------------------------------------------------------------------
- // Diagnostic
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Diagnostic instance
- // into a byte array
- func (target *Diagnostic) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this Diagnostic instance
- // into a byte array leveraging a predefined context.
- func (target *Diagnostic) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- // --- [begin][write][reference](time.Time) ---
- a, errA := target.Timestamp.MarshalBinary()
- if errA != nil {
- return errA
- }
- buff.WriteInt(len(a))
- buff.WriteBytes(a)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][alias](DiagnosticLevel) ---
- buff.WriteInt(int(target.Level)) // write int
- // --- [end][write][alias](DiagnosticLevel) ---
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.Message)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.Message) // write string
- }
- if target.Details == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Details)) // map length
- for v, z := range target.Details {
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(v)
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(v) // write string
- }
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(z)
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(z) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Diagnostic type
- func (target *Diagnostic) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the Diagnostic type
- func (target *Diagnostic) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the Diagnostic type
- func (target *Diagnostic) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling Diagnostic. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][reference](time.Time) ---
- a := new(time.Time)
- b := buff.ReadInt() // byte array length
- c := buff.ReadBytes(b)
- errA := a.UnmarshalBinary(c)
- if errA != nil {
- return errA
- }
- target.Timestamp = *a
- // --- [end][read][reference](time.Time) ---
- } else {
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][alias](DiagnosticLevel) ---
- var d int
- e := buff.ReadInt() // read int
- d = e
- target.Level = DiagnosticLevel(d)
- // --- [end][read][alias](DiagnosticLevel) ---
- } else {
- }
- // field version check
- if uint8(1) <= version {
- var g string
- if ctx.IsStringTable() {
- h := buff.ReadInt() // read string index
- g = ctx.Table.At(h)
- } else {
- g = buff.ReadString() // read string
- }
- f := g
- target.Message = f
- } else {
- target.Message = "" // default
- }
- // field version check
- if uint8(1) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Details = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- m := buff.ReadInt() // map len
- l := make(map[string]string, m)
- for range m {
- var v string
- var o string
- if ctx.IsStringTable() {
- p := buff.ReadInt() // read string index
- o = ctx.Table.At(p)
- } else {
- o = buff.ReadString() // read string
- }
- n := o
- v = n
- var z string
- var r string
- if ctx.IsStringTable() {
- s := buff.ReadInt() // read string index
- r = ctx.Table.At(s)
- } else {
- r = buff.ReadString() // read string
- }
- q := r
- z = q
- l[v] = z
- }
- target.Details = l
- // --- [end][read][map](map[string]string) ---
- }
- } else {
- target.Details = nil
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // FileSystem
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this FileSystem instance
- // into a byte array
- func (target *FileSystem) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this FileSystem instance
- // into a byte array leveraging a predefined context.
- func (target *FileSystem) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- buff.WriteFloat64(target.CapacityBytes) // write float64
- buff.WriteFloat64(target.UsageByteAvg) // write float64
- buff.WriteFloat64(target.UsageByteMax) // write float64
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the FileSystem type
- func (target *FileSystem) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the FileSystem type
- func (target *FileSystem) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the FileSystem type
- func (target *FileSystem) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling FileSystem. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- a := buff.ReadFloat64() // read float64
- target.CapacityBytes = a
- b := buff.ReadFloat64() // read float64
- target.UsageByteAvg = b
- c := buff.ReadFloat64() // read float64
- target.UsageByteMax = c
- return nil
- }
- //--------------------------------------------------------------------------
- // Job
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Job instance
- // into a byte array
- func (target *Job) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this Job instance
- // into a byte array leveraging a predefined context.
- func (target *Job) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.UID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.UID) // write string
- }
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.NamespaceUID)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.NamespaceUID) // write string
- }
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(target.Name)
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(target.Name) // write string
- }
- if target.Labels == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Labels)) // map length
- for v, z := range target.Labels {
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(v)
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(v) // write string
- }
- if ctx.IsStringTable() {
- e := ctx.Table.AddOrGet(z)
- buff.WriteInt(e) // write table index
- } else {
- buff.WriteString(z) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- if target.Annotations == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Annotations)) // map length
- for vv, zz := range target.Annotations {
- if ctx.IsStringTable() {
- f := ctx.Table.AddOrGet(vv)
- buff.WriteInt(f) // write table index
- } else {
- buff.WriteString(vv) // write string
- }
- if ctx.IsStringTable() {
- g := ctx.Table.AddOrGet(zz)
- buff.WriteInt(g) // write table index
- } else {
- buff.WriteString(zz) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [begin][write][reference](time.Time) ---
- h, errA := target.Start.MarshalBinary()
- if errA != nil {
- return errA
- }
- buff.WriteInt(len(h))
- buff.WriteBytes(h)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- l, errB := target.End.MarshalBinary()
- if errB != nil {
- return errB
- }
- buff.WriteInt(len(l))
- buff.WriteBytes(l)
- // --- [end][write][reference](time.Time) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Job type
- func (target *Job) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the Job type
- func (target *Job) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the Job type
- func (target *Job) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling Job. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.UID = a
- var e string
- if ctx.IsStringTable() {
- f := buff.ReadInt() // read string index
- e = ctx.Table.At(f)
- } else {
- e = buff.ReadString() // read string
- }
- d := e
- target.NamespaceUID = d
- var h string
- if ctx.IsStringTable() {
- l := buff.ReadInt() // read string index
- h = ctx.Table.At(l)
- } else {
- h = buff.ReadString() // read string
- }
- g := h
- target.Name = g
- if buff.ReadUInt8() == uint8(0) {
- target.Labels = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- n := buff.ReadInt() // map len
- m := make(map[string]string, n)
- for range n {
- var v string
- var p string
- if ctx.IsStringTable() {
- q := buff.ReadInt() // read string index
- p = ctx.Table.At(q)
- } else {
- p = buff.ReadString() // read string
- }
- o := p
- v = o
- var z string
- var s string
- if ctx.IsStringTable() {
- t := buff.ReadInt() // read string index
- s = ctx.Table.At(t)
- } else {
- s = buff.ReadString() // read string
- }
- r := s
- z = r
- m[v] = z
- }
- target.Labels = m
- // --- [end][read][map](map[string]string) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.Annotations = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- w := buff.ReadInt() // map len
- u := make(map[string]string, w)
- for range w {
- var vv string
- var y string
- if ctx.IsStringTable() {
- aa := buff.ReadInt() // read string index
- y = ctx.Table.At(aa)
- } else {
- y = buff.ReadString() // read string
- }
- x := y
- vv = x
- var zz string
- var cc string
- if ctx.IsStringTable() {
- dd := buff.ReadInt() // read string index
- cc = ctx.Table.At(dd)
- } else {
- cc = buff.ReadString() // read string
- }
- bb := cc
- zz = bb
- u[vv] = zz
- }
- target.Annotations = u
- // --- [end][read][map](map[string]string) ---
- }
- // --- [begin][read][reference](time.Time) ---
- ee := new(time.Time)
- ff := buff.ReadInt() // byte array length
- gg := buff.ReadBytes(ff)
- errA := ee.UnmarshalBinary(gg)
- if errA != nil {
- return errA
- }
- target.Start = *ee
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- hh := new(time.Time)
- ll := buff.ReadInt() // byte array length
- mm := buff.ReadBytes(ll)
- errB := hh.UnmarshalBinary(mm)
- if errB != nil {
- return errB
- }
- target.End = *hh
- // --- [end][read][reference](time.Time) ---
- return nil
- }
- //--------------------------------------------------------------------------
- // KubeModelSet
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this KubeModelSet instance
- // into a byte array
- func (target *KubeModelSet) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: NewStringTableWriter(),
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- sTableBytes := ctx.Table.ToBytes()
- merged := appendBytes(sTableBytes, encBytes)
- return merged, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this KubeModelSet instance
- // into a byte array leveraging a predefined context.
- func (target *KubeModelSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if target.Metadata == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](Metadata) ---
- buff.WriteInt(0) // [compatibility, unused]
- errA := target.Metadata.MarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- // --- [end][write][struct](Metadata) ---
- }
- // --- [begin][write][struct](Window) ---
- buff.WriteInt(0) // [compatibility, unused]
- errB := target.Window.MarshalBinaryWithContext(ctx)
- if errB != nil {
- return errB
- }
- // --- [end][write][struct](Window) ---
- if target.Cluster == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](Cluster) ---
- buff.WriteInt(0) // [compatibility, unused]
- errC := target.Cluster.MarshalBinaryWithContext(ctx)
- if errC != nil {
- return errC
- }
- // --- [end][write][struct](Cluster) ---
- }
- if target.Namespaces == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]*Namespace) ---
- buff.WriteInt(len(target.Namespaces)) // map length
- for v, z := range target.Namespaces {
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(v)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(v) // write string
- }
- if z == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](Namespace) ---
- buff.WriteInt(0) // [compatibility, unused]
- errD := z.MarshalBinaryWithContext(ctx)
- if errD != nil {
- return errD
- }
- // --- [end][write][struct](Namespace) ---
- }
- }
- // --- [end][write][map](map[string]*Namespace) ---
- }
- if target.ResourceQuotas == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]*ResourceQuota) ---
- buff.WriteInt(len(target.ResourceQuotas)) // map length
- for vv, zz := range target.ResourceQuotas {
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(vv)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(vv) // write string
- }
- if zz == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](ResourceQuota) ---
- buff.WriteInt(0) // [compatibility, unused]
- errE := zz.MarshalBinaryWithContext(ctx)
- if errE != nil {
- return errE
- }
- // --- [end][write][struct](ResourceQuota) ---
- }
- }
- // --- [end][write][map](map[string]*ResourceQuota) ---
- }
- if target.Services == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]*Service) ---
- buff.WriteInt(len(target.Services)) // map length
- for vvv, zzz := range target.Services {
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(vvv)
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(vvv) // write string
- }
- if zzz == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](Service) ---
- buff.WriteInt(0) // [compatibility, unused]
- errF := zzz.MarshalBinaryWithContext(ctx)
- if errF != nil {
- return errF
- }
- // --- [end][write][struct](Service) ---
- }
- }
- // --- [end][write][map](map[string]*Service) ---
- }
- if target.Deployments == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]*Deployment) ---
- buff.WriteInt(len(target.Deployments)) // map length
- for vvvv, zzzz := range target.Deployments {
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(vvvv)
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(vvvv) // write string
- }
- if zzzz == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](Deployment) ---
- buff.WriteInt(0) // [compatibility, unused]
- errG := zzzz.MarshalBinaryWithContext(ctx)
- if errG != nil {
- return errG
- }
- // --- [end][write][struct](Deployment) ---
- }
- }
- // --- [end][write][map](map[string]*Deployment) ---
- }
- if target.StatefulSets == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]*StatefulSet) ---
- buff.WriteInt(len(target.StatefulSets)) // map length
- for vvvvv, zzzzz := range target.StatefulSets {
- if ctx.IsStringTable() {
- e := ctx.Table.AddOrGet(vvvvv)
- buff.WriteInt(e) // write table index
- } else {
- buff.WriteString(vvvvv) // write string
- }
- if zzzzz == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](StatefulSet) ---
- buff.WriteInt(0) // [compatibility, unused]
- errH := zzzzz.MarshalBinaryWithContext(ctx)
- if errH != nil {
- return errH
- }
- // --- [end][write][struct](StatefulSet) ---
- }
- }
- // --- [end][write][map](map[string]*StatefulSet) ---
- }
- if target.DaemonSets == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]*DaemonSet) ---
- buff.WriteInt(len(target.DaemonSets)) // map length
- for vvvvvv, zzzzzz := range target.DaemonSets {
- if ctx.IsStringTable() {
- f := ctx.Table.AddOrGet(vvvvvv)
- buff.WriteInt(f) // write table index
- } else {
- buff.WriteString(vvvvvv) // write string
- }
- if zzzzzz == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](DaemonSet) ---
- buff.WriteInt(0) // [compatibility, unused]
- errI := zzzzzz.MarshalBinaryWithContext(ctx)
- if errI != nil {
- return errI
- }
- // --- [end][write][struct](DaemonSet) ---
- }
- }
- // --- [end][write][map](map[string]*DaemonSet) ---
- }
- if target.Jobs == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]*Job) ---
- buff.WriteInt(len(target.Jobs)) // map length
- for vvvvvvv, zzzzzzz := range target.Jobs {
- if ctx.IsStringTable() {
- g := ctx.Table.AddOrGet(vvvvvvv)
- buff.WriteInt(g) // write table index
- } else {
- buff.WriteString(vvvvvvv) // write string
- }
- if zzzzzzz == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](Job) ---
- buff.WriteInt(0) // [compatibility, unused]
- errJ := zzzzzzz.MarshalBinaryWithContext(ctx)
- if errJ != nil {
- return errJ
- }
- // --- [end][write][struct](Job) ---
- }
- }
- // --- [end][write][map](map[string]*Job) ---
- }
- if target.CronJobs == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]*CronJob) ---
- buff.WriteInt(len(target.CronJobs)) // map length
- for vvvvvvvv, zzzzzzzz := range target.CronJobs {
- if ctx.IsStringTable() {
- h := ctx.Table.AddOrGet(vvvvvvvv)
- buff.WriteInt(h) // write table index
- } else {
- buff.WriteString(vvvvvvvv) // write string
- }
- if zzzzzzzz == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](CronJob) ---
- buff.WriteInt(0) // [compatibility, unused]
- errK := zzzzzzzz.MarshalBinaryWithContext(ctx)
- if errK != nil {
- return errK
- }
- // --- [end][write][struct](CronJob) ---
- }
- }
- // --- [end][write][map](map[string]*CronJob) ---
- }
- if target.ReplicaSets == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]*ReplicaSet) ---
- buff.WriteInt(len(target.ReplicaSets)) // map length
- for vvvvvvvvv, zzzzzzzzz := range target.ReplicaSets {
- if ctx.IsStringTable() {
- l := ctx.Table.AddOrGet(vvvvvvvvv)
- buff.WriteInt(l) // write table index
- } else {
- buff.WriteString(vvvvvvvvv) // write string
- }
- if zzzzzzzzz == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](ReplicaSet) ---
- buff.WriteInt(0) // [compatibility, unused]
- errL := zzzzzzzzz.MarshalBinaryWithContext(ctx)
- if errL != nil {
- return errL
- }
- // --- [end][write][struct](ReplicaSet) ---
- }
- }
- // --- [end][write][map](map[string]*ReplicaSet) ---
- }
- if target.Nodes == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]*Node) ---
- buff.WriteInt(len(target.Nodes)) // map length
- for vvvvvvvvvv, zzzzzzzzzz := range target.Nodes {
- if ctx.IsStringTable() {
- m := ctx.Table.AddOrGet(vvvvvvvvvv)
- buff.WriteInt(m) // write table index
- } else {
- buff.WriteString(vvvvvvvvvv) // write string
- }
- if zzzzzzzzzz == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](Node) ---
- buff.WriteInt(0) // [compatibility, unused]
- errM := zzzzzzzzzz.MarshalBinaryWithContext(ctx)
- if errM != nil {
- return errM
- }
- // --- [end][write][struct](Node) ---
- }
- }
- // --- [end][write][map](map[string]*Node) ---
- }
- if target.PersistentVolumes == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]*PersistentVolume) ---
- buff.WriteInt(len(target.PersistentVolumes)) // map length
- for vvvvvvvvvvv, zzzzzzzzzzz := range target.PersistentVolumes {
- if ctx.IsStringTable() {
- n := ctx.Table.AddOrGet(vvvvvvvvvvv)
- buff.WriteInt(n) // write table index
- } else {
- buff.WriteString(vvvvvvvvvvv) // write string
- }
- if zzzzzzzzzzz == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](PersistentVolume) ---
- buff.WriteInt(0) // [compatibility, unused]
- errN := zzzzzzzzzzz.MarshalBinaryWithContext(ctx)
- if errN != nil {
- return errN
- }
- // --- [end][write][struct](PersistentVolume) ---
- }
- }
- // --- [end][write][map](map[string]*PersistentVolume) ---
- }
- if target.PersistentVolumeClaims == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]*PersistentVolumeClaim) ---
- buff.WriteInt(len(target.PersistentVolumeClaims)) // map length
- for vvvvvvvvvvvv, zzzzzzzzzzzz := range target.PersistentVolumeClaims {
- if ctx.IsStringTable() {
- o := ctx.Table.AddOrGet(vvvvvvvvvvvv)
- buff.WriteInt(o) // write table index
- } else {
- buff.WriteString(vvvvvvvvvvvv) // write string
- }
- if zzzzzzzzzzzz == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](PersistentVolumeClaim) ---
- buff.WriteInt(0) // [compatibility, unused]
- errO := zzzzzzzzzzzz.MarshalBinaryWithContext(ctx)
- if errO != nil {
- return errO
- }
- // --- [end][write][struct](PersistentVolumeClaim) ---
- }
- }
- // --- [end][write][map](map[string]*PersistentVolumeClaim) ---
- }
- if target.Pods == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]*Pod) ---
- buff.WriteInt(len(target.Pods)) // map length
- for vvvvvvvvvvvvv, zzzzzzzzzzzzz := range target.Pods {
- if ctx.IsStringTable() {
- p := ctx.Table.AddOrGet(vvvvvvvvvvvvv)
- buff.WriteInt(p) // write table index
- } else {
- buff.WriteString(vvvvvvvvvvvvv) // write string
- }
- if zzzzzzzzzzzzz == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](Pod) ---
- buff.WriteInt(0) // [compatibility, unused]
- errP := zzzzzzzzzzzzz.MarshalBinaryWithContext(ctx)
- if errP != nil {
- return errP
- }
- // --- [end][write][struct](Pod) ---
- }
- }
- // --- [end][write][map](map[string]*Pod) ---
- }
- if target.Containers == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]*Container) ---
- buff.WriteInt(len(target.Containers)) // map length
- for vvvvvvvvvvvvvv, zzzzzzzzzzzzzz := range target.Containers {
- if ctx.IsStringTable() {
- q := ctx.Table.AddOrGet(vvvvvvvvvvvvvv)
- buff.WriteInt(q) // write table index
- } else {
- buff.WriteString(vvvvvvvvvvvvvv) // write string
- }
- if zzzzzzzzzzzzzz == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](Container) ---
- buff.WriteInt(0) // [compatibility, unused]
- errQ := zzzzzzzzzzzzzz.MarshalBinaryWithContext(ctx)
- if errQ != nil {
- return errQ
- }
- // --- [end][write][struct](Container) ---
- }
- }
- // --- [end][write][map](map[string]*Container) ---
- }
- if target.DCGMDevices == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]*DCGMDevice) ---
- buff.WriteInt(len(target.DCGMDevices)) // map length
- for vvvvvvvvvvvvvvv, zzzzzzzzzzzzzzz := range target.DCGMDevices {
- if ctx.IsStringTable() {
- r := ctx.Table.AddOrGet(vvvvvvvvvvvvvvv)
- buff.WriteInt(r) // write table index
- } else {
- buff.WriteString(vvvvvvvvvvvvvvv) // write string
- }
- if zzzzzzzzzzzzzzz == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](DCGMDevice) ---
- buff.WriteInt(0) // [compatibility, unused]
- errR := zzzzzzzzzzzzzzz.MarshalBinaryWithContext(ctx)
- if errR != nil {
- return errR
- }
- // --- [end][write][struct](DCGMDevice) ---
- }
- }
- // --- [end][write][map](map[string]*DCGMDevice) ---
- }
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the KubeModelSet type
- func (target *KubeModelSet) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the KubeModelSet type
- func (target *KubeModelSet) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the KubeModelSet type
- func (target *KubeModelSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling KubeModelSet. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- // field version check
- if uint8(1) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Metadata = nil
- } else {
- // --- [begin][read][struct](Metadata) ---
- a := new(Metadata)
- buff.ReadInt() // [compatibility, unused]
- errA := a.UnmarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- target.Metadata = a
- // --- [end][read][struct](Metadata) ---
- }
- } else {
- target.Metadata = nil
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][struct](Window) ---
- b := new(Window)
- buff.ReadInt() // [compatibility, unused]
- errB := b.UnmarshalBinaryWithContext(ctx)
- if errB != nil {
- return errB
- }
- target.Window = *b
- // --- [end][read][struct](Window) ---
- } else {
- }
- // field version check
- if uint8(1) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Cluster = nil
- } else {
- // --- [begin][read][struct](Cluster) ---
- c := new(Cluster)
- buff.ReadInt() // [compatibility, unused]
- errC := c.UnmarshalBinaryWithContext(ctx)
- if errC != nil {
- return errC
- }
- target.Cluster = c
- // --- [end][read][struct](Cluster) ---
- }
- } else {
- target.Cluster = nil
- }
- // field version check
- if uint8(1) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Namespaces = nil
- } else {
- // --- [begin][read][map](map[string]*Namespace) ---
- e := buff.ReadInt() // map len
- d := make(map[string]*Namespace, e)
- for range e {
- var v string
- var g string
- if ctx.IsStringTable() {
- h := buff.ReadInt() // read string index
- g = ctx.Table.At(h)
- } else {
- g = buff.ReadString() // read string
- }
- f := g
- v = f
- var z *Namespace
- if buff.ReadUInt8() == uint8(0) {
- z = nil
- } else {
- // --- [begin][read][struct](Namespace) ---
- l := new(Namespace)
- buff.ReadInt() // [compatibility, unused]
- errD := l.UnmarshalBinaryWithContext(ctx)
- if errD != nil {
- return errD
- }
- z = l
- // --- [end][read][struct](Namespace) ---
- }
- d[v] = z
- }
- target.Namespaces = d
- // --- [end][read][map](map[string]*Namespace) ---
- }
- } else {
- target.Namespaces = nil
- }
- // field version check
- if uint8(1) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.ResourceQuotas = nil
- } else {
- // --- [begin][read][map](map[string]*ResourceQuota) ---
- n := buff.ReadInt() // map len
- m := make(map[string]*ResourceQuota, n)
- for range n {
- var vv string
- var p string
- if ctx.IsStringTable() {
- q := buff.ReadInt() // read string index
- p = ctx.Table.At(q)
- } else {
- p = buff.ReadString() // read string
- }
- o := p
- vv = o
- var zz *ResourceQuota
- if buff.ReadUInt8() == uint8(0) {
- zz = nil
- } else {
- // --- [begin][read][struct](ResourceQuota) ---
- r := new(ResourceQuota)
- buff.ReadInt() // [compatibility, unused]
- errE := r.UnmarshalBinaryWithContext(ctx)
- if errE != nil {
- return errE
- }
- zz = r
- // --- [end][read][struct](ResourceQuota) ---
- }
- m[vv] = zz
- }
- target.ResourceQuotas = m
- // --- [end][read][map](map[string]*ResourceQuota) ---
- }
- } else {
- target.ResourceQuotas = nil
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Services = nil
- } else {
- // --- [begin][read][map](map[string]*Service) ---
- t := buff.ReadInt() // map len
- s := make(map[string]*Service, t)
- for range t {
- var vvv string
- var w string
- if ctx.IsStringTable() {
- x := buff.ReadInt() // read string index
- w = ctx.Table.At(x)
- } else {
- w = buff.ReadString() // read string
- }
- u := w
- vvv = u
- var zzz *Service
- if buff.ReadUInt8() == uint8(0) {
- zzz = nil
- } else {
- // --- [begin][read][struct](Service) ---
- y := new(Service)
- buff.ReadInt() // [compatibility, unused]
- errF := y.UnmarshalBinaryWithContext(ctx)
- if errF != nil {
- return errF
- }
- zzz = y
- // --- [end][read][struct](Service) ---
- }
- s[vvv] = zzz
- }
- target.Services = s
- // --- [end][read][map](map[string]*Service) ---
- }
- } else {
- target.Services = nil
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Deployments = nil
- } else {
- // --- [begin][read][map](map[string]*Deployment) ---
- bb := buff.ReadInt() // map len
- aa := make(map[string]*Deployment, bb)
- for range bb {
- var vvvv string
- var dd string
- if ctx.IsStringTable() {
- ee := buff.ReadInt() // read string index
- dd = ctx.Table.At(ee)
- } else {
- dd = buff.ReadString() // read string
- }
- cc := dd
- vvvv = cc
- var zzzz *Deployment
- if buff.ReadUInt8() == uint8(0) {
- zzzz = nil
- } else {
- // --- [begin][read][struct](Deployment) ---
- ff := new(Deployment)
- buff.ReadInt() // [compatibility, unused]
- errG := ff.UnmarshalBinaryWithContext(ctx)
- if errG != nil {
- return errG
- }
- zzzz = ff
- // --- [end][read][struct](Deployment) ---
- }
- aa[vvvv] = zzzz
- }
- target.Deployments = aa
- // --- [end][read][map](map[string]*Deployment) ---
- }
- } else {
- target.Deployments = nil
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.StatefulSets = nil
- } else {
- // --- [begin][read][map](map[string]*StatefulSet) ---
- hh := buff.ReadInt() // map len
- gg := make(map[string]*StatefulSet, hh)
- for range hh {
- var vvvvv string
- var mm string
- if ctx.IsStringTable() {
- nn := buff.ReadInt() // read string index
- mm = ctx.Table.At(nn)
- } else {
- mm = buff.ReadString() // read string
- }
- ll := mm
- vvvvv = ll
- var zzzzz *StatefulSet
- if buff.ReadUInt8() == uint8(0) {
- zzzzz = nil
- } else {
- // --- [begin][read][struct](StatefulSet) ---
- oo := new(StatefulSet)
- buff.ReadInt() // [compatibility, unused]
- errH := oo.UnmarshalBinaryWithContext(ctx)
- if errH != nil {
- return errH
- }
- zzzzz = oo
- // --- [end][read][struct](StatefulSet) ---
- }
- gg[vvvvv] = zzzzz
- }
- target.StatefulSets = gg
- // --- [end][read][map](map[string]*StatefulSet) ---
- }
- } else {
- target.StatefulSets = nil
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.DaemonSets = nil
- } else {
- // --- [begin][read][map](map[string]*DaemonSet) ---
- qq := buff.ReadInt() // map len
- pp := make(map[string]*DaemonSet, qq)
- for range qq {
- var vvvvvv string
- var ss string
- if ctx.IsStringTable() {
- tt := buff.ReadInt() // read string index
- ss = ctx.Table.At(tt)
- } else {
- ss = buff.ReadString() // read string
- }
- rr := ss
- vvvvvv = rr
- var zzzzzz *DaemonSet
- if buff.ReadUInt8() == uint8(0) {
- zzzzzz = nil
- } else {
- // --- [begin][read][struct](DaemonSet) ---
- uu := new(DaemonSet)
- buff.ReadInt() // [compatibility, unused]
- errI := uu.UnmarshalBinaryWithContext(ctx)
- if errI != nil {
- return errI
- }
- zzzzzz = uu
- // --- [end][read][struct](DaemonSet) ---
- }
- pp[vvvvvv] = zzzzzz
- }
- target.DaemonSets = pp
- // --- [end][read][map](map[string]*DaemonSet) ---
- }
- } else {
- target.DaemonSets = nil
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Jobs = nil
- } else {
- // --- [begin][read][map](map[string]*Job) ---
- xx := buff.ReadInt() // map len
- ww := make(map[string]*Job, xx)
- for range xx {
- var vvvvvvv string
- var aaa string
- if ctx.IsStringTable() {
- bbb := buff.ReadInt() // read string index
- aaa = ctx.Table.At(bbb)
- } else {
- aaa = buff.ReadString() // read string
- }
- yy := aaa
- vvvvvvv = yy
- var zzzzzzz *Job
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzz = nil
- } else {
- // --- [begin][read][struct](Job) ---
- ccc := new(Job)
- buff.ReadInt() // [compatibility, unused]
- errJ := ccc.UnmarshalBinaryWithContext(ctx)
- if errJ != nil {
- return errJ
- }
- zzzzzzz = ccc
- // --- [end][read][struct](Job) ---
- }
- ww[vvvvvvv] = zzzzzzz
- }
- target.Jobs = ww
- // --- [end][read][map](map[string]*Job) ---
- }
- } else {
- target.Jobs = nil
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.CronJobs = nil
- } else {
- // --- [begin][read][map](map[string]*CronJob) ---
- eee := buff.ReadInt() // map len
- ddd := make(map[string]*CronJob, eee)
- for range eee {
- var vvvvvvvv string
- var ggg string
- if ctx.IsStringTable() {
- hhh := buff.ReadInt() // read string index
- ggg = ctx.Table.At(hhh)
- } else {
- ggg = buff.ReadString() // read string
- }
- fff := ggg
- vvvvvvvv = fff
- var zzzzzzzz *CronJob
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzzz = nil
- } else {
- // --- [begin][read][struct](CronJob) ---
- lll := new(CronJob)
- buff.ReadInt() // [compatibility, unused]
- errK := lll.UnmarshalBinaryWithContext(ctx)
- if errK != nil {
- return errK
- }
- zzzzzzzz = lll
- // --- [end][read][struct](CronJob) ---
- }
- ddd[vvvvvvvv] = zzzzzzzz
- }
- target.CronJobs = ddd
- // --- [end][read][map](map[string]*CronJob) ---
- }
- } else {
- target.CronJobs = nil
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.ReplicaSets = nil
- } else {
- // --- [begin][read][map](map[string]*ReplicaSet) ---
- nnn := buff.ReadInt() // map len
- mmm := make(map[string]*ReplicaSet, nnn)
- for range nnn {
- var vvvvvvvvv string
- var ppp string
- if ctx.IsStringTable() {
- qqq := buff.ReadInt() // read string index
- ppp = ctx.Table.At(qqq)
- } else {
- ppp = buff.ReadString() // read string
- }
- ooo := ppp
- vvvvvvvvv = ooo
- var zzzzzzzzz *ReplicaSet
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzzzz = nil
- } else {
- // --- [begin][read][struct](ReplicaSet) ---
- rrr := new(ReplicaSet)
- buff.ReadInt() // [compatibility, unused]
- errL := rrr.UnmarshalBinaryWithContext(ctx)
- if errL != nil {
- return errL
- }
- zzzzzzzzz = rrr
- // --- [end][read][struct](ReplicaSet) ---
- }
- mmm[vvvvvvvvv] = zzzzzzzzz
- }
- target.ReplicaSets = mmm
- // --- [end][read][map](map[string]*ReplicaSet) ---
- }
- } else {
- target.ReplicaSets = nil
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Nodes = nil
- } else {
- // --- [begin][read][map](map[string]*Node) ---
- ttt := buff.ReadInt() // map len
- sss := make(map[string]*Node, ttt)
- for range ttt {
- var vvvvvvvvvv string
- var www string
- if ctx.IsStringTable() {
- xxx := buff.ReadInt() // read string index
- www = ctx.Table.At(xxx)
- } else {
- www = buff.ReadString() // read string
- }
- uuu := www
- vvvvvvvvvv = uuu
- var zzzzzzzzzz *Node
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzzzzz = nil
- } else {
- // --- [begin][read][struct](Node) ---
- yyy := new(Node)
- buff.ReadInt() // [compatibility, unused]
- errM := yyy.UnmarshalBinaryWithContext(ctx)
- if errM != nil {
- return errM
- }
- zzzzzzzzzz = yyy
- // --- [end][read][struct](Node) ---
- }
- sss[vvvvvvvvvv] = zzzzzzzzzz
- }
- target.Nodes = sss
- // --- [end][read][map](map[string]*Node) ---
- }
- } else {
- target.Nodes = nil
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.PersistentVolumes = nil
- } else {
- // --- [begin][read][map](map[string]*PersistentVolume) ---
- bbbb := buff.ReadInt() // map len
- aaaa := make(map[string]*PersistentVolume, bbbb)
- for range bbbb {
- var vvvvvvvvvvv string
- var dddd string
- if ctx.IsStringTable() {
- eeee := buff.ReadInt() // read string index
- dddd = ctx.Table.At(eeee)
- } else {
- dddd = buff.ReadString() // read string
- }
- cccc := dddd
- vvvvvvvvvvv = cccc
- var zzzzzzzzzzz *PersistentVolume
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzzzzzz = nil
- } else {
- // --- [begin][read][struct](PersistentVolume) ---
- ffff := new(PersistentVolume)
- buff.ReadInt() // [compatibility, unused]
- errN := ffff.UnmarshalBinaryWithContext(ctx)
- if errN != nil {
- return errN
- }
- zzzzzzzzzzz = ffff
- // --- [end][read][struct](PersistentVolume) ---
- }
- aaaa[vvvvvvvvvvv] = zzzzzzzzzzz
- }
- target.PersistentVolumes = aaaa
- // --- [end][read][map](map[string]*PersistentVolume) ---
- }
- } else {
- target.PersistentVolumes = nil
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.PersistentVolumeClaims = nil
- } else {
- // --- [begin][read][map](map[string]*PersistentVolumeClaim) ---
- hhhh := buff.ReadInt() // map len
- gggg := make(map[string]*PersistentVolumeClaim, hhhh)
- for range hhhh {
- var vvvvvvvvvvvv string
- var mmmm string
- if ctx.IsStringTable() {
- nnnn := buff.ReadInt() // read string index
- mmmm = ctx.Table.At(nnnn)
- } else {
- mmmm = buff.ReadString() // read string
- }
- llll := mmmm
- vvvvvvvvvvvv = llll
- var zzzzzzzzzzzz *PersistentVolumeClaim
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzzzzzzz = nil
- } else {
- // --- [begin][read][struct](PersistentVolumeClaim) ---
- oooo := new(PersistentVolumeClaim)
- buff.ReadInt() // [compatibility, unused]
- errO := oooo.UnmarshalBinaryWithContext(ctx)
- if errO != nil {
- return errO
- }
- zzzzzzzzzzzz = oooo
- // --- [end][read][struct](PersistentVolumeClaim) ---
- }
- gggg[vvvvvvvvvvvv] = zzzzzzzzzzzz
- }
- target.PersistentVolumeClaims = gggg
- // --- [end][read][map](map[string]*PersistentVolumeClaim) ---
- }
- } else {
- target.PersistentVolumeClaims = nil
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Pods = nil
- } else {
- // --- [begin][read][map](map[string]*Pod) ---
- qqqq := buff.ReadInt() // map len
- pppp := make(map[string]*Pod, qqqq)
- for range qqqq {
- var vvvvvvvvvvvvv string
- var ssss string
- if ctx.IsStringTable() {
- tttt := buff.ReadInt() // read string index
- ssss = ctx.Table.At(tttt)
- } else {
- ssss = buff.ReadString() // read string
- }
- rrrr := ssss
- vvvvvvvvvvvvv = rrrr
- var zzzzzzzzzzzzz *Pod
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzzzzzzzz = nil
- } else {
- // --- [begin][read][struct](Pod) ---
- uuuu := new(Pod)
- buff.ReadInt() // [compatibility, unused]
- errP := uuuu.UnmarshalBinaryWithContext(ctx)
- if errP != nil {
- return errP
- }
- zzzzzzzzzzzzz = uuuu
- // --- [end][read][struct](Pod) ---
- }
- pppp[vvvvvvvvvvvvv] = zzzzzzzzzzzzz
- }
- target.Pods = pppp
- // --- [end][read][map](map[string]*Pod) ---
- }
- } else {
- target.Pods = nil
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Containers = nil
- } else {
- // --- [begin][read][map](map[string]*Container) ---
- xxxx := buff.ReadInt() // map len
- wwww := make(map[string]*Container, xxxx)
- for range xxxx {
- var vvvvvvvvvvvvvv string
- var aaaaa string
- if ctx.IsStringTable() {
- bbbbb := buff.ReadInt() // read string index
- aaaaa = ctx.Table.At(bbbbb)
- } else {
- aaaaa = buff.ReadString() // read string
- }
- yyyy := aaaaa
- vvvvvvvvvvvvvv = yyyy
- var zzzzzzzzzzzzzz *Container
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzzzzzzzzz = nil
- } else {
- // --- [begin][read][struct](Container) ---
- ccccc := new(Container)
- buff.ReadInt() // [compatibility, unused]
- errQ := ccccc.UnmarshalBinaryWithContext(ctx)
- if errQ != nil {
- return errQ
- }
- zzzzzzzzzzzzzz = ccccc
- // --- [end][read][struct](Container) ---
- }
- wwww[vvvvvvvvvvvvvv] = zzzzzzzzzzzzzz
- }
- target.Containers = wwww
- // --- [end][read][map](map[string]*Container) ---
- }
- } else {
- target.Containers = nil
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.DCGMDevices = nil
- } else {
- // --- [begin][read][map](map[string]*DCGMDevice) ---
- eeeee := buff.ReadInt() // map len
- ddddd := make(map[string]*DCGMDevice, eeeee)
- for range eeeee {
- var vvvvvvvvvvvvvvv string
- var ggggg string
- if ctx.IsStringTable() {
- hhhhh := buff.ReadInt() // read string index
- ggggg = ctx.Table.At(hhhhh)
- } else {
- ggggg = buff.ReadString() // read string
- }
- fffff := ggggg
- vvvvvvvvvvvvvvv = fffff
- var zzzzzzzzzzzzzzz *DCGMDevice
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzzzzzzzzzz = nil
- } else {
- // --- [begin][read][struct](DCGMDevice) ---
- lllll := new(DCGMDevice)
- buff.ReadInt() // [compatibility, unused]
- errR := lllll.UnmarshalBinaryWithContext(ctx)
- if errR != nil {
- return errR
- }
- zzzzzzzzzzzzzzz = lllll
- // --- [end][read][struct](DCGMDevice) ---
- }
- ddddd[vvvvvvvvvvvvvvv] = zzzzzzzzzzzzzzz
- }
- target.DCGMDevices = ddddd
- // --- [end][read][map](map[string]*DCGMDevice) ---
- }
- } else {
- target.DCGMDevices = nil
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // KubeModelSetStream
- //--------------------------------------------------------------------------
- // KubeModelSetStream is a single use field stream for the contents of an KubeModelSet instance. Instead of creating an instance and populating
- // the fields on that instance, we provide a streaming iterator which yields (BingenFieldInfo, *BingenValue) tuples for each
- // streamable element. All slices and maps will be flattened one depth and each element streamed individually.
- type KubeModelSetStream struct {
- reader io.Reader
- ctx *DecodingContext
- err error
- }
- // Closes closes the internal io.Reader used to read and parse the KubeModelSet fields.
- // This should be called once the stream is no longer needed.
- func (stream *KubeModelSetStream) Close() {
- if closer, ok := stream.reader.(io.Closer); ok {
- closer.Close()
- }
- stream.ctx.Close()
- }
- // Error returns an error if one occurred during the process of streaming the KubeModelSet
- // This can be checked after iterating through the Stream().
- func (stream *KubeModelSetStream) Error() error {
- return stream.err
- }
- // NewKubeModelSetStream creates a new KubeModelSetStream, which uses the io.Reader data to stream all internal fields of an KubeModelSet instance
- func NewKubeModelSetStream(reader io.Reader) BingenStream {
- ctx := NewDecodingContextFromReader(reader)
- return &KubeModelSetStream{
- ctx: ctx,
- reader: reader,
- }
- }
- // Stream returns the iterator which will stream each field of the target type.
- func (stream *KubeModelSetStream) Stream() iter.Seq2[BingenFieldInfo, *BingenValue] {
- return func(yield func(BingenFieldInfo, *BingenValue) bool) {
- var fi BingenFieldInfo
- ctx := stream.ctx
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- stream.err = fmt.Errorf("Invalid Version Unmarshalling KubeModelSet. Expected %d or less, got %d", DefaultCodecVersion, version)
- return
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[*Metadata](),
- Name: "Metadata",
- }
- // field version check
- if uint8(1) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][struct](Metadata) ---
- b := new(Metadata)
- buff.ReadInt() // [compatibility, unused]
- errA := b.UnmarshalBinaryWithContext(ctx)
- if errA != nil {
- stream.err = errA
- return
- }
- a := b
- // --- [end][read][struct](Metadata) ---
- if !yield(fi, singleV(a)) {
- return
- }
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[Window](),
- Name: "Window",
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][struct](Window) ---
- d := new(Window)
- buff.ReadInt() // [compatibility, unused]
- errB := d.UnmarshalBinaryWithContext(ctx)
- if errB != nil {
- stream.err = errB
- return
- }
- c := *d
- // --- [end][read][struct](Window) ---
- if !yield(fi, singleV(c)) {
- return
- }
- } else {
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[*Cluster](),
- Name: "Cluster",
- }
- // field version check
- if uint8(1) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][struct](Cluster) ---
- f := new(Cluster)
- buff.ReadInt() // [compatibility, unused]
- errC := f.UnmarshalBinaryWithContext(ctx)
- if errC != nil {
- stream.err = errC
- return
- }
- e := f
- // --- [end][read][struct](Cluster) ---
- if !yield(fi, singleV(e)) {
- return
- }
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[map[string]*Namespace](),
- Name: "Namespaces",
- }
- // field version check
- if uint8(1) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][streaming-map](map[string]*Namespace) ---
- g := buff.ReadInt() // map len
- for range g {
- var v string
- var l string
- if ctx.IsStringTable() {
- m := buff.ReadInt() // read string index
- l = ctx.Table.At(m)
- } else {
- l = buff.ReadString() // read string
- }
- h := l
- v = h
- var z *Namespace
- if buff.ReadUInt8() == uint8(0) {
- z = nil
- } else {
- // --- [begin][read][struct](Namespace) ---
- n := new(Namespace)
- buff.ReadInt() // [compatibility, unused]
- errD := n.UnmarshalBinaryWithContext(ctx)
- if errD != nil {
- stream.err = errD
- return
- }
- z = n
- // --- [end][read][struct](Namespace) ---
- }
- if !yield(fi, pairV(v, z)) {
- return
- }
- }
- // --- [end][read][streaming-map](map[string]*Namespace) ---
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[map[string]*ResourceQuota](),
- Name: "ResourceQuotas",
- }
- // field version check
- if uint8(1) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][streaming-map](map[string]*ResourceQuota) ---
- o := buff.ReadInt() // map len
- for range o {
- var vv string
- var q string
- if ctx.IsStringTable() {
- r := buff.ReadInt() // read string index
- q = ctx.Table.At(r)
- } else {
- q = buff.ReadString() // read string
- }
- p := q
- vv = p
- var zz *ResourceQuota
- if buff.ReadUInt8() == uint8(0) {
- zz = nil
- } else {
- // --- [begin][read][struct](ResourceQuota) ---
- s := new(ResourceQuota)
- buff.ReadInt() // [compatibility, unused]
- errE := s.UnmarshalBinaryWithContext(ctx)
- if errE != nil {
- stream.err = errE
- return
- }
- zz = s
- // --- [end][read][struct](ResourceQuota) ---
- }
- if !yield(fi, pairV(vv, zz)) {
- return
- }
- }
- // --- [end][read][streaming-map](map[string]*ResourceQuota) ---
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[map[string]*Service](),
- Name: "Services",
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][streaming-map](map[string]*Service) ---
- t := buff.ReadInt() // map len
- for range t {
- var vvv string
- var w string
- if ctx.IsStringTable() {
- x := buff.ReadInt() // read string index
- w = ctx.Table.At(x)
- } else {
- w = buff.ReadString() // read string
- }
- u := w
- vvv = u
- var zzz *Service
- if buff.ReadUInt8() == uint8(0) {
- zzz = nil
- } else {
- // --- [begin][read][struct](Service) ---
- y := new(Service)
- buff.ReadInt() // [compatibility, unused]
- errF := y.UnmarshalBinaryWithContext(ctx)
- if errF != nil {
- stream.err = errF
- return
- }
- zzz = y
- // --- [end][read][struct](Service) ---
- }
- if !yield(fi, pairV(vvv, zzz)) {
- return
- }
- }
- // --- [end][read][streaming-map](map[string]*Service) ---
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[map[string]*Deployment](),
- Name: "Deployments",
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][streaming-map](map[string]*Deployment) ---
- aa := buff.ReadInt() // map len
- for range aa {
- var vvvv string
- var cc string
- if ctx.IsStringTable() {
- dd := buff.ReadInt() // read string index
- cc = ctx.Table.At(dd)
- } else {
- cc = buff.ReadString() // read string
- }
- bb := cc
- vvvv = bb
- var zzzz *Deployment
- if buff.ReadUInt8() == uint8(0) {
- zzzz = nil
- } else {
- // --- [begin][read][struct](Deployment) ---
- ee := new(Deployment)
- buff.ReadInt() // [compatibility, unused]
- errG := ee.UnmarshalBinaryWithContext(ctx)
- if errG != nil {
- stream.err = errG
- return
- }
- zzzz = ee
- // --- [end][read][struct](Deployment) ---
- }
- if !yield(fi, pairV(vvvv, zzzz)) {
- return
- }
- }
- // --- [end][read][streaming-map](map[string]*Deployment) ---
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[map[string]*StatefulSet](),
- Name: "StatefulSets",
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][streaming-map](map[string]*StatefulSet) ---
- ff := buff.ReadInt() // map len
- for range ff {
- var vvvvv string
- var hh string
- if ctx.IsStringTable() {
- ll := buff.ReadInt() // read string index
- hh = ctx.Table.At(ll)
- } else {
- hh = buff.ReadString() // read string
- }
- gg := hh
- vvvvv = gg
- var zzzzz *StatefulSet
- if buff.ReadUInt8() == uint8(0) {
- zzzzz = nil
- } else {
- // --- [begin][read][struct](StatefulSet) ---
- mm := new(StatefulSet)
- buff.ReadInt() // [compatibility, unused]
- errH := mm.UnmarshalBinaryWithContext(ctx)
- if errH != nil {
- stream.err = errH
- return
- }
- zzzzz = mm
- // --- [end][read][struct](StatefulSet) ---
- }
- if !yield(fi, pairV(vvvvv, zzzzz)) {
- return
- }
- }
- // --- [end][read][streaming-map](map[string]*StatefulSet) ---
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[map[string]*DaemonSet](),
- Name: "DaemonSets",
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][streaming-map](map[string]*DaemonSet) ---
- nn := buff.ReadInt() // map len
- for range nn {
- var vvvvvv string
- var pp string
- if ctx.IsStringTable() {
- qq := buff.ReadInt() // read string index
- pp = ctx.Table.At(qq)
- } else {
- pp = buff.ReadString() // read string
- }
- oo := pp
- vvvvvv = oo
- var zzzzzz *DaemonSet
- if buff.ReadUInt8() == uint8(0) {
- zzzzzz = nil
- } else {
- // --- [begin][read][struct](DaemonSet) ---
- rr := new(DaemonSet)
- buff.ReadInt() // [compatibility, unused]
- errI := rr.UnmarshalBinaryWithContext(ctx)
- if errI != nil {
- stream.err = errI
- return
- }
- zzzzzz = rr
- // --- [end][read][struct](DaemonSet) ---
- }
- if !yield(fi, pairV(vvvvvv, zzzzzz)) {
- return
- }
- }
- // --- [end][read][streaming-map](map[string]*DaemonSet) ---
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[map[string]*Job](),
- Name: "Jobs",
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][streaming-map](map[string]*Job) ---
- ss := buff.ReadInt() // map len
- for range ss {
- var vvvvvvv string
- var uu string
- if ctx.IsStringTable() {
- ww := buff.ReadInt() // read string index
- uu = ctx.Table.At(ww)
- } else {
- uu = buff.ReadString() // read string
- }
- tt := uu
- vvvvvvv = tt
- var zzzzzzz *Job
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzz = nil
- } else {
- // --- [begin][read][struct](Job) ---
- xx := new(Job)
- buff.ReadInt() // [compatibility, unused]
- errJ := xx.UnmarshalBinaryWithContext(ctx)
- if errJ != nil {
- stream.err = errJ
- return
- }
- zzzzzzz = xx
- // --- [end][read][struct](Job) ---
- }
- if !yield(fi, pairV(vvvvvvv, zzzzzzz)) {
- return
- }
- }
- // --- [end][read][streaming-map](map[string]*Job) ---
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[map[string]*CronJob](),
- Name: "CronJobs",
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][streaming-map](map[string]*CronJob) ---
- yy := buff.ReadInt() // map len
- for range yy {
- var vvvvvvvv string
- var bbb string
- if ctx.IsStringTable() {
- ccc := buff.ReadInt() // read string index
- bbb = ctx.Table.At(ccc)
- } else {
- bbb = buff.ReadString() // read string
- }
- aaa := bbb
- vvvvvvvv = aaa
- var zzzzzzzz *CronJob
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzzz = nil
- } else {
- // --- [begin][read][struct](CronJob) ---
- ddd := new(CronJob)
- buff.ReadInt() // [compatibility, unused]
- errK := ddd.UnmarshalBinaryWithContext(ctx)
- if errK != nil {
- stream.err = errK
- return
- }
- zzzzzzzz = ddd
- // --- [end][read][struct](CronJob) ---
- }
- if !yield(fi, pairV(vvvvvvvv, zzzzzzzz)) {
- return
- }
- }
- // --- [end][read][streaming-map](map[string]*CronJob) ---
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[map[string]*ReplicaSet](),
- Name: "ReplicaSets",
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][streaming-map](map[string]*ReplicaSet) ---
- eee := buff.ReadInt() // map len
- for range eee {
- var vvvvvvvvv string
- var ggg string
- if ctx.IsStringTable() {
- hhh := buff.ReadInt() // read string index
- ggg = ctx.Table.At(hhh)
- } else {
- ggg = buff.ReadString() // read string
- }
- fff := ggg
- vvvvvvvvv = fff
- var zzzzzzzzz *ReplicaSet
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzzzz = nil
- } else {
- // --- [begin][read][struct](ReplicaSet) ---
- lll := new(ReplicaSet)
- buff.ReadInt() // [compatibility, unused]
- errL := lll.UnmarshalBinaryWithContext(ctx)
- if errL != nil {
- stream.err = errL
- return
- }
- zzzzzzzzz = lll
- // --- [end][read][struct](ReplicaSet) ---
- }
- if !yield(fi, pairV(vvvvvvvvv, zzzzzzzzz)) {
- return
- }
- }
- // --- [end][read][streaming-map](map[string]*ReplicaSet) ---
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[map[string]*Node](),
- Name: "Nodes",
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][streaming-map](map[string]*Node) ---
- mmm := buff.ReadInt() // map len
- for range mmm {
- var vvvvvvvvvv string
- var ooo string
- if ctx.IsStringTable() {
- ppp := buff.ReadInt() // read string index
- ooo = ctx.Table.At(ppp)
- } else {
- ooo = buff.ReadString() // read string
- }
- nnn := ooo
- vvvvvvvvvv = nnn
- var zzzzzzzzzz *Node
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzzzzz = nil
- } else {
- // --- [begin][read][struct](Node) ---
- qqq := new(Node)
- buff.ReadInt() // [compatibility, unused]
- errM := qqq.UnmarshalBinaryWithContext(ctx)
- if errM != nil {
- stream.err = errM
- return
- }
- zzzzzzzzzz = qqq
- // --- [end][read][struct](Node) ---
- }
- if !yield(fi, pairV(vvvvvvvvvv, zzzzzzzzzz)) {
- return
- }
- }
- // --- [end][read][streaming-map](map[string]*Node) ---
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[map[string]*PersistentVolume](),
- Name: "PersistentVolumes",
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][streaming-map](map[string]*PersistentVolume) ---
- rrr := buff.ReadInt() // map len
- for range rrr {
- var vvvvvvvvvvv string
- var ttt string
- if ctx.IsStringTable() {
- uuu := buff.ReadInt() // read string index
- ttt = ctx.Table.At(uuu)
- } else {
- ttt = buff.ReadString() // read string
- }
- sss := ttt
- vvvvvvvvvvv = sss
- var zzzzzzzzzzz *PersistentVolume
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzzzzzz = nil
- } else {
- // --- [begin][read][struct](PersistentVolume) ---
- www := new(PersistentVolume)
- buff.ReadInt() // [compatibility, unused]
- errN := www.UnmarshalBinaryWithContext(ctx)
- if errN != nil {
- stream.err = errN
- return
- }
- zzzzzzzzzzz = www
- // --- [end][read][struct](PersistentVolume) ---
- }
- if !yield(fi, pairV(vvvvvvvvvvv, zzzzzzzzzzz)) {
- return
- }
- }
- // --- [end][read][streaming-map](map[string]*PersistentVolume) ---
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[map[string]*PersistentVolumeClaim](),
- Name: "PersistentVolumeClaims",
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][streaming-map](map[string]*PersistentVolumeClaim) ---
- xxx := buff.ReadInt() // map len
- for range xxx {
- var vvvvvvvvvvvv string
- var aaaa string
- if ctx.IsStringTable() {
- bbbb := buff.ReadInt() // read string index
- aaaa = ctx.Table.At(bbbb)
- } else {
- aaaa = buff.ReadString() // read string
- }
- yyy := aaaa
- vvvvvvvvvvvv = yyy
- var zzzzzzzzzzzz *PersistentVolumeClaim
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzzzzzzz = nil
- } else {
- // --- [begin][read][struct](PersistentVolumeClaim) ---
- cccc := new(PersistentVolumeClaim)
- buff.ReadInt() // [compatibility, unused]
- errO := cccc.UnmarshalBinaryWithContext(ctx)
- if errO != nil {
- stream.err = errO
- return
- }
- zzzzzzzzzzzz = cccc
- // --- [end][read][struct](PersistentVolumeClaim) ---
- }
- if !yield(fi, pairV(vvvvvvvvvvvv, zzzzzzzzzzzz)) {
- return
- }
- }
- // --- [end][read][streaming-map](map[string]*PersistentVolumeClaim) ---
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[map[string]*Pod](),
- Name: "Pods",
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][streaming-map](map[string]*Pod) ---
- dddd := buff.ReadInt() // map len
- for range dddd {
- var vvvvvvvvvvvvv string
- var ffff string
- if ctx.IsStringTable() {
- gggg := buff.ReadInt() // read string index
- ffff = ctx.Table.At(gggg)
- } else {
- ffff = buff.ReadString() // read string
- }
- eeee := ffff
- vvvvvvvvvvvvv = eeee
- var zzzzzzzzzzzzz *Pod
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzzzzzzzz = nil
- } else {
- // --- [begin][read][struct](Pod) ---
- hhhh := new(Pod)
- buff.ReadInt() // [compatibility, unused]
- errP := hhhh.UnmarshalBinaryWithContext(ctx)
- if errP != nil {
- stream.err = errP
- return
- }
- zzzzzzzzzzzzz = hhhh
- // --- [end][read][struct](Pod) ---
- }
- if !yield(fi, pairV(vvvvvvvvvvvvv, zzzzzzzzzzzzz)) {
- return
- }
- }
- // --- [end][read][streaming-map](map[string]*Pod) ---
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[map[string]*Container](),
- Name: "Containers",
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][streaming-map](map[string]*Container) ---
- llll := buff.ReadInt() // map len
- for range llll {
- var vvvvvvvvvvvvvv string
- var nnnn string
- if ctx.IsStringTable() {
- oooo := buff.ReadInt() // read string index
- nnnn = ctx.Table.At(oooo)
- } else {
- nnnn = buff.ReadString() // read string
- }
- mmmm := nnnn
- vvvvvvvvvvvvvv = mmmm
- var zzzzzzzzzzzzzz *Container
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzzzzzzzzz = nil
- } else {
- // --- [begin][read][struct](Container) ---
- pppp := new(Container)
- buff.ReadInt() // [compatibility, unused]
- errQ := pppp.UnmarshalBinaryWithContext(ctx)
- if errQ != nil {
- stream.err = errQ
- return
- }
- zzzzzzzzzzzzzz = pppp
- // --- [end][read][struct](Container) ---
- }
- if !yield(fi, pairV(vvvvvvvvvvvvvv, zzzzzzzzzzzzzz)) {
- return
- }
- }
- // --- [end][read][streaming-map](map[string]*Container) ---
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- fi = BingenFieldInfo{
- Type: reflect.TypeFor[map[string]*DCGMDevice](),
- Name: "DCGMDevices",
- }
- // field version check
- if uint8(2) <= version {
- if buff.ReadUInt8() == uint8(0) {
- if !yield(fi, nil) {
- return
- }
- } else {
- // --- [begin][read][streaming-map](map[string]*DCGMDevice) ---
- qqqq := buff.ReadInt() // map len
- for range qqqq {
- var vvvvvvvvvvvvvvv string
- var ssss string
- if ctx.IsStringTable() {
- tttt := buff.ReadInt() // read string index
- ssss = ctx.Table.At(tttt)
- } else {
- ssss = buff.ReadString() // read string
- }
- rrrr := ssss
- vvvvvvvvvvvvvvv = rrrr
- var zzzzzzzzzzzzzzz *DCGMDevice
- if buff.ReadUInt8() == uint8(0) {
- zzzzzzzzzzzzzzz = nil
- } else {
- // --- [begin][read][struct](DCGMDevice) ---
- uuuu := new(DCGMDevice)
- buff.ReadInt() // [compatibility, unused]
- errR := uuuu.UnmarshalBinaryWithContext(ctx)
- if errR != nil {
- stream.err = errR
- return
- }
- zzzzzzzzzzzzzzz = uuuu
- // --- [end][read][struct](DCGMDevice) ---
- }
- if !yield(fi, pairV(vvvvvvvvvvvvvvv, zzzzzzzzzzzzzzz)) {
- return
- }
- }
- // --- [end][read][streaming-map](map[string]*DCGMDevice) ---
- }
- } else {
- if !yield(fi, nil) {
- return
- }
- }
- }
- }
- //--------------------------------------------------------------------------
- // Metadata
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Metadata instance
- // into a byte array
- func (target *Metadata) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this Metadata instance
- // into a byte array leveraging a predefined context.
- func (target *Metadata) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- // --- [begin][write][reference](time.Time) ---
- a, errA := target.CreatedAt.MarshalBinary()
- if errA != nil {
- return errA
- }
- buff.WriteInt(len(a))
- buff.WriteBytes(a)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- b, errB := target.CompletedAt.MarshalBinary()
- if errB != nil {
- return errB
- }
- buff.WriteInt(len(b))
- buff.WriteBytes(b)
- // --- [end][write][reference](time.Time) ---
- buff.WriteInt(target.ObjectCount) // write int
- if target.Diagnostics == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][slice]([]Diagnostic) ---
- buff.WriteInt(len(target.Diagnostics)) // slice length
- for i := range target.Diagnostics {
- // --- [begin][write][struct](Diagnostic) ---
- buff.WriteInt(0) // [compatibility, unused]
- errC := target.Diagnostics[i].MarshalBinaryWithContext(ctx)
- if errC != nil {
- return errC
- }
- // --- [end][write][struct](Diagnostic) ---
- }
- // --- [end][write][slice]([]Diagnostic) ---
- }
- // --- [begin][write][alias](DiagnosticLevel) ---
- buff.WriteInt(int(target.DiagnosticLevel)) // write int
- // --- [end][write][alias](DiagnosticLevel) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Metadata type
- func (target *Metadata) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the Metadata type
- func (target *Metadata) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the Metadata type
- func (target *Metadata) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling Metadata. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][reference](time.Time) ---
- a := new(time.Time)
- b := buff.ReadInt() // byte array length
- c := buff.ReadBytes(b)
- errA := a.UnmarshalBinary(c)
- if errA != nil {
- return errA
- }
- target.CreatedAt = *a
- // --- [end][read][reference](time.Time) ---
- } else {
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][reference](time.Time) ---
- d := new(time.Time)
- e := buff.ReadInt() // byte array length
- f := buff.ReadBytes(e)
- errB := d.UnmarshalBinary(f)
- if errB != nil {
- return errB
- }
- target.CompletedAt = *d
- // --- [end][read][reference](time.Time) ---
- } else {
- }
- // field version check
- if uint8(1) <= version {
- g := buff.ReadInt() // read int
- target.ObjectCount = g
- } else {
- target.ObjectCount = int(0) // default
- }
- // field version check
- if uint8(1) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Diagnostics = nil
- } else {
- // --- [begin][read][slice]([]Diagnostic) ---
- l := buff.ReadInt() // slice len
- h := make([]Diagnostic, l)
- for i := range l {
- // --- [begin][read][struct](Diagnostic) ---
- n := new(Diagnostic)
- buff.ReadInt() // [compatibility, unused]
- errC := n.UnmarshalBinaryWithContext(ctx)
- if errC != nil {
- return errC
- }
- m := *n
- // --- [end][read][struct](Diagnostic) ---
- h[i] = m
- }
- target.Diagnostics = h
- // --- [end][read][slice]([]Diagnostic) ---
- }
- } else {
- target.Diagnostics = nil
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][alias](DiagnosticLevel) ---
- var o int
- p := buff.ReadInt() // read int
- o = p
- target.DiagnosticLevel = DiagnosticLevel(o)
- // --- [end][read][alias](DiagnosticLevel) ---
- } else {
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // Namespace
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Namespace instance
- // into a byte array
- func (target *Namespace) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this Namespace instance
- // into a byte array leveraging a predefined context.
- func (target *Namespace) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.UID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.UID) // write string
- }
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.bingenPlaceHolder)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.bingenPlaceHolder) // write string
- }
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(target.Name)
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(target.Name) // write string
- }
- if target.Labels == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Labels)) // map length
- for v, z := range target.Labels {
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(v)
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(v) // write string
- }
- if ctx.IsStringTable() {
- e := ctx.Table.AddOrGet(z)
- buff.WriteInt(e) // write table index
- } else {
- buff.WriteString(z) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- if target.Annotations == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Annotations)) // map length
- for vv, zz := range target.Annotations {
- if ctx.IsStringTable() {
- f := ctx.Table.AddOrGet(vv)
- buff.WriteInt(f) // write table index
- } else {
- buff.WriteString(vv) // write string
- }
- if ctx.IsStringTable() {
- g := ctx.Table.AddOrGet(zz)
- buff.WriteInt(g) // write table index
- } else {
- buff.WriteString(zz) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [begin][write][reference](time.Time) ---
- h, errA := target.Start.MarshalBinary()
- if errA != nil {
- return errA
- }
- buff.WriteInt(len(h))
- buff.WriteBytes(h)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- l, errB := target.End.MarshalBinary()
- if errB != nil {
- return errB
- }
- buff.WriteInt(len(l))
- buff.WriteBytes(l)
- // --- [end][write][reference](time.Time) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Namespace type
- func (target *Namespace) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the Namespace type
- func (target *Namespace) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the Namespace type
- func (target *Namespace) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling Namespace. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- // field version check
- if uint8(1) <= version {
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.UID = a
- } else {
- target.UID = "" // default
- }
- // field version check
- if uint8(1) <= version {
- var e string
- if ctx.IsStringTable() {
- f := buff.ReadInt() // read string index
- e = ctx.Table.At(f)
- } else {
- e = buff.ReadString() // read string
- }
- d := e
- target.bingenPlaceHolder = d
- } else {
- target.bingenPlaceHolder = "" // default
- }
- // field version check
- if uint8(1) <= version {
- var h string
- if ctx.IsStringTable() {
- l := buff.ReadInt() // read string index
- h = ctx.Table.At(l)
- } else {
- h = buff.ReadString() // read string
- }
- g := h
- target.Name = g
- } else {
- target.Name = "" // default
- }
- // field version check
- if uint8(1) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Labels = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- n := buff.ReadInt() // map len
- m := make(map[string]string, n)
- for range n {
- var v string
- var p string
- if ctx.IsStringTable() {
- q := buff.ReadInt() // read string index
- p = ctx.Table.At(q)
- } else {
- p = buff.ReadString() // read string
- }
- o := p
- v = o
- var z string
- var s string
- if ctx.IsStringTable() {
- t := buff.ReadInt() // read string index
- s = ctx.Table.At(t)
- } else {
- s = buff.ReadString() // read string
- }
- r := s
- z = r
- m[v] = z
- }
- target.Labels = m
- // --- [end][read][map](map[string]string) ---
- }
- } else {
- target.Labels = nil
- }
- // field version check
- if uint8(1) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Annotations = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- w := buff.ReadInt() // map len
- u := make(map[string]string, w)
- for range w {
- var vv string
- var y string
- if ctx.IsStringTable() {
- aa := buff.ReadInt() // read string index
- y = ctx.Table.At(aa)
- } else {
- y = buff.ReadString() // read string
- }
- x := y
- vv = x
- var zz string
- var cc string
- if ctx.IsStringTable() {
- dd := buff.ReadInt() // read string index
- cc = ctx.Table.At(dd)
- } else {
- cc = buff.ReadString() // read string
- }
- bb := cc
- zz = bb
- u[vv] = zz
- }
- target.Annotations = u
- // --- [end][read][map](map[string]string) ---
- }
- } else {
- target.Annotations = nil
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][reference](time.Time) ---
- ee := new(time.Time)
- ff := buff.ReadInt() // byte array length
- gg := buff.ReadBytes(ff)
- errA := ee.UnmarshalBinary(gg)
- if errA != nil {
- return errA
- }
- target.Start = *ee
- // --- [end][read][reference](time.Time) ---
- } else {
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][reference](time.Time) ---
- hh := new(time.Time)
- ll := buff.ReadInt() // byte array length
- mm := buff.ReadBytes(ll)
- errB := hh.UnmarshalBinary(mm)
- if errB != nil {
- return errB
- }
- target.End = *hh
- // --- [end][read][reference](time.Time) ---
- } else {
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // NetworkTrafficDetail
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this NetworkTrafficDetail instance
- // into a byte array
- func (target *NetworkTrafficDetail) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this NetworkTrafficDetail instance
- // into a byte array leveraging a predefined context.
- func (target *NetworkTrafficDetail) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.PodUID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.PodUID) // write string
- }
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.Endpoint)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.Endpoint) // write string
- }
- // --- [begin][write][alias](TrafficDirection) ---
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(string(target.TrafficDirection))
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(string(target.TrafficDirection)) // write string
- }
- // --- [end][write][alias](TrafficDirection) ---
- // --- [begin][write][alias](TrafficType) ---
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(string(target.TrafficType))
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(string(target.TrafficType)) // write string
- }
- // --- [end][write][alias](TrafficType) ---
- buff.WriteBool(target.IsNatGateway) // write bool
- buff.WriteFloat64(target.Bytes) // write float64
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the NetworkTrafficDetail type
- func (target *NetworkTrafficDetail) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the NetworkTrafficDetail type
- func (target *NetworkTrafficDetail) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the NetworkTrafficDetail type
- func (target *NetworkTrafficDetail) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling NetworkTrafficDetail. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.PodUID = a
- var e string
- if ctx.IsStringTable() {
- f := buff.ReadInt() // read string index
- e = ctx.Table.At(f)
- } else {
- e = buff.ReadString() // read string
- }
- d := e
- target.Endpoint = d
- // --- [begin][read][alias](TrafficDirection) ---
- var g string
- var l string
- if ctx.IsStringTable() {
- m := buff.ReadInt() // read string index
- l = ctx.Table.At(m)
- } else {
- l = buff.ReadString() // read string
- }
- h := l
- g = h
- target.TrafficDirection = TrafficDirection(g)
- // --- [end][read][alias](TrafficDirection) ---
- // --- [begin][read][alias](TrafficType) ---
- var n string
- var p string
- if ctx.IsStringTable() {
- q := buff.ReadInt() // read string index
- p = ctx.Table.At(q)
- } else {
- p = buff.ReadString() // read string
- }
- o := p
- n = o
- target.TrafficType = TrafficType(n)
- // --- [end][read][alias](TrafficType) ---
- r := buff.ReadBool() // read bool
- target.IsNatGateway = r
- s := buff.ReadFloat64() // read float64
- target.Bytes = s
- return nil
- }
- //--------------------------------------------------------------------------
- // Node
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Node instance
- // into a byte array
- func (target *Node) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this Node instance
- // into a byte array leveraging a predefined context.
- func (target *Node) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.UID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.UID) // write string
- }
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.ProviderID)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.ProviderID) // write string
- }
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(target.Name)
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(target.Name) // write string
- }
- if target.Labels == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Labels)) // map length
- for v, z := range target.Labels {
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(v)
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(v) // write string
- }
- if ctx.IsStringTable() {
- e := ctx.Table.AddOrGet(z)
- buff.WriteInt(e) // write table index
- } else {
- buff.WriteString(z) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [begin][write][alias](ResourceQuantities) ---
- if map[Resource]ResourceQuantity(target.ResourceCapacities) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[Resource]ResourceQuantity) ---
- buff.WriteInt(len(map[Resource]ResourceQuantity(target.ResourceCapacities))) // map length
- for vv, zz := range map[Resource]ResourceQuantity(target.ResourceCapacities) {
- // --- [begin][write][alias](Resource) ---
- if ctx.IsStringTable() {
- f := ctx.Table.AddOrGet(string(vv))
- buff.WriteInt(f) // write table index
- } else {
- buff.WriteString(string(vv)) // write string
- }
- // --- [end][write][alias](Resource) ---
- // --- [begin][write][struct](ResourceQuantity) ---
- buff.WriteInt(0) // [compatibility, unused]
- errA := zz.MarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- // --- [end][write][struct](ResourceQuantity) ---
- }
- // --- [end][write][map](map[Resource]ResourceQuantity) ---
- }
- // --- [end][write][alias](ResourceQuantities) ---
- // --- [begin][write][alias](ResourceQuantities) ---
- if map[Resource]ResourceQuantity(target.ResourcesAllocatable) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[Resource]ResourceQuantity) ---
- buff.WriteInt(len(map[Resource]ResourceQuantity(target.ResourcesAllocatable))) // map length
- for vvv, zzz := range map[Resource]ResourceQuantity(target.ResourcesAllocatable) {
- // --- [begin][write][alias](Resource) ---
- if ctx.IsStringTable() {
- g := ctx.Table.AddOrGet(string(vvv))
- buff.WriteInt(g) // write table index
- } else {
- buff.WriteString(string(vvv)) // write string
- }
- // --- [end][write][alias](Resource) ---
- // --- [begin][write][struct](ResourceQuantity) ---
- buff.WriteInt(0) // [compatibility, unused]
- errB := zzz.MarshalBinaryWithContext(ctx)
- if errB != nil {
- return errB
- }
- // --- [end][write][struct](ResourceQuantity) ---
- }
- // --- [end][write][map](map[Resource]ResourceQuantity) ---
- }
- // --- [end][write][alias](ResourceQuantities) ---
- // --- [begin][write][struct](FileSystem) ---
- buff.WriteInt(0) // [compatibility, unused]
- errC := target.FileSystem.MarshalBinaryWithContext(ctx)
- if errC != nil {
- return errC
- }
- // --- [end][write][struct](FileSystem) ---
- // --- [begin][write][reference](time.Time) ---
- h, errD := target.Start.MarshalBinary()
- if errD != nil {
- return errD
- }
- buff.WriteInt(len(h))
- buff.WriteBytes(h)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- l, errE := target.End.MarshalBinary()
- if errE != nil {
- return errE
- }
- buff.WriteInt(len(l))
- buff.WriteBytes(l)
- // --- [end][write][reference](time.Time) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Node type
- func (target *Node) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the Node type
- func (target *Node) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the Node type
- func (target *Node) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling Node. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.UID = a
- var e string
- if ctx.IsStringTable() {
- f := buff.ReadInt() // read string index
- e = ctx.Table.At(f)
- } else {
- e = buff.ReadString() // read string
- }
- d := e
- target.ProviderID = d
- var h string
- if ctx.IsStringTable() {
- l := buff.ReadInt() // read string index
- h = ctx.Table.At(l)
- } else {
- h = buff.ReadString() // read string
- }
- g := h
- target.Name = g
- if buff.ReadUInt8() == uint8(0) {
- target.Labels = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- n := buff.ReadInt() // map len
- m := make(map[string]string, n)
- for range n {
- var v string
- var p string
- if ctx.IsStringTable() {
- q := buff.ReadInt() // read string index
- p = ctx.Table.At(q)
- } else {
- p = buff.ReadString() // read string
- }
- o := p
- v = o
- var z string
- var s string
- if ctx.IsStringTable() {
- t := buff.ReadInt() // read string index
- s = ctx.Table.At(t)
- } else {
- s = buff.ReadString() // read string
- }
- r := s
- z = r
- m[v] = z
- }
- target.Labels = m
- // --- [end][read][map](map[string]string) ---
- }
- // --- [begin][read][alias](ResourceQuantities) ---
- var u map[Resource]ResourceQuantity
- if buff.ReadUInt8() == uint8(0) {
- u = nil
- } else {
- // --- [begin][read][map](map[Resource]ResourceQuantity) ---
- x := buff.ReadInt() // map len
- w := make(map[Resource]ResourceQuantity, x)
- for range x {
- // --- [begin][read][alias](Resource) ---
- var y string
- var bb string
- if ctx.IsStringTable() {
- cc := buff.ReadInt() // read string index
- bb = ctx.Table.At(cc)
- } else {
- bb = buff.ReadString() // read string
- }
- aa := bb
- y = aa
- vv := Resource(y)
- // --- [end][read][alias](Resource) ---
- // --- [begin][read][struct](ResourceQuantity) ---
- dd := new(ResourceQuantity)
- buff.ReadInt() // [compatibility, unused]
- errA := dd.UnmarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- zz := *dd
- // --- [end][read][struct](ResourceQuantity) ---
- w[vv] = zz
- }
- u = w
- // --- [end][read][map](map[Resource]ResourceQuantity) ---
- }
- target.ResourceCapacities = ResourceQuantities(u)
- // --- [end][read][alias](ResourceQuantities) ---
- // --- [begin][read][alias](ResourceQuantities) ---
- var ee map[Resource]ResourceQuantity
- if buff.ReadUInt8() == uint8(0) {
- ee = nil
- } else {
- // --- [begin][read][map](map[Resource]ResourceQuantity) ---
- gg := buff.ReadInt() // map len
- ff := make(map[Resource]ResourceQuantity, gg)
- for range gg {
- // --- [begin][read][alias](Resource) ---
- var hh string
- var mm string
- if ctx.IsStringTable() {
- nn := buff.ReadInt() // read string index
- mm = ctx.Table.At(nn)
- } else {
- mm = buff.ReadString() // read string
- }
- ll := mm
- hh = ll
- vvv := Resource(hh)
- // --- [end][read][alias](Resource) ---
- // --- [begin][read][struct](ResourceQuantity) ---
- oo := new(ResourceQuantity)
- buff.ReadInt() // [compatibility, unused]
- errB := oo.UnmarshalBinaryWithContext(ctx)
- if errB != nil {
- return errB
- }
- zzz := *oo
- // --- [end][read][struct](ResourceQuantity) ---
- ff[vvv] = zzz
- }
- ee = ff
- // --- [end][read][map](map[Resource]ResourceQuantity) ---
- }
- target.ResourcesAllocatable = ResourceQuantities(ee)
- // --- [end][read][alias](ResourceQuantities) ---
- // --- [begin][read][struct](FileSystem) ---
- pp := new(FileSystem)
- buff.ReadInt() // [compatibility, unused]
- errC := pp.UnmarshalBinaryWithContext(ctx)
- if errC != nil {
- return errC
- }
- target.FileSystem = *pp
- // --- [end][read][struct](FileSystem) ---
- // --- [begin][read][reference](time.Time) ---
- qq := new(time.Time)
- rr := buff.ReadInt() // byte array length
- ss := buff.ReadBytes(rr)
- errD := qq.UnmarshalBinary(ss)
- if errD != nil {
- return errD
- }
- target.Start = *qq
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- tt := new(time.Time)
- uu := buff.ReadInt() // byte array length
- ww := buff.ReadBytes(uu)
- errE := tt.UnmarshalBinary(ww)
- if errE != nil {
- return errE
- }
- target.End = *tt
- // --- [end][read][reference](time.Time) ---
- return nil
- }
- //--------------------------------------------------------------------------
- // Owner
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Owner instance
- // into a byte array
- func (target *Owner) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this Owner instance
- // into a byte array leveraging a predefined context.
- func (target *Owner) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.UID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.UID) // write string
- }
- buff.WriteBool(target.Controller) // write bool
- // --- [begin][write][alias](OwnerKind) ---
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(string(target.Kind))
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(string(target.Kind)) // write string
- }
- // --- [end][write][alias](OwnerKind) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Owner type
- func (target *Owner) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the Owner type
- func (target *Owner) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the Owner type
- func (target *Owner) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling Owner. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.UID = a
- d := buff.ReadBool() // read bool
- target.Controller = d
- // --- [begin][read][alias](OwnerKind) ---
- var e string
- var g string
- if ctx.IsStringTable() {
- h := buff.ReadInt() // read string index
- g = ctx.Table.At(h)
- } else {
- g = buff.ReadString() // read string
- }
- f := g
- e = f
- target.Kind = OwnerKind(e)
- // --- [end][read][alias](OwnerKind) ---
- return nil
- }
- //--------------------------------------------------------------------------
- // PersistentVolume
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this PersistentVolume instance
- // into a byte array
- func (target *PersistentVolume) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this PersistentVolume instance
- // into a byte array leveraging a predefined context.
- func (target *PersistentVolume) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.UID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.UID) // write string
- }
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.Name)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.Name) // write string
- }
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(target.StorageClass)
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(target.StorageClass) // write string
- }
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(target.CSIVolumeHandle)
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(target.CSIVolumeHandle) // write string
- }
- buff.WriteFloat64(target.SizeBytes) // write float64
- // --- [begin][write][reference](time.Time) ---
- e, errA := target.Start.MarshalBinary()
- if errA != nil {
- return errA
- }
- buff.WriteInt(len(e))
- buff.WriteBytes(e)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- f, errB := target.End.MarshalBinary()
- if errB != nil {
- return errB
- }
- buff.WriteInt(len(f))
- buff.WriteBytes(f)
- // --- [end][write][reference](time.Time) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the PersistentVolume type
- func (target *PersistentVolume) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the PersistentVolume type
- func (target *PersistentVolume) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the PersistentVolume type
- func (target *PersistentVolume) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling PersistentVolume. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.UID = a
- var e string
- if ctx.IsStringTable() {
- f := buff.ReadInt() // read string index
- e = ctx.Table.At(f)
- } else {
- e = buff.ReadString() // read string
- }
- d := e
- target.Name = d
- var h string
- if ctx.IsStringTable() {
- l := buff.ReadInt() // read string index
- h = ctx.Table.At(l)
- } else {
- h = buff.ReadString() // read string
- }
- g := h
- target.StorageClass = g
- var n string
- if ctx.IsStringTable() {
- o := buff.ReadInt() // read string index
- n = ctx.Table.At(o)
- } else {
- n = buff.ReadString() // read string
- }
- m := n
- target.CSIVolumeHandle = m
- p := buff.ReadFloat64() // read float64
- target.SizeBytes = p
- // --- [begin][read][reference](time.Time) ---
- q := new(time.Time)
- r := buff.ReadInt() // byte array length
- s := buff.ReadBytes(r)
- errA := q.UnmarshalBinary(s)
- if errA != nil {
- return errA
- }
- target.Start = *q
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- t := new(time.Time)
- u := buff.ReadInt() // byte array length
- w := buff.ReadBytes(u)
- errB := t.UnmarshalBinary(w)
- if errB != nil {
- return errB
- }
- target.End = *t
- // --- [end][read][reference](time.Time) ---
- return nil
- }
- //--------------------------------------------------------------------------
- // PersistentVolumeClaim
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this PersistentVolumeClaim instance
- // into a byte array
- func (target *PersistentVolumeClaim) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this PersistentVolumeClaim instance
- // into a byte array leveraging a predefined context.
- func (target *PersistentVolumeClaim) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.UID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.UID) // write string
- }
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.NamespaceUID)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.NamespaceUID) // write string
- }
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(target.Name)
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(target.Name) // write string
- }
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(target.PersistentVolumeUID)
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(target.PersistentVolumeUID) // write string
- }
- if ctx.IsStringTable() {
- e := ctx.Table.AddOrGet(target.StorageClass)
- buff.WriteInt(e) // write table index
- } else {
- buff.WriteString(target.StorageClass) // write string
- }
- // --- [begin][write][reference](time.Time) ---
- f, errA := target.Start.MarshalBinary()
- if errA != nil {
- return errA
- }
- buff.WriteInt(len(f))
- buff.WriteBytes(f)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- g, errB := target.End.MarshalBinary()
- if errB != nil {
- return errB
- }
- buff.WriteInt(len(g))
- buff.WriteBytes(g)
- // --- [end][write][reference](time.Time) ---
- buff.WriteFloat64(target.RequestedBytes) // write float64
- buff.WriteFloat64(target.UsageBytesAvg) // write float64
- buff.WriteFloat64(target.UsageBytesMax) // write float64
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the PersistentVolumeClaim type
- func (target *PersistentVolumeClaim) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the PersistentVolumeClaim type
- func (target *PersistentVolumeClaim) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the PersistentVolumeClaim type
- func (target *PersistentVolumeClaim) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling PersistentVolumeClaim. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.UID = a
- var e string
- if ctx.IsStringTable() {
- f := buff.ReadInt() // read string index
- e = ctx.Table.At(f)
- } else {
- e = buff.ReadString() // read string
- }
- d := e
- target.NamespaceUID = d
- var h string
- if ctx.IsStringTable() {
- l := buff.ReadInt() // read string index
- h = ctx.Table.At(l)
- } else {
- h = buff.ReadString() // read string
- }
- g := h
- target.Name = g
- var n string
- if ctx.IsStringTable() {
- o := buff.ReadInt() // read string index
- n = ctx.Table.At(o)
- } else {
- n = buff.ReadString() // read string
- }
- m := n
- target.PersistentVolumeUID = m
- var q string
- if ctx.IsStringTable() {
- r := buff.ReadInt() // read string index
- q = ctx.Table.At(r)
- } else {
- q = buff.ReadString() // read string
- }
- p := q
- target.StorageClass = p
- // --- [begin][read][reference](time.Time) ---
- s := new(time.Time)
- t := buff.ReadInt() // byte array length
- u := buff.ReadBytes(t)
- errA := s.UnmarshalBinary(u)
- if errA != nil {
- return errA
- }
- target.Start = *s
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- w := new(time.Time)
- x := buff.ReadInt() // byte array length
- y := buff.ReadBytes(x)
- errB := w.UnmarshalBinary(y)
- if errB != nil {
- return errB
- }
- target.End = *w
- // --- [end][read][reference](time.Time) ---
- aa := buff.ReadFloat64() // read float64
- target.RequestedBytes = aa
- bb := buff.ReadFloat64() // read float64
- target.UsageBytesAvg = bb
- cc := buff.ReadFloat64() // read float64
- target.UsageBytesMax = cc
- return nil
- }
- //--------------------------------------------------------------------------
- // Pod
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Pod instance
- // into a byte array
- func (target *Pod) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this Pod instance
- // into a byte array leveraging a predefined context.
- func (target *Pod) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.UID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.UID) // write string
- }
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.NamespaceUID)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.NamespaceUID) // write string
- }
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(target.NodeUID)
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(target.NodeUID) // write string
- }
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(target.Name)
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(target.Name) // write string
- }
- if target.Owners == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][slice]([]Owner) ---
- buff.WriteInt(len(target.Owners)) // slice length
- for i := range target.Owners {
- // --- [begin][write][struct](Owner) ---
- buff.WriteInt(0) // [compatibility, unused]
- errA := target.Owners[i].MarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- // --- [end][write][struct](Owner) ---
- }
- // --- [end][write][slice]([]Owner) ---
- }
- if target.PVCVolumes == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][slice]([]PodPVCVolume) ---
- buff.WriteInt(len(target.PVCVolumes)) // slice length
- for j := range target.PVCVolumes {
- // --- [begin][write][struct](PodPVCVolume) ---
- buff.WriteInt(0) // [compatibility, unused]
- errB := target.PVCVolumes[j].MarshalBinaryWithContext(ctx)
- if errB != nil {
- return errB
- }
- // --- [end][write][struct](PodPVCVolume) ---
- }
- // --- [end][write][slice]([]PodPVCVolume) ---
- }
- if target.Labels == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Labels)) // map length
- for v, z := range target.Labels {
- if ctx.IsStringTable() {
- e := ctx.Table.AddOrGet(v)
- buff.WriteInt(e) // write table index
- } else {
- buff.WriteString(v) // write string
- }
- if ctx.IsStringTable() {
- f := ctx.Table.AddOrGet(z)
- buff.WriteInt(f) // write table index
- } else {
- buff.WriteString(z) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- if target.Annotations == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Annotations)) // map length
- for vv, zz := range target.Annotations {
- if ctx.IsStringTable() {
- g := ctx.Table.AddOrGet(vv)
- buff.WriteInt(g) // write table index
- } else {
- buff.WriteString(vv) // write string
- }
- if ctx.IsStringTable() {
- h := ctx.Table.AddOrGet(zz)
- buff.WriteInt(h) // write table index
- } else {
- buff.WriteString(zz) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- if target.NetworkTrafficDetails == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][slice]([]NetworkTrafficDetail) ---
- buff.WriteInt(len(target.NetworkTrafficDetails)) // slice length
- for ii := range target.NetworkTrafficDetails {
- // --- [begin][write][struct](NetworkTrafficDetail) ---
- buff.WriteInt(0) // [compatibility, unused]
- errC := target.NetworkTrafficDetails[ii].MarshalBinaryWithContext(ctx)
- if errC != nil {
- return errC
- }
- // --- [end][write][struct](NetworkTrafficDetail) ---
- }
- // --- [end][write][slice]([]NetworkTrafficDetail) ---
- }
- // --- [begin][write][reference](time.Time) ---
- l, errD := target.Start.MarshalBinary()
- if errD != nil {
- return errD
- }
- buff.WriteInt(len(l))
- buff.WriteBytes(l)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- m, errE := target.End.MarshalBinary()
- if errE != nil {
- return errE
- }
- buff.WriteInt(len(m))
- buff.WriteBytes(m)
- // --- [end][write][reference](time.Time) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Pod type
- func (target *Pod) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the Pod type
- func (target *Pod) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the Pod type
- func (target *Pod) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling Pod. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.UID = a
- var e string
- if ctx.IsStringTable() {
- f := buff.ReadInt() // read string index
- e = ctx.Table.At(f)
- } else {
- e = buff.ReadString() // read string
- }
- d := e
- target.NamespaceUID = d
- var h string
- if ctx.IsStringTable() {
- l := buff.ReadInt() // read string index
- h = ctx.Table.At(l)
- } else {
- h = buff.ReadString() // read string
- }
- g := h
- target.NodeUID = g
- var n string
- if ctx.IsStringTable() {
- o := buff.ReadInt() // read string index
- n = ctx.Table.At(o)
- } else {
- n = buff.ReadString() // read string
- }
- m := n
- target.Name = m
- if buff.ReadUInt8() == uint8(0) {
- target.Owners = nil
- } else {
- // --- [begin][read][slice]([]Owner) ---
- q := buff.ReadInt() // slice len
- p := make([]Owner, q)
- for i := range q {
- // --- [begin][read][struct](Owner) ---
- s := new(Owner)
- buff.ReadInt() // [compatibility, unused]
- errA := s.UnmarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- r := *s
- // --- [end][read][struct](Owner) ---
- p[i] = r
- }
- target.Owners = p
- // --- [end][read][slice]([]Owner) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.PVCVolumes = nil
- } else {
- // --- [begin][read][slice]([]PodPVCVolume) ---
- u := buff.ReadInt() // slice len
- t := make([]PodPVCVolume, u)
- for j := range u {
- // --- [begin][read][struct](PodPVCVolume) ---
- x := new(PodPVCVolume)
- buff.ReadInt() // [compatibility, unused]
- errB := x.UnmarshalBinaryWithContext(ctx)
- if errB != nil {
- return errB
- }
- w := *x
- // --- [end][read][struct](PodPVCVolume) ---
- t[j] = w
- }
- target.PVCVolumes = t
- // --- [end][read][slice]([]PodPVCVolume) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.Labels = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- aa := buff.ReadInt() // map len
- y := make(map[string]string, aa)
- for range aa {
- var v string
- var cc string
- if ctx.IsStringTable() {
- dd := buff.ReadInt() // read string index
- cc = ctx.Table.At(dd)
- } else {
- cc = buff.ReadString() // read string
- }
- bb := cc
- v = bb
- var z string
- var ff string
- if ctx.IsStringTable() {
- gg := buff.ReadInt() // read string index
- ff = ctx.Table.At(gg)
- } else {
- ff = buff.ReadString() // read string
- }
- ee := ff
- z = ee
- y[v] = z
- }
- target.Labels = y
- // --- [end][read][map](map[string]string) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.Annotations = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- ll := buff.ReadInt() // map len
- hh := make(map[string]string, ll)
- for range ll {
- var vv string
- var nn string
- if ctx.IsStringTable() {
- oo := buff.ReadInt() // read string index
- nn = ctx.Table.At(oo)
- } else {
- nn = buff.ReadString() // read string
- }
- mm := nn
- vv = mm
- var zz string
- var qq string
- if ctx.IsStringTable() {
- rr := buff.ReadInt() // read string index
- qq = ctx.Table.At(rr)
- } else {
- qq = buff.ReadString() // read string
- }
- pp := qq
- zz = pp
- hh[vv] = zz
- }
- target.Annotations = hh
- // --- [end][read][map](map[string]string) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.NetworkTrafficDetails = nil
- } else {
- // --- [begin][read][slice]([]NetworkTrafficDetail) ---
- tt := buff.ReadInt() // slice len
- ss := make([]NetworkTrafficDetail, tt)
- for ii := range tt {
- // --- [begin][read][struct](NetworkTrafficDetail) ---
- ww := new(NetworkTrafficDetail)
- buff.ReadInt() // [compatibility, unused]
- errC := ww.UnmarshalBinaryWithContext(ctx)
- if errC != nil {
- return errC
- }
- uu := *ww
- // --- [end][read][struct](NetworkTrafficDetail) ---
- ss[ii] = uu
- }
- target.NetworkTrafficDetails = ss
- // --- [end][read][slice]([]NetworkTrafficDetail) ---
- }
- // --- [begin][read][reference](time.Time) ---
- xx := new(time.Time)
- yy := buff.ReadInt() // byte array length
- aaa := buff.ReadBytes(yy)
- errD := xx.UnmarshalBinary(aaa)
- if errD != nil {
- return errD
- }
- target.Start = *xx
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- bbb := new(time.Time)
- ccc := buff.ReadInt() // byte array length
- ddd := buff.ReadBytes(ccc)
- errE := bbb.UnmarshalBinary(ddd)
- if errE != nil {
- return errE
- }
- target.End = *bbb
- // --- [end][read][reference](time.Time) ---
- return nil
- }
- //--------------------------------------------------------------------------
- // PodPVCVolume
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this PodPVCVolume instance
- // into a byte array
- func (target *PodPVCVolume) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this PodPVCVolume instance
- // into a byte array leveraging a predefined context.
- func (target *PodPVCVolume) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.Name)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.Name) // write string
- }
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.PersistentVolumeClaimUID)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.PersistentVolumeClaimUID) // write string
- }
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the PodPVCVolume type
- func (target *PodPVCVolume) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the PodPVCVolume type
- func (target *PodPVCVolume) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the PodPVCVolume type
- func (target *PodPVCVolume) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling PodPVCVolume. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.Name = a
- var e string
- if ctx.IsStringTable() {
- f := buff.ReadInt() // read string index
- e = ctx.Table.At(f)
- } else {
- e = buff.ReadString() // read string
- }
- d := e
- target.PersistentVolumeClaimUID = d
- return nil
- }
- //--------------------------------------------------------------------------
- // ReplicaSet
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this ReplicaSet instance
- // into a byte array
- func (target *ReplicaSet) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this ReplicaSet instance
- // into a byte array leveraging a predefined context.
- func (target *ReplicaSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.UID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.UID) // write string
- }
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.NamespaceUID)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.NamespaceUID) // write string
- }
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(target.Name)
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(target.Name) // write string
- }
- if target.Owners == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][slice]([]Owner) ---
- buff.WriteInt(len(target.Owners)) // slice length
- for i := range target.Owners {
- // --- [begin][write][struct](Owner) ---
- buff.WriteInt(0) // [compatibility, unused]
- errA := target.Owners[i].MarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- // --- [end][write][struct](Owner) ---
- }
- // --- [end][write][slice]([]Owner) ---
- }
- if target.Labels == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Labels)) // map length
- for v, z := range target.Labels {
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(v)
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(v) // write string
- }
- if ctx.IsStringTable() {
- e := ctx.Table.AddOrGet(z)
- buff.WriteInt(e) // write table index
- } else {
- buff.WriteString(z) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- if target.Annotations == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Annotations)) // map length
- for vv, zz := range target.Annotations {
- if ctx.IsStringTable() {
- f := ctx.Table.AddOrGet(vv)
- buff.WriteInt(f) // write table index
- } else {
- buff.WriteString(vv) // write string
- }
- if ctx.IsStringTable() {
- g := ctx.Table.AddOrGet(zz)
- buff.WriteInt(g) // write table index
- } else {
- buff.WriteString(zz) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [begin][write][reference](time.Time) ---
- h, errB := target.Start.MarshalBinary()
- if errB != nil {
- return errB
- }
- buff.WriteInt(len(h))
- buff.WriteBytes(h)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- l, errC := target.End.MarshalBinary()
- if errC != nil {
- return errC
- }
- buff.WriteInt(len(l))
- buff.WriteBytes(l)
- // --- [end][write][reference](time.Time) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the ReplicaSet type
- func (target *ReplicaSet) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the ReplicaSet type
- func (target *ReplicaSet) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the ReplicaSet type
- func (target *ReplicaSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling ReplicaSet. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.UID = a
- var e string
- if ctx.IsStringTable() {
- f := buff.ReadInt() // read string index
- e = ctx.Table.At(f)
- } else {
- e = buff.ReadString() // read string
- }
- d := e
- target.NamespaceUID = d
- var h string
- if ctx.IsStringTable() {
- l := buff.ReadInt() // read string index
- h = ctx.Table.At(l)
- } else {
- h = buff.ReadString() // read string
- }
- g := h
- target.Name = g
- if buff.ReadUInt8() == uint8(0) {
- target.Owners = nil
- } else {
- // --- [begin][read][slice]([]Owner) ---
- n := buff.ReadInt() // slice len
- m := make([]Owner, n)
- for i := range n {
- // --- [begin][read][struct](Owner) ---
- p := new(Owner)
- buff.ReadInt() // [compatibility, unused]
- errA := p.UnmarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- o := *p
- // --- [end][read][struct](Owner) ---
- m[i] = o
- }
- target.Owners = m
- // --- [end][read][slice]([]Owner) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.Labels = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- r := buff.ReadInt() // map len
- q := make(map[string]string, r)
- for range r {
- var v string
- var t string
- if ctx.IsStringTable() {
- u := buff.ReadInt() // read string index
- t = ctx.Table.At(u)
- } else {
- t = buff.ReadString() // read string
- }
- s := t
- v = s
- var z string
- var x string
- if ctx.IsStringTable() {
- y := buff.ReadInt() // read string index
- x = ctx.Table.At(y)
- } else {
- x = buff.ReadString() // read string
- }
- w := x
- z = w
- q[v] = z
- }
- target.Labels = q
- // --- [end][read][map](map[string]string) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.Annotations = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- bb := buff.ReadInt() // map len
- aa := make(map[string]string, bb)
- for range bb {
- var vv string
- var dd string
- if ctx.IsStringTable() {
- ee := buff.ReadInt() // read string index
- dd = ctx.Table.At(ee)
- } else {
- dd = buff.ReadString() // read string
- }
- cc := dd
- vv = cc
- var zz string
- var gg string
- if ctx.IsStringTable() {
- hh := buff.ReadInt() // read string index
- gg = ctx.Table.At(hh)
- } else {
- gg = buff.ReadString() // read string
- }
- ff := gg
- zz = ff
- aa[vv] = zz
- }
- target.Annotations = aa
- // --- [end][read][map](map[string]string) ---
- }
- // --- [begin][read][reference](time.Time) ---
- ll := new(time.Time)
- mm := buff.ReadInt() // byte array length
- nn := buff.ReadBytes(mm)
- errB := ll.UnmarshalBinary(nn)
- if errB != nil {
- return errB
- }
- target.Start = *ll
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- oo := new(time.Time)
- pp := buff.ReadInt() // byte array length
- qq := buff.ReadBytes(pp)
- errC := oo.UnmarshalBinary(qq)
- if errC != nil {
- return errC
- }
- target.End = *oo
- // --- [end][read][reference](time.Time) ---
- return nil
- }
- //--------------------------------------------------------------------------
- // ResourceQuantity
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this ResourceQuantity instance
- // into a byte array
- func (target *ResourceQuantity) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this ResourceQuantity instance
- // into a byte array leveraging a predefined context.
- func (target *ResourceQuantity) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- // --- [begin][write][alias](Resource) ---
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(string(target.Resource))
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(string(target.Resource)) // write string
- }
- // --- [end][write][alias](Resource) ---
- // --- [begin][write][alias](Unit) ---
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(string(target.Unit))
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(string(target.Unit)) // write string
- }
- // --- [end][write][alias](Unit) ---
- // --- [begin][write][alias](Stats) ---
- if map[StatType]float64(target.Values) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[StatType]float64) ---
- buff.WriteInt(len(map[StatType]float64(target.Values))) // map length
- for v, z := range map[StatType]float64(target.Values) {
- // --- [begin][write][alias](StatType) ---
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(string(v))
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(string(v)) // write string
- }
- // --- [end][write][alias](StatType) ---
- buff.WriteFloat64(z) // write float64
- }
- // --- [end][write][map](map[StatType]float64) ---
- }
- // --- [end][write][alias](Stats) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the ResourceQuantity type
- func (target *ResourceQuantity) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the ResourceQuantity type
- func (target *ResourceQuantity) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the ResourceQuantity type
- func (target *ResourceQuantity) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling ResourceQuantity. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][alias](Resource) ---
- var a string
- var c string
- if ctx.IsStringTable() {
- d := buff.ReadInt() // read string index
- c = ctx.Table.At(d)
- } else {
- c = buff.ReadString() // read string
- }
- b := c
- a = b
- target.Resource = Resource(a)
- // --- [end][read][alias](Resource) ---
- } else {
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][alias](Unit) ---
- var e string
- var g string
- if ctx.IsStringTable() {
- h := buff.ReadInt() // read string index
- g = ctx.Table.At(h)
- } else {
- g = buff.ReadString() // read string
- }
- f := g
- e = f
- target.Unit = Unit(e)
- // --- [end][read][alias](Unit) ---
- } else {
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][alias](Stats) ---
- var l map[StatType]float64
- if buff.ReadUInt8() == uint8(0) {
- l = nil
- } else {
- // --- [begin][read][map](map[StatType]float64) ---
- n := buff.ReadInt() // map len
- m := make(map[StatType]float64, n)
- for range n {
- // --- [begin][read][alias](StatType) ---
- var o string
- var q string
- if ctx.IsStringTable() {
- r := buff.ReadInt() // read string index
- q = ctx.Table.At(r)
- } else {
- q = buff.ReadString() // read string
- }
- p := q
- o = p
- v := StatType(o)
- // --- [end][read][alias](StatType) ---
- var z float64
- s := buff.ReadFloat64() // read float64
- z = s
- m[v] = z
- }
- l = m
- // --- [end][read][map](map[StatType]float64) ---
- }
- target.Values = Stats(l)
- // --- [end][read][alias](Stats) ---
- } else {
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // ResourceQuota
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this ResourceQuota instance
- // into a byte array
- func (target *ResourceQuota) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this ResourceQuota instance
- // into a byte array leveraging a predefined context.
- func (target *ResourceQuota) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.UID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.UID) // write string
- }
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.NamespaceUID)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.NamespaceUID) // write string
- }
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(target.Name)
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(target.Name) // write string
- }
- if target.Spec == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](ResourceQuotaSpec) ---
- buff.WriteInt(0) // [compatibility, unused]
- errA := target.Spec.MarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- // --- [end][write][struct](ResourceQuotaSpec) ---
- }
- if target.Status == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](ResourceQuotaStatus) ---
- buff.WriteInt(0) // [compatibility, unused]
- errB := target.Status.MarshalBinaryWithContext(ctx)
- if errB != nil {
- return errB
- }
- // --- [end][write][struct](ResourceQuotaStatus) ---
- }
- // --- [begin][write][reference](time.Time) ---
- d, errC := target.Start.MarshalBinary()
- if errC != nil {
- return errC
- }
- buff.WriteInt(len(d))
- buff.WriteBytes(d)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- e, errD := target.End.MarshalBinary()
- if errD != nil {
- return errD
- }
- buff.WriteInt(len(e))
- buff.WriteBytes(e)
- // --- [end][write][reference](time.Time) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the ResourceQuota type
- func (target *ResourceQuota) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the ResourceQuota type
- func (target *ResourceQuota) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the ResourceQuota type
- func (target *ResourceQuota) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling ResourceQuota. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- // field version check
- if uint8(1) <= version {
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.UID = a
- } else {
- target.UID = "" // default
- }
- // field version check
- if uint8(1) <= version {
- var e string
- if ctx.IsStringTable() {
- f := buff.ReadInt() // read string index
- e = ctx.Table.At(f)
- } else {
- e = buff.ReadString() // read string
- }
- d := e
- target.NamespaceUID = d
- } else {
- target.NamespaceUID = "" // default
- }
- // field version check
- if uint8(1) <= version {
- var h string
- if ctx.IsStringTable() {
- l := buff.ReadInt() // read string index
- h = ctx.Table.At(l)
- } else {
- h = buff.ReadString() // read string
- }
- g := h
- target.Name = g
- } else {
- target.Name = "" // default
- }
- // field version check
- if uint8(1) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Spec = nil
- } else {
- // --- [begin][read][struct](ResourceQuotaSpec) ---
- m := new(ResourceQuotaSpec)
- buff.ReadInt() // [compatibility, unused]
- errA := m.UnmarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- target.Spec = m
- // --- [end][read][struct](ResourceQuotaSpec) ---
- }
- } else {
- target.Spec = nil
- }
- // field version check
- if uint8(1) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Status = nil
- } else {
- // --- [begin][read][struct](ResourceQuotaStatus) ---
- n := new(ResourceQuotaStatus)
- buff.ReadInt() // [compatibility, unused]
- errB := n.UnmarshalBinaryWithContext(ctx)
- if errB != nil {
- return errB
- }
- target.Status = n
- // --- [end][read][struct](ResourceQuotaStatus) ---
- }
- } else {
- target.Status = nil
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][reference](time.Time) ---
- o := new(time.Time)
- p := buff.ReadInt() // byte array length
- q := buff.ReadBytes(p)
- errC := o.UnmarshalBinary(q)
- if errC != nil {
- return errC
- }
- target.Start = *o
- // --- [end][read][reference](time.Time) ---
- } else {
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][reference](time.Time) ---
- r := new(time.Time)
- s := buff.ReadInt() // byte array length
- t := buff.ReadBytes(s)
- errD := r.UnmarshalBinary(t)
- if errD != nil {
- return errD
- }
- target.End = *r
- // --- [end][read][reference](time.Time) ---
- } else {
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // ResourceQuotaSpec
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this ResourceQuotaSpec instance
- // into a byte array
- func (target *ResourceQuotaSpec) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this ResourceQuotaSpec instance
- // into a byte array leveraging a predefined context.
- func (target *ResourceQuotaSpec) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if target.Hard == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](ResourceQuotaSpecHard) ---
- buff.WriteInt(0) // [compatibility, unused]
- errA := target.Hard.MarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- // --- [end][write][struct](ResourceQuotaSpecHard) ---
- }
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the ResourceQuotaSpec type
- func (target *ResourceQuotaSpec) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the ResourceQuotaSpec type
- func (target *ResourceQuotaSpec) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the ResourceQuotaSpec type
- func (target *ResourceQuotaSpec) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling ResourceQuotaSpec. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- // field version check
- if uint8(1) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Hard = nil
- } else {
- // --- [begin][read][struct](ResourceQuotaSpecHard) ---
- a := new(ResourceQuotaSpecHard)
- buff.ReadInt() // [compatibility, unused]
- errA := a.UnmarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- target.Hard = a
- // --- [end][read][struct](ResourceQuotaSpecHard) ---
- }
- } else {
- target.Hard = nil
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // ResourceQuotaSpecHard
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this ResourceQuotaSpecHard instance
- // into a byte array
- func (target *ResourceQuotaSpecHard) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this ResourceQuotaSpecHard instance
- // into a byte array leveraging a predefined context.
- func (target *ResourceQuotaSpecHard) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- // --- [begin][write][alias](ResourceQuantities) ---
- if map[Resource]ResourceQuantity(target.Requests) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[Resource]ResourceQuantity) ---
- buff.WriteInt(len(map[Resource]ResourceQuantity(target.Requests))) // map length
- for v, z := range map[Resource]ResourceQuantity(target.Requests) {
- // --- [begin][write][alias](Resource) ---
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(string(v))
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(string(v)) // write string
- }
- // --- [end][write][alias](Resource) ---
- // --- [begin][write][struct](ResourceQuantity) ---
- buff.WriteInt(0) // [compatibility, unused]
- errA := z.MarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- // --- [end][write][struct](ResourceQuantity) ---
- }
- // --- [end][write][map](map[Resource]ResourceQuantity) ---
- }
- // --- [end][write][alias](ResourceQuantities) ---
- // --- [begin][write][alias](ResourceQuantities) ---
- if map[Resource]ResourceQuantity(target.Limits) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[Resource]ResourceQuantity) ---
- buff.WriteInt(len(map[Resource]ResourceQuantity(target.Limits))) // map length
- for vv, zz := range map[Resource]ResourceQuantity(target.Limits) {
- // --- [begin][write][alias](Resource) ---
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(string(vv))
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(string(vv)) // write string
- }
- // --- [end][write][alias](Resource) ---
- // --- [begin][write][struct](ResourceQuantity) ---
- buff.WriteInt(0) // [compatibility, unused]
- errB := zz.MarshalBinaryWithContext(ctx)
- if errB != nil {
- return errB
- }
- // --- [end][write][struct](ResourceQuantity) ---
- }
- // --- [end][write][map](map[Resource]ResourceQuantity) ---
- }
- // --- [end][write][alias](ResourceQuantities) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the ResourceQuotaSpecHard type
- func (target *ResourceQuotaSpecHard) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the ResourceQuotaSpecHard type
- func (target *ResourceQuotaSpecHard) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the ResourceQuotaSpecHard type
- func (target *ResourceQuotaSpecHard) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling ResourceQuotaSpecHard. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][alias](ResourceQuantities) ---
- var a map[Resource]ResourceQuantity
- if buff.ReadUInt8() == uint8(0) {
- a = nil
- } else {
- // --- [begin][read][map](map[Resource]ResourceQuantity) ---
- c := buff.ReadInt() // map len
- b := make(map[Resource]ResourceQuantity, c)
- for range c {
- // --- [begin][read][alias](Resource) ---
- var d string
- var f string
- if ctx.IsStringTable() {
- g := buff.ReadInt() // read string index
- f = ctx.Table.At(g)
- } else {
- f = buff.ReadString() // read string
- }
- e := f
- d = e
- v := Resource(d)
- // --- [end][read][alias](Resource) ---
- // --- [begin][read][struct](ResourceQuantity) ---
- h := new(ResourceQuantity)
- buff.ReadInt() // [compatibility, unused]
- errA := h.UnmarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- z := *h
- // --- [end][read][struct](ResourceQuantity) ---
- b[v] = z
- }
- a = b
- // --- [end][read][map](map[Resource]ResourceQuantity) ---
- }
- target.Requests = ResourceQuantities(a)
- // --- [end][read][alias](ResourceQuantities) ---
- } else {
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][alias](ResourceQuantities) ---
- var l map[Resource]ResourceQuantity
- if buff.ReadUInt8() == uint8(0) {
- l = nil
- } else {
- // --- [begin][read][map](map[Resource]ResourceQuantity) ---
- n := buff.ReadInt() // map len
- m := make(map[Resource]ResourceQuantity, n)
- for range n {
- // --- [begin][read][alias](Resource) ---
- var o string
- var q string
- if ctx.IsStringTable() {
- r := buff.ReadInt() // read string index
- q = ctx.Table.At(r)
- } else {
- q = buff.ReadString() // read string
- }
- p := q
- o = p
- vv := Resource(o)
- // --- [end][read][alias](Resource) ---
- // --- [begin][read][struct](ResourceQuantity) ---
- s := new(ResourceQuantity)
- buff.ReadInt() // [compatibility, unused]
- errB := s.UnmarshalBinaryWithContext(ctx)
- if errB != nil {
- return errB
- }
- zz := *s
- // --- [end][read][struct](ResourceQuantity) ---
- m[vv] = zz
- }
- l = m
- // --- [end][read][map](map[Resource]ResourceQuantity) ---
- }
- target.Limits = ResourceQuantities(l)
- // --- [end][read][alias](ResourceQuantities) ---
- } else {
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // ResourceQuotaStatus
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this ResourceQuotaStatus instance
- // into a byte array
- func (target *ResourceQuotaStatus) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this ResourceQuotaStatus instance
- // into a byte array leveraging a predefined context.
- func (target *ResourceQuotaStatus) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if target.Used == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][struct](ResourceQuotaStatusUsed) ---
- buff.WriteInt(0) // [compatibility, unused]
- errA := target.Used.MarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- // --- [end][write][struct](ResourceQuotaStatusUsed) ---
- }
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the ResourceQuotaStatus type
- func (target *ResourceQuotaStatus) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the ResourceQuotaStatus type
- func (target *ResourceQuotaStatus) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the ResourceQuotaStatus type
- func (target *ResourceQuotaStatus) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling ResourceQuotaStatus. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- // field version check
- if uint8(1) <= version {
- if buff.ReadUInt8() == uint8(0) {
- target.Used = nil
- } else {
- // --- [begin][read][struct](ResourceQuotaStatusUsed) ---
- a := new(ResourceQuotaStatusUsed)
- buff.ReadInt() // [compatibility, unused]
- errA := a.UnmarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- target.Used = a
- // --- [end][read][struct](ResourceQuotaStatusUsed) ---
- }
- } else {
- target.Used = nil
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // ResourceQuotaStatusUsed
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this ResourceQuotaStatusUsed instance
- // into a byte array
- func (target *ResourceQuotaStatusUsed) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this ResourceQuotaStatusUsed instance
- // into a byte array leveraging a predefined context.
- func (target *ResourceQuotaStatusUsed) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- // --- [begin][write][alias](ResourceQuantities) ---
- if map[Resource]ResourceQuantity(target.Requests) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[Resource]ResourceQuantity) ---
- buff.WriteInt(len(map[Resource]ResourceQuantity(target.Requests))) // map length
- for v, z := range map[Resource]ResourceQuantity(target.Requests) {
- // --- [begin][write][alias](Resource) ---
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(string(v))
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(string(v)) // write string
- }
- // --- [end][write][alias](Resource) ---
- // --- [begin][write][struct](ResourceQuantity) ---
- buff.WriteInt(0) // [compatibility, unused]
- errA := z.MarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- // --- [end][write][struct](ResourceQuantity) ---
- }
- // --- [end][write][map](map[Resource]ResourceQuantity) ---
- }
- // --- [end][write][alias](ResourceQuantities) ---
- // --- [begin][write][alias](ResourceQuantities) ---
- if map[Resource]ResourceQuantity(target.Limits) == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[Resource]ResourceQuantity) ---
- buff.WriteInt(len(map[Resource]ResourceQuantity(target.Limits))) // map length
- for vv, zz := range map[Resource]ResourceQuantity(target.Limits) {
- // --- [begin][write][alias](Resource) ---
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(string(vv))
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(string(vv)) // write string
- }
- // --- [end][write][alias](Resource) ---
- // --- [begin][write][struct](ResourceQuantity) ---
- buff.WriteInt(0) // [compatibility, unused]
- errB := zz.MarshalBinaryWithContext(ctx)
- if errB != nil {
- return errB
- }
- // --- [end][write][struct](ResourceQuantity) ---
- }
- // --- [end][write][map](map[Resource]ResourceQuantity) ---
- }
- // --- [end][write][alias](ResourceQuantities) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the ResourceQuotaStatusUsed type
- func (target *ResourceQuotaStatusUsed) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the ResourceQuotaStatusUsed type
- func (target *ResourceQuotaStatusUsed) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the ResourceQuotaStatusUsed type
- func (target *ResourceQuotaStatusUsed) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling ResourceQuotaStatusUsed. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][alias](ResourceQuantities) ---
- var a map[Resource]ResourceQuantity
- if buff.ReadUInt8() == uint8(0) {
- a = nil
- } else {
- // --- [begin][read][map](map[Resource]ResourceQuantity) ---
- c := buff.ReadInt() // map len
- b := make(map[Resource]ResourceQuantity, c)
- for range c {
- // --- [begin][read][alias](Resource) ---
- var d string
- var f string
- if ctx.IsStringTable() {
- g := buff.ReadInt() // read string index
- f = ctx.Table.At(g)
- } else {
- f = buff.ReadString() // read string
- }
- e := f
- d = e
- v := Resource(d)
- // --- [end][read][alias](Resource) ---
- // --- [begin][read][struct](ResourceQuantity) ---
- h := new(ResourceQuantity)
- buff.ReadInt() // [compatibility, unused]
- errA := h.UnmarshalBinaryWithContext(ctx)
- if errA != nil {
- return errA
- }
- z := *h
- // --- [end][read][struct](ResourceQuantity) ---
- b[v] = z
- }
- a = b
- // --- [end][read][map](map[Resource]ResourceQuantity) ---
- }
- target.Requests = ResourceQuantities(a)
- // --- [end][read][alias](ResourceQuantities) ---
- } else {
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][alias](ResourceQuantities) ---
- var l map[Resource]ResourceQuantity
- if buff.ReadUInt8() == uint8(0) {
- l = nil
- } else {
- // --- [begin][read][map](map[Resource]ResourceQuantity) ---
- n := buff.ReadInt() // map len
- m := make(map[Resource]ResourceQuantity, n)
- for range n {
- // --- [begin][read][alias](Resource) ---
- var o string
- var q string
- if ctx.IsStringTable() {
- r := buff.ReadInt() // read string index
- q = ctx.Table.At(r)
- } else {
- q = buff.ReadString() // read string
- }
- p := q
- o = p
- vv := Resource(o)
- // --- [end][read][alias](Resource) ---
- // --- [begin][read][struct](ResourceQuantity) ---
- s := new(ResourceQuantity)
- buff.ReadInt() // [compatibility, unused]
- errB := s.UnmarshalBinaryWithContext(ctx)
- if errB != nil {
- return errB
- }
- zz := *s
- // --- [end][read][struct](ResourceQuantity) ---
- m[vv] = zz
- }
- l = m
- // --- [end][read][map](map[Resource]ResourceQuantity) ---
- }
- target.Limits = ResourceQuantities(l)
- // --- [end][read][alias](ResourceQuantities) ---
- } else {
- }
- return nil
- }
- //--------------------------------------------------------------------------
- // Service
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Service instance
- // into a byte array
- func (target *Service) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this Service instance
- // into a byte array leveraging a predefined context.
- func (target *Service) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.UID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.UID) // write string
- }
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.NamespaceUID)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.NamespaceUID) // write string
- }
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(target.Name)
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(target.Name) // write string
- }
- // --- [begin][write][alias](ServiceType) ---
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(string(target.Type))
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(string(target.Type)) // write string
- }
- // --- [end][write][alias](ServiceType) ---
- // --- [begin][write][reference](time.Time) ---
- e, errA := target.Start.MarshalBinary()
- if errA != nil {
- return errA
- }
- buff.WriteInt(len(e))
- buff.WriteBytes(e)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- f, errB := target.End.MarshalBinary()
- if errB != nil {
- return errB
- }
- buff.WriteInt(len(f))
- buff.WriteBytes(f)
- // --- [end][write][reference](time.Time) ---
- if target.Selector == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Selector)) // map length
- for v, z := range target.Selector {
- if ctx.IsStringTable() {
- g := ctx.Table.AddOrGet(v)
- buff.WriteInt(g) // write table index
- } else {
- buff.WriteString(v) // write string
- }
- if ctx.IsStringTable() {
- h := ctx.Table.AddOrGet(z)
- buff.WriteInt(h) // write table index
- } else {
- buff.WriteString(z) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- if ctx.IsStringTable() {
- l := ctx.Table.AddOrGet(target.LBIngressAddress)
- buff.WriteInt(l) // write table index
- } else {
- buff.WriteString(target.LBIngressAddress) // write string
- }
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Service type
- func (target *Service) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the Service type
- func (target *Service) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the Service type
- func (target *Service) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling Service. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.UID = a
- var e string
- if ctx.IsStringTable() {
- f := buff.ReadInt() // read string index
- e = ctx.Table.At(f)
- } else {
- e = buff.ReadString() // read string
- }
- d := e
- target.NamespaceUID = d
- var h string
- if ctx.IsStringTable() {
- l := buff.ReadInt() // read string index
- h = ctx.Table.At(l)
- } else {
- h = buff.ReadString() // read string
- }
- g := h
- target.Name = g
- // --- [begin][read][alias](ServiceType) ---
- var m string
- var o string
- if ctx.IsStringTable() {
- p := buff.ReadInt() // read string index
- o = ctx.Table.At(p)
- } else {
- o = buff.ReadString() // read string
- }
- n := o
- m = n
- target.Type = ServiceType(m)
- // --- [end][read][alias](ServiceType) ---
- // --- [begin][read][reference](time.Time) ---
- q := new(time.Time)
- r := buff.ReadInt() // byte array length
- s := buff.ReadBytes(r)
- errA := q.UnmarshalBinary(s)
- if errA != nil {
- return errA
- }
- target.Start = *q
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- t := new(time.Time)
- u := buff.ReadInt() // byte array length
- w := buff.ReadBytes(u)
- errB := t.UnmarshalBinary(w)
- if errB != nil {
- return errB
- }
- target.End = *t
- // --- [end][read][reference](time.Time) ---
- if buff.ReadUInt8() == uint8(0) {
- target.Selector = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- y := buff.ReadInt() // map len
- x := make(map[string]string, y)
- for range y {
- var v string
- var bb string
- if ctx.IsStringTable() {
- cc := buff.ReadInt() // read string index
- bb = ctx.Table.At(cc)
- } else {
- bb = buff.ReadString() // read string
- }
- aa := bb
- v = aa
- var z string
- var ee string
- if ctx.IsStringTable() {
- ff := buff.ReadInt() // read string index
- ee = ctx.Table.At(ff)
- } else {
- ee = buff.ReadString() // read string
- }
- dd := ee
- z = dd
- x[v] = z
- }
- target.Selector = x
- // --- [end][read][map](map[string]string) ---
- }
- var hh string
- if ctx.IsStringTable() {
- ll := buff.ReadInt() // read string index
- hh = ctx.Table.At(ll)
- } else {
- hh = buff.ReadString() // read string
- }
- gg := hh
- target.LBIngressAddress = gg
- return nil
- }
- //--------------------------------------------------------------------------
- // StatefulSet
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this StatefulSet instance
- // into a byte array
- func (target *StatefulSet) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this StatefulSet instance
- // into a byte array leveraging a predefined context.
- func (target *StatefulSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- if ctx.IsStringTable() {
- a := ctx.Table.AddOrGet(target.UID)
- buff.WriteInt(a) // write table index
- } else {
- buff.WriteString(target.UID) // write string
- }
- if ctx.IsStringTable() {
- b := ctx.Table.AddOrGet(target.NamespaceUID)
- buff.WriteInt(b) // write table index
- } else {
- buff.WriteString(target.NamespaceUID) // write string
- }
- if ctx.IsStringTable() {
- c := ctx.Table.AddOrGet(target.Name)
- buff.WriteInt(c) // write table index
- } else {
- buff.WriteString(target.Name) // write string
- }
- if target.Labels == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Labels)) // map length
- for v, z := range target.Labels {
- if ctx.IsStringTable() {
- d := ctx.Table.AddOrGet(v)
- buff.WriteInt(d) // write table index
- } else {
- buff.WriteString(v) // write string
- }
- if ctx.IsStringTable() {
- e := ctx.Table.AddOrGet(z)
- buff.WriteInt(e) // write table index
- } else {
- buff.WriteString(z) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- if target.Annotations == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.Annotations)) // map length
- for vv, zz := range target.Annotations {
- if ctx.IsStringTable() {
- f := ctx.Table.AddOrGet(vv)
- buff.WriteInt(f) // write table index
- } else {
- buff.WriteString(vv) // write string
- }
- if ctx.IsStringTable() {
- g := ctx.Table.AddOrGet(zz)
- buff.WriteInt(g) // write table index
- } else {
- buff.WriteString(zz) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- if target.MatchLabels == nil {
- buff.WriteUInt8(uint8(0)) // write nil byte
- } else {
- buff.WriteUInt8(uint8(1)) // write non-nil byte
- // --- [begin][write][map](map[string]string) ---
- buff.WriteInt(len(target.MatchLabels)) // map length
- for vvv, zzz := range target.MatchLabels {
- if ctx.IsStringTable() {
- h := ctx.Table.AddOrGet(vvv)
- buff.WriteInt(h) // write table index
- } else {
- buff.WriteString(vvv) // write string
- }
- if ctx.IsStringTable() {
- l := ctx.Table.AddOrGet(zzz)
- buff.WriteInt(l) // write table index
- } else {
- buff.WriteString(zzz) // write string
- }
- }
- // --- [end][write][map](map[string]string) ---
- }
- // --- [begin][write][reference](time.Time) ---
- m, errA := target.Start.MarshalBinary()
- if errA != nil {
- return errA
- }
- buff.WriteInt(len(m))
- buff.WriteBytes(m)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- n, errB := target.End.MarshalBinary()
- if errB != nil {
- return errB
- }
- buff.WriteInt(len(n))
- buff.WriteBytes(n)
- // --- [end][write][reference](time.Time) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the StatefulSet type
- func (target *StatefulSet) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the StatefulSet type
- func (target *StatefulSet) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the StatefulSet type
- func (target *StatefulSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling StatefulSet. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- var b string
- if ctx.IsStringTable() {
- c := buff.ReadInt() // read string index
- b = ctx.Table.At(c)
- } else {
- b = buff.ReadString() // read string
- }
- a := b
- target.UID = a
- var e string
- if ctx.IsStringTable() {
- f := buff.ReadInt() // read string index
- e = ctx.Table.At(f)
- } else {
- e = buff.ReadString() // read string
- }
- d := e
- target.NamespaceUID = d
- var h string
- if ctx.IsStringTable() {
- l := buff.ReadInt() // read string index
- h = ctx.Table.At(l)
- } else {
- h = buff.ReadString() // read string
- }
- g := h
- target.Name = g
- if buff.ReadUInt8() == uint8(0) {
- target.Labels = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- n := buff.ReadInt() // map len
- m := make(map[string]string, n)
- for range n {
- var v string
- var p string
- if ctx.IsStringTable() {
- q := buff.ReadInt() // read string index
- p = ctx.Table.At(q)
- } else {
- p = buff.ReadString() // read string
- }
- o := p
- v = o
- var z string
- var s string
- if ctx.IsStringTable() {
- t := buff.ReadInt() // read string index
- s = ctx.Table.At(t)
- } else {
- s = buff.ReadString() // read string
- }
- r := s
- z = r
- m[v] = z
- }
- target.Labels = m
- // --- [end][read][map](map[string]string) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.Annotations = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- w := buff.ReadInt() // map len
- u := make(map[string]string, w)
- for range w {
- var vv string
- var y string
- if ctx.IsStringTable() {
- aa := buff.ReadInt() // read string index
- y = ctx.Table.At(aa)
- } else {
- y = buff.ReadString() // read string
- }
- x := y
- vv = x
- var zz string
- var cc string
- if ctx.IsStringTable() {
- dd := buff.ReadInt() // read string index
- cc = ctx.Table.At(dd)
- } else {
- cc = buff.ReadString() // read string
- }
- bb := cc
- zz = bb
- u[vv] = zz
- }
- target.Annotations = u
- // --- [end][read][map](map[string]string) ---
- }
- if buff.ReadUInt8() == uint8(0) {
- target.MatchLabels = nil
- } else {
- // --- [begin][read][map](map[string]string) ---
- ff := buff.ReadInt() // map len
- ee := make(map[string]string, ff)
- for range ff {
- var vvv string
- var hh string
- if ctx.IsStringTable() {
- ll := buff.ReadInt() // read string index
- hh = ctx.Table.At(ll)
- } else {
- hh = buff.ReadString() // read string
- }
- gg := hh
- vvv = gg
- var zzz string
- var nn string
- if ctx.IsStringTable() {
- oo := buff.ReadInt() // read string index
- nn = ctx.Table.At(oo)
- } else {
- nn = buff.ReadString() // read string
- }
- mm := nn
- zzz = mm
- ee[vvv] = zzz
- }
- target.MatchLabels = ee
- // --- [end][read][map](map[string]string) ---
- }
- // --- [begin][read][reference](time.Time) ---
- pp := new(time.Time)
- qq := buff.ReadInt() // byte array length
- rr := buff.ReadBytes(qq)
- errA := pp.UnmarshalBinary(rr)
- if errA != nil {
- return errA
- }
- target.Start = *pp
- // --- [end][read][reference](time.Time) ---
- // --- [begin][read][reference](time.Time) ---
- ss := new(time.Time)
- tt := buff.ReadInt() // byte array length
- uu := buff.ReadBytes(tt)
- errB := ss.UnmarshalBinary(uu)
- if errB != nil {
- return errB
- }
- target.End = *ss
- // --- [end][read][reference](time.Time) ---
- return nil
- }
- //--------------------------------------------------------------------------
- // Window
- //--------------------------------------------------------------------------
- // MarshalBinary serializes the internal properties of this Window instance
- // into a byte array
- func (target *Window) MarshalBinary() (data []byte, err error) {
- ctx := &EncodingContext{
- Buffer: util.NewBuffer(),
- Table: nil,
- }
- e := target.MarshalBinaryWithContext(ctx)
- if e != nil {
- return nil, e
- }
- encBytes := ctx.Buffer.Bytes()
- return encBytes, nil
- }
- // MarshalBinaryWithContext serializes the internal properties of this Window instance
- // into a byte array leveraging a predefined context.
- func (target *Window) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- buff.WriteUInt8(DefaultCodecVersion) // version
- // --- [begin][write][reference](time.Time) ---
- a, errA := target.Start.MarshalBinary()
- if errA != nil {
- return errA
- }
- buff.WriteInt(len(a))
- buff.WriteBytes(a)
- // --- [end][write][reference](time.Time) ---
- // --- [begin][write][reference](time.Time) ---
- b, errB := target.End.MarshalBinary()
- if errB != nil {
- return errB
- }
- buff.WriteInt(len(b))
- buff.WriteBytes(b)
- // --- [end][write][reference](time.Time) ---
- return nil
- }
- // UnmarshalBinary uses the data passed byte array to set all the internal properties of
- // the Window type
- func (target *Window) UnmarshalBinary(data []byte) error {
- ctx := NewDecodingContextFromBytes(data)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryFromReader uses the io.Reader data to set all the internal properties of
- // the Window type
- func (target *Window) UnmarshalBinaryFromReader(reader io.Reader) error {
- ctx := NewDecodingContextFromReader(reader)
- defer ctx.Close()
- err := target.UnmarshalBinaryWithContext(ctx)
- if err != nil {
- return err
- }
- return nil
- }
- // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
- // the Window type
- func (target *Window) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
- // panics are recovered and propagated as errors
- defer func() {
- if r := recover(); r != nil {
- if e, ok := r.(error); ok {
- err = e
- } else if s, ok := r.(string); ok {
- err = fmt.Errorf("unexpected panic: %s", s)
- } else {
- err = fmt.Errorf("unexpected panic: %+v", r)
- }
- }
- }()
- buff := ctx.Buffer
- version := buff.ReadUInt8()
- if version > DefaultCodecVersion {
- return fmt.Errorf("Invalid Version Unmarshalling Window. Expected %d or less, got %d", DefaultCodecVersion, version)
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][reference](time.Time) ---
- a := new(time.Time)
- b := buff.ReadInt() // byte array length
- c := buff.ReadBytes(b)
- errA := a.UnmarshalBinary(c)
- if errA != nil {
- return errA
- }
- target.Start = *a
- // --- [end][read][reference](time.Time) ---
- } else {
- }
- // field version check
- if uint8(1) <= version {
- // --- [begin][read][reference](time.Time) ---
- d := new(time.Time)
- e := buff.ReadInt() // byte array length
- f := buff.ReadBytes(e)
- errB := d.UnmarshalBinary(f)
- if errB != nil {
- return errB
- }
- target.End = *d
- // --- [end][read][reference](time.Time) ---
- } else {
- }
- return nil
- }
|