Просмотр исходного кода

KubeModel structure and binary codecs

Niko Kovacevic 6 месяцев назад
Родитель
Сommit
7a40abe835

+ 44 - 0
core/pkg/model/kubemodel/bingen.go

@@ -0,0 +1,44 @@
+package kubemodel
+
+////////////////////////////////////////////////////////////////////////////////
+// NOTE: If you add fields to _any_ struct that is serialized by bingen, please
+// make sure to add those fields to the END of the struct definition. This is
+// required for backwards-compatibility. So:
+//
+// type Foo struct {
+//     ExistingField1 string
+//     ExistingField2 int
+// }
+//
+// becomes:
+//
+// type Foo struct {
+//     ExistingField1 string
+//     ExistingField2 int
+//     NewField       float64 // @bingen: <- annotation ref: bingen README
+// }
+//
+////////////////////////////////////////////////////////////////////////////////
+
+// Kubemodel Version Set: Includes Kubemodel pipeline specific resources
+// @bingen:set[name=KubeModel,version=1]
+// @bingen:generate[stringtable]:KubeModelSet
+// @bingen:generate:Cluster
+// @bingen:generate:Metadata
+// @bingen:generate:Namespace
+// @bingen:generate:Provider
+// @bingen:generate:Resource
+// @bingen:generate:ResourceQuantity
+// @bingen:generate:ResourceQuantities
+// @bingen:generate:ResourceQuota
+// @bingen:generate:ResourceQuotaSpec
+// @bingen:generate:ResourceQuotaSpecHard
+// @bingen:generate:ResourceQuotaStatus
+// @bingen:generate:ResourceQuotaStatusUsed
+// @bingen:generate:Stats
+// @bingen:generate:StatType
+// @bingen:generate:Unit
+// @bingen:generate:Window
+// @bingen:end
+
+//go:generate bingen -package=kubemodel -version=1 -buffer=github.com/opencost/opencost/core/pkg/util

+ 6 - 6
core/pkg/model/kubemodel/cluster.go

@@ -3,10 +3,10 @@ package kubemodel
 import "time"
 
 type Cluster struct {
-	UID      string
-	Provider Provider
-	Account  string
-	Name     string
-	Start    time.Time
-	End      time.Time
+	UID      string    `json:"uid"`      // @bingen:field[version=1]
+	Provider Provider  `json:"provider"` // @bingen:field[version=1]
+	Account  string    `json:"account"`  // @bingen:field[version=1]
+	Name     string    `json:"name"`     // @bingen:field[version=1]
+	Start    time.Time `json:"start"`    // @bingen:field[version=1]
+	End      time.Time `json:"end"`      // @bingen:field[version=1]
 }

+ 0 - 35
core/pkg/model/kubemodel/container.go

@@ -1,35 +0,0 @@
-package kubemodel
-
-import "time"
-
-// TODO complete
-// TODO (start, end) here, or defer to Pod?
-// TODO how to handle network bytes?
-// TODO how to handle GPUs?
-// TODO how to handle storage?
-// TODO how to handle devices?
-// TODO uint64 or float64 for numbers?
-type Container struct {
-	UID                           string
-	PodUID                        string
-	Name                          string
-	Start                         time.Time
-	End                           time.Time
-	CPUAllocationMillicoreSeconds uint64
-	CPURequestMillicoreAverage    uint64
-	CPULimitMillicoreAverage      uint64
-	CPUUsageMillicoreAverage      uint64
-	CPUUsageMillicoreMax          uint64
-	RAMAllocationByteSeconds      uint64
-	RAMRequestByteAverage         uint64
-	RAMLimitByteAverage           uint64
-	RAMUsageByteAverage           uint64
-	RAMUsageByteMax               uint64
-	PVCMounts                     map[string]*MountedVolume
-}
-
-type MountedVolume struct {
-	PersistentVolumeClaimUID string
-	Name                     string
-	StorageCapacityBytes     uint64
-}

+ 21 - 36
core/pkg/model/kubemodel/kubemodel.go

