kubecost_codecs.go 231 KB

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