@@ -7,26 +7,21 @@ import (
 )
 
 type KubeModelSet struct {
-	Metadata               *KubeModelSetMetadata
-	Window                 Window
-	Cluster                *Cluster
-	Containers             map[string]*Container
-	Nodes                  map[string]*Node
-	Namespaces             map[string]*Namespace
-	PersistentVolumes      map[string]*PersistentVolume
-	PersistentVolumeClaims map[string]*PersistentVolumeClaim
-	Pods                   map[string]*Pod
-	ResourceQuotas         map[string]*ResourceQuota
-	Indices                *Indices
+	Metadata       *Metadata                 `json:"meta"`           // @bingen:field[version=1]
+	Window         Window                    `json:"window"`         // @bingen:field[version=1]
+	Cluster        *Cluster                  `json:"cluster"`        // @bingen:field[version=1]
+	Namespaces     map[string]*Namespace     `json:"namespaces"`     // @bingen:field[version=1]
+	ResourceQuotas map[string]*ResourceQuota `json:"resourceQuotas"` // @bingen:field[version=1]
+	idx            *index                    // @bingen:field[ignore]
 }
 
 func NewKubeModelSet(start, end time.Time) *KubeModelSet {
-	indices := &Indices{
-		NamespaceNameToUID: map[string]string{},
+	index := &index{
+		namespaceByName: map[string]*Namespace{},
 	}
 
 	return &KubeModelSet{
-		Metadata: &KubeModelSetMetadata{
+		Metadata: &Metadata{
 			CreatedAt: time.Now().UTC(),
 		},
 		Window: Window{
@@ -35,7 +30,7 @@ func NewKubeModelSet(start, end time.Time) *KubeModelSet {
 		},
 		Namespaces:     map[string]*Namespace{},
 		ResourceQuotas: map[string]*ResourceQuota{},
-		Indices:        indices,
+		idx:            index,
 	}
 }
 
@@ -51,7 +46,9 @@ func (kms *KubeModelSet) RegisterNamespace(uid, name string) error {
 			Name:       name,
 		}
 
-		kms.Indices.NamespaceNameToUID[name] = uid
+		kms.idx.namespaceByName[name] = kms.Namespaces[uid]
+
+		kms.Metadata.ObjectCount++
 	}
 
 	return nil
@@ -59,40 +56,28 @@ func (kms *KubeModelSet) RegisterNamespace(uid, name string) error {
 
 func (kms *KubeModelSet) RegisterResourceQuota(uid, name, namespace string) error {
 	if _, ok := kms.ResourceQuotas[uid]; !ok {
-		if _, ok := kms.Indices.NamespaceNameToUID[namespace]; !ok {
-			return fmt.Errorf("KubeModelSet missing NamespaceUID for namespace=%s", namespace)
+		if _, ok := kms.idx.namespaceByName[namespace]; !ok {
+			return fmt.Errorf("KubeModelSet missing namespace '%s'", namespace)
 		}
 
 		kms.ResourceQuotas[uid] = &ResourceQuota{
 			UID:          uid,
 			Name:         name,
-			NamespaceUID: kms.Indices.NamespaceNameToUID[namespace],
+			NamespaceUID: kms.idx.namespaceByName[namespace].UID,
 			Spec:         &ResourceQuotaSpec{Hard: &ResourceQuotaSpecHard{}},
 			Status:       &ResourceQuotaStatus{Used: &ResourceQuotaStatusUsed{}},
 		}
+
+		kms.Metadata.ObjectCount++
 	}
 
 	return nil
 }
 
-// TODO: determine what "IsEmpty()" should mean here
 func (kms *KubeModelSet) IsEmpty() bool {
-	return kms == nil || kms.Cluster == nil
-}
-
-// TODO: generate bingen codec
-func (kms *KubeModelSet) MarshalBinary() ([]byte, error) {
-	return nil, errors.New("not implemented")
-}
-
-type KubeModelSetMetadata struct {
-	CreatedAt   time.Time
-	CompletedAt time.Time
-	ObjectCount int
-	Errors      []error
-	Warnings    []string
+	return kms == nil || kms.Cluster == nil || kms.Metadata.ObjectCount == 0
 }
 
-type Indices struct {
-	NamespaceNameToUID map[string]string
+type index struct {
+	namespaceByName map[string]*Namespace
 }

+ 2836 - 0
core/pkg/model/kubemodel/kubemodel_codecs.go

@@ -0,0 +1,2836 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//                             DO NOT MODIFY
+//
+//                          ┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻
+//
+//
+//            This source file was automatically generated by bingen.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package kubemodel
+
+import (
+	"fmt"
+	util "github.com/opencost/opencost/core/pkg/util"
+	"reflect"
+	"strings"
+	"sync"
+	"time"
+)
+
+const (
+	// GeneratorPackageName is the package the generator is targetting
+	GeneratorPackageName string = "kubemodel"
+)
+
+// BinaryTags represent the formatting tag used for specific optimization features
+const (
+	// BinaryTagStringTable is written and/or read prior to the existence of a string
+	// table (where each index is encoded as a string entry in the resource
+	BinaryTagStringTable string = "BGST"
+)
+
+const (
+	// KubeModelCodecVersion is used for any resources listed in the KubeModel version set
+	KubeModelCodecVersion uint8 = 1
+)
+
+//--------------------------------------------------------------------------
+//  Type Map
+//--------------------------------------------------------------------------
+
+// Generated type map for resolving interface implementations to
+// to concrete types
+var typeMap map[string]reflect.Type = map[string]reflect.Type{
+	"Cluster":                 reflect.TypeOf((*Cluster)(nil)).Elem(),
+	"KubeModelSet":            reflect.TypeOf((*KubeModelSet)(nil)).Elem(),
+	"Metadata":                reflect.TypeOf((*Metadata)(nil)).Elem(),
+	"Namespace":               reflect.TypeOf((*Namespace)(nil)).Elem(),
+	"ResourceQuantity":        reflect.TypeOf((*ResourceQuantity)(nil)).Elem(),
+	"ResourceQuota":           reflect.TypeOf((*ResourceQuota)(nil)).Elem(),
+	"ResourceQuotaSpec":       reflect.TypeOf((*ResourceQuotaSpec)(nil)).Elem(),
+	"ResourceQuotaSpecHard":   reflect.TypeOf((*ResourceQuotaSpecHard)(nil)).Elem(),
+	"ResourceQuotaStatus":     reflect.TypeOf((*ResourceQuotaStatus)(nil)).Elem(),
+	"ResourceQuotaStatusUsed": reflect.TypeOf((*ResourceQuotaStatusUsed)(nil)).Elem(),
+	"Window":                  reflect.TypeOf((*Window)(nil)).Elem(),
+}
+
+//--------------------------------------------------------------------------
+//  Type Helpers
+//--------------------------------------------------------------------------
+
+// isBinaryTag returns true when the first bytes in the provided binary matches the tag
+func isBinaryTag(data []byte, tag string) bool {
+	return string(data[:len(tag)]) == tag
+}
+
+// appendBytes combines a and b into a new byte array
+func appendBytes(a []byte, b []byte) []byte {
+	al := len(a)
+	bl := len(b)
+	tl := al + bl
+
+	// allocate a new byte array for the combined
+	// use native copy for speedy byte copying
+	result := make([]byte, tl, tl)
+	copy(result, a)
+	copy(result[al:], b)
+
+	return result
+}
+
+// typeToString determines the basic properties of the type, the qualifier, package path, and
+// type name, and returns the qualified type
+func typeToString(f interface{}) string {
+	qual := ""
+	t := reflect.TypeOf(f)
+	if t.Kind() == reflect.Ptr {
+		t = t.Elem()
+		qual = "*"
+	}
+
+	return fmt.Sprintf("%s%s.%s", qual, t.PkgPath(), t.Name())
+}
+
+// resolveType uses the name of a type and returns the package, base type name, and whether
+// or not it's a pointer.
+func resolveType(t string) (pkg string, name string, isPtr bool) {
+	isPtr = t[:1] == "*"
+	if isPtr {
+		t = t[1:]
+	}
+
+	slashIndex := strings.LastIndex(t, "/")
+	if slashIndex >= 0 {
+		t = t[slashIndex+1:]
+	}
+	parts := strings.Split(t, ".")
+	if parts[0] == GeneratorPackageName {
+		parts[0] = ""
+	}
+
+	pkg = parts[0]
+	name = parts[1]
+	return
+}
+
+//--------------------------------------------------------------------------
+//  StringTable
+//--------------------------------------------------------------------------
+
+// StringTable maps strings to specific indices for encoding
+type StringTable struct {
+	l       *sync.Mutex
+	indices map[string]int
+	next    int
+}
+
+// NewStringTable Creates a new StringTable instance with provided contents
+func NewStringTable(contents ...string) *StringTable {
+	st := &StringTable{
+		l:       new(sync.Mutex),
+		indices: make(map[string]int),
+		next:    len(contents),
+	}
+
+	for i, entry := range contents {
+		st.indices[entry] = i
+	}
+
+	return st
+}
+
+// AddOrGet atomically retrieves a string entry's index if it exist. Otherwise, it will
+// add the entry and return the index.
+func (st *StringTable) AddOrGet(s string) int {
+	st.l.Lock()
+	defer st.l.Unlock()
+
+	if ind, ok := st.indices[s]; ok {
+		return ind
+	}
+
+	current := st.next
+	st.next++
+
+	st.indices[s] = current
+	return current
+}
+
+// ToSlice Converts the contents to a string array for encoding.
+func (st *StringTable) ToSlice() []string {
+	st.l.Lock()
+	defer st.l.Unlock()
+
+	if st.next == 0 {
+		return []string{}
+	}
+
+	sl := make([]string, st.next, st.next)
+	for s, i := range st.indices {
+		sl[i] = s
+	}
+	return sl
+}
+
+// ToBytes Converts the contents to a binary encoded representation
+func (st *StringTable) ToBytes() []byte {
+	buff := util.NewBuffer()
+	buff.WriteBytes([]byte(BinaryTagStringTable)) // bingen table header
+
+	strs := st.ToSlice()
+
+	buff.WriteInt(len(strs)) // table length
+	for _, s := range strs {
+		buff.WriteString(s)
+	}
+
+	return buff.Bytes()
+}
+
+//--------------------------------------------------------------------------
+//  Codec Context
+//--------------------------------------------------------------------------
+
+// EncodingContext is a context object passed to the encoders to ensure reuse of buffer
+// and table data
+type EncodingContext struct {
+	Buffer *util.Buffer
+	Table  *StringTable
+}
+
+// IsStringTable returns true if the table is available
+func (ec *EncodingContext) IsStringTable() bool {
+	return ec.Table != nil
+}
+
+// DecodingContext is a context object passed to the decoders to ensure parent objects
+// reuse as much data as possible
+type DecodingContext struct {
+	Buffer *util.Buffer
+	Table  []string
+}
+
+// IsStringTable returns true if the table is available
+func (dc *DecodingContext) IsStringTable() bool {
+	return len(dc.Table) > 0
+}
+
+//--------------------------------------------------------------------------
+//  Binary Codec
+//--------------------------------------------------------------------------
+
+// BinEncoder is an encoding interface which defines a context based marshal contract.
+type BinEncoder interface {
+	MarshalBinaryWithContext(*EncodingContext) error
+}
+
+// BinDecoder is a decoding interface which defines a context based unmarshal contract.
+type BinDecoder interface {
+	UnmarshalBinaryWithContext(*DecodingContext) error
+}
+
+//--------------------------------------------------------------------------
+//  Cluster
+//--------------------------------------------------------------------------
+
+// MarshalBinary serializes the internal properties of this Cluster instance
+// into a byte array
+func (target *Cluster) MarshalBinary() (data []byte, err error) {
+	ctx := &EncodingContext{
+		Buffer: util.NewBuffer(),
+		Table:  nil,
+	}
+
+	e := target.MarshalBinaryWithContext(ctx)
+	if e != nil {
+		return nil, e
+	}
+
+	encBytes := ctx.Buffer.Bytes()
+	return encBytes, nil
+}
+
+// MarshalBinaryWithContext serializes the internal properties of this Cluster instance
+// into a byte array leveraging a predefined context.
+func (target *Cluster) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	buff.WriteUInt8(KubeModelCodecVersion) // version
+
+	if ctx.IsStringTable() {
+		a := ctx.Table.AddOrGet(target.UID)
+		buff.WriteInt(a) // write table index
+	} else {
+		buff.WriteString(target.UID) // write string
+	}
+	// --- [begin][write][alias](Provider) ---
+	if ctx.IsStringTable() {
+		b := ctx.Table.AddOrGet(string(target.Provider))
+		buff.WriteInt(b) // write table index
+	} else {
+		buff.WriteString(string(target.Provider)) // write string
+	}
+	// --- [end][write][alias](Provider) ---
+
+	if ctx.IsStringTable() {
+		c := ctx.Table.AddOrGet(target.Account)
+		buff.WriteInt(c) // write table index
+	} else {
+		buff.WriteString(target.Account) // write string
+	}
+	if ctx.IsStringTable() {
+		d := ctx.Table.AddOrGet(target.Name)
+		buff.WriteInt(d) // write table index
+	} else {
+		buff.WriteString(target.Name) // write string
+	}
+	// --- [begin][write][reference](time.Time) ---
+	e, errA := target.Start.MarshalBinary()
+	if errA != nil {
+		return errA
+	}
+	buff.WriteInt(len(e))
+	buff.WriteBytes(e)
+	// --- [end][write][reference](time.Time) ---
+
+	// --- [begin][write][reference](time.Time) ---
+	f, errB := target.End.MarshalBinary()
+	if errB != nil {
+		return errB
+	}
+	buff.WriteInt(len(f))
+	buff.WriteBytes(f)
+	// --- [end][write][reference](time.Time) ---
+
+	return nil
+}
+
+// UnmarshalBinary uses the data passed byte array to set all the internal properties of
+// the Cluster type
+func (target *Cluster) UnmarshalBinary(data []byte) error {
+	var table []string
+	buff := util.NewBufferFromBytes(data)
+
+	// string table header validation
+	if isBinaryTag(data, BinaryTagStringTable) {
+		buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
+		tl := buff.ReadInt()                      // table length
+		if tl > 0 {
+			table = make([]string, tl, tl)
+			for i := 0; i < tl; i++ {
+				table[i] = buff.ReadString()
+			}
+		}
+	}
+
+	ctx := &DecodingContext{
+		Buffer: buff,
+		Table:  table,
+	}
+
+	err := target.UnmarshalBinaryWithContext(ctx)
+	if err != nil {
+		return err
+	}
+
+	return nil
+}
+
+// UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
+// the Cluster type
+func (target *Cluster) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	version := buff.ReadUInt8()
+
+	if version > KubeModelCodecVersion {
+		return fmt.Errorf("Invalid Version Unmarshaling Cluster. Expected %d or less, got %d", KubeModelCodecVersion, version)
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		var b string
+		if ctx.IsStringTable() {
+			c := buff.ReadInt() // read string index
+			b = ctx.Table[c]
+		} else {
+			b = buff.ReadString() // read string
+		}
+		a := b
+		target.UID = a
+
+	} else {
+		target.UID = "" // default
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][alias](Provider) ---
+		var d string
+		var f string
+		if ctx.IsStringTable() {
+			g := buff.ReadInt() // read string index
+			f = ctx.Table[g]
+		} else {
+			f = buff.ReadString() // read string
+		}
+		e := f
+		d = e
+
+		target.Provider = Provider(d)
+		// --- [end][read][alias](Provider) ---
+
+	} else {
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		var k string
+		if ctx.IsStringTable() {
+			l := buff.ReadInt() // read string index
+			k = ctx.Table[l]
+		} else {
+			k = buff.ReadString() // read string
+		}
+		h := k
+		target.Account = h
+
+	} else {
+		target.Account = "" // default
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		var n string
+		if ctx.IsStringTable() {
+			o := buff.ReadInt() // read string index
+			n = ctx.Table[o]
+		} else {
+			n = buff.ReadString() // read string
+		}
+		m := n
+		target.Name = m
+
+	} else {
+		target.Name = "" // default
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][reference](time.Time) ---
+		p := &time.Time{}
+		q := buff.ReadInt()    // byte array length
+		r := buff.ReadBytes(q) // byte array
+		errA := p.UnmarshalBinary(r)
+		if errA != nil {
+			return errA
+		}
+		target.Start = *p
+		// --- [end][read][reference](time.Time) ---
+
+	} else {
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][reference](time.Time) ---
+		s := &time.Time{}
+		t := buff.ReadInt()    // byte array length
+		u := buff.ReadBytes(t) // byte array
+		errB := s.UnmarshalBinary(u)
+		if errB != nil {
+			return errB
+		}
+		target.End = *s
+		// --- [end][read][reference](time.Time) ---
+
+	} else {
+	}
+
+	return nil
+}
+
+//--------------------------------------------------------------------------
+//  KubeModelSet
+//--------------------------------------------------------------------------
+
+// MarshalBinary serializes the internal properties of this KubeModelSet instance
+// into a byte array
+func (target *KubeModelSet) MarshalBinary() (data []byte, err error) {
+	ctx := &EncodingContext{
+		Buffer: util.NewBuffer(),
+		Table:  NewStringTable(),
+	}
+
+	e := target.MarshalBinaryWithContext(ctx)
+	if e != nil {
+		return nil, e
+	}
+
+	encBytes := ctx.Buffer.Bytes()
+	sTableBytes := ctx.Table.ToBytes()
+	merged := appendBytes(sTableBytes, encBytes)
+	return merged, nil
+}
+
+// MarshalBinaryWithContext serializes the internal properties of this KubeModelSet instance
+// into a byte array leveraging a predefined context.
+func (target *KubeModelSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	buff.WriteUInt8(KubeModelCodecVersion) // version
+
+	if target.Metadata == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][struct](Metadata) ---
+		buff.WriteInt(0) // [compatibility, unused]
+		errA := target.Metadata.MarshalBinaryWithContext(ctx)
+		if errA != nil {
+			return errA
+		}
+		// --- [end][write][struct](Metadata) ---
+
+	}
+	// --- [begin][write][struct](Window) ---
+	buff.WriteInt(0) // [compatibility, unused]
+	errB := target.Window.MarshalBinaryWithContext(ctx)
+	if errB != nil {
+		return errB
+	}
+	// --- [end][write][struct](Window) ---
+
+	if target.Cluster == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][struct](Cluster) ---
+		buff.WriteInt(0) // [compatibility, unused]
+		errC := target.Cluster.MarshalBinaryWithContext(ctx)
+		if errC != nil {
+			return errC
+		}
+		// --- [end][write][struct](Cluster) ---
+
+	}
+	if target.Namespaces == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][map](map[string]*Namespace) ---
+		buff.WriteInt(len(target.Namespaces)) // map length
+		for v, z := range target.Namespaces {
+			if ctx.IsStringTable() {
+				a := ctx.Table.AddOrGet(v)
+				buff.WriteInt(a) // write table index
+			} else {
+				buff.WriteString(v) // write string
+			}
+			if z == nil {
+				buff.WriteUInt8(uint8(0)) // write nil byte
+			} else {
+				buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+				// --- [begin][write][struct](Namespace) ---
+				buff.WriteInt(0) // [compatibility, unused]
+				errD := z.MarshalBinaryWithContext(ctx)
+				if errD != nil {
+					return errD
+				}
+				// --- [end][write][struct](Namespace) ---
+
+			}
+		}
+		// --- [end][write][map](map[string]*Namespace) ---
+
+	}
+	if target.ResourceQuotas == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][map](map[string]*ResourceQuota) ---
+		buff.WriteInt(len(target.ResourceQuotas)) // map length
+		for vv, zz := range target.ResourceQuotas {
+			if ctx.IsStringTable() {
+				b := ctx.Table.AddOrGet(vv)
+				buff.WriteInt(b) // write table index
+			} else {
+				buff.WriteString(vv) // write string
+			}
+			if zz == nil {
+				buff.WriteUInt8(uint8(0)) // write nil byte
+			} else {
+				buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+				// --- [begin][write][struct](ResourceQuota) ---
+				buff.WriteInt(0) // [compatibility, unused]
+				errE := zz.MarshalBinaryWithContext(ctx)
+				if errE != nil {
+					return errE
+				}
+				// --- [end][write][struct](ResourceQuota) ---
+
+			}
+		}
+		// --- [end][write][map](map[string]*ResourceQuota) ---
+
+	}
+	return nil
+}
+
+// UnmarshalBinary uses the data passed byte array to set all the internal properties of
+// the KubeModelSet type
+func (target *KubeModelSet) UnmarshalBinary(data []byte) error {
+	var table []string
+	buff := util.NewBufferFromBytes(data)
+
+	// string table header validation
+	if isBinaryTag(data, BinaryTagStringTable) {
+		buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
+		tl := buff.ReadInt()                      // table length
+		if tl > 0 {
+			table = make([]string, tl, tl)
+			for i := 0; i < tl; i++ {
+				table[i] = buff.ReadString()
+			}
+		}
+	}
+
+	ctx := &DecodingContext{
+		Buffer: buff,
+		Table:  table,
+	}
+
+	err := target.UnmarshalBinaryWithContext(ctx)
+	if err != nil {
+		return err
+	}
+
+	return nil
+}
+
+// UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
+// the KubeModelSet type
+func (target *KubeModelSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	version := buff.ReadUInt8()
+
+	if version > KubeModelCodecVersion {
+		return fmt.Errorf("Invalid Version Unmarshaling KubeModelSet. Expected %d or less, got %d", KubeModelCodecVersion, version)
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		if buff.ReadUInt8() == uint8(0) {
+			target.Metadata = nil
+		} else {
+			// --- [begin][read][struct](Metadata) ---
+			a := &Metadata{}
+			buff.ReadInt() // [compatibility, unused]
+			errA := a.UnmarshalBinaryWithContext(ctx)
+			if errA != nil {
+				return errA
+			}
+			target.Metadata = a
+			// --- [end][read][struct](Metadata) ---
+
+		}
+	} else {
+		target.Metadata = nil
+
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][struct](Window) ---
+		b := &Window{}
+		buff.ReadInt() // [compatibility, unused]
+		errB := b.UnmarshalBinaryWithContext(ctx)
+		if errB != nil {
+			return errB
+		}
+		target.Window = *b
+		// --- [end][read][struct](Window) ---
+
+	} else {
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		if buff.ReadUInt8() == uint8(0) {
+			target.Cluster = nil
+		} else {
+			// --- [begin][read][struct](Cluster) ---
+			c := &Cluster{}
+			buff.ReadInt() // [compatibility, unused]
+			errC := c.UnmarshalBinaryWithContext(ctx)
+			if errC != nil {
+				return errC
+			}
+			target.Cluster = c
+			// --- [end][read][struct](Cluster) ---
+
+		}
+	} else {
+		target.Cluster = nil
+
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		if buff.ReadUInt8() == uint8(0) {
+			target.Namespaces = nil
+		} else {
+			// --- [begin][read][map](map[string]*Namespace) ---
+			e := buff.ReadInt() // map len
+			d := make(map[string]*Namespace, e)
+			for i := 0; i < e; i++ {
+				var v string
+				var g string
+				if ctx.IsStringTable() {
+					h := buff.ReadInt() // read string index
+					g = ctx.Table[h]
+				} else {
+					g = buff.ReadString() // read string
+				}
+				f := g
+				v = f
+
+				var z *Namespace
+				if buff.ReadUInt8() == uint8(0) {
+					z = nil
+				} else {
+					// --- [begin][read][struct](Namespace) ---
+					k := &Namespace{}
+					buff.ReadInt() // [compatibility, unused]
+					errD := k.UnmarshalBinaryWithContext(ctx)
+					if errD != nil {
+						return errD
+					}
+					z = k
+					// --- [end][read][struct](Namespace) ---
+
+				}
+				d[v] = z
+			}
+			target.Namespaces = d
+			// --- [end][read][map](map[string]*Namespace) ---
+
+		}
+	} else {
+		target.Namespaces = nil
+
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		if buff.ReadUInt8() == uint8(0) {
+			target.ResourceQuotas = nil
+		} else {
+			// --- [begin][read][map](map[string]*ResourceQuota) ---
+			m := buff.ReadInt() // map len
+			l := make(map[string]*ResourceQuota, m)
+			for j := 0; j < m; j++ {
+				var vv string
+				var o string
+				if ctx.IsStringTable() {
+					p := buff.ReadInt() // read string index
+					o = ctx.Table[p]
+				} else {
+					o = buff.ReadString() // read string
+				}
+				n := o
+				vv = n
+
+				var zz *ResourceQuota
+				if buff.ReadUInt8() == uint8(0) {
+					zz = nil
+				} else {
+					// --- [begin][read][struct](ResourceQuota) ---
+					q := &ResourceQuota{}
+					buff.ReadInt() // [compatibility, unused]
+					errE := q.UnmarshalBinaryWithContext(ctx)
+					if errE != nil {
+						return errE
+					}
+					zz = q
+					// --- [end][read][struct](ResourceQuota) ---
+
+				}
+				l[vv] = zz
+			}
+			target.ResourceQuotas = l
+			// --- [end][read][map](map[string]*ResourceQuota) ---
+
+		}
+	} else {
+		target.ResourceQuotas = nil
+
+	}
+
+	return nil
+}
+
+//--------------------------------------------------------------------------
+//  Metadata
+//--------------------------------------------------------------------------
+
+// MarshalBinary serializes the internal properties of this Metadata instance
+// into a byte array
+func (target *Metadata) MarshalBinary() (data []byte, err error) {
+	ctx := &EncodingContext{
+		Buffer: util.NewBuffer(),
+		Table:  nil,
+	}
+
+	e := target.MarshalBinaryWithContext(ctx)
+	if e != nil {
+		return nil, e
+	}
+
+	encBytes := ctx.Buffer.Bytes()
+	return encBytes, nil
+}
+
+// MarshalBinaryWithContext serializes the internal properties of this Metadata instance
+// into a byte array leveraging a predefined context.
+func (target *Metadata) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	buff.WriteUInt8(KubeModelCodecVersion) // version
+
+	// --- [begin][write][reference](time.Time) ---
+	a, errA := target.CreatedAt.MarshalBinary()
+	if errA != nil {
+		return errA
+	}
+	buff.WriteInt(len(a))
+	buff.WriteBytes(a)
+	// --- [end][write][reference](time.Time) ---
+
+	// --- [begin][write][reference](time.Time) ---
+	b, errB := target.CompletedAt.MarshalBinary()
+	if errB != nil {
+		return errB
+	}
+	buff.WriteInt(len(b))
+	buff.WriteBytes(b)
+	// --- [end][write][reference](time.Time) ---
+
+	buff.WriteInt(target.ObjectCount) // write int
+	if target.Errors == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][slice]([]string) ---
+		buff.WriteInt(len(target.Errors)) // array length
+		for i := 0; i < len(target.Errors); i++ {
+			if ctx.IsStringTable() {
+				c := ctx.Table.AddOrGet(target.Errors[i])
+				buff.WriteInt(c) // write table index
+			} else {
+				buff.WriteString(target.Errors[i]) // write string
+			}
+		}
+		// --- [end][write][slice]([]string) ---
+
+	}
+	if target.Warnings == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][slice]([]string) ---
+		buff.WriteInt(len(target.Warnings)) // array length
+		for j := 0; j < len(target.Warnings); j++ {
+			if ctx.IsStringTable() {
+				d := ctx.Table.AddOrGet(target.Warnings[j])
+				buff.WriteInt(d) // write table index
+			} else {
+				buff.WriteString(target.Warnings[j]) // write string
+			}
+		}
+		// --- [end][write][slice]([]string) ---
+
+	}
+	return nil
+}
+
+// UnmarshalBinary uses the data passed byte array to set all the internal properties of
+// the Metadata type
+func (target *Metadata) UnmarshalBinary(data []byte) error {
+	var table []string
+	buff := util.NewBufferFromBytes(data)
+
+	// string table header validation
+	if isBinaryTag(data, BinaryTagStringTable) {
+		buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
+		tl := buff.ReadInt()                      // table length
+		if tl > 0 {
+			table = make([]string, tl, tl)
+			for i := 0; i < tl; i++ {
+				table[i] = buff.ReadString()
+			}
+		}
+	}
+
+	ctx := &DecodingContext{
+		Buffer: buff,
+		Table:  table,
+	}
+
+	err := target.UnmarshalBinaryWithContext(ctx)
+	if err != nil {
+		return err
+	}
+
+	return nil
+}
+
+// UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
+// the Metadata type
+func (target *Metadata) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	version := buff.ReadUInt8()
+
+	if version > KubeModelCodecVersion {
+		return fmt.Errorf("Invalid Version Unmarshaling Metadata. Expected %d or less, got %d", KubeModelCodecVersion, version)
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][reference](time.Time) ---
+		a := &time.Time{}
+		b := buff.ReadInt()    // byte array length
+		c := buff.ReadBytes(b) // byte array
+		errA := a.UnmarshalBinary(c)
+		if errA != nil {
+			return errA
+		}
+		target.CreatedAt = *a
+		// --- [end][read][reference](time.Time) ---
+
+	} else {
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][reference](time.Time) ---
+		d := &time.Time{}
+		e := buff.ReadInt()    // byte array length
+		f := buff.ReadBytes(e) // byte array
+		errB := d.UnmarshalBinary(f)
+		if errB != nil {
+			return errB
+		}
+		target.CompletedAt = *d
+		// --- [end][read][reference](time.Time) ---
+
+	} else {
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		g := buff.ReadInt() // read int
+		target.ObjectCount = g
+
+	} else {
+		target.ObjectCount = int(0) // default
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		if buff.ReadUInt8() == uint8(0) {
+			target.Errors = nil
+		} else {
+			// --- [begin][read][slice]([]string) ---
+			k := buff.ReadInt() // array len
+			h := make([]string, k)
+			for i := 0; i < k; i++ {
+				var l string
+				var n string
+				if ctx.IsStringTable() {
+					o := buff.ReadInt() // read string index
+					n = ctx.Table[o]
+				} else {
+					n = buff.ReadString() // read string
+				}
+				m := n
+				l = m
+
+				h[i] = l
+			}
+			target.Errors = h
+			// --- [end][read][slice]([]string) ---
+
+		}
+	} else {
+		target.Errors = nil
+
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		if buff.ReadUInt8() == uint8(0) {
+			target.Warnings = nil
+		} else {
+			// --- [begin][read][slice]([]string) ---
+			q := buff.ReadInt() // array len
+			p := make([]string, q)
+			for j := 0; j < q; j++ {
+				var r string
+				var t string
+				if ctx.IsStringTable() {
+					u := buff.ReadInt() // read string index
+					t = ctx.Table[u]
+				} else {
+					t = buff.ReadString() // read string
+				}
+				s := t
+				r = s
+
+				p[j] = r
+			}
+			target.Warnings = p
+			// --- [end][read][slice]([]string) ---
+
+		}
+	} else {
+		target.Warnings = nil
+
+	}
+
+	return nil
+}
+
+//--------------------------------------------------------------------------
+//  Namespace
+//--------------------------------------------------------------------------
+
+// MarshalBinary serializes the internal properties of this Namespace instance
+// into a byte array
+func (target *Namespace) MarshalBinary() (data []byte, err error) {
+	ctx := &EncodingContext{
+		Buffer: util.NewBuffer(),
+		Table:  nil,
+	}
+
+	e := target.MarshalBinaryWithContext(ctx)
+	if e != nil {
+		return nil, e
+	}
+
+	encBytes := ctx.Buffer.Bytes()
+	return encBytes, nil
+}
+
+// MarshalBinaryWithContext serializes the internal properties of this Namespace instance
+// into a byte array leveraging a predefined context.
+func (target *Namespace) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	buff.WriteUInt8(KubeModelCodecVersion) // version
+
+	if ctx.IsStringTable() {
+		a := ctx.Table.AddOrGet(target.UID)
+		buff.WriteInt(a) // write table index
+	} else {
+		buff.WriteString(target.UID) // write string
+	}
+	if ctx.IsStringTable() {
+		b := ctx.Table.AddOrGet(target.ClusterUID)
+		buff.WriteInt(b) // write table index
+	} else {
+		buff.WriteString(target.ClusterUID) // write string
+	}
+	if ctx.IsStringTable() {
+		c := ctx.Table.AddOrGet(target.Name)
+		buff.WriteInt(c) // write table index
+	} else {
+		buff.WriteString(target.Name) // write string
+	}
+	if target.Labels == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][map](map[string]string) ---
+		buff.WriteInt(len(target.Labels)) // map length
+		for v, z := range target.Labels {
+			if ctx.IsStringTable() {
+				d := ctx.Table.AddOrGet(v)
+				buff.WriteInt(d) // write table index
+			} else {
+				buff.WriteString(v) // write string
+			}
+			if ctx.IsStringTable() {
+				e := ctx.Table.AddOrGet(z)
+				buff.WriteInt(e) // write table index
+			} else {
+				buff.WriteString(z) // write string
+			}
+		}
+		// --- [end][write][map](map[string]string) ---
+
+	}
+	if target.Annotations == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][map](map[string]string) ---
+		buff.WriteInt(len(target.Annotations)) // map length
+		for vv, zz := range target.Annotations {
+			if ctx.IsStringTable() {
+				f := ctx.Table.AddOrGet(vv)
+				buff.WriteInt(f) // write table index
+			} else {
+				buff.WriteString(vv) // write string
+			}
+			if ctx.IsStringTable() {
+				g := ctx.Table.AddOrGet(zz)
+				buff.WriteInt(g) // write table index
+			} else {
+				buff.WriteString(zz) // write string
+			}
+		}
+		// --- [end][write][map](map[string]string) ---
+
+	}
+	// --- [begin][write][reference](time.Time) ---
+	h, errA := target.Start.MarshalBinary()
+	if errA != nil {
+		return errA
+	}
+	buff.WriteInt(len(h))
+	buff.WriteBytes(h)
+	// --- [end][write][reference](time.Time) ---
+
+	// --- [begin][write][reference](time.Time) ---
+	k, errB := target.End.MarshalBinary()
+	if errB != nil {
+		return errB
+	}
+	buff.WriteInt(len(k))
+	buff.WriteBytes(k)
+	// --- [end][write][reference](time.Time) ---
+
+	return nil
+}
+
+// UnmarshalBinary uses the data passed byte array to set all the internal properties of
+// the Namespace type
+func (target *Namespace) UnmarshalBinary(data []byte) error {
+	var table []string
+	buff := util.NewBufferFromBytes(data)
+
+	// string table header validation
+	if isBinaryTag(data, BinaryTagStringTable) {
+		buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
+		tl := buff.ReadInt()                      // table length
+		if tl > 0 {
+			table = make([]string, tl, tl)
+			for i := 0; i < tl; i++ {
+				table[i] = buff.ReadString()
+			}
+		}
+	}
+
+	ctx := &DecodingContext{
+		Buffer: buff,
+		Table:  table,
+	}
+
+	err := target.UnmarshalBinaryWithContext(ctx)
+	if err != nil {
+		return err
+	}
+
+	return nil
+}
+
+// UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
+// the Namespace type
+func (target *Namespace) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	version := buff.ReadUInt8()
+
+	if version > KubeModelCodecVersion {
+		return fmt.Errorf("Invalid Version Unmarshaling Namespace. Expected %d or less, got %d", KubeModelCodecVersion, version)
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		var b string
+		if ctx.IsStringTable() {
+			c := buff.ReadInt() // read string index
+			b = ctx.Table[c]
+		} else {
+			b = buff.ReadString() // read string
+		}
+		a := b
+		target.UID = a
+
+	} else {
+		target.UID = "" // default
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		var e string
+		if ctx.IsStringTable() {
+			f := buff.ReadInt() // read string index
+			e = ctx.Table[f]
+		} else {
+			e = buff.ReadString() // read string
+		}
+		d := e
+		target.ClusterUID = d
+
+	} else {
+		target.ClusterUID = "" // default
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		var h string
+		if ctx.IsStringTable() {
+			k := buff.ReadInt() // read string index
+			h = ctx.Table[k]
+		} else {
+			h = buff.ReadString() // read string
+		}
+		g := h
+		target.Name = g
+
+	} else {
+		target.Name = "" // default
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		if buff.ReadUInt8() == uint8(0) {
+			target.Labels = nil
+		} else {
+			// --- [begin][read][map](map[string]string) ---
+			m := buff.ReadInt() // map len
+			l := make(map[string]string, m)
+			for i := 0; i < m; i++ {
+				var v string
+				var o string
+				if ctx.IsStringTable() {
+					p := buff.ReadInt() // read string index
+					o = ctx.Table[p]
+				} else {
+					o = buff.ReadString() // read string
+				}
+				n := o
+				v = n
+
+				var z string
+				var r string
+				if ctx.IsStringTable() {
+					s := buff.ReadInt() // read string index
+					r = ctx.Table[s]
+				} else {
+					r = buff.ReadString() // read string
+				}
+				q := r
+				z = q
+
+				l[v] = z
+			}
+			target.Labels = l
+			// --- [end][read][map](map[string]string) ---
+
+		}
+	} else {
+		target.Labels = nil
+
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		if buff.ReadUInt8() == uint8(0) {
+			target.Annotations = nil
+		} else {
+			// --- [begin][read][map](map[string]string) ---
+			u := buff.ReadInt() // map len
+			t := make(map[string]string, u)
+			for j := 0; j < u; j++ {
+				var vv string
+				var x string
+				if ctx.IsStringTable() {
+					y := buff.ReadInt() // read string index
+					x = ctx.Table[y]
+				} else {
+					x = buff.ReadString() // read string
+				}
+				w := x
+				vv = w
+
+				var zz string
+				var bb string
+				if ctx.IsStringTable() {
+					cc := buff.ReadInt() // read string index
+					bb = ctx.Table[cc]
+				} else {
+					bb = buff.ReadString() // read string
+				}
+				aa := bb
+				zz = aa
+
+				t[vv] = zz
+			}
+			target.Annotations = t
+			// --- [end][read][map](map[string]string) ---
+
+		}
+	} else {
+		target.Annotations = nil
+
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][reference](time.Time) ---
+		dd := &time.Time{}
+		ee := buff.ReadInt()     // byte array length
+		ff := buff.ReadBytes(ee) // byte array
+		errA := dd.UnmarshalBinary(ff)
+		if errA != nil {
+			return errA
+		}
+		target.Start = *dd
+		// --- [end][read][reference](time.Time) ---
+
+	} else {
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][reference](time.Time) ---
+		gg := &time.Time{}
+		hh := buff.ReadInt()     // byte array length
+		kk := buff.ReadBytes(hh) // byte array
+		errB := gg.UnmarshalBinary(kk)
+		if errB != nil {
+			return errB
+		}
+		target.End = *gg
+		// --- [end][read][reference](time.Time) ---
+
+	} else {
+	}
+
+	return nil
+}
+
+//--------------------------------------------------------------------------
+//  ResourceQuantity
+//--------------------------------------------------------------------------
+
+// MarshalBinary serializes the internal properties of this ResourceQuantity instance
+// into a byte array
+func (target *ResourceQuantity) MarshalBinary() (data []byte, err error) {
+	ctx := &EncodingContext{
+		Buffer: util.NewBuffer(),
+		Table:  nil,
+	}
+
+	e := target.MarshalBinaryWithContext(ctx)
+	if e != nil {
+		return nil, e
+	}
+
+	encBytes := ctx.Buffer.Bytes()
+	return encBytes, nil
+}
+
+// MarshalBinaryWithContext serializes the internal properties of this ResourceQuantity instance
+// into a byte array leveraging a predefined context.
+func (target *ResourceQuantity) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	buff.WriteUInt8(KubeModelCodecVersion) // version
+
+	// --- [begin][write][alias](Resource) ---
+	if ctx.IsStringTable() {
+		a := ctx.Table.AddOrGet(string(target.Resource))
+		buff.WriteInt(a) // write table index
+	} else {
+		buff.WriteString(string(target.Resource)) // write string
+	}
+	// --- [end][write][alias](Resource) ---
+
+	// --- [begin][write][alias](Unit) ---
+	if ctx.IsStringTable() {
+		b := ctx.Table.AddOrGet(string(target.Unit))
+		buff.WriteInt(b) // write table index
+	} else {
+		buff.WriteString(string(target.Unit)) // write string
+	}
+	// --- [end][write][alias](Unit) ---
+
+	// --- [begin][write][alias](Stats) ---
+	if map[StatType]float64(target.Values) == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][map](map[StatType]float64) ---
+		buff.WriteInt(len(map[StatType]float64(target.Values))) // map length
+		for v, z := range map[StatType]float64(target.Values) {
+			// --- [begin][write][alias](StatType) ---
+			if ctx.IsStringTable() {
+				c := ctx.Table.AddOrGet(string(v))
+				buff.WriteInt(c) // write table index
+			} else {
+				buff.WriteString(string(v)) // write string
+			}
+			// --- [end][write][alias](StatType) ---
+
+			buff.WriteFloat64(z) // write float64
+		}
+		// --- [end][write][map](map[StatType]float64) ---
+
+	}
+	// --- [end][write][alias](Stats) ---
+
+	return nil
+}
+
+// UnmarshalBinary uses the data passed byte array to set all the internal properties of
+// the ResourceQuantity type
+func (target *ResourceQuantity) UnmarshalBinary(data []byte) error {
+	var table []string
+	buff := util.NewBufferFromBytes(data)
+
+	// string table header validation
+	if isBinaryTag(data, BinaryTagStringTable) {
+		buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
+		tl := buff.ReadInt()                      // table length
+		if tl > 0 {
+			table = make([]string, tl, tl)
+			for i := 0; i < tl; i++ {
+				table[i] = buff.ReadString()
+			}
+		}
+	}
+
+	ctx := &DecodingContext{
+		Buffer: buff,
+		Table:  table,
+	}
+
+	err := target.UnmarshalBinaryWithContext(ctx)
+	if err != nil {
+		return err
+	}
+
+	return nil
+}
+
+// UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
+// the ResourceQuantity type
+func (target *ResourceQuantity) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	version := buff.ReadUInt8()
+
+	if version > KubeModelCodecVersion {
+		return fmt.Errorf("Invalid Version Unmarshaling ResourceQuantity. Expected %d or less, got %d", KubeModelCodecVersion, version)
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][alias](Resource) ---
+		var a string
+		var c string
+		if ctx.IsStringTable() {
+			d := buff.ReadInt() // read string index
+			c = ctx.Table[d]
+		} else {
+			c = buff.ReadString() // read string
+		}
+		b := c
+		a = b
+
+		target.Resource = Resource(a)
+		// --- [end][read][alias](Resource) ---
+
+	} else {
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][alias](Unit) ---
+		var e string
+		var g string
+		if ctx.IsStringTable() {
+			h := buff.ReadInt() // read string index
+			g = ctx.Table[h]
+		} else {
+			g = buff.ReadString() // read string
+		}
+		f := g
+		e = f
+
+		target.Unit = Unit(e)
+		// --- [end][read][alias](Unit) ---
+
+	} else {
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][alias](Stats) ---
+		var k map[StatType]float64
+		if buff.ReadUInt8() == uint8(0) {
+			k = nil
+		} else {
+			// --- [begin][read][map](map[StatType]float64) ---
+			m := buff.ReadInt() // map len
+			l := make(map[StatType]float64, m)
+			for i := 0; i < m; i++ {
+				// --- [begin][read][alias](StatType) ---
+				var n string
+				var p string
+				if ctx.IsStringTable() {
+					q := buff.ReadInt() // read string index
+					p = ctx.Table[q]
+				} else {
+					p = buff.ReadString() // read string
+				}
+				o := p
+				n = o
+
+				v := StatType(n)
+				// --- [end][read][alias](StatType) ---
+
+				var z float64
+				r := buff.ReadFloat64() // read float64
+				z = r
+
+				l[v] = z
+			}
+			k = l
+			// --- [end][read][map](map[StatType]float64) ---
+
+		}
+		target.Values = Stats(k)
+		// --- [end][read][alias](Stats) ---
+
+	} else {
+	}
+
+	return nil
+}
+
+//--------------------------------------------------------------------------
+//  ResourceQuota
+//--------------------------------------------------------------------------
+
+// MarshalBinary serializes the internal properties of this ResourceQuota instance
+// into a byte array
+func (target *ResourceQuota) MarshalBinary() (data []byte, err error) {
+	ctx := &EncodingContext{
+		Buffer: util.NewBuffer(),
+		Table:  nil,
+	}
+
+	e := target.MarshalBinaryWithContext(ctx)
+	if e != nil {
+		return nil, e
+	}
+
+	encBytes := ctx.Buffer.Bytes()
+	return encBytes, nil
+}
+
+// MarshalBinaryWithContext serializes the internal properties of this ResourceQuota instance
+// into a byte array leveraging a predefined context.
+func (target *ResourceQuota) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	buff.WriteUInt8(KubeModelCodecVersion) // version
+
+	if ctx.IsStringTable() {
+		a := ctx.Table.AddOrGet(target.UID)
+		buff.WriteInt(a) // write table index
+	} else {
+		buff.WriteString(target.UID) // write string
+	}
+	if ctx.IsStringTable() {
+		b := ctx.Table.AddOrGet(target.NamespaceUID)
+		buff.WriteInt(b) // write table index
+	} else {
+		buff.WriteString(target.NamespaceUID) // write string
+	}
+	if ctx.IsStringTable() {
+		c := ctx.Table.AddOrGet(target.Name)
+		buff.WriteInt(c) // write table index
+	} else {
+		buff.WriteString(target.Name) // write string
+	}
+	if target.Spec == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][struct](ResourceQuotaSpec) ---
+		buff.WriteInt(0) // [compatibility, unused]
+		errA := target.Spec.MarshalBinaryWithContext(ctx)
+		if errA != nil {
+			return errA
+		}
+		// --- [end][write][struct](ResourceQuotaSpec) ---
+
+	}
+	if target.Status == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][struct](ResourceQuotaStatus) ---
+		buff.WriteInt(0) // [compatibility, unused]
+		errB := target.Status.MarshalBinaryWithContext(ctx)
+		if errB != nil {
+			return errB
+		}
+		// --- [end][write][struct](ResourceQuotaStatus) ---
+
+	}
+	return nil
+}
+
+// UnmarshalBinary uses the data passed byte array to set all the internal properties of
+// the ResourceQuota type
+func (target *ResourceQuota) UnmarshalBinary(data []byte) error {
+	var table []string
+	buff := util.NewBufferFromBytes(data)
+
+	// string table header validation
+	if isBinaryTag(data, BinaryTagStringTable) {
+		buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
+		tl := buff.ReadInt()                      // table length
+		if tl > 0 {
+			table = make([]string, tl, tl)
+			for i := 0; i < tl; i++ {
+				table[i] = buff.ReadString()
+			}
+		}
+	}
+
+	ctx := &DecodingContext{
+		Buffer: buff,
+		Table:  table,
+	}
+
+	err := target.UnmarshalBinaryWithContext(ctx)
+	if err != nil {
+		return err
+	}
+
+	return nil
+}
+
+// UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
+// the ResourceQuota type
+func (target *ResourceQuota) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	version := buff.ReadUInt8()
+
+	if version > KubeModelCodecVersion {
+		return fmt.Errorf("Invalid Version Unmarshaling ResourceQuota. Expected %d or less, got %d", KubeModelCodecVersion, version)
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		var b string
+		if ctx.IsStringTable() {
+			c := buff.ReadInt() // read string index
+			b = ctx.Table[c]
+		} else {
+			b = buff.ReadString() // read string
+		}
+		a := b
+		target.UID = a
+
+	} else {
+		target.UID = "" // default
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		var e string
+		if ctx.IsStringTable() {
+			f := buff.ReadInt() // read string index
+			e = ctx.Table[f]
+		} else {
+			e = buff.ReadString() // read string
+		}
+		d := e
+		target.NamespaceUID = d
+
+	} else {
+		target.NamespaceUID = "" // default
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		var h string
+		if ctx.IsStringTable() {
+			k := buff.ReadInt() // read string index
+			h = ctx.Table[k]
+		} else {
+			h = buff.ReadString() // read string
+		}
+		g := h
+		target.Name = g
+
+	} else {
+		target.Name = "" // default
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		if buff.ReadUInt8() == uint8(0) {
+			target.Spec = nil
+		} else {
+			// --- [begin][read][struct](ResourceQuotaSpec) ---
+			l := &ResourceQuotaSpec{}
+			buff.ReadInt() // [compatibility, unused]
+			errA := l.UnmarshalBinaryWithContext(ctx)
+			if errA != nil {
+				return errA
+			}
+			target.Spec = l
+			// --- [end][read][struct](ResourceQuotaSpec) ---
+
+		}
+	} else {
+		target.Spec = nil
+
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		if buff.ReadUInt8() == uint8(0) {
+			target.Status = nil
+		} else {
+			// --- [begin][read][struct](ResourceQuotaStatus) ---
+			m := &ResourceQuotaStatus{}
+			buff.ReadInt() // [compatibility, unused]
+			errB := m.UnmarshalBinaryWithContext(ctx)
+			if errB != nil {
+				return errB
+			}
+			target.Status = m
+			// --- [end][read][struct](ResourceQuotaStatus) ---
+
+		}
+	} else {
+		target.Status = nil
+
+	}
+
+	return nil
+}
+
+//--------------------------------------------------------------------------
+//  ResourceQuotaSpec
+//--------------------------------------------------------------------------
+
+// MarshalBinary serializes the internal properties of this ResourceQuotaSpec instance
+// into a byte array
+func (target *ResourceQuotaSpec) MarshalBinary() (data []byte, err error) {
+	ctx := &EncodingContext{
+		Buffer: util.NewBuffer(),
+		Table:  nil,
+	}
+
+	e := target.MarshalBinaryWithContext(ctx)
+	if e != nil {
+		return nil, e
+	}
+
+	encBytes := ctx.Buffer.Bytes()
+	return encBytes, nil
+}
+
+// MarshalBinaryWithContext serializes the internal properties of this ResourceQuotaSpec instance
+// into a byte array leveraging a predefined context.
+func (target *ResourceQuotaSpec) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	buff.WriteUInt8(KubeModelCodecVersion) // version
+
+	if target.Hard == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][struct](ResourceQuotaSpecHard) ---
+		buff.WriteInt(0) // [compatibility, unused]
+		errA := target.Hard.MarshalBinaryWithContext(ctx)
+		if errA != nil {
+			return errA
+		}
+		// --- [end][write][struct](ResourceQuotaSpecHard) ---
+
+	}
+	return nil
+}
+
+// UnmarshalBinary uses the data passed byte array to set all the internal properties of
+// the ResourceQuotaSpec type
+func (target *ResourceQuotaSpec) UnmarshalBinary(data []byte) error {
+	var table []string
+	buff := util.NewBufferFromBytes(data)
+
+	// string table header validation
+	if isBinaryTag(data, BinaryTagStringTable) {
+		buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
+		tl := buff.ReadInt()                      // table length
+		if tl > 0 {
+			table = make([]string, tl, tl)
+			for i := 0; i < tl; i++ {
+				table[i] = buff.ReadString()
+			}
+		}
+	}
+
+	ctx := &DecodingContext{
+		Buffer: buff,
+		Table:  table,
+	}
+
+	err := target.UnmarshalBinaryWithContext(ctx)
+	if err != nil {
+		return err
+	}
+
+	return nil
+}
+
+// UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
+// the ResourceQuotaSpec type
+func (target *ResourceQuotaSpec) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	version := buff.ReadUInt8()
+
+	if version > KubeModelCodecVersion {
+		return fmt.Errorf("Invalid Version Unmarshaling ResourceQuotaSpec. Expected %d or less, got %d", KubeModelCodecVersion, version)
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		if buff.ReadUInt8() == uint8(0) {
+			target.Hard = nil
+		} else {
+			// --- [begin][read][struct](ResourceQuotaSpecHard) ---
+			a := &ResourceQuotaSpecHard{}
+			buff.ReadInt() // [compatibility, unused]
+			errA := a.UnmarshalBinaryWithContext(ctx)
+			if errA != nil {
+				return errA
+			}
+			target.Hard = a
+			// --- [end][read][struct](ResourceQuotaSpecHard) ---
+
+		}
+	} else {
+		target.Hard = nil
+
+	}
+
+	return nil
+}
+
+//--------------------------------------------------------------------------
+//  ResourceQuotaSpecHard
+//--------------------------------------------------------------------------
+
+// MarshalBinary serializes the internal properties of this ResourceQuotaSpecHard instance
+// into a byte array
+func (target *ResourceQuotaSpecHard) MarshalBinary() (data []byte, err error) {
+	ctx := &EncodingContext{
+		Buffer: util.NewBuffer(),
+		Table:  nil,
+	}
+
+	e := target.MarshalBinaryWithContext(ctx)
+	if e != nil {
+		return nil, e
+	}
+
+	encBytes := ctx.Buffer.Bytes()
+	return encBytes, nil
+}
+
+// MarshalBinaryWithContext serializes the internal properties of this ResourceQuotaSpecHard instance
+// into a byte array leveraging a predefined context.
+func (target *ResourceQuotaSpecHard) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	buff.WriteUInt8(KubeModelCodecVersion) // version
+
+	// --- [begin][write][alias](ResourceQuantities) ---
+	if map[Resource]ResourceQuantity(target.Requests) == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][map](map[Resource]ResourceQuantity) ---
+		buff.WriteInt(len(map[Resource]ResourceQuantity(target.Requests))) // map length
+		for v, z := range map[Resource]ResourceQuantity(target.Requests) {
+			// --- [begin][write][alias](Resource) ---
+			if ctx.IsStringTable() {
+				a := ctx.Table.AddOrGet(string(v))
+				buff.WriteInt(a) // write table index
+			} else {
+				buff.WriteString(string(v)) // write string
+			}
+			// --- [end][write][alias](Resource) ---
+
+			// --- [begin][write][struct](ResourceQuantity) ---
+			buff.WriteInt(0) // [compatibility, unused]
+			errA := z.MarshalBinaryWithContext(ctx)
+			if errA != nil {
+				return errA
+			}
+			// --- [end][write][struct](ResourceQuantity) ---
+
+		}
+		// --- [end][write][map](map[Resource]ResourceQuantity) ---
+
+	}
+	// --- [end][write][alias](ResourceQuantities) ---
+
+	// --- [begin][write][alias](ResourceQuantities) ---
+	if map[Resource]ResourceQuantity(target.Limits) == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][map](map[Resource]ResourceQuantity) ---
+		buff.WriteInt(len(map[Resource]ResourceQuantity(target.Limits))) // map length
+		for vv, zz := range map[Resource]ResourceQuantity(target.Limits) {
+			// --- [begin][write][alias](Resource) ---
+			if ctx.IsStringTable() {
+				b := ctx.Table.AddOrGet(string(vv))
+				buff.WriteInt(b) // write table index
+			} else {
+				buff.WriteString(string(vv)) // write string
+			}
+			// --- [end][write][alias](Resource) ---
+
+			// --- [begin][write][struct](ResourceQuantity) ---
+			buff.WriteInt(0) // [compatibility, unused]
+			errB := zz.MarshalBinaryWithContext(ctx)
+			if errB != nil {
+				return errB
+			}
+			// --- [end][write][struct](ResourceQuantity) ---
+
+		}
+		// --- [end][write][map](map[Resource]ResourceQuantity) ---
+
+	}
+	// --- [end][write][alias](ResourceQuantities) ---
+
+	return nil
+}
+
+// UnmarshalBinary uses the data passed byte array to set all the internal properties of
+// the ResourceQuotaSpecHard type
+func (target *ResourceQuotaSpecHard) UnmarshalBinary(data []byte) error {
+	var table []string
+	buff := util.NewBufferFromBytes(data)
+
+	// string table header validation
+	if isBinaryTag(data, BinaryTagStringTable) {
+		buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
+		tl := buff.ReadInt()                      // table length
+		if tl > 0 {
+			table = make([]string, tl, tl)
+			for i := 0; i < tl; i++ {
+				table[i] = buff.ReadString()
+			}
+		}
+	}
+
+	ctx := &DecodingContext{
+		Buffer: buff,
+		Table:  table,
+	}
+
+	err := target.UnmarshalBinaryWithContext(ctx)
+	if err != nil {
+		return err
+	}
+
+	return nil
+}
+
+// UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
+// the ResourceQuotaSpecHard type
+func (target *ResourceQuotaSpecHard) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	version := buff.ReadUInt8()
+
+	if version > KubeModelCodecVersion {
+		return fmt.Errorf("Invalid Version Unmarshaling ResourceQuotaSpecHard. Expected %d or less, got %d", KubeModelCodecVersion, version)
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][alias](ResourceQuantities) ---
+		var a map[Resource]ResourceQuantity
+		if buff.ReadUInt8() == uint8(0) {
+			a = nil
+		} else {
+			// --- [begin][read][map](map[Resource]ResourceQuantity) ---
+			c := buff.ReadInt() // map len
+			b := make(map[Resource]ResourceQuantity, c)
+			for i := 0; i < c; i++ {
+				// --- [begin][read][alias](Resource) ---
+				var d string
+				var f string
+				if ctx.IsStringTable() {
+					g := buff.ReadInt() // read string index
+					f = ctx.Table[g]
+				} else {
+					f = buff.ReadString() // read string
+				}
+				e := f
+				d = e
+
+				v := Resource(d)
+				// --- [end][read][alias](Resource) ---
+
+				// --- [begin][read][struct](ResourceQuantity) ---
+				h := &ResourceQuantity{}
+				buff.ReadInt() // [compatibility, unused]
+				errA := h.UnmarshalBinaryWithContext(ctx)
+				if errA != nil {
+					return errA
+				}
+				z := *h
+				// --- [end][read][struct](ResourceQuantity) ---
+
+				b[v] = z
+			}
+			a = b
+			// --- [end][read][map](map[Resource]ResourceQuantity) ---
+
+		}
+		target.Requests = ResourceQuantities(a)
+		// --- [end][read][alias](ResourceQuantities) ---
+
+	} else {
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][alias](ResourceQuantities) ---
+		var k map[Resource]ResourceQuantity
+		if buff.ReadUInt8() == uint8(0) {
+			k = nil
+		} else {
+			// --- [begin][read][map](map[Resource]ResourceQuantity) ---
+			m := buff.ReadInt() // map len
+			l := make(map[Resource]ResourceQuantity, m)
+			for j := 0; j < m; j++ {
+				// --- [begin][read][alias](Resource) ---
+				var n string
+				var p string
+				if ctx.IsStringTable() {
+					q := buff.ReadInt() // read string index
+					p = ctx.Table[q]
+				} else {
+					p = buff.ReadString() // read string
+				}
+				o := p
+				n = o
+
+				vv := Resource(n)
+				// --- [end][read][alias](Resource) ---
+
+				// --- [begin][read][struct](ResourceQuantity) ---
+				r := &ResourceQuantity{}
+				buff.ReadInt() // [compatibility, unused]
+				errB := r.UnmarshalBinaryWithContext(ctx)
+				if errB != nil {
+					return errB
+				}
+				zz := *r
+				// --- [end][read][struct](ResourceQuantity) ---
+
+				l[vv] = zz
+			}
+			k = l
+			// --- [end][read][map](map[Resource]ResourceQuantity) ---
+
+		}
+		target.Limits = ResourceQuantities(k)
+		// --- [end][read][alias](ResourceQuantities) ---
+
+	} else {
+	}
+
+	return nil
+}
+
+//--------------------------------------------------------------------------
+//  ResourceQuotaStatus
+//--------------------------------------------------------------------------
+
+// MarshalBinary serializes the internal properties of this ResourceQuotaStatus instance
+// into a byte array
+func (target *ResourceQuotaStatus) MarshalBinary() (data []byte, err error) {
+	ctx := &EncodingContext{
+		Buffer: util.NewBuffer(),
+		Table:  nil,
+	}
+
+	e := target.MarshalBinaryWithContext(ctx)
+	if e != nil {
+		return nil, e
+	}
+
+	encBytes := ctx.Buffer.Bytes()
+	return encBytes, nil
+}
+
+// MarshalBinaryWithContext serializes the internal properties of this ResourceQuotaStatus instance
+// into a byte array leveraging a predefined context.
+func (target *ResourceQuotaStatus) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	buff.WriteUInt8(KubeModelCodecVersion) // version
+
+	if target.Used == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][struct](ResourceQuotaStatusUsed) ---
+		buff.WriteInt(0) // [compatibility, unused]
+		errA := target.Used.MarshalBinaryWithContext(ctx)
+		if errA != nil {
+			return errA
+		}
+		// --- [end][write][struct](ResourceQuotaStatusUsed) ---
+
+	}
+	return nil
+}
+
+// UnmarshalBinary uses the data passed byte array to set all the internal properties of
+// the ResourceQuotaStatus type
+func (target *ResourceQuotaStatus) UnmarshalBinary(data []byte) error {
+	var table []string
+	buff := util.NewBufferFromBytes(data)
+
+	// string table header validation
+	if isBinaryTag(data, BinaryTagStringTable) {
+		buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
+		tl := buff.ReadInt()                      // table length
+		if tl > 0 {
+			table = make([]string, tl, tl)
+			for i := 0; i < tl; i++ {
+				table[i] = buff.ReadString()
+			}
+		}
+	}
+
+	ctx := &DecodingContext{
+		Buffer: buff,
+		Table:  table,
+	}
+
+	err := target.UnmarshalBinaryWithContext(ctx)
+	if err != nil {
+		return err
+	}
+
+	return nil
+}
+
+// UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
+// the ResourceQuotaStatus type
+func (target *ResourceQuotaStatus) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	version := buff.ReadUInt8()
+
+	if version > KubeModelCodecVersion {
+		return fmt.Errorf("Invalid Version Unmarshaling ResourceQuotaStatus. Expected %d or less, got %d", KubeModelCodecVersion, version)
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		if buff.ReadUInt8() == uint8(0) {
+			target.Used = nil
+		} else {
+			// --- [begin][read][struct](ResourceQuotaStatusUsed) ---
+			a := &ResourceQuotaStatusUsed{}
+			buff.ReadInt() // [compatibility, unused]
+			errA := a.UnmarshalBinaryWithContext(ctx)
+			if errA != nil {
+				return errA
+			}
+			target.Used = a
+			// --- [end][read][struct](ResourceQuotaStatusUsed) ---
+
+		}
+	} else {
+		target.Used = nil
+
+	}
+
+	return nil
+}
+
+//--------------------------------------------------------------------------
+//  ResourceQuotaStatusUsed
+//--------------------------------------------------------------------------
+
+// MarshalBinary serializes the internal properties of this ResourceQuotaStatusUsed instance
+// into a byte array
+func (target *ResourceQuotaStatusUsed) MarshalBinary() (data []byte, err error) {
+	ctx := &EncodingContext{
+		Buffer: util.NewBuffer(),
+		Table:  nil,
+	}
+
+	e := target.MarshalBinaryWithContext(ctx)
+	if e != nil {
+		return nil, e
+	}
+
+	encBytes := ctx.Buffer.Bytes()
+	return encBytes, nil
+}
+
+// MarshalBinaryWithContext serializes the internal properties of this ResourceQuotaStatusUsed instance
+// into a byte array leveraging a predefined context.
+func (target *ResourceQuotaStatusUsed) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	buff.WriteUInt8(KubeModelCodecVersion) // version
+
+	// --- [begin][write][alias](ResourceQuantities) ---
+	if map[Resource]ResourceQuantity(target.Requests) == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][map](map[Resource]ResourceQuantity) ---
+		buff.WriteInt(len(map[Resource]ResourceQuantity(target.Requests))) // map length
+		for v, z := range map[Resource]ResourceQuantity(target.Requests) {
+			// --- [begin][write][alias](Resource) ---
+			if ctx.IsStringTable() {
+				a := ctx.Table.AddOrGet(string(v))
+				buff.WriteInt(a) // write table index
+			} else {
+				buff.WriteString(string(v)) // write string
+			}
+			// --- [end][write][alias](Resource) ---
+
+			// --- [begin][write][struct](ResourceQuantity) ---
+			buff.WriteInt(0) // [compatibility, unused]
+			errA := z.MarshalBinaryWithContext(ctx)
+			if errA != nil {
+				return errA
+			}
+			// --- [end][write][struct](ResourceQuantity) ---
+
+		}
+		// --- [end][write][map](map[Resource]ResourceQuantity) ---
+
+	}
+	// --- [end][write][alias](ResourceQuantities) ---
+
+	// --- [begin][write][alias](ResourceQuantities) ---
+	if map[Resource]ResourceQuantity(target.Limits) == nil {
+		buff.WriteUInt8(uint8(0)) // write nil byte
+	} else {
+		buff.WriteUInt8(uint8(1)) // write non-nil byte
+
+		// --- [begin][write][map](map[Resource]ResourceQuantity) ---
+		buff.WriteInt(len(map[Resource]ResourceQuantity(target.Limits))) // map length
+		for vv, zz := range map[Resource]ResourceQuantity(target.Limits) {
+			// --- [begin][write][alias](Resource) ---
+			if ctx.IsStringTable() {
+				b := ctx.Table.AddOrGet(string(vv))
+				buff.WriteInt(b) // write table index
+			} else {
+				buff.WriteString(string(vv)) // write string
+			}
+			// --- [end][write][alias](Resource) ---
+
+			// --- [begin][write][struct](ResourceQuantity) ---
+			buff.WriteInt(0) // [compatibility, unused]
+			errB := zz.MarshalBinaryWithContext(ctx)
+			if errB != nil {
+				return errB
+			}
+			// --- [end][write][struct](ResourceQuantity) ---
+
+		}
+		// --- [end][write][map](map[Resource]ResourceQuantity) ---
+
+	}
+	// --- [end][write][alias](ResourceQuantities) ---
+
+	return nil
+}
+
+// UnmarshalBinary uses the data passed byte array to set all the internal properties of
+// the ResourceQuotaStatusUsed type
+func (target *ResourceQuotaStatusUsed) UnmarshalBinary(data []byte) error {
+	var table []string
+	buff := util.NewBufferFromBytes(data)
+
+	// string table header validation
+	if isBinaryTag(data, BinaryTagStringTable) {
+		buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
+		tl := buff.ReadInt()                      // table length
+		if tl > 0 {
+			table = make([]string, tl, tl)
+			for i := 0; i < tl; i++ {
+				table[i] = buff.ReadString()
+			}
+		}
+	}
+
+	ctx := &DecodingContext{
+		Buffer: buff,
+		Table:  table,
+	}
+
+	err := target.UnmarshalBinaryWithContext(ctx)
+	if err != nil {
+		return err
+	}
+
+	return nil
+}
+
+// UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
+// the ResourceQuotaStatusUsed type
+func (target *ResourceQuotaStatusUsed) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	version := buff.ReadUInt8()
+
+	if version > KubeModelCodecVersion {
+		return fmt.Errorf("Invalid Version Unmarshaling ResourceQuotaStatusUsed. Expected %d or less, got %d", KubeModelCodecVersion, version)
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][alias](ResourceQuantities) ---
+		var a map[Resource]ResourceQuantity
+		if buff.ReadUInt8() == uint8(0) {
+			a = nil
+		} else {
+			// --- [begin][read][map](map[Resource]ResourceQuantity) ---
+			c := buff.ReadInt() // map len
+			b := make(map[Resource]ResourceQuantity, c)
+			for i := 0; i < c; i++ {
+				// --- [begin][read][alias](Resource) ---
+				var d string
+				var f string
+				if ctx.IsStringTable() {
+					g := buff.ReadInt() // read string index
+					f = ctx.Table[g]
+				} else {
+					f = buff.ReadString() // read string
+				}
+				e := f
+				d = e
+
+				v := Resource(d)
+				// --- [end][read][alias](Resource) ---
+
+				// --- [begin][read][struct](ResourceQuantity) ---
+				h := &ResourceQuantity{}
+				buff.ReadInt() // [compatibility, unused]
+				errA := h.UnmarshalBinaryWithContext(ctx)
+				if errA != nil {
+					return errA
+				}
+				z := *h
+				// --- [end][read][struct](ResourceQuantity) ---
+
+				b[v] = z
+			}
+			a = b
+			// --- [end][read][map](map[Resource]ResourceQuantity) ---
+
+		}
+		target.Requests = ResourceQuantities(a)
+		// --- [end][read][alias](ResourceQuantities) ---
+
+	} else {
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][alias](ResourceQuantities) ---
+		var k map[Resource]ResourceQuantity
+		if buff.ReadUInt8() == uint8(0) {
+			k = nil
+		} else {
+			// --- [begin][read][map](map[Resource]ResourceQuantity) ---
+			m := buff.ReadInt() // map len
+			l := make(map[Resource]ResourceQuantity, m)
+			for j := 0; j < m; j++ {
+				// --- [begin][read][alias](Resource) ---
+				var n string
+				var p string
+				if ctx.IsStringTable() {
+					q := buff.ReadInt() // read string index
+					p = ctx.Table[q]
+				} else {
+					p = buff.ReadString() // read string
+				}
+				o := p
+				n = o
+
+				vv := Resource(n)
+				// --- [end][read][alias](Resource) ---
+
+				// --- [begin][read][struct](ResourceQuantity) ---
+				r := &ResourceQuantity{}
+				buff.ReadInt() // [compatibility, unused]
+				errB := r.UnmarshalBinaryWithContext(ctx)
+				if errB != nil {
+					return errB
+				}
+				zz := *r
+				// --- [end][read][struct](ResourceQuantity) ---
+
+				l[vv] = zz
+			}
+			k = l
+			// --- [end][read][map](map[Resource]ResourceQuantity) ---
+
+		}
+		target.Limits = ResourceQuantities(k)
+		// --- [end][read][alias](ResourceQuantities) ---
+
+	} else {
+	}
+
+	return nil
+}
+
+//--------------------------------------------------------------------------
+//  Window
+//--------------------------------------------------------------------------
+
+// MarshalBinary serializes the internal properties of this Window instance
+// into a byte array
+func (target *Window) MarshalBinary() (data []byte, err error) {
+	ctx := &EncodingContext{
+		Buffer: util.NewBuffer(),
+		Table:  nil,
+	}
+
+	e := target.MarshalBinaryWithContext(ctx)
+	if e != nil {
+		return nil, e
+	}
+
+	encBytes := ctx.Buffer.Bytes()
+	return encBytes, nil
+}
+
+// MarshalBinaryWithContext serializes the internal properties of this Window instance
+// into a byte array leveraging a predefined context.
+func (target *Window) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	buff.WriteUInt8(KubeModelCodecVersion) // version
+
+	// --- [begin][write][reference](time.Time) ---
+	a, errA := target.Start.MarshalBinary()
+	if errA != nil {
+		return errA
+	}
+	buff.WriteInt(len(a))
+	buff.WriteBytes(a)
+	// --- [end][write][reference](time.Time) ---
+
+	// --- [begin][write][reference](time.Time) ---
+	b, errB := target.End.MarshalBinary()
+	if errB != nil {
+		return errB
+	}
+	buff.WriteInt(len(b))
+	buff.WriteBytes(b)
+	// --- [end][write][reference](time.Time) ---
+
+	return nil
+}
+
+// UnmarshalBinary uses the data passed byte array to set all the internal properties of
+// the Window type
+func (target *Window) UnmarshalBinary(data []byte) error {
+	var table []string
+	buff := util.NewBufferFromBytes(data)
+
+	// string table header validation
+	if isBinaryTag(data, BinaryTagStringTable) {
+		buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
+		tl := buff.ReadInt()                      // table length
+		if tl > 0 {
+			table = make([]string, tl, tl)
+			for i := 0; i < tl; i++ {
+				table[i] = buff.ReadString()
+			}
+		}
+	}
+
+	ctx := &DecodingContext{
+		Buffer: buff,
+		Table:  table,
+	}
+
+	err := target.UnmarshalBinaryWithContext(ctx)
+	if err != nil {
+		return err
+	}
+
+	return nil
+}
+
+// UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
+// the Window type
+func (target *Window) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
+	// panics are recovered and propagated as errors
+	defer func() {
+		if r := recover(); r != nil {
+			if e, ok := r.(error); ok {
+				err = e
+			} else if s, ok := r.(string); ok {
+				err = fmt.Errorf("Unexpected panic: %s", s)
+			} else {
+				err = fmt.Errorf("Unexpected panic: %+v", r)
+			}
+		}
+	}()
+
+	buff := ctx.Buffer
+	version := buff.ReadUInt8()
+
+	if version > KubeModelCodecVersion {
+		return fmt.Errorf("Invalid Version Unmarshaling Window. Expected %d or less, got %d", KubeModelCodecVersion, version)
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][reference](time.Time) ---
+		a := &time.Time{}
+		b := buff.ReadInt()    // byte array length
+		c := buff.ReadBytes(b) // byte array
+		errA := a.UnmarshalBinary(c)
+		if errA != nil {
+			return errA
+		}
+		target.Start = *a
+		// --- [end][read][reference](time.Time) ---
+
+	} else {
+	}
+
+	// field version check
+	if uint8(1) <= version {
+		// --- [begin][read][reference](time.Time) ---
+		d := &time.Time{}
+		e := buff.ReadInt()    // byte array length
+		f := buff.ReadBytes(e) // byte array
+		errB := d.UnmarshalBinary(f)
+		if errB != nil {
+			return errB
+		}
+		target.End = *d
+		// --- [end][read][reference](time.Time) ---
+
+	} else {
+	}
+
+	return nil
+}

+ 1 - 0
core/pkg/model/kubemodel/kubemodel_test.go

@@ -0,0 +1 @@
+package kubemodel

+ 12 - 0
core/pkg/model/kubemodel/metadata.go

@@ -0,0 +1,12 @@
+package kubemodel
+
+import "time"
+
+// TODO can bingen support marshaling type `error`?
+type Metadata struct {
+	CreatedAt   time.Time `json:"createdAt"`   // @bingen:field[version=1]
+	CompletedAt time.Time `json:"completedAt"` // @bingen:field[version=1]
+	ObjectCount int       `json:"objectCount"` // @bingen:field[version=1]
+	Errors      []string  `json:"errors"`      // @bingen:field[version=1]
+	Warnings    []string  `json:"warnings"`    // @bingen:field[version=1]
+}

+ 7 - 7
core/pkg/model/kubemodel/namespace.go

@@ -3,11 +3,11 @@ package kubemodel
 import "time"
 
 type Namespace struct {
-	UID         string
-	ClusterUID  string
-	Name        string
-	Labels      map[string]string
-	Annotations map[string]string
-	Start       time.Time
-	End         time.Time
+	UID         string            `json:"uid"`         // @bingen:field[version=1]
+	ClusterUID  string            `json:"clusterUID"`  // @bingen:field[version=1]
+	Name        string            `json:"name"`        // @bingen:field[version=1]
+	Labels      map[string]string `json:"labels"`      // @bingen:field[version=1]
+	Annotations map[string]string `json:"annotations"` // @bingen:field[version=1]
+	Start       time.Time         `json:"start"`       // @bingen:field[version=1]
+	End         time.Time         `json:"end"`         // @bingen:field[version=1]
 }

+ 0 - 15
core/pkg/model/kubemodel/node.go

@@ -1,15 +0,0 @@
-package kubemodel
-
-import "time"
-
-// TODO complete
-// TODO uint64 or float64 for numbers?
-type Node struct {
-	UID                 string
-	ClusterUID          string
-	Name                string
-	Start               time.Time
-	End                 time.Time
-	CPUMillicoreSeconds uint64
-	RAMByteSeconds      uint64
-}

+ 0 - 14
core/pkg/model/kubemodel/persistentvolume.go

@@ -1,14 +0,0 @@
-package kubemodel
-
-import "time"
-
-// TODO complete
-// TODO uint64 or float64 for numbers?
-type PersistentVolume struct {
-	UID                        string
-	ClusterUID                 string
-	Name                       string
-	Start                      time.Time
-	End                        time.Time
-	StorageCapacityByteSeconds uint64
-}

+ 0 - 13
core/pkg/model/kubemodel/persistentvolumeclaim.go

@@ -1,13 +0,0 @@
-package kubemodel
-
-import "time"
-
-// TODO complete
-type PersistentVolumeClaim struct {
-	UID                        string
-	PersistentVolumeUID        string
-	Name                       string
-	Start                      time.Time
-	End                        time.Time
-	StorageCapacityByteSeconds uint64
-}

+ 0 - 20
core/pkg/model/kubemodel/pod.go

@@ -1,20 +0,0 @@
-package kubemodel
-
-import "time"
-
-// TODO complete
-// TODO how to handle PVCs?
-// TODO how to handle attached devices?
-// TODO how to handle labels and annos?
-type Pod struct {
-	UID                       string
-	NamespaceUID              string
-	NodeUID                   string
-	OwnerUID                  string
-	PersistentVolumeClaimUIDs map[string]struct{}
-	Name                      string
-	Labels                    map[string]string
-	Annotations               map[string]string
-	Start                     time.Time
-	End                       time.Time
-}

+ 5 - 7
core/pkg/model/kubemodel/resource.go

@@ -1,7 +1,5 @@
 package kubemodel
 
-import "github.com/opencost/opencost/core/pkg/stats"
-
 type Resource string
 
 const (
@@ -30,19 +28,19 @@ const (
 )
 
 type ResourceQuantity struct {
-	Resource Resource
-	Unit     Unit
-	Values   stats.Stats
+	Resource Resource `json:"resource"` // @bingen:field[version=1]
+	Unit     Unit     `json:"unit"`     // @bingen:field[version=1]
+	Values   Stats    `json:"values"`   // @bingen:field[version=1]
 }
 
 type ResourceQuantities map[Resource]ResourceQuantity
 
-func (rqs ResourceQuantities) Set(resource Resource, unit Unit, statType stats.StatType, value float64) {
+func (rqs ResourceQuantities) Set(resource Resource, unit Unit, statType StatType, value float64) {
 	if _, ok := rqs[resource]; !ok {
 		rqs[resource] = ResourceQuantity{
 			Resource: resource,
 			Unit:     unit,
-			Values:   stats.NewStats(),
+			Values:   NewStats(),
 		}
 	}
 

+ 11 - 13
core/pkg/model/kubemodel/resourcequota.go

@@ -1,29 +1,27 @@
 package kubemodel
 
-type ResourceQuotaKind string
-
 type ResourceQuota struct {
-	UID          string
-	NamespaceUID string
-	Name         string
-	Spec         *ResourceQuotaSpec
-	Status       *ResourceQuotaStatus
+	UID          string               `json:"uid"`          // @bingen:field[version=1]
+	NamespaceUID string               `json:"namespaceUID"` // @bingen:field[version=1]
+	Name         string               `json:"name"`         // @bingen:field[version=1]
+	Spec         *ResourceQuotaSpec   `json:"spec"`         // @bingen:field[version=1]
+	Status       *ResourceQuotaStatus `json:"status"`       // @bingen:field[version=1]
 }
 
 type ResourceQuotaSpec struct {
-	Hard *ResourceQuotaSpecHard
+	Hard *ResourceQuotaSpecHard `json:"hard"` // @bingen:field[version=1]
 }
 
 type ResourceQuotaSpecHard struct {
-	Requests ResourceQuantities
-	Limits   ResourceQuantities
+	Requests ResourceQuantities `json:"requests"` // @bingen:field[version=1]
+	Limits   ResourceQuantities `json:"limits"`   // @bingen:field[version=1]
 }
 
 type ResourceQuotaStatus struct {
-	Used *ResourceQuotaStatusUsed
+	Used *ResourceQuotaStatusUsed `json:"used"` // @bingen:field[version=1]
 }
 
 type ResourceQuotaStatusUsed struct {
-	Requests ResourceQuantities
-	Limits   ResourceQuantities
+	Requests ResourceQuantities `json:"requests"` // @bingen:field[version=1]
+	Limits   ResourceQuantities `json:"limits"`   // @bingen:field[version=1]
 }

+ 1 - 12
core/pkg/stats/stats.go → core/pkg/model/kubemodel/stats.go

@@ -1,4 +1,4 @@
-package stats
+package kubemodel
 
 import (
 	"errors"
@@ -9,7 +9,6 @@ import (
 type StatType string
 
 const (
-	Val StatType = ""
 	Avg StatType = "avg"
 	Max StatType = "max"
 	Min StatType = "min"
@@ -28,16 +27,6 @@ func NewStats(capacity ...int) Stats {
 	return map[StatType]float64{}
 }
 
-func (s Stats) Value() (float64, bool) {
-	if s == nil {
-		return 0.0, false
-	}
-
-	val, ok := s[Val]
-
-	return val, ok
-}
-
 func (s Stats) Avg() (float64, bool) {
 	if s == nil {
 		return 0.0, false

+ 1 - 7
core/pkg/stats/stats_test.go → core/pkg/model/kubemodel/stats_test.go

@@ -1,4 +1,4 @@
-package stats
+package kubemodel
 
 import (
 	"errors"
@@ -21,12 +21,6 @@ func TestStats_Sanitize(t *testing.T) {
 			Stats{},
 			nil,
 		},
-		{
-			Stats{
-				Val: 1.0,
-			},
-			nil,
-		},
 		{
 			Stats{
 				Avg: 0.1,

+ 2 - 2
core/pkg/model/kubemodel/window.go

@@ -3,6 +3,6 @@ package kubemodel
 import "time"
 
 type Window struct {
-	Start time.Time
-	End   time.Time
+	Start time.Time `json:"start"` // @bingen:field[version=1]
+	End   time.Time `json:"end"`   // @bingen:field[version=1]
 }

+ 19 - 24
pkg/costmodel/kubemodel.go

@@ -7,7 +7,6 @@ import (
 	"github.com/opencost/opencost/core/pkg/env"
 	"github.com/opencost/opencost/core/pkg/model/kubemodel"
 	"github.com/opencost/opencost/core/pkg/source"
-	"github.com/opencost/opencost/core/pkg/stats"
 )
 
 const logTimeFmt string = "2006-01-02T15:04:05"
@@ -25,23 +24,21 @@ func (cm *CostModel) ComputeKubeModel(start, end time.Time) (*kubemodel.KubeMode
 	// 2.1 Compute Cluster
 	err = cm.kmComputeCluster(kms, start, end)
 	if err != nil {
-		kms.Metadata.Errors = append(kms.Metadata.Errors, err)
+		kms.Metadata.Errors = append(kms.Metadata.Errors, err.Error())
 		return kms, fmt.Errorf("error computing kubemodel.Cluster for (%s, %s): %w", start.Format(logTimeFmt), end.Format(logTimeFmt), err)
 	}
 
 	// 2.2 Compute Namespaces
 	err = cm.kmComputeNamespaces(kms, start, end)
 	if err != nil {
-		kms.Metadata.Errors = append(kms.Metadata.Errors, err)
+		kms.Metadata.Errors = append(kms.Metadata.Errors, err.Error())
 	}
-	kms.Metadata.ObjectCount += len(kms.Namespaces)
 
 	// 2.3 Compute ResourceQuotas
 	err = cm.kmComputeResourceQuotas(kms, start, end)
 	if err != nil {
-		kms.Metadata.Errors = append(kms.Metadata.Errors, err)
+		kms.Metadata.Errors = append(kms.Metadata.Errors, err.Error())
 	}
-	kms.Metadata.ObjectCount += len(kms.ResourceQuotas)
 
 	// 3. Mark KubeModelSet as completed
 	kms.Metadata.CompletedAt = time.Now().UTC()
@@ -60,8 +57,6 @@ func (cm *CostModel) kmComputeCluster(kms *kubemodel.KubeModelSet, start, end ti
 		Name: env.GetClusterID(), // TODO: do we still want to use this env var for Name?
 	}
 
-	kms.Metadata.ObjectCount += 1
-
 	return nil
 }
 
@@ -120,104 +115,104 @@ func (cm *CostModel) kmComputeResourceQuotas(kms *kubemodel.KubeModelSet, start,
 	for _, res := range rqSpecCPURequestAverageResult {
 		kms.RegisterResourceQuota(res.UID, res.ResourceQuota, res.Namespace)
 		mcpu := res.Data[0].Value * 1000
-		kms.ResourceQuotas[res.UID].Spec.Hard.Requests.Set(kubemodel.ResourceCPU, kubemodel.UnitMillicore, stats.Avg, mcpu)
+		kms.ResourceQuotas[res.UID].Spec.Hard.Requests.Set(kubemodel.ResourceCPU, kubemodel.UnitMillicore, kubemodel.Avg, mcpu)
 	}
 
 	rqSpecCPURequestMaxResult, _ := rqSpecCPURequestMaxResultFuture.Await()
 	for _, res := range rqSpecCPURequestMaxResult {
 		kms.RegisterResourceQuota(res.UID, res.ResourceQuota, res.Namespace)
 		mcpu := res.Data[0].Value * 1000
-		kms.ResourceQuotas[res.UID].Spec.Hard.Requests.Set(kubemodel.ResourceCPU, kubemodel.UnitMillicore, stats.Max, mcpu)
+		kms.ResourceQuotas[res.UID].Spec.Hard.Requests.Set(kubemodel.ResourceCPU, kubemodel.UnitMillicore, kubemodel.Max, mcpu)
 	}
 
 	rqSpecRAMRequestAverageResult, _ := rqSpecRAMRequestAverageResultFuture.Await()
 	for _, res := range rqSpecRAMRequestAverageResult {
 		kms.RegisterResourceQuota(res.UID, res.ResourceQuota, res.Namespace)
-		kms.ResourceQuotas[res.UID].Spec.Hard.Requests.Set(kubemodel.ResourceMemory, kubemodel.UnitByte, stats.Avg, res.Data[0].Value)
+		kms.ResourceQuotas[res.UID].Spec.Hard.Requests.Set(kubemodel.ResourceMemory, kubemodel.UnitByte, kubemodel.Avg, res.Data[0].Value)
 	}
 
 	rqSpecRAMRequestMaxResult, _ := rqSpecRAMRequestMaxResultFuture.Await()
 	for _, res := range rqSpecRAMRequestMaxResult {
 		kms.RegisterResourceQuota(res.UID, res.ResourceQuota, res.Namespace)
-		kms.ResourceQuotas[res.UID].Spec.Hard.Requests.Set(kubemodel.ResourceMemory, kubemodel.UnitByte, stats.Max, res.Data[0].Value)
+		kms.ResourceQuotas[res.UID].Spec.Hard.Requests.Set(kubemodel.ResourceMemory, kubemodel.UnitByte, kubemodel.Max, res.Data[0].Value)
 	}
 
 	rqSpecCPULimitAverageResult, _ := rqSpecCPULimitAverageResultFuture.Await()
 	for _, res := range rqSpecCPULimitAverageResult {
 		kms.RegisterResourceQuota(res.UID, res.ResourceQuota, res.Namespace)
 		mcpu := res.Data[0].Value * 1000
-		kms.ResourceQuotas[res.UID].Spec.Hard.Limits.Set(kubemodel.ResourceCPU, kubemodel.UnitMillicore, stats.Avg, mcpu)
+		kms.ResourceQuotas[res.UID].Spec.Hard.Limits.Set(kubemodel.ResourceCPU, kubemodel.UnitMillicore, kubemodel.Avg, mcpu)
 	}
 
 	rqSpecCPULimitMaxResult, _ := rqSpecCPULimitMaxResultFuture.Await()
 	for _, res := range rqSpecCPULimitMaxResult {
 		kms.RegisterResourceQuota(res.UID, res.ResourceQuota, res.Namespace)
 		mcpu := res.Data[0].Value * 1000
-		kms.ResourceQuotas[res.UID].Spec.Hard.Limits.Set(kubemodel.ResourceCPU, kubemodel.UnitMillicore, stats.Max, mcpu)
+		kms.ResourceQuotas[res.UID].Spec.Hard.Limits.Set(kubemodel.ResourceCPU, kubemodel.UnitMillicore, kubemodel.Max, mcpu)
 	}
 
 	rqSpecRAMLimitAverageResult, _ := rqSpecRAMLimitAverageResultFuture.Await()
 	for _, res := range rqSpecRAMLimitAverageResult {
 		kms.RegisterResourceQuota(res.UID, res.ResourceQuota, res.Namespace)
-		kms.ResourceQuotas[res.UID].Spec.Hard.Limits.Set(kubemodel.ResourceMemory, kubemodel.UnitByte, stats.Avg, res.Data[0].Value)
+		kms.ResourceQuotas[res.UID].Spec.Hard.Limits.Set(kubemodel.ResourceMemory, kubemodel.UnitByte, kubemodel.Avg, res.Data[0].Value)
 	}
 
 	rqSpecRAMLimitMaxResult, _ := rqSpecRAMLimitMaxResultFuture.Await()
 	for _, res := range rqSpecRAMLimitMaxResult {
 		kms.RegisterResourceQuota(res.UID, res.ResourceQuota, res.Namespace)
-		kms.ResourceQuotas[res.UID].Spec.Hard.Limits.Set(kubemodel.ResourceMemory, kubemodel.UnitByte, stats.Max, res.Data[0].Value)
+		kms.ResourceQuotas[res.UID].Spec.Hard.Limits.Set(kubemodel.ResourceMemory, kubemodel.UnitByte, kubemodel.Max, res.Data[0].Value)
 	}
 
 	rqStatusUsedCPURequestAverageResult, _ := rqStatusUsedCPURequestAverageResultFuture.Await()
 	for _, res := range rqStatusUsedCPURequestAverageResult {
 		kms.RegisterResourceQuota(res.UID, res.ResourceQuota, res.Namespace)
 		mcpu := res.Data[0].Value * 1000
-		kms.ResourceQuotas[res.UID].Status.Used.Requests.Set(kubemodel.ResourceCPU, kubemodel.UnitMillicore, stats.Avg, mcpu)
+		kms.ResourceQuotas[res.UID].Status.Used.Requests.Set(kubemodel.ResourceCPU, kubemodel.UnitMillicore, kubemodel.Avg, mcpu)
 	}
 
 	rqStatusUsedCPURequestMaxResult, _ := rqStatusUsedCPURequestMaxResultFuture.Await()
 	for _, res := range rqStatusUsedCPURequestMaxResult {
 		kms.RegisterResourceQuota(res.UID, res.ResourceQuota, res.Namespace)
 		mcpu := res.Data[0].Value * 1000
-		kms.ResourceQuotas[res.UID].Status.Used.Requests.Set(kubemodel.ResourceCPU, kubemodel.UnitMillicore, stats.Max, mcpu)
+		kms.ResourceQuotas[res.UID].Status.Used.Requests.Set(kubemodel.ResourceCPU, kubemodel.UnitMillicore, kubemodel.Max, mcpu)
 	}
 
 	rqStatusUsedRAMRequestAverageResult, _ := rqStatusUsedRAMRequestAverageResultFuture.Await()
 	for _, res := range rqStatusUsedRAMRequestAverageResult {
 		kms.RegisterResourceQuota(res.UID, res.ResourceQuota, res.Namespace)
-		kms.ResourceQuotas[res.UID].Status.Used.Requests.Set(kubemodel.ResourceMemory, kubemodel.UnitByte, stats.Avg, res.Data[0].Value)
+		kms.ResourceQuotas[res.UID].Status.Used.Requests.Set(kubemodel.ResourceMemory, kubemodel.UnitByte, kubemodel.Avg, res.Data[0].Value)
 	}
 
 	rqStatusUsedRAMRequestMaxResult, _ := rqStatusUsedRAMRequestMaxResultFuture.Await()
 	for _, res := range rqStatusUsedRAMRequestMaxResult {
 		kms.RegisterResourceQuota(res.UID, res.ResourceQuota, res.Namespace)
-		kms.ResourceQuotas[res.UID].Status.Used.Requests.Set(kubemodel.ResourceMemory, kubemodel.UnitByte, stats.Max, res.Data[0].Value)
+		kms.ResourceQuotas[res.UID].Status.Used.Requests.Set(kubemodel.ResourceMemory, kubemodel.UnitByte, kubemodel.Max, res.Data[0].Value)
 	}
 
 	rqStatusUsedCPULimitAverageResult, _ := rqStatusUsedCPULimitAverageResultFuture.Await()
 	for _, res := range rqStatusUsedCPULimitAverageResult {
 		kms.RegisterResourceQuota(res.UID, res.ResourceQuota, res.Namespace)
 		mcpu := res.Data[0].Value * 1000
-		kms.ResourceQuotas[res.UID].Status.Used.Limits.Set(kubemodel.ResourceCPU, kubemodel.UnitMillicore, stats.Avg, mcpu)
+		kms.ResourceQuotas[res.UID].Status.Used.Limits.Set(kubemodel.ResourceCPU, kubemodel.UnitMillicore, kubemodel.Avg, mcpu)
 	}
 
 	rqStatusUsedCPULimitMaxResult, _ := rqStatusUsedCPULimitMaxResultFuture.Await()
 	for _, res := range rqStatusUsedCPULimitMaxResult {
 		kms.RegisterResourceQuota(res.UID, res.ResourceQuota, res.Namespace)
 		mcpu := res.Data[0].Value * 1000
-		kms.ResourceQuotas[res.UID].Status.Used.Limits.Set(kubemodel.ResourceCPU, kubemodel.UnitMillicore, stats.Max, mcpu)
+		kms.ResourceQuotas[res.UID].Status.Used.Limits.Set(kubemodel.ResourceCPU, kubemodel.UnitMillicore, kubemodel.Max, mcpu)
 	}
 
 	rqStatusUsedRAMLimitAverageResult, _ := rqStatusUsedRAMLimitAverageResultFuture.Await()
 	for _, res := range rqStatusUsedRAMLimitAverageResult {
 		kms.RegisterResourceQuota(res.UID, res.ResourceQuota, res.Namespace)
-		kms.ResourceQuotas[res.UID].Status.Used.Limits.Set(kubemodel.ResourceMemory, kubemodel.UnitByte, stats.Avg, res.Data[0].Value)
+		kms.ResourceQuotas[res.UID].Status.Used.Limits.Set(kubemodel.ResourceMemory, kubemodel.UnitByte, kubemodel.Avg, res.Data[0].Value)
 	}
 
 	rqStatusUsedRAMLimitMaxResult, _ := rqStatusUsedRAMLimitMaxResultFuture.Await()
 	for _, res := range rqStatusUsedRAMLimitMaxResult {
 		kms.RegisterResourceQuota(res.UID, res.ResourceQuota, res.Namespace)
-		kms.ResourceQuotas[res.UID].Status.Used.Limits.Set(kubemodel.ResourceMemory, kubemodel.UnitByte, stats.Max, res.Data[0].Value)
+		kms.ResourceQuotas[res.UID].Status.Used.Limits.Set(kubemodel.ResourceMemory, kubemodel.UnitByte, kubemodel.Max, res.Data[0].Value)
 	}
 
 	return nil