From 1117a7cbf93c0332bd3f4839931fcaeadd5037c7 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Fri, 1 Apr 2016 13:00:44 -0700 Subject: [PATCH] Bump specs to 93ca97e83ca7fb4fba6d9e30d5470f99ddc0 This bumps specs to version 93ca97e83ca7fb4fba6d9e30d5470f99ddc02d11 which fixes the json marshal/unmarshal issue with blkio major/minor and adds masked and readonly paths to the spec. Signed-off-by: Michael Crosby --- Godeps/Godeps.json | 4 +- .../opencontainers/specs/specs-go/config.go | 4 + .../specs/specs-go/config_ffjson.go | 12128 ---------------- .../specs/specs-go/state_ffjson.go | 351 - 4 files changed, 6 insertions(+), 12481 deletions(-) delete mode 100644 Godeps/_workspace/src/github.com/opencontainers/specs/specs-go/config_ffjson.go delete mode 100644 Godeps/_workspace/src/github.com/opencontainers/specs/specs-go/state_ffjson.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 9cd6e8a2..a85e3d3a 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -58,8 +58,8 @@ }, { "ImportPath": "github.com/opencontainers/specs/specs-go", - "Comment": "v0.4.0-27-gcf8ebc9", - "Rev": "cf8ebc9d6e34a61c6a5dc82d749089ef40184238" + "Comment": "v0.4.0-35-g93ca97e", + "Rev": "93ca97e83ca7fb4fba6d9e30d5470f99ddc02d11" }, { "ImportPath": "github.com/seccomp/libseccomp-golang", diff --git a/Godeps/_workspace/src/github.com/opencontainers/specs/specs-go/config.go b/Godeps/_workspace/src/github.com/opencontainers/specs/specs-go/config.go index 162993d5..3e5d499e 100644 --- a/Godeps/_workspace/src/github.com/opencontainers/specs/specs-go/config.go +++ b/Godeps/_workspace/src/github.com/opencontainers/specs/specs-go/config.go @@ -136,6 +136,10 @@ type Linux struct { Seccomp *Seccomp `json:"seccomp,omitempty"` // RootfsPropagation is the rootfs mount propagation mode for the container. RootfsPropagation string `json:"rootfsPropagation,omitempty"` + // MaskedPaths masks over the provided paths inside the container. + MaskedPaths []string `json:"maskedPaths,omitempty"` + // ReadonlyPaths sets the provided paths as RO inside the container. + ReadonlyPaths []string `json:"readonlyPaths,omitempty"` } // Namespace is the configuration for a Linux namespace diff --git a/Godeps/_workspace/src/github.com/opencontainers/specs/specs-go/config_ffjson.go b/Godeps/_workspace/src/github.com/opencontainers/specs/specs-go/config_ffjson.go deleted file mode 100644 index 36eacc2d..00000000 --- a/Godeps/_workspace/src/github.com/opencontainers/specs/specs-go/config_ffjson.go +++ /dev/null @@ -1,12128 +0,0 @@ -// DO NOT EDIT! -// Code generated by ffjson -// source: config.go -// DO NOT EDIT! - -package specs - -import ( - "bytes" - "errors" - "fmt" - fflib "github.com/pquerna/ffjson/fflib/v1" - "os" -) - -func (mj *Arg) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Arg) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{"index":`) - fflib.FormatBits2(buf, uint64(mj.Index), 10, false) - buf.WriteString(`,"value":`) - fflib.FormatBits2(buf, uint64(mj.Value), 10, false) - buf.WriteString(`,"valueTwo":`) - fflib.FormatBits2(buf, uint64(mj.ValueTwo), 10, false) - buf.WriteString(`,"op":`) - fflib.WriteJsonString(buf, string(mj.Op)) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Argbase = iota - ffj_t_Argno_such_key - - ffj_t_Arg_Index - - ffj_t_Arg_Value - - ffj_t_Arg_ValueTwo - - ffj_t_Arg_Op -) - -var ffj_key_Arg_Index = []byte("index") - -var ffj_key_Arg_Value = []byte("value") - -var ffj_key_Arg_ValueTwo = []byte("valueTwo") - -var ffj_key_Arg_Op = []byte("op") - -func (uj *Arg) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Arg) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Argbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Argno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'i': - - if bytes.Equal(ffj_key_Arg_Index, kn) { - currentKey = ffj_t_Arg_Index - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'o': - - if bytes.Equal(ffj_key_Arg_Op, kn) { - currentKey = ffj_t_Arg_Op - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'v': - - if bytes.Equal(ffj_key_Arg_Value, kn) { - currentKey = ffj_t_Arg_Value - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_Arg_ValueTwo, kn) { - currentKey = ffj_t_Arg_ValueTwo - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.SimpleLetterEqualFold(ffj_key_Arg_Op, kn) { - currentKey = ffj_t_Arg_Op - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Arg_ValueTwo, kn) { - currentKey = ffj_t_Arg_ValueTwo - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Arg_Value, kn) { - currentKey = ffj_t_Arg_Value - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Arg_Index, kn) { - currentKey = ffj_t_Arg_Index - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Argno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Arg_Index: - goto handle_Index - - case ffj_t_Arg_Value: - goto handle_Value - - case ffj_t_Arg_ValueTwo: - goto handle_ValueTwo - - case ffj_t_Arg_Op: - goto handle_Op - - case ffj_t_Argno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Index: - - /* handler: uj.Index type=uint kind=uint quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - uj.Index = uint(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Value: - - /* handler: uj.Value type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - uj.Value = uint64(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_ValueTwo: - - /* handler: uj.ValueTwo type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - uj.ValueTwo = uint64(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Op: - - /* handler: uj.Op type=specs.Operator kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for Operator", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Op = Operator(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *BlockIO) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *BlockIO) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ `) - if mj.Weight != nil { - if true { - buf.WriteString(`"blkioWeight":`) - fflib.FormatBits2(buf, uint64(*mj.Weight), 10, false) - buf.WriteByte(',') - } - } - if mj.LeafWeight != nil { - if true { - buf.WriteString(`"blkioLeafWeight":`) - fflib.FormatBits2(buf, uint64(*mj.LeafWeight), 10, false) - buf.WriteByte(',') - } - } - if len(mj.WeightDevice) != 0 { - buf.WriteString(`"blkioWeightDevice":`) - if mj.WeightDevice != nil { - buf.WriteString(`[`) - for i, v := range mj.WeightDevice { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(mj.ThrottleReadBpsDevice) != 0 { - buf.WriteString(`"blkioThrottleReadBpsDevice":`) - if mj.ThrottleReadBpsDevice != nil { - buf.WriteString(`[`) - for i, v := range mj.ThrottleReadBpsDevice { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(mj.ThrottleWriteBpsDevice) != 0 { - buf.WriteString(`"blkioThrottleWriteBpsDevice":`) - if mj.ThrottleWriteBpsDevice != nil { - buf.WriteString(`[`) - for i, v := range mj.ThrottleWriteBpsDevice { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(mj.ThrottleReadIOPSDevice) != 0 { - buf.WriteString(`"blkioThrottleReadIOPSDevice":`) - if mj.ThrottleReadIOPSDevice != nil { - buf.WriteString(`[`) - for i, v := range mj.ThrottleReadIOPSDevice { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(mj.ThrottleWriteIOPSDevice) != 0 { - buf.WriteString(`"blkioThrottleWriteIOPSDevice":`) - if mj.ThrottleWriteIOPSDevice != nil { - buf.WriteString(`[`) - for i, v := range mj.ThrottleWriteIOPSDevice { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_BlockIObase = iota - ffj_t_BlockIOno_such_key - - ffj_t_BlockIO_Weight - - ffj_t_BlockIO_LeafWeight - - ffj_t_BlockIO_WeightDevice - - ffj_t_BlockIO_ThrottleReadBpsDevice - - ffj_t_BlockIO_ThrottleWriteBpsDevice - - ffj_t_BlockIO_ThrottleReadIOPSDevice - - ffj_t_BlockIO_ThrottleWriteIOPSDevice -) - -var ffj_key_BlockIO_Weight = []byte("blkioWeight") - -var ffj_key_BlockIO_LeafWeight = []byte("blkioLeafWeight") - -var ffj_key_BlockIO_WeightDevice = []byte("blkioWeightDevice") - -var ffj_key_BlockIO_ThrottleReadBpsDevice = []byte("blkioThrottleReadBpsDevice") - -var ffj_key_BlockIO_ThrottleWriteBpsDevice = []byte("blkioThrottleWriteBpsDevice") - -var ffj_key_BlockIO_ThrottleReadIOPSDevice = []byte("blkioThrottleReadIOPSDevice") - -var ffj_key_BlockIO_ThrottleWriteIOPSDevice = []byte("blkioThrottleWriteIOPSDevice") - -func (uj *BlockIO) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *BlockIO) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_BlockIObase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_BlockIOno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'b': - - if bytes.Equal(ffj_key_BlockIO_Weight, kn) { - currentKey = ffj_t_BlockIO_Weight - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_BlockIO_LeafWeight, kn) { - currentKey = ffj_t_BlockIO_LeafWeight - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_BlockIO_WeightDevice, kn) { - currentKey = ffj_t_BlockIO_WeightDevice - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_BlockIO_ThrottleReadBpsDevice, kn) { - currentKey = ffj_t_BlockIO_ThrottleReadBpsDevice - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_BlockIO_ThrottleWriteBpsDevice, kn) { - currentKey = ffj_t_BlockIO_ThrottleWriteBpsDevice - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_BlockIO_ThrottleReadIOPSDevice, kn) { - currentKey = ffj_t_BlockIO_ThrottleReadIOPSDevice - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_BlockIO_ThrottleWriteIOPSDevice, kn) { - currentKey = ffj_t_BlockIO_ThrottleWriteIOPSDevice - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffj_key_BlockIO_ThrottleWriteIOPSDevice, kn) { - currentKey = ffj_t_BlockIO_ThrottleWriteIOPSDevice - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_BlockIO_ThrottleReadIOPSDevice, kn) { - currentKey = ffj_t_BlockIO_ThrottleReadIOPSDevice - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_BlockIO_ThrottleWriteBpsDevice, kn) { - currentKey = ffj_t_BlockIO_ThrottleWriteBpsDevice - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_BlockIO_ThrottleReadBpsDevice, kn) { - currentKey = ffj_t_BlockIO_ThrottleReadBpsDevice - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_BlockIO_WeightDevice, kn) { - currentKey = ffj_t_BlockIO_WeightDevice - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_BlockIO_LeafWeight, kn) { - currentKey = ffj_t_BlockIO_LeafWeight - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_BlockIO_Weight, kn) { - currentKey = ffj_t_BlockIO_Weight - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_BlockIOno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_BlockIO_Weight: - goto handle_Weight - - case ffj_t_BlockIO_LeafWeight: - goto handle_LeafWeight - - case ffj_t_BlockIO_WeightDevice: - goto handle_WeightDevice - - case ffj_t_BlockIO_ThrottleReadBpsDevice: - goto handle_ThrottleReadBpsDevice - - case ffj_t_BlockIO_ThrottleWriteBpsDevice: - goto handle_ThrottleWriteBpsDevice - - case ffj_t_BlockIO_ThrottleReadIOPSDevice: - goto handle_ThrottleReadIOPSDevice - - case ffj_t_BlockIO_ThrottleWriteIOPSDevice: - goto handle_ThrottleWriteIOPSDevice - - case ffj_t_BlockIOno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Weight: - - /* handler: uj.Weight type=uint16 kind=uint16 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint16", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.Weight = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 16) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint16(tval) - uj.Weight = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_LeafWeight: - - /* handler: uj.LeafWeight type=uint16 kind=uint16 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint16", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.LeafWeight = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 16) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint16(tval) - uj.LeafWeight = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_WeightDevice: - - /* handler: uj.WeightDevice type=[]specs.WeightDevice kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.WeightDevice = nil - } else { - - uj.WeightDevice = make([]WeightDevice, 0) - - wantVal := true - - for { - - var tmp_uj__WeightDevice WeightDevice - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__WeightDevice type=specs.WeightDevice kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__WeightDevice.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.WeightDevice = append(uj.WeightDevice, tmp_uj__WeightDevice) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_ThrottleReadBpsDevice: - - /* handler: uj.ThrottleReadBpsDevice type=[]specs.ThrottleDevice kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.ThrottleReadBpsDevice = nil - } else { - - uj.ThrottleReadBpsDevice = make([]ThrottleDevice, 0) - - wantVal := true - - for { - - var tmp_uj__ThrottleReadBpsDevice ThrottleDevice - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__ThrottleReadBpsDevice type=specs.ThrottleDevice kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__ThrottleReadBpsDevice.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.ThrottleReadBpsDevice = append(uj.ThrottleReadBpsDevice, tmp_uj__ThrottleReadBpsDevice) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_ThrottleWriteBpsDevice: - - /* handler: uj.ThrottleWriteBpsDevice type=[]specs.ThrottleDevice kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.ThrottleWriteBpsDevice = nil - } else { - - uj.ThrottleWriteBpsDevice = make([]ThrottleDevice, 0) - - wantVal := true - - for { - - var tmp_uj__ThrottleWriteBpsDevice ThrottleDevice - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__ThrottleWriteBpsDevice type=specs.ThrottleDevice kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__ThrottleWriteBpsDevice.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.ThrottleWriteBpsDevice = append(uj.ThrottleWriteBpsDevice, tmp_uj__ThrottleWriteBpsDevice) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_ThrottleReadIOPSDevice: - - /* handler: uj.ThrottleReadIOPSDevice type=[]specs.ThrottleDevice kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.ThrottleReadIOPSDevice = nil - } else { - - uj.ThrottleReadIOPSDevice = make([]ThrottleDevice, 0) - - wantVal := true - - for { - - var tmp_uj__ThrottleReadIOPSDevice ThrottleDevice - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__ThrottleReadIOPSDevice type=specs.ThrottleDevice kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__ThrottleReadIOPSDevice.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.ThrottleReadIOPSDevice = append(uj.ThrottleReadIOPSDevice, tmp_uj__ThrottleReadIOPSDevice) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_ThrottleWriteIOPSDevice: - - /* handler: uj.ThrottleWriteIOPSDevice type=[]specs.ThrottleDevice kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.ThrottleWriteIOPSDevice = nil - } else { - - uj.ThrottleWriteIOPSDevice = make([]ThrottleDevice, 0) - - wantVal := true - - for { - - var tmp_uj__ThrottleWriteIOPSDevice ThrottleDevice - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__ThrottleWriteIOPSDevice type=specs.ThrottleDevice kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__ThrottleWriteIOPSDevice.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.ThrottleWriteIOPSDevice = append(uj.ThrottleWriteIOPSDevice, tmp_uj__ThrottleWriteIOPSDevice) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *CPU) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *CPU) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ `) - if mj.Shares != nil { - if true { - buf.WriteString(`"shares":`) - fflib.FormatBits2(buf, uint64(*mj.Shares), 10, false) - buf.WriteByte(',') - } - } - if mj.Quota != nil { - if true { - buf.WriteString(`"quota":`) - fflib.FormatBits2(buf, uint64(*mj.Quota), 10, false) - buf.WriteByte(',') - } - } - if mj.Period != nil { - if true { - buf.WriteString(`"period":`) - fflib.FormatBits2(buf, uint64(*mj.Period), 10, false) - buf.WriteByte(',') - } - } - if mj.RealtimeRuntime != nil { - if true { - buf.WriteString(`"realtimeRuntime":`) - fflib.FormatBits2(buf, uint64(*mj.RealtimeRuntime), 10, false) - buf.WriteByte(',') - } - } - if mj.RealtimePeriod != nil { - if true { - buf.WriteString(`"realtimePeriod":`) - fflib.FormatBits2(buf, uint64(*mj.RealtimePeriod), 10, false) - buf.WriteByte(',') - } - } - if mj.Cpus != nil { - if true { - buf.WriteString(`"cpus":`) - fflib.WriteJsonString(buf, string(*mj.Cpus)) - buf.WriteByte(',') - } - } - if mj.Mems != nil { - if true { - buf.WriteString(`"mems":`) - fflib.WriteJsonString(buf, string(*mj.Mems)) - buf.WriteByte(',') - } - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_CPUbase = iota - ffj_t_CPUno_such_key - - ffj_t_CPU_Shares - - ffj_t_CPU_Quota - - ffj_t_CPU_Period - - ffj_t_CPU_RealtimeRuntime - - ffj_t_CPU_RealtimePeriod - - ffj_t_CPU_Cpus - - ffj_t_CPU_Mems -) - -var ffj_key_CPU_Shares = []byte("shares") - -var ffj_key_CPU_Quota = []byte("quota") - -var ffj_key_CPU_Period = []byte("period") - -var ffj_key_CPU_RealtimeRuntime = []byte("realtimeRuntime") - -var ffj_key_CPU_RealtimePeriod = []byte("realtimePeriod") - -var ffj_key_CPU_Cpus = []byte("cpus") - -var ffj_key_CPU_Mems = []byte("mems") - -func (uj *CPU) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *CPU) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_CPUbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_CPUno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'c': - - if bytes.Equal(ffj_key_CPU_Cpus, kn) { - currentKey = ffj_t_CPU_Cpus - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'm': - - if bytes.Equal(ffj_key_CPU_Mems, kn) { - currentKey = ffj_t_CPU_Mems - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'p': - - if bytes.Equal(ffj_key_CPU_Period, kn) { - currentKey = ffj_t_CPU_Period - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'q': - - if bytes.Equal(ffj_key_CPU_Quota, kn) { - currentKey = ffj_t_CPU_Quota - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'r': - - if bytes.Equal(ffj_key_CPU_RealtimeRuntime, kn) { - currentKey = ffj_t_CPU_RealtimeRuntime - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_CPU_RealtimePeriod, kn) { - currentKey = ffj_t_CPU_RealtimePeriod - state = fflib.FFParse_want_colon - goto mainparse - } - - case 's': - - if bytes.Equal(ffj_key_CPU_Shares, kn) { - currentKey = ffj_t_CPU_Shares - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffj_key_CPU_Mems, kn) { - currentKey = ffj_t_CPU_Mems - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_CPU_Cpus, kn) { - currentKey = ffj_t_CPU_Cpus - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_CPU_RealtimePeriod, kn) { - currentKey = ffj_t_CPU_RealtimePeriod - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_CPU_RealtimeRuntime, kn) { - currentKey = ffj_t_CPU_RealtimeRuntime - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_CPU_Period, kn) { - currentKey = ffj_t_CPU_Period - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_CPU_Quota, kn) { - currentKey = ffj_t_CPU_Quota - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_CPU_Shares, kn) { - currentKey = ffj_t_CPU_Shares - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_CPUno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_CPU_Shares: - goto handle_Shares - - case ffj_t_CPU_Quota: - goto handle_Quota - - case ffj_t_CPU_Period: - goto handle_Period - - case ffj_t_CPU_RealtimeRuntime: - goto handle_RealtimeRuntime - - case ffj_t_CPU_RealtimePeriod: - goto handle_RealtimePeriod - - case ffj_t_CPU_Cpus: - goto handle_Cpus - - case ffj_t_CPU_Mems: - goto handle_Mems - - case ffj_t_CPUno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Shares: - - /* handler: uj.Shares type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.Shares = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint64(tval) - uj.Shares = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Quota: - - /* handler: uj.Quota type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.Quota = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint64(tval) - uj.Quota = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Period: - - /* handler: uj.Period type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.Period = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint64(tval) - uj.Period = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_RealtimeRuntime: - - /* handler: uj.RealtimeRuntime type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.RealtimeRuntime = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint64(tval) - uj.RealtimeRuntime = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_RealtimePeriod: - - /* handler: uj.RealtimePeriod type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.RealtimePeriod = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint64(tval) - uj.RealtimePeriod = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Cpus: - - /* handler: uj.Cpus type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - uj.Cpus = nil - - } else { - - var tval string - outBuf := fs.Output.Bytes() - - tval = string(string(outBuf)) - uj.Cpus = &tval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Mems: - - /* handler: uj.Mems type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - uj.Mems = nil - - } else { - - var tval string - outBuf := fs.Output.Bytes() - - tval = string(string(outBuf)) - uj.Mems = &tval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Device) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Device) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ "path":`) - fflib.WriteJsonString(buf, string(mj.Path)) - buf.WriteString(`,"type":`) - fflib.WriteJsonString(buf, string(mj.Type)) - buf.WriteString(`,"major":`) - fflib.FormatBits2(buf, uint64(mj.Major), 10, mj.Major < 0) - buf.WriteString(`,"minor":`) - fflib.FormatBits2(buf, uint64(mj.Minor), 10, mj.Minor < 0) - buf.WriteByte(',') - if mj.FileMode != nil { - if true { - buf.WriteString(`"fileMode":`) - fflib.FormatBits2(buf, uint64(*mj.FileMode), 10, false) - buf.WriteByte(',') - } - } - if mj.UID != nil { - if true { - buf.WriteString(`"uid":`) - fflib.FormatBits2(buf, uint64(*mj.UID), 10, false) - buf.WriteByte(',') - } - } - if mj.GID != nil { - if true { - buf.WriteString(`"gid":`) - fflib.FormatBits2(buf, uint64(*mj.GID), 10, false) - buf.WriteByte(',') - } - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Devicebase = iota - ffj_t_Deviceno_such_key - - ffj_t_Device_Path - - ffj_t_Device_Type - - ffj_t_Device_Major - - ffj_t_Device_Minor - - ffj_t_Device_FileMode - - ffj_t_Device_UID - - ffj_t_Device_GID -) - -var ffj_key_Device_Path = []byte("path") - -var ffj_key_Device_Type = []byte("type") - -var ffj_key_Device_Major = []byte("major") - -var ffj_key_Device_Minor = []byte("minor") - -var ffj_key_Device_FileMode = []byte("fileMode") - -var ffj_key_Device_UID = []byte("uid") - -var ffj_key_Device_GID = []byte("gid") - -func (uj *Device) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Device) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Devicebase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Deviceno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'f': - - if bytes.Equal(ffj_key_Device_FileMode, kn) { - currentKey = ffj_t_Device_FileMode - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'g': - - if bytes.Equal(ffj_key_Device_GID, kn) { - currentKey = ffj_t_Device_GID - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'm': - - if bytes.Equal(ffj_key_Device_Major, kn) { - currentKey = ffj_t_Device_Major - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_Device_Minor, kn) { - currentKey = ffj_t_Device_Minor - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'p': - - if bytes.Equal(ffj_key_Device_Path, kn) { - currentKey = ffj_t_Device_Path - state = fflib.FFParse_want_colon - goto mainparse - } - - case 't': - - if bytes.Equal(ffj_key_Device_Type, kn) { - currentKey = ffj_t_Device_Type - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'u': - - if bytes.Equal(ffj_key_Device_UID, kn) { - currentKey = ffj_t_Device_UID - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.SimpleLetterEqualFold(ffj_key_Device_GID, kn) { - currentKey = ffj_t_Device_GID - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Device_UID, kn) { - currentKey = ffj_t_Device_UID - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Device_FileMode, kn) { - currentKey = ffj_t_Device_FileMode - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Device_Minor, kn) { - currentKey = ffj_t_Device_Minor - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Device_Major, kn) { - currentKey = ffj_t_Device_Major - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Device_Type, kn) { - currentKey = ffj_t_Device_Type - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Device_Path, kn) { - currentKey = ffj_t_Device_Path - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Deviceno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Device_Path: - goto handle_Path - - case ffj_t_Device_Type: - goto handle_Type - - case ffj_t_Device_Major: - goto handle_Major - - case ffj_t_Device_Minor: - goto handle_Minor - - case ffj_t_Device_FileMode: - goto handle_FileMode - - case ffj_t_Device_UID: - goto handle_UID - - case ffj_t_Device_GID: - goto handle_GID - - case ffj_t_Deviceno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Path: - - /* handler: uj.Path type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Path = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Type: - - /* handler: uj.Type type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Type = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Major: - - /* handler: uj.Major type=int64 kind=int64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - uj.Major = int64(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Minor: - - /* handler: uj.Minor type=int64 kind=int64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - uj.Minor = int64(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_FileMode: - - /* handler: uj.FileMode type=os.FileMode kind=uint32 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for FileMode", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.FileMode = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 32) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := os.FileMode(tval) - uj.FileMode = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_UID: - - /* handler: uj.UID type=uint32 kind=uint32 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint32", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.UID = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 32) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint32(tval) - uj.UID = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_GID: - - /* handler: uj.GID type=uint32 kind=uint32 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint32", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.GID = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 32) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint32(tval) - uj.GID = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *DeviceCgroup) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *DeviceCgroup) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - if mj.Allow { - buf.WriteString(`{ "allow":true`) - } else { - buf.WriteString(`{ "allow":false`) - } - buf.WriteByte(',') - if mj.Type != nil { - if true { - buf.WriteString(`"type":`) - fflib.WriteJsonString(buf, string(*mj.Type)) - buf.WriteByte(',') - } - } - if mj.Major != nil { - if true { - buf.WriteString(`"major":`) - fflib.FormatBits2(buf, uint64(*mj.Major), 10, *mj.Major < 0) - buf.WriteByte(',') - } - } - if mj.Minor != nil { - if true { - buf.WriteString(`"minor":`) - fflib.FormatBits2(buf, uint64(*mj.Minor), 10, *mj.Minor < 0) - buf.WriteByte(',') - } - } - if mj.Access != nil { - if true { - buf.WriteString(`"access":`) - fflib.WriteJsonString(buf, string(*mj.Access)) - buf.WriteByte(',') - } - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_DeviceCgroupbase = iota - ffj_t_DeviceCgroupno_such_key - - ffj_t_DeviceCgroup_Allow - - ffj_t_DeviceCgroup_Type - - ffj_t_DeviceCgroup_Major - - ffj_t_DeviceCgroup_Minor - - ffj_t_DeviceCgroup_Access -) - -var ffj_key_DeviceCgroup_Allow = []byte("allow") - -var ffj_key_DeviceCgroup_Type = []byte("type") - -var ffj_key_DeviceCgroup_Major = []byte("major") - -var ffj_key_DeviceCgroup_Minor = []byte("minor") - -var ffj_key_DeviceCgroup_Access = []byte("access") - -func (uj *DeviceCgroup) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *DeviceCgroup) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_DeviceCgroupbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_DeviceCgroupno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'a': - - if bytes.Equal(ffj_key_DeviceCgroup_Allow, kn) { - currentKey = ffj_t_DeviceCgroup_Allow - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_DeviceCgroup_Access, kn) { - currentKey = ffj_t_DeviceCgroup_Access - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'm': - - if bytes.Equal(ffj_key_DeviceCgroup_Major, kn) { - currentKey = ffj_t_DeviceCgroup_Major - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_DeviceCgroup_Minor, kn) { - currentKey = ffj_t_DeviceCgroup_Minor - state = fflib.FFParse_want_colon - goto mainparse - } - - case 't': - - if bytes.Equal(ffj_key_DeviceCgroup_Type, kn) { - currentKey = ffj_t_DeviceCgroup_Type - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffj_key_DeviceCgroup_Access, kn) { - currentKey = ffj_t_DeviceCgroup_Access - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_DeviceCgroup_Minor, kn) { - currentKey = ffj_t_DeviceCgroup_Minor - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_DeviceCgroup_Major, kn) { - currentKey = ffj_t_DeviceCgroup_Major - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_DeviceCgroup_Type, kn) { - currentKey = ffj_t_DeviceCgroup_Type - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_DeviceCgroup_Allow, kn) { - currentKey = ffj_t_DeviceCgroup_Allow - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_DeviceCgroupno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_DeviceCgroup_Allow: - goto handle_Allow - - case ffj_t_DeviceCgroup_Type: - goto handle_Type - - case ffj_t_DeviceCgroup_Major: - goto handle_Major - - case ffj_t_DeviceCgroup_Minor: - goto handle_Minor - - case ffj_t_DeviceCgroup_Access: - goto handle_Access - - case ffj_t_DeviceCgroupno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Allow: - - /* handler: uj.Allow type=bool kind=bool quoted=false*/ - - { - if tok != fflib.FFTok_bool && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for bool", tok)) - } - } - - { - if tok == fflib.FFTok_null { - - } else { - tmpb := fs.Output.Bytes() - - if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { - - uj.Allow = true - - } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { - - uj.Allow = false - - } else { - err = errors.New("unexpected bytes for true/false value") - return fs.WrapErr(err) - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Type: - - /* handler: uj.Type type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - uj.Type = nil - - } else { - - var tval string - outBuf := fs.Output.Bytes() - - tval = string(string(outBuf)) - uj.Type = &tval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Major: - - /* handler: uj.Major type=int64 kind=int64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.Major = nil - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := int64(tval) - uj.Major = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Minor: - - /* handler: uj.Minor type=int64 kind=int64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.Minor = nil - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := int64(tval) - uj.Minor = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Access: - - /* handler: uj.Access type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - uj.Access = nil - - } else { - - var tval string - outBuf := fs.Output.Bytes() - - tval = string(string(outBuf)) - uj.Access = &tval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Hook) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Hook) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ "path":`) - fflib.WriteJsonString(buf, string(mj.Path)) - buf.WriteByte(',') - if len(mj.Args) != 0 { - buf.WriteString(`"args":`) - if mj.Args != nil { - buf.WriteString(`[`) - for i, v := range mj.Args { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(mj.Env) != 0 { - buf.WriteString(`"env":`) - if mj.Env != nil { - buf.WriteString(`[`) - for i, v := range mj.Env { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if mj.Timeout != nil { - if true { - buf.WriteString(`"timeout":`) - fflib.FormatBits2(buf, uint64(*mj.Timeout), 10, *mj.Timeout < 0) - buf.WriteByte(',') - } - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Hookbase = iota - ffj_t_Hookno_such_key - - ffj_t_Hook_Path - - ffj_t_Hook_Args - - ffj_t_Hook_Env - - ffj_t_Hook_Timeout -) - -var ffj_key_Hook_Path = []byte("path") - -var ffj_key_Hook_Args = []byte("args") - -var ffj_key_Hook_Env = []byte("env") - -var ffj_key_Hook_Timeout = []byte("timeout") - -func (uj *Hook) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Hook) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Hookbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Hookno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'a': - - if bytes.Equal(ffj_key_Hook_Args, kn) { - currentKey = ffj_t_Hook_Args - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'e': - - if bytes.Equal(ffj_key_Hook_Env, kn) { - currentKey = ffj_t_Hook_Env - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'p': - - if bytes.Equal(ffj_key_Hook_Path, kn) { - currentKey = ffj_t_Hook_Path - state = fflib.FFParse_want_colon - goto mainparse - } - - case 't': - - if bytes.Equal(ffj_key_Hook_Timeout, kn) { - currentKey = ffj_t_Hook_Timeout - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.SimpleLetterEqualFold(ffj_key_Hook_Timeout, kn) { - currentKey = ffj_t_Hook_Timeout - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Hook_Env, kn) { - currentKey = ffj_t_Hook_Env - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Hook_Args, kn) { - currentKey = ffj_t_Hook_Args - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Hook_Path, kn) { - currentKey = ffj_t_Hook_Path - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Hookno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Hook_Path: - goto handle_Path - - case ffj_t_Hook_Args: - goto handle_Args - - case ffj_t_Hook_Env: - goto handle_Env - - case ffj_t_Hook_Timeout: - goto handle_Timeout - - case ffj_t_Hookno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Path: - - /* handler: uj.Path type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Path = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Args: - - /* handler: uj.Args type=[]string kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Args = nil - } else { - - uj.Args = make([]string, 0) - - wantVal := true - - for { - - var tmp_uj__Args string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Args type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmp_uj__Args = string(string(outBuf)) - - } - } - - uj.Args = append(uj.Args, tmp_uj__Args) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Env: - - /* handler: uj.Env type=[]string kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Env = nil - } else { - - uj.Env = make([]string, 0) - - wantVal := true - - for { - - var tmp_uj__Env string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Env type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmp_uj__Env = string(string(outBuf)) - - } - } - - uj.Env = append(uj.Env, tmp_uj__Env) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Timeout: - - /* handler: uj.Timeout type=int kind=int quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.Timeout = nil - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := int(tval) - uj.Timeout = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Hooks) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Hooks) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ `) - if len(mj.Prestart) != 0 { - buf.WriteString(`"prestart":`) - if mj.Prestart != nil { - buf.WriteString(`[`) - for i, v := range mj.Prestart { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(mj.Poststart) != 0 { - buf.WriteString(`"poststart":`) - if mj.Poststart != nil { - buf.WriteString(`[`) - for i, v := range mj.Poststart { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(mj.Poststop) != 0 { - buf.WriteString(`"poststop":`) - if mj.Poststop != nil { - buf.WriteString(`[`) - for i, v := range mj.Poststop { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Hooksbase = iota - ffj_t_Hooksno_such_key - - ffj_t_Hooks_Prestart - - ffj_t_Hooks_Poststart - - ffj_t_Hooks_Poststop -) - -var ffj_key_Hooks_Prestart = []byte("prestart") - -var ffj_key_Hooks_Poststart = []byte("poststart") - -var ffj_key_Hooks_Poststop = []byte("poststop") - -func (uj *Hooks) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Hooks) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Hooksbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Hooksno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'p': - - if bytes.Equal(ffj_key_Hooks_Prestart, kn) { - currentKey = ffj_t_Hooks_Prestart - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_Hooks_Poststart, kn) { - currentKey = ffj_t_Hooks_Poststart - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_Hooks_Poststop, kn) { - currentKey = ffj_t_Hooks_Poststop - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffj_key_Hooks_Poststop, kn) { - currentKey = ffj_t_Hooks_Poststop - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Hooks_Poststart, kn) { - currentKey = ffj_t_Hooks_Poststart - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Hooks_Prestart, kn) { - currentKey = ffj_t_Hooks_Prestart - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Hooksno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Hooks_Prestart: - goto handle_Prestart - - case ffj_t_Hooks_Poststart: - goto handle_Poststart - - case ffj_t_Hooks_Poststop: - goto handle_Poststop - - case ffj_t_Hooksno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Prestart: - - /* handler: uj.Prestart type=[]specs.Hook kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Prestart = nil - } else { - - uj.Prestart = make([]Hook, 0) - - wantVal := true - - for { - - var tmp_uj__Prestart Hook - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Prestart type=specs.Hook kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__Prestart.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.Prestart = append(uj.Prestart, tmp_uj__Prestart) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Poststart: - - /* handler: uj.Poststart type=[]specs.Hook kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Poststart = nil - } else { - - uj.Poststart = make([]Hook, 0) - - wantVal := true - - for { - - var tmp_uj__Poststart Hook - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Poststart type=specs.Hook kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__Poststart.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.Poststart = append(uj.Poststart, tmp_uj__Poststart) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Poststop: - - /* handler: uj.Poststop type=[]specs.Hook kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Poststop = nil - } else { - - uj.Poststop = make([]Hook, 0) - - wantVal := true - - for { - - var tmp_uj__Poststop Hook - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Poststop type=specs.Hook kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__Poststop.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.Poststop = append(uj.Poststop, tmp_uj__Poststop) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *HugepageLimit) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *HugepageLimit) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ `) - if mj.Pagesize != nil { - if true { - buf.WriteString(`"pageSize":`) - fflib.WriteJsonString(buf, string(*mj.Pagesize)) - buf.WriteByte(',') - } - } - if mj.Limit != nil { - if true { - buf.WriteString(`"limit":`) - fflib.FormatBits2(buf, uint64(*mj.Limit), 10, false) - buf.WriteByte(',') - } - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_HugepageLimitbase = iota - ffj_t_HugepageLimitno_such_key - - ffj_t_HugepageLimit_Pagesize - - ffj_t_HugepageLimit_Limit -) - -var ffj_key_HugepageLimit_Pagesize = []byte("pageSize") - -var ffj_key_HugepageLimit_Limit = []byte("limit") - -func (uj *HugepageLimit) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *HugepageLimit) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_HugepageLimitbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_HugepageLimitno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'l': - - if bytes.Equal(ffj_key_HugepageLimit_Limit, kn) { - currentKey = ffj_t_HugepageLimit_Limit - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'p': - - if bytes.Equal(ffj_key_HugepageLimit_Pagesize, kn) { - currentKey = ffj_t_HugepageLimit_Pagesize - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.SimpleLetterEqualFold(ffj_key_HugepageLimit_Limit, kn) { - currentKey = ffj_t_HugepageLimit_Limit - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_HugepageLimit_Pagesize, kn) { - currentKey = ffj_t_HugepageLimit_Pagesize - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_HugepageLimitno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_HugepageLimit_Pagesize: - goto handle_Pagesize - - case ffj_t_HugepageLimit_Limit: - goto handle_Limit - - case ffj_t_HugepageLimitno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Pagesize: - - /* handler: uj.Pagesize type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - uj.Pagesize = nil - - } else { - - var tval string - outBuf := fs.Output.Bytes() - - tval = string(string(outBuf)) - uj.Pagesize = &tval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Limit: - - /* handler: uj.Limit type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.Limit = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint64(tval) - uj.Limit = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *IDMapping) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *IDMapping) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{"hostID":`) - fflib.FormatBits2(buf, uint64(mj.HostID), 10, false) - buf.WriteString(`,"containerID":`) - fflib.FormatBits2(buf, uint64(mj.ContainerID), 10, false) - buf.WriteString(`,"size":`) - fflib.FormatBits2(buf, uint64(mj.Size), 10, false) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_IDMappingbase = iota - ffj_t_IDMappingno_such_key - - ffj_t_IDMapping_HostID - - ffj_t_IDMapping_ContainerID - - ffj_t_IDMapping_Size -) - -var ffj_key_IDMapping_HostID = []byte("hostID") - -var ffj_key_IDMapping_ContainerID = []byte("containerID") - -var ffj_key_IDMapping_Size = []byte("size") - -func (uj *IDMapping) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *IDMapping) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_IDMappingbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_IDMappingno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'c': - - if bytes.Equal(ffj_key_IDMapping_ContainerID, kn) { - currentKey = ffj_t_IDMapping_ContainerID - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'h': - - if bytes.Equal(ffj_key_IDMapping_HostID, kn) { - currentKey = ffj_t_IDMapping_HostID - state = fflib.FFParse_want_colon - goto mainparse - } - - case 's': - - if bytes.Equal(ffj_key_IDMapping_Size, kn) { - currentKey = ffj_t_IDMapping_Size - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffj_key_IDMapping_Size, kn) { - currentKey = ffj_t_IDMapping_Size - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_IDMapping_ContainerID, kn) { - currentKey = ffj_t_IDMapping_ContainerID - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_IDMapping_HostID, kn) { - currentKey = ffj_t_IDMapping_HostID - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_IDMappingno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_IDMapping_HostID: - goto handle_HostID - - case ffj_t_IDMapping_ContainerID: - goto handle_ContainerID - - case ffj_t_IDMapping_Size: - goto handle_Size - - case ffj_t_IDMappingno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_HostID: - - /* handler: uj.HostID type=uint32 kind=uint32 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint32", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 32) - - if err != nil { - return fs.WrapErr(err) - } - - uj.HostID = uint32(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_ContainerID: - - /* handler: uj.ContainerID type=uint32 kind=uint32 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint32", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 32) - - if err != nil { - return fs.WrapErr(err) - } - - uj.ContainerID = uint32(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Size: - - /* handler: uj.Size type=uint32 kind=uint32 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint32", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 32) - - if err != nil { - return fs.WrapErr(err) - } - - uj.Size = uint32(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *InterfacePriority) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *InterfacePriority) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{"name":`) - fflib.WriteJsonString(buf, string(mj.Name)) - buf.WriteString(`,"priority":`) - fflib.FormatBits2(buf, uint64(mj.Priority), 10, false) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_InterfacePrioritybase = iota - ffj_t_InterfacePriorityno_such_key - - ffj_t_InterfacePriority_Name - - ffj_t_InterfacePriority_Priority -) - -var ffj_key_InterfacePriority_Name = []byte("name") - -var ffj_key_InterfacePriority_Priority = []byte("priority") - -func (uj *InterfacePriority) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *InterfacePriority) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_InterfacePrioritybase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_InterfacePriorityno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'n': - - if bytes.Equal(ffj_key_InterfacePriority_Name, kn) { - currentKey = ffj_t_InterfacePriority_Name - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'p': - - if bytes.Equal(ffj_key_InterfacePriority_Priority, kn) { - currentKey = ffj_t_InterfacePriority_Priority - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.SimpleLetterEqualFold(ffj_key_InterfacePriority_Priority, kn) { - currentKey = ffj_t_InterfacePriority_Priority - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_InterfacePriority_Name, kn) { - currentKey = ffj_t_InterfacePriority_Name - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_InterfacePriorityno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_InterfacePriority_Name: - goto handle_Name - - case ffj_t_InterfacePriority_Priority: - goto handle_Priority - - case ffj_t_InterfacePriorityno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Name: - - /* handler: uj.Name type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Name = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Priority: - - /* handler: uj.Priority type=uint32 kind=uint32 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint32", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 32) - - if err != nil { - return fs.WrapErr(err) - } - - uj.Priority = uint32(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Linux) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Linux) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ `) - if len(mj.UIDMappings) != 0 { - buf.WriteString(`"uidMappings":`) - if mj.UIDMappings != nil { - buf.WriteString(`[`) - for i, v := range mj.UIDMappings { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(mj.GIDMappings) != 0 { - buf.WriteString(`"gidMappings":`) - if mj.GIDMappings != nil { - buf.WriteString(`[`) - for i, v := range mj.GIDMappings { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(mj.Sysctl) != 0 { - if mj.Sysctl == nil { - buf.WriteString(`"sysctl":null`) - } else { - buf.WriteString(`"sysctl":{ `) - for key, value := range mj.Sysctl { - fflib.WriteJsonString(buf, key) - buf.WriteString(`:`) - fflib.WriteJsonString(buf, string(value)) - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - } - buf.WriteByte(',') - } - if mj.Resources != nil { - if true { - buf.WriteString(`"resources":`) - - { - - err = mj.Resources.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - buf.WriteByte(',') - } - } - if mj.CgroupsPath != nil { - if true { - buf.WriteString(`"cgroupsPath":`) - fflib.WriteJsonString(buf, string(*mj.CgroupsPath)) - buf.WriteByte(',') - } - } - if len(mj.Namespaces) != 0 { - buf.WriteString(`"namespaces":`) - if mj.Namespaces != nil { - buf.WriteString(`[`) - for i, v := range mj.Namespaces { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(mj.Devices) != 0 { - buf.WriteString(`"devices":`) - if mj.Devices != nil { - buf.WriteString(`[`) - for i, v := range mj.Devices { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if mj.Seccomp != nil { - if true { - buf.WriteString(`"seccomp":`) - - { - - err = mj.Seccomp.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - buf.WriteByte(',') - } - } - if len(mj.RootfsPropagation) != 0 { - buf.WriteString(`"rootfsPropagation":`) - fflib.WriteJsonString(buf, string(mj.RootfsPropagation)) - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Linuxbase = iota - ffj_t_Linuxno_such_key - - ffj_t_Linux_UIDMappings - - ffj_t_Linux_GIDMappings - - ffj_t_Linux_Sysctl - - ffj_t_Linux_Resources - - ffj_t_Linux_CgroupsPath - - ffj_t_Linux_Namespaces - - ffj_t_Linux_Devices - - ffj_t_Linux_Seccomp - - ffj_t_Linux_RootfsPropagation -) - -var ffj_key_Linux_UIDMappings = []byte("uidMappings") - -var ffj_key_Linux_GIDMappings = []byte("gidMappings") - -var ffj_key_Linux_Sysctl = []byte("sysctl") - -var ffj_key_Linux_Resources = []byte("resources") - -var ffj_key_Linux_CgroupsPath = []byte("cgroupsPath") - -var ffj_key_Linux_Namespaces = []byte("namespaces") - -var ffj_key_Linux_Devices = []byte("devices") - -var ffj_key_Linux_Seccomp = []byte("seccomp") - -var ffj_key_Linux_RootfsPropagation = []byte("rootfsPropagation") - -func (uj *Linux) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Linux) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Linuxbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Linuxno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'c': - - if bytes.Equal(ffj_key_Linux_CgroupsPath, kn) { - currentKey = ffj_t_Linux_CgroupsPath - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'd': - - if bytes.Equal(ffj_key_Linux_Devices, kn) { - currentKey = ffj_t_Linux_Devices - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'g': - - if bytes.Equal(ffj_key_Linux_GIDMappings, kn) { - currentKey = ffj_t_Linux_GIDMappings - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'n': - - if bytes.Equal(ffj_key_Linux_Namespaces, kn) { - currentKey = ffj_t_Linux_Namespaces - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'r': - - if bytes.Equal(ffj_key_Linux_Resources, kn) { - currentKey = ffj_t_Linux_Resources - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_Linux_RootfsPropagation, kn) { - currentKey = ffj_t_Linux_RootfsPropagation - state = fflib.FFParse_want_colon - goto mainparse - } - - case 's': - - if bytes.Equal(ffj_key_Linux_Sysctl, kn) { - currentKey = ffj_t_Linux_Sysctl - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_Linux_Seccomp, kn) { - currentKey = ffj_t_Linux_Seccomp - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'u': - - if bytes.Equal(ffj_key_Linux_UIDMappings, kn) { - currentKey = ffj_t_Linux_UIDMappings - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffj_key_Linux_RootfsPropagation, kn) { - currentKey = ffj_t_Linux_RootfsPropagation - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Linux_Seccomp, kn) { - currentKey = ffj_t_Linux_Seccomp - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Linux_Devices, kn) { - currentKey = ffj_t_Linux_Devices - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Linux_Namespaces, kn) { - currentKey = ffj_t_Linux_Namespaces - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Linux_CgroupsPath, kn) { - currentKey = ffj_t_Linux_CgroupsPath - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Linux_Resources, kn) { - currentKey = ffj_t_Linux_Resources - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Linux_Sysctl, kn) { - currentKey = ffj_t_Linux_Sysctl - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Linux_GIDMappings, kn) { - currentKey = ffj_t_Linux_GIDMappings - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Linux_UIDMappings, kn) { - currentKey = ffj_t_Linux_UIDMappings - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Linuxno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Linux_UIDMappings: - goto handle_UIDMappings - - case ffj_t_Linux_GIDMappings: - goto handle_GIDMappings - - case ffj_t_Linux_Sysctl: - goto handle_Sysctl - - case ffj_t_Linux_Resources: - goto handle_Resources - - case ffj_t_Linux_CgroupsPath: - goto handle_CgroupsPath - - case ffj_t_Linux_Namespaces: - goto handle_Namespaces - - case ffj_t_Linux_Devices: - goto handle_Devices - - case ffj_t_Linux_Seccomp: - goto handle_Seccomp - - case ffj_t_Linux_RootfsPropagation: - goto handle_RootfsPropagation - - case ffj_t_Linuxno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_UIDMappings: - - /* handler: uj.UIDMappings type=[]specs.IDMapping kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.UIDMappings = nil - } else { - - uj.UIDMappings = make([]IDMapping, 0) - - wantVal := true - - for { - - var tmp_uj__UIDMappings IDMapping - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__UIDMappings type=specs.IDMapping kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__UIDMappings.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.UIDMappings = append(uj.UIDMappings, tmp_uj__UIDMappings) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_GIDMappings: - - /* handler: uj.GIDMappings type=[]specs.IDMapping kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.GIDMappings = nil - } else { - - uj.GIDMappings = make([]IDMapping, 0) - - wantVal := true - - for { - - var tmp_uj__GIDMappings IDMapping - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__GIDMappings type=specs.IDMapping kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__GIDMappings.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.GIDMappings = append(uj.GIDMappings, tmp_uj__GIDMappings) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Sysctl: - - /* handler: uj.Sysctl type=map[string]string kind=map quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_bracket && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Sysctl = nil - } else { - - uj.Sysctl = make(map[string]string, 0) - - wantVal := true - - for { - - var k string - - var tmp_uj__Sysctl string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_bracket { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: k type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - k = string(string(outBuf)) - - } - } - - // Expect ':' after key - tok = fs.Scan() - if tok != fflib.FFTok_colon { - return fs.WrapErr(fmt.Errorf("wanted colon token, but got token: %v", tok)) - } - - tok = fs.Scan() - /* handler: tmp_uj__Sysctl type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmp_uj__Sysctl = string(string(outBuf)) - - } - } - - uj.Sysctl[k] = tmp_uj__Sysctl - - wantVal = false - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Resources: - - /* handler: uj.Resources type=specs.Resources kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - uj.Resources = nil - - state = fflib.FFParse_after_value - goto mainparse - } - - if uj.Resources == nil { - uj.Resources = new(Resources) - } - - err = uj.Resources.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_CgroupsPath: - - /* handler: uj.CgroupsPath type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - uj.CgroupsPath = nil - - } else { - - var tval string - outBuf := fs.Output.Bytes() - - tval = string(string(outBuf)) - uj.CgroupsPath = &tval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Namespaces: - - /* handler: uj.Namespaces type=[]specs.Namespace kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Namespaces = nil - } else { - - uj.Namespaces = make([]Namespace, 0) - - wantVal := true - - for { - - var tmp_uj__Namespaces Namespace - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Namespaces type=specs.Namespace kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__Namespaces.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.Namespaces = append(uj.Namespaces, tmp_uj__Namespaces) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Devices: - - /* handler: uj.Devices type=[]specs.Device kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Devices = nil - } else { - - uj.Devices = make([]Device, 0) - - wantVal := true - - for { - - var tmp_uj__Devices Device - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Devices type=specs.Device kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__Devices.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.Devices = append(uj.Devices, tmp_uj__Devices) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Seccomp: - - /* handler: uj.Seccomp type=specs.Seccomp kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - uj.Seccomp = nil - - state = fflib.FFParse_after_value - goto mainparse - } - - if uj.Seccomp == nil { - uj.Seccomp = new(Seccomp) - } - - err = uj.Seccomp.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_RootfsPropagation: - - /* handler: uj.RootfsPropagation type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.RootfsPropagation = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Memory) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Memory) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ `) - if mj.Limit != nil { - if true { - buf.WriteString(`"limit":`) - fflib.FormatBits2(buf, uint64(*mj.Limit), 10, false) - buf.WriteByte(',') - } - } - if mj.Reservation != nil { - if true { - buf.WriteString(`"reservation":`) - fflib.FormatBits2(buf, uint64(*mj.Reservation), 10, false) - buf.WriteByte(',') - } - } - if mj.Swap != nil { - if true { - buf.WriteString(`"swap":`) - fflib.FormatBits2(buf, uint64(*mj.Swap), 10, false) - buf.WriteByte(',') - } - } - if mj.Kernel != nil { - if true { - buf.WriteString(`"kernel":`) - fflib.FormatBits2(buf, uint64(*mj.Kernel), 10, false) - buf.WriteByte(',') - } - } - if mj.KernelTCP != nil { - buf.WriteString(`"kernelTCP":`) - fflib.FormatBits2(buf, uint64(*mj.KernelTCP), 10, false) - } else { - buf.WriteString(`"kernelTCP":null`) - } - buf.WriteByte(',') - if mj.Swappiness != nil { - if true { - buf.WriteString(`"swappiness":`) - fflib.FormatBits2(buf, uint64(*mj.Swappiness), 10, false) - buf.WriteByte(',') - } - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Memorybase = iota - ffj_t_Memoryno_such_key - - ffj_t_Memory_Limit - - ffj_t_Memory_Reservation - - ffj_t_Memory_Swap - - ffj_t_Memory_Kernel - - ffj_t_Memory_KernelTCP - - ffj_t_Memory_Swappiness -) - -var ffj_key_Memory_Limit = []byte("limit") - -var ffj_key_Memory_Reservation = []byte("reservation") - -var ffj_key_Memory_Swap = []byte("swap") - -var ffj_key_Memory_Kernel = []byte("kernel") - -var ffj_key_Memory_KernelTCP = []byte("kernelTCP") - -var ffj_key_Memory_Swappiness = []byte("swappiness") - -func (uj *Memory) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Memory) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Memorybase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Memoryno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'k': - - if bytes.Equal(ffj_key_Memory_Kernel, kn) { - currentKey = ffj_t_Memory_Kernel - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_Memory_KernelTCP, kn) { - currentKey = ffj_t_Memory_KernelTCP - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'l': - - if bytes.Equal(ffj_key_Memory_Limit, kn) { - currentKey = ffj_t_Memory_Limit - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'r': - - if bytes.Equal(ffj_key_Memory_Reservation, kn) { - currentKey = ffj_t_Memory_Reservation - state = fflib.FFParse_want_colon - goto mainparse - } - - case 's': - - if bytes.Equal(ffj_key_Memory_Swap, kn) { - currentKey = ffj_t_Memory_Swap - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_Memory_Swappiness, kn) { - currentKey = ffj_t_Memory_Swappiness - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffj_key_Memory_Swappiness, kn) { - currentKey = ffj_t_Memory_Swappiness - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Memory_KernelTCP, kn) { - currentKey = ffj_t_Memory_KernelTCP - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Memory_Kernel, kn) { - currentKey = ffj_t_Memory_Kernel - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Memory_Swap, kn) { - currentKey = ffj_t_Memory_Swap - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Memory_Reservation, kn) { - currentKey = ffj_t_Memory_Reservation - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Memory_Limit, kn) { - currentKey = ffj_t_Memory_Limit - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Memoryno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Memory_Limit: - goto handle_Limit - - case ffj_t_Memory_Reservation: - goto handle_Reservation - - case ffj_t_Memory_Swap: - goto handle_Swap - - case ffj_t_Memory_Kernel: - goto handle_Kernel - - case ffj_t_Memory_KernelTCP: - goto handle_KernelTCP - - case ffj_t_Memory_Swappiness: - goto handle_Swappiness - - case ffj_t_Memoryno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Limit: - - /* handler: uj.Limit type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.Limit = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint64(tval) - uj.Limit = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Reservation: - - /* handler: uj.Reservation type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.Reservation = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint64(tval) - uj.Reservation = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Swap: - - /* handler: uj.Swap type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.Swap = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint64(tval) - uj.Swap = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Kernel: - - /* handler: uj.Kernel type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.Kernel = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint64(tval) - uj.Kernel = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_KernelTCP: - - /* handler: uj.KernelTCP type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.KernelTCP = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint64(tval) - uj.KernelTCP = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Swappiness: - - /* handler: uj.Swappiness type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.Swappiness = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint64(tval) - uj.Swappiness = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Mount) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Mount) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ "destination":`) - fflib.WriteJsonString(buf, string(mj.Destination)) - buf.WriteString(`,"type":`) - fflib.WriteJsonString(buf, string(mj.Type)) - buf.WriteString(`,"source":`) - fflib.WriteJsonString(buf, string(mj.Source)) - buf.WriteByte(',') - if len(mj.Options) != 0 { - buf.WriteString(`"options":`) - if mj.Options != nil { - buf.WriteString(`[`) - for i, v := range mj.Options { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Mountbase = iota - ffj_t_Mountno_such_key - - ffj_t_Mount_Destination - - ffj_t_Mount_Type - - ffj_t_Mount_Source - - ffj_t_Mount_Options -) - -var ffj_key_Mount_Destination = []byte("destination") - -var ffj_key_Mount_Type = []byte("type") - -var ffj_key_Mount_Source = []byte("source") - -var ffj_key_Mount_Options = []byte("options") - -func (uj *Mount) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Mount) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Mountbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Mountno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'd': - - if bytes.Equal(ffj_key_Mount_Destination, kn) { - currentKey = ffj_t_Mount_Destination - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'o': - - if bytes.Equal(ffj_key_Mount_Options, kn) { - currentKey = ffj_t_Mount_Options - state = fflib.FFParse_want_colon - goto mainparse - } - - case 's': - - if bytes.Equal(ffj_key_Mount_Source, kn) { - currentKey = ffj_t_Mount_Source - state = fflib.FFParse_want_colon - goto mainparse - } - - case 't': - - if bytes.Equal(ffj_key_Mount_Type, kn) { - currentKey = ffj_t_Mount_Type - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffj_key_Mount_Options, kn) { - currentKey = ffj_t_Mount_Options - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Mount_Source, kn) { - currentKey = ffj_t_Mount_Source - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Mount_Type, kn) { - currentKey = ffj_t_Mount_Type - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Mount_Destination, kn) { - currentKey = ffj_t_Mount_Destination - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Mountno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Mount_Destination: - goto handle_Destination - - case ffj_t_Mount_Type: - goto handle_Type - - case ffj_t_Mount_Source: - goto handle_Source - - case ffj_t_Mount_Options: - goto handle_Options - - case ffj_t_Mountno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Destination: - - /* handler: uj.Destination type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Destination = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Type: - - /* handler: uj.Type type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Type = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Source: - - /* handler: uj.Source type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Source = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Options: - - /* handler: uj.Options type=[]string kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Options = nil - } else { - - uj.Options = make([]string, 0) - - wantVal := true - - for { - - var tmp_uj__Options string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Options type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmp_uj__Options = string(string(outBuf)) - - } - } - - uj.Options = append(uj.Options, tmp_uj__Options) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Namespace) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Namespace) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ "type":`) - fflib.WriteJsonString(buf, string(mj.Type)) - buf.WriteByte(',') - if len(mj.Path) != 0 { - buf.WriteString(`"path":`) - fflib.WriteJsonString(buf, string(mj.Path)) - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Namespacebase = iota - ffj_t_Namespaceno_such_key - - ffj_t_Namespace_Type - - ffj_t_Namespace_Path -) - -var ffj_key_Namespace_Type = []byte("type") - -var ffj_key_Namespace_Path = []byte("path") - -func (uj *Namespace) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Namespace) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Namespacebase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Namespaceno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'p': - - if bytes.Equal(ffj_key_Namespace_Path, kn) { - currentKey = ffj_t_Namespace_Path - state = fflib.FFParse_want_colon - goto mainparse - } - - case 't': - - if bytes.Equal(ffj_key_Namespace_Type, kn) { - currentKey = ffj_t_Namespace_Type - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.SimpleLetterEqualFold(ffj_key_Namespace_Path, kn) { - currentKey = ffj_t_Namespace_Path - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Namespace_Type, kn) { - currentKey = ffj_t_Namespace_Type - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Namespaceno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Namespace_Type: - goto handle_Type - - case ffj_t_Namespace_Path: - goto handle_Path - - case ffj_t_Namespaceno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Type: - - /* handler: uj.Type type=specs.NamespaceType kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for NamespaceType", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Type = NamespaceType(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Path: - - /* handler: uj.Path type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Path = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Network) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Network) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - if mj.ClassID != nil { - buf.WriteString(`{ "classID":`) - fflib.FormatBits2(buf, uint64(*mj.ClassID), 10, false) - } else { - buf.WriteString(`{ "classID":null`) - } - buf.WriteByte(',') - if len(mj.Priorities) != 0 { - buf.WriteString(`"priorities":`) - if mj.Priorities != nil { - buf.WriteString(`[`) - for i, v := range mj.Priorities { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Networkbase = iota - ffj_t_Networkno_such_key - - ffj_t_Network_ClassID - - ffj_t_Network_Priorities -) - -var ffj_key_Network_ClassID = []byte("classID") - -var ffj_key_Network_Priorities = []byte("priorities") - -func (uj *Network) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Network) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Networkbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Networkno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'c': - - if bytes.Equal(ffj_key_Network_ClassID, kn) { - currentKey = ffj_t_Network_ClassID - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'p': - - if bytes.Equal(ffj_key_Network_Priorities, kn) { - currentKey = ffj_t_Network_Priorities - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffj_key_Network_Priorities, kn) { - currentKey = ffj_t_Network_Priorities - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Network_ClassID, kn) { - currentKey = ffj_t_Network_ClassID - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Networkno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Network_ClassID: - goto handle_ClassID - - case ffj_t_Network_Priorities: - goto handle_Priorities - - case ffj_t_Networkno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_ClassID: - - /* handler: uj.ClassID type=uint32 kind=uint32 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint32", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.ClassID = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 32) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint32(tval) - uj.ClassID = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Priorities: - - /* handler: uj.Priorities type=[]specs.InterfacePriority kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Priorities = nil - } else { - - uj.Priorities = make([]InterfacePriority, 0) - - wantVal := true - - for { - - var tmp_uj__Priorities InterfacePriority - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Priorities type=specs.InterfacePriority kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__Priorities.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.Priorities = append(uj.Priorities, tmp_uj__Priorities) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Pids) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Pids) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ `) - if mj.Limit != nil { - if true { - buf.WriteString(`"limit":`) - fflib.FormatBits2(buf, uint64(*mj.Limit), 10, *mj.Limit < 0) - buf.WriteByte(',') - } - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Pidsbase = iota - ffj_t_Pidsno_such_key - - ffj_t_Pids_Limit -) - -var ffj_key_Pids_Limit = []byte("limit") - -func (uj *Pids) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Pids) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Pidsbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Pidsno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'l': - - if bytes.Equal(ffj_key_Pids_Limit, kn) { - currentKey = ffj_t_Pids_Limit - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.SimpleLetterEqualFold(ffj_key_Pids_Limit, kn) { - currentKey = ffj_t_Pids_Limit - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Pidsno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Pids_Limit: - goto handle_Limit - - case ffj_t_Pidsno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Limit: - - /* handler: uj.Limit type=int64 kind=int64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.Limit = nil - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := int64(tval) - uj.Limit = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Platform) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Platform) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{"os":`) - fflib.WriteJsonString(buf, string(mj.OS)) - buf.WriteString(`,"arch":`) - fflib.WriteJsonString(buf, string(mj.Arch)) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Platformbase = iota - ffj_t_Platformno_such_key - - ffj_t_Platform_OS - - ffj_t_Platform_Arch -) - -var ffj_key_Platform_OS = []byte("os") - -var ffj_key_Platform_Arch = []byte("arch") - -func (uj *Platform) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Platform) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Platformbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Platformno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'a': - - if bytes.Equal(ffj_key_Platform_Arch, kn) { - currentKey = ffj_t_Platform_Arch - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'o': - - if bytes.Equal(ffj_key_Platform_OS, kn) { - currentKey = ffj_t_Platform_OS - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.SimpleLetterEqualFold(ffj_key_Platform_Arch, kn) { - currentKey = ffj_t_Platform_Arch - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Platform_OS, kn) { - currentKey = ffj_t_Platform_OS - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Platformno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Platform_OS: - goto handle_OS - - case ffj_t_Platform_Arch: - goto handle_Arch - - case ffj_t_Platformno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_OS: - - /* handler: uj.OS type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.OS = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Arch: - - /* handler: uj.Arch type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Arch = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Process) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Process) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - if mj.Terminal { - buf.WriteString(`{ "terminal":true`) - } else { - buf.WriteString(`{ "terminal":false`) - } - buf.WriteString(`,"user":`) - - { - - err = mj.User.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - buf.WriteString(`,"args":`) - if mj.Args != nil { - buf.WriteString(`[`) - for i, v := range mj.Args { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - if len(mj.Env) != 0 { - buf.WriteString(`"env":`) - if mj.Env != nil { - buf.WriteString(`[`) - for i, v := range mj.Env { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - buf.WriteString(`"cwd":`) - fflib.WriteJsonString(buf, string(mj.Cwd)) - buf.WriteByte(',') - if len(mj.Capabilities) != 0 { - buf.WriteString(`"capabilities":`) - if mj.Capabilities != nil { - buf.WriteString(`[`) - for i, v := range mj.Capabilities { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(mj.Rlimits) != 0 { - buf.WriteString(`"rlimits":`) - if mj.Rlimits != nil { - buf.WriteString(`[`) - for i, v := range mj.Rlimits { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if mj.NoNewPrivileges != false { - if mj.NoNewPrivileges { - buf.WriteString(`"noNewPrivileges":true`) - } else { - buf.WriteString(`"noNewPrivileges":false`) - } - buf.WriteByte(',') - } - if len(mj.ApparmorProfile) != 0 { - buf.WriteString(`"apparmorProfile":`) - fflib.WriteJsonString(buf, string(mj.ApparmorProfile)) - buf.WriteByte(',') - } - if len(mj.SelinuxLabel) != 0 { - buf.WriteString(`"selinuxLabel":`) - fflib.WriteJsonString(buf, string(mj.SelinuxLabel)) - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Processbase = iota - ffj_t_Processno_such_key - - ffj_t_Process_Terminal - - ffj_t_Process_User - - ffj_t_Process_Args - - ffj_t_Process_Env - - ffj_t_Process_Cwd - - ffj_t_Process_Capabilities - - ffj_t_Process_Rlimits - - ffj_t_Process_NoNewPrivileges - - ffj_t_Process_ApparmorProfile - - ffj_t_Process_SelinuxLabel -) - -var ffj_key_Process_Terminal = []byte("terminal") - -var ffj_key_Process_User = []byte("user") - -var ffj_key_Process_Args = []byte("args") - -var ffj_key_Process_Env = []byte("env") - -var ffj_key_Process_Cwd = []byte("cwd") - -var ffj_key_Process_Capabilities = []byte("capabilities") - -var ffj_key_Process_Rlimits = []byte("rlimits") - -var ffj_key_Process_NoNewPrivileges = []byte("noNewPrivileges") - -var ffj_key_Process_ApparmorProfile = []byte("apparmorProfile") - -var ffj_key_Process_SelinuxLabel = []byte("selinuxLabel") - -func (uj *Process) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Process) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Processbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Processno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'a': - - if bytes.Equal(ffj_key_Process_Args, kn) { - currentKey = ffj_t_Process_Args - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_Process_ApparmorProfile, kn) { - currentKey = ffj_t_Process_ApparmorProfile - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'c': - - if bytes.Equal(ffj_key_Process_Cwd, kn) { - currentKey = ffj_t_Process_Cwd - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_Process_Capabilities, kn) { - currentKey = ffj_t_Process_Capabilities - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'e': - - if bytes.Equal(ffj_key_Process_Env, kn) { - currentKey = ffj_t_Process_Env - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'n': - - if bytes.Equal(ffj_key_Process_NoNewPrivileges, kn) { - currentKey = ffj_t_Process_NoNewPrivileges - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'r': - - if bytes.Equal(ffj_key_Process_Rlimits, kn) { - currentKey = ffj_t_Process_Rlimits - state = fflib.FFParse_want_colon - goto mainparse - } - - case 's': - - if bytes.Equal(ffj_key_Process_SelinuxLabel, kn) { - currentKey = ffj_t_Process_SelinuxLabel - state = fflib.FFParse_want_colon - goto mainparse - } - - case 't': - - if bytes.Equal(ffj_key_Process_Terminal, kn) { - currentKey = ffj_t_Process_Terminal - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'u': - - if bytes.Equal(ffj_key_Process_User, kn) { - currentKey = ffj_t_Process_User - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffj_key_Process_SelinuxLabel, kn) { - currentKey = ffj_t_Process_SelinuxLabel - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Process_ApparmorProfile, kn) { - currentKey = ffj_t_Process_ApparmorProfile - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Process_NoNewPrivileges, kn) { - currentKey = ffj_t_Process_NoNewPrivileges - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Process_Rlimits, kn) { - currentKey = ffj_t_Process_Rlimits - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Process_Capabilities, kn) { - currentKey = ffj_t_Process_Capabilities - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Process_Cwd, kn) { - currentKey = ffj_t_Process_Cwd - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Process_Env, kn) { - currentKey = ffj_t_Process_Env - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Process_Args, kn) { - currentKey = ffj_t_Process_Args - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Process_User, kn) { - currentKey = ffj_t_Process_User - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Process_Terminal, kn) { - currentKey = ffj_t_Process_Terminal - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Processno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Process_Terminal: - goto handle_Terminal - - case ffj_t_Process_User: - goto handle_User - - case ffj_t_Process_Args: - goto handle_Args - - case ffj_t_Process_Env: - goto handle_Env - - case ffj_t_Process_Cwd: - goto handle_Cwd - - case ffj_t_Process_Capabilities: - goto handle_Capabilities - - case ffj_t_Process_Rlimits: - goto handle_Rlimits - - case ffj_t_Process_NoNewPrivileges: - goto handle_NoNewPrivileges - - case ffj_t_Process_ApparmorProfile: - goto handle_ApparmorProfile - - case ffj_t_Process_SelinuxLabel: - goto handle_SelinuxLabel - - case ffj_t_Processno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Terminal: - - /* handler: uj.Terminal type=bool kind=bool quoted=false*/ - - { - if tok != fflib.FFTok_bool && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for bool", tok)) - } - } - - { - if tok == fflib.FFTok_null { - - } else { - tmpb := fs.Output.Bytes() - - if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { - - uj.Terminal = true - - } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { - - uj.Terminal = false - - } else { - err = errors.New("unexpected bytes for true/false value") - return fs.WrapErr(err) - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_User: - - /* handler: uj.User type=specs.User kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = uj.User.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Args: - - /* handler: uj.Args type=[]string kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Args = nil - } else { - - uj.Args = make([]string, 0) - - wantVal := true - - for { - - var tmp_uj__Args string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Args type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmp_uj__Args = string(string(outBuf)) - - } - } - - uj.Args = append(uj.Args, tmp_uj__Args) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Env: - - /* handler: uj.Env type=[]string kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Env = nil - } else { - - uj.Env = make([]string, 0) - - wantVal := true - - for { - - var tmp_uj__Env string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Env type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmp_uj__Env = string(string(outBuf)) - - } - } - - uj.Env = append(uj.Env, tmp_uj__Env) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Cwd: - - /* handler: uj.Cwd type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Cwd = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Capabilities: - - /* handler: uj.Capabilities type=[]string kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Capabilities = nil - } else { - - uj.Capabilities = make([]string, 0) - - wantVal := true - - for { - - var tmp_uj__Capabilities string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Capabilities type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmp_uj__Capabilities = string(string(outBuf)) - - } - } - - uj.Capabilities = append(uj.Capabilities, tmp_uj__Capabilities) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Rlimits: - - /* handler: uj.Rlimits type=[]specs.Rlimit kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Rlimits = nil - } else { - - uj.Rlimits = make([]Rlimit, 0) - - wantVal := true - - for { - - var tmp_uj__Rlimits Rlimit - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Rlimits type=specs.Rlimit kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__Rlimits.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.Rlimits = append(uj.Rlimits, tmp_uj__Rlimits) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_NoNewPrivileges: - - /* handler: uj.NoNewPrivileges type=bool kind=bool quoted=false*/ - - { - if tok != fflib.FFTok_bool && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for bool", tok)) - } - } - - { - if tok == fflib.FFTok_null { - - } else { - tmpb := fs.Output.Bytes() - - if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { - - uj.NoNewPrivileges = true - - } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { - - uj.NoNewPrivileges = false - - } else { - err = errors.New("unexpected bytes for true/false value") - return fs.WrapErr(err) - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_ApparmorProfile: - - /* handler: uj.ApparmorProfile type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.ApparmorProfile = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_SelinuxLabel: - - /* handler: uj.SelinuxLabel type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.SelinuxLabel = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Resources) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Resources) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ "devices":`) - if mj.Devices != nil { - buf.WriteString(`[`) - for i, v := range mj.Devices { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - if mj.DisableOOMKiller != nil { - if true { - if *mj.DisableOOMKiller { - buf.WriteString(`"disableOOMKiller":true`) - } else { - buf.WriteString(`"disableOOMKiller":false`) - } - buf.WriteByte(',') - } - } - if mj.OOMScoreAdj != nil { - if true { - buf.WriteString(`"oomScoreAdj":`) - fflib.FormatBits2(buf, uint64(*mj.OOMScoreAdj), 10, *mj.OOMScoreAdj < 0) - buf.WriteByte(',') - } - } - if mj.Memory != nil { - if true { - buf.WriteString(`"memory":`) - - { - - err = mj.Memory.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - buf.WriteByte(',') - } - } - if mj.CPU != nil { - if true { - buf.WriteString(`"cpu":`) - - { - - err = mj.CPU.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - buf.WriteByte(',') - } - } - if mj.Pids != nil { - if true { - buf.WriteString(`"pids":`) - - { - - err = mj.Pids.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - buf.WriteByte(',') - } - } - if mj.BlockIO != nil { - if true { - buf.WriteString(`"blockIO":`) - - { - - err = mj.BlockIO.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - buf.WriteByte(',') - } - } - if len(mj.HugepageLimits) != 0 { - buf.WriteString(`"hugepageLimits":`) - if mj.HugepageLimits != nil { - buf.WriteString(`[`) - for i, v := range mj.HugepageLimits { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if mj.Network != nil { - if true { - buf.WriteString(`"network":`) - - { - - err = mj.Network.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - buf.WriteByte(',') - } - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Resourcesbase = iota - ffj_t_Resourcesno_such_key - - ffj_t_Resources_Devices - - ffj_t_Resources_DisableOOMKiller - - ffj_t_Resources_OOMScoreAdj - - ffj_t_Resources_Memory - - ffj_t_Resources_CPU - - ffj_t_Resources_Pids - - ffj_t_Resources_BlockIO - - ffj_t_Resources_HugepageLimits - - ffj_t_Resources_Network -) - -var ffj_key_Resources_Devices = []byte("devices") - -var ffj_key_Resources_DisableOOMKiller = []byte("disableOOMKiller") - -var ffj_key_Resources_OOMScoreAdj = []byte("oomScoreAdj") - -var ffj_key_Resources_Memory = []byte("memory") - -var ffj_key_Resources_CPU = []byte("cpu") - -var ffj_key_Resources_Pids = []byte("pids") - -var ffj_key_Resources_BlockIO = []byte("blockIO") - -var ffj_key_Resources_HugepageLimits = []byte("hugepageLimits") - -var ffj_key_Resources_Network = []byte("network") - -func (uj *Resources) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Resources) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Resourcesbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Resourcesno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'b': - - if bytes.Equal(ffj_key_Resources_BlockIO, kn) { - currentKey = ffj_t_Resources_BlockIO - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'c': - - if bytes.Equal(ffj_key_Resources_CPU, kn) { - currentKey = ffj_t_Resources_CPU - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'd': - - if bytes.Equal(ffj_key_Resources_Devices, kn) { - currentKey = ffj_t_Resources_Devices - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_Resources_DisableOOMKiller, kn) { - currentKey = ffj_t_Resources_DisableOOMKiller - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'h': - - if bytes.Equal(ffj_key_Resources_HugepageLimits, kn) { - currentKey = ffj_t_Resources_HugepageLimits - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'm': - - if bytes.Equal(ffj_key_Resources_Memory, kn) { - currentKey = ffj_t_Resources_Memory - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'n': - - if bytes.Equal(ffj_key_Resources_Network, kn) { - currentKey = ffj_t_Resources_Network - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'o': - - if bytes.Equal(ffj_key_Resources_OOMScoreAdj, kn) { - currentKey = ffj_t_Resources_OOMScoreAdj - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'p': - - if bytes.Equal(ffj_key_Resources_Pids, kn) { - currentKey = ffj_t_Resources_Pids - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffj_key_Resources_Network, kn) { - currentKey = ffj_t_Resources_Network - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Resources_HugepageLimits, kn) { - currentKey = ffj_t_Resources_HugepageLimits - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Resources_BlockIO, kn) { - currentKey = ffj_t_Resources_BlockIO - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Resources_Pids, kn) { - currentKey = ffj_t_Resources_Pids - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Resources_CPU, kn) { - currentKey = ffj_t_Resources_CPU - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Resources_Memory, kn) { - currentKey = ffj_t_Resources_Memory - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Resources_OOMScoreAdj, kn) { - currentKey = ffj_t_Resources_OOMScoreAdj - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Resources_DisableOOMKiller, kn) { - currentKey = ffj_t_Resources_DisableOOMKiller - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Resources_Devices, kn) { - currentKey = ffj_t_Resources_Devices - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Resourcesno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Resources_Devices: - goto handle_Devices - - case ffj_t_Resources_DisableOOMKiller: - goto handle_DisableOOMKiller - - case ffj_t_Resources_OOMScoreAdj: - goto handle_OOMScoreAdj - - case ffj_t_Resources_Memory: - goto handle_Memory - - case ffj_t_Resources_CPU: - goto handle_CPU - - case ffj_t_Resources_Pids: - goto handle_Pids - - case ffj_t_Resources_BlockIO: - goto handle_BlockIO - - case ffj_t_Resources_HugepageLimits: - goto handle_HugepageLimits - - case ffj_t_Resources_Network: - goto handle_Network - - case ffj_t_Resourcesno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Devices: - - /* handler: uj.Devices type=[]specs.DeviceCgroup kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Devices = nil - } else { - - uj.Devices = make([]DeviceCgroup, 0) - - wantVal := true - - for { - - var tmp_uj__Devices DeviceCgroup - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Devices type=specs.DeviceCgroup kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__Devices.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.Devices = append(uj.Devices, tmp_uj__Devices) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_DisableOOMKiller: - - /* handler: uj.DisableOOMKiller type=bool kind=bool quoted=false*/ - - { - if tok != fflib.FFTok_bool && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for bool", tok)) - } - } - - { - if tok == fflib.FFTok_null { - - uj.DisableOOMKiller = nil - - } else { - tmpb := fs.Output.Bytes() - - var tval bool - - if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { - - tval = true - - } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { - - tval = false - - } else { - err = errors.New("unexpected bytes for true/false value") - return fs.WrapErr(err) - } - - uj.DisableOOMKiller = &tval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_OOMScoreAdj: - - /* handler: uj.OOMScoreAdj type=int kind=int quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.OOMScoreAdj = nil - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := int(tval) - uj.OOMScoreAdj = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Memory: - - /* handler: uj.Memory type=specs.Memory kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - uj.Memory = nil - - state = fflib.FFParse_after_value - goto mainparse - } - - if uj.Memory == nil { - uj.Memory = new(Memory) - } - - err = uj.Memory.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_CPU: - - /* handler: uj.CPU type=specs.CPU kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - uj.CPU = nil - - state = fflib.FFParse_after_value - goto mainparse - } - - if uj.CPU == nil { - uj.CPU = new(CPU) - } - - err = uj.CPU.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Pids: - - /* handler: uj.Pids type=specs.Pids kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - uj.Pids = nil - - state = fflib.FFParse_after_value - goto mainparse - } - - if uj.Pids == nil { - uj.Pids = new(Pids) - } - - err = uj.Pids.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_BlockIO: - - /* handler: uj.BlockIO type=specs.BlockIO kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - uj.BlockIO = nil - - state = fflib.FFParse_after_value - goto mainparse - } - - if uj.BlockIO == nil { - uj.BlockIO = new(BlockIO) - } - - err = uj.BlockIO.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_HugepageLimits: - - /* handler: uj.HugepageLimits type=[]specs.HugepageLimit kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.HugepageLimits = nil - } else { - - uj.HugepageLimits = make([]HugepageLimit, 0) - - wantVal := true - - for { - - var tmp_uj__HugepageLimits HugepageLimit - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__HugepageLimits type=specs.HugepageLimit kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__HugepageLimits.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.HugepageLimits = append(uj.HugepageLimits, tmp_uj__HugepageLimits) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Network: - - /* handler: uj.Network type=specs.Network kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - uj.Network = nil - - state = fflib.FFParse_after_value - goto mainparse - } - - if uj.Network == nil { - uj.Network = new(Network) - } - - err = uj.Network.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Rlimit) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Rlimit) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{"type":`) - fflib.WriteJsonString(buf, string(mj.Type)) - buf.WriteString(`,"hard":`) - fflib.FormatBits2(buf, uint64(mj.Hard), 10, false) - buf.WriteString(`,"soft":`) - fflib.FormatBits2(buf, uint64(mj.Soft), 10, false) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Rlimitbase = iota - ffj_t_Rlimitno_such_key - - ffj_t_Rlimit_Type - - ffj_t_Rlimit_Hard - - ffj_t_Rlimit_Soft -) - -var ffj_key_Rlimit_Type = []byte("type") - -var ffj_key_Rlimit_Hard = []byte("hard") - -var ffj_key_Rlimit_Soft = []byte("soft") - -func (uj *Rlimit) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Rlimit) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Rlimitbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Rlimitno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'h': - - if bytes.Equal(ffj_key_Rlimit_Hard, kn) { - currentKey = ffj_t_Rlimit_Hard - state = fflib.FFParse_want_colon - goto mainparse - } - - case 's': - - if bytes.Equal(ffj_key_Rlimit_Soft, kn) { - currentKey = ffj_t_Rlimit_Soft - state = fflib.FFParse_want_colon - goto mainparse - } - - case 't': - - if bytes.Equal(ffj_key_Rlimit_Type, kn) { - currentKey = ffj_t_Rlimit_Type - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffj_key_Rlimit_Soft, kn) { - currentKey = ffj_t_Rlimit_Soft - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Rlimit_Hard, kn) { - currentKey = ffj_t_Rlimit_Hard - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Rlimit_Type, kn) { - currentKey = ffj_t_Rlimit_Type - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Rlimitno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Rlimit_Type: - goto handle_Type - - case ffj_t_Rlimit_Hard: - goto handle_Hard - - case ffj_t_Rlimit_Soft: - goto handle_Soft - - case ffj_t_Rlimitno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Type: - - /* handler: uj.Type type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Type = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Hard: - - /* handler: uj.Hard type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - uj.Hard = uint64(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Soft: - - /* handler: uj.Soft type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - uj.Soft = uint64(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Root) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Root) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{"path":`) - fflib.WriteJsonString(buf, string(mj.Path)) - if mj.Readonly { - buf.WriteString(`,"readonly":true`) - } else { - buf.WriteString(`,"readonly":false`) - } - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Rootbase = iota - ffj_t_Rootno_such_key - - ffj_t_Root_Path - - ffj_t_Root_Readonly -) - -var ffj_key_Root_Path = []byte("path") - -var ffj_key_Root_Readonly = []byte("readonly") - -func (uj *Root) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Root) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Rootbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Rootno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'p': - - if bytes.Equal(ffj_key_Root_Path, kn) { - currentKey = ffj_t_Root_Path - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'r': - - if bytes.Equal(ffj_key_Root_Readonly, kn) { - currentKey = ffj_t_Root_Readonly - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.SimpleLetterEqualFold(ffj_key_Root_Readonly, kn) { - currentKey = ffj_t_Root_Readonly - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Root_Path, kn) { - currentKey = ffj_t_Root_Path - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Rootno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Root_Path: - goto handle_Path - - case ffj_t_Root_Readonly: - goto handle_Readonly - - case ffj_t_Rootno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Path: - - /* handler: uj.Path type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Path = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Readonly: - - /* handler: uj.Readonly type=bool kind=bool quoted=false*/ - - { - if tok != fflib.FFTok_bool && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for bool", tok)) - } - } - - { - if tok == fflib.FFTok_null { - - } else { - tmpb := fs.Output.Bytes() - - if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { - - uj.Readonly = true - - } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { - - uj.Readonly = false - - } else { - err = errors.New("unexpected bytes for true/false value") - return fs.WrapErr(err) - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Seccomp) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Seccomp) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ "defaultAction":`) - fflib.WriteJsonString(buf, string(mj.DefaultAction)) - buf.WriteString(`,"architectures":`) - if mj.Architectures != nil { - buf.WriteString(`[`) - for i, v := range mj.Architectures { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - if len(mj.Syscalls) != 0 { - buf.WriteString(`"syscalls":`) - if mj.Syscalls != nil { - buf.WriteString(`[`) - for i, v := range mj.Syscalls { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Seccompbase = iota - ffj_t_Seccompno_such_key - - ffj_t_Seccomp_DefaultAction - - ffj_t_Seccomp_Architectures - - ffj_t_Seccomp_Syscalls -) - -var ffj_key_Seccomp_DefaultAction = []byte("defaultAction") - -var ffj_key_Seccomp_Architectures = []byte("architectures") - -var ffj_key_Seccomp_Syscalls = []byte("syscalls") - -func (uj *Seccomp) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Seccomp) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Seccompbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Seccompno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'a': - - if bytes.Equal(ffj_key_Seccomp_Architectures, kn) { - currentKey = ffj_t_Seccomp_Architectures - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'd': - - if bytes.Equal(ffj_key_Seccomp_DefaultAction, kn) { - currentKey = ffj_t_Seccomp_DefaultAction - state = fflib.FFParse_want_colon - goto mainparse - } - - case 's': - - if bytes.Equal(ffj_key_Seccomp_Syscalls, kn) { - currentKey = ffj_t_Seccomp_Syscalls - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffj_key_Seccomp_Syscalls, kn) { - currentKey = ffj_t_Seccomp_Syscalls - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Seccomp_Architectures, kn) { - currentKey = ffj_t_Seccomp_Architectures - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Seccomp_DefaultAction, kn) { - currentKey = ffj_t_Seccomp_DefaultAction - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Seccompno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Seccomp_DefaultAction: - goto handle_DefaultAction - - case ffj_t_Seccomp_Architectures: - goto handle_Architectures - - case ffj_t_Seccomp_Syscalls: - goto handle_Syscalls - - case ffj_t_Seccompno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_DefaultAction: - - /* handler: uj.DefaultAction type=specs.Action kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for Action", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.DefaultAction = Action(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Architectures: - - /* handler: uj.Architectures type=[]specs.Arch kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Architectures = nil - } else { - - uj.Architectures = make([]Arch, 0) - - wantVal := true - - for { - - var tmp_uj__Architectures Arch - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Architectures type=specs.Arch kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for Arch", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmp_uj__Architectures = Arch(string(outBuf)) - - } - } - - uj.Architectures = append(uj.Architectures, tmp_uj__Architectures) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Syscalls: - - /* handler: uj.Syscalls type=[]specs.Syscall kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Syscalls = nil - } else { - - uj.Syscalls = make([]Syscall, 0) - - wantVal := true - - for { - - var tmp_uj__Syscalls Syscall - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Syscalls type=specs.Syscall kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__Syscalls.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.Syscalls = append(uj.Syscalls, tmp_uj__Syscalls) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Spec) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Spec) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{"ociVersion":`) - fflib.WriteJsonString(buf, string(mj.Version)) - buf.WriteString(`,"platform":`) - - { - - err = mj.Platform.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - buf.WriteString(`,"process":`) - - { - - err = mj.Process.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - buf.WriteString(`,"root":`) - - { - - err = mj.Root.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - buf.WriteByte(',') - if len(mj.Hostname) != 0 { - buf.WriteString(`"hostname":`) - fflib.WriteJsonString(buf, string(mj.Hostname)) - buf.WriteByte(',') - } - buf.WriteString(`"mounts":`) - if mj.Mounts != nil { - buf.WriteString(`[`) - for i, v := range mj.Mounts { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteString(`,"hooks":`) - - { - - err = mj.Hooks.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - buf.WriteByte(',') - if len(mj.Annotations) != 0 { - if mj.Annotations == nil { - buf.WriteString(`"annotations":null`) - } else { - buf.WriteString(`"annotations":{ `) - for key, value := range mj.Annotations { - fflib.WriteJsonString(buf, key) - buf.WriteString(`:`) - fflib.WriteJsonString(buf, string(value)) - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - } - buf.WriteByte(',') - } - buf.WriteString(`"linux":`) - - { - - err = mj.Linux.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Specbase = iota - ffj_t_Specno_such_key - - ffj_t_Spec_Version - - ffj_t_Spec_Platform - - ffj_t_Spec_Process - - ffj_t_Spec_Root - - ffj_t_Spec_Hostname - - ffj_t_Spec_Mounts - - ffj_t_Spec_Hooks - - ffj_t_Spec_Annotations - - ffj_t_Spec_Linux -) - -var ffj_key_Spec_Version = []byte("ociVersion") - -var ffj_key_Spec_Platform = []byte("platform") - -var ffj_key_Spec_Process = []byte("process") - -var ffj_key_Spec_Root = []byte("root") - -var ffj_key_Spec_Hostname = []byte("hostname") - -var ffj_key_Spec_Mounts = []byte("mounts") - -var ffj_key_Spec_Hooks = []byte("hooks") - -var ffj_key_Spec_Annotations = []byte("annotations") - -var ffj_key_Spec_Linux = []byte("linux") - -func (uj *Spec) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Spec) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Specbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Specno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'a': - - if bytes.Equal(ffj_key_Spec_Annotations, kn) { - currentKey = ffj_t_Spec_Annotations - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'h': - - if bytes.Equal(ffj_key_Spec_Hostname, kn) { - currentKey = ffj_t_Spec_Hostname - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_Spec_Hooks, kn) { - currentKey = ffj_t_Spec_Hooks - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'l': - - if bytes.Equal(ffj_key_Spec_Linux, kn) { - currentKey = ffj_t_Spec_Linux - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'm': - - if bytes.Equal(ffj_key_Spec_Mounts, kn) { - currentKey = ffj_t_Spec_Mounts - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'o': - - if bytes.Equal(ffj_key_Spec_Version, kn) { - currentKey = ffj_t_Spec_Version - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'p': - - if bytes.Equal(ffj_key_Spec_Platform, kn) { - currentKey = ffj_t_Spec_Platform - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_Spec_Process, kn) { - currentKey = ffj_t_Spec_Process - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'r': - - if bytes.Equal(ffj_key_Spec_Root, kn) { - currentKey = ffj_t_Spec_Root - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.SimpleLetterEqualFold(ffj_key_Spec_Linux, kn) { - currentKey = ffj_t_Spec_Linux - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Spec_Annotations, kn) { - currentKey = ffj_t_Spec_Annotations - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Spec_Hooks, kn) { - currentKey = ffj_t_Spec_Hooks - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Spec_Mounts, kn) { - currentKey = ffj_t_Spec_Mounts - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Spec_Hostname, kn) { - currentKey = ffj_t_Spec_Hostname - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Spec_Root, kn) { - currentKey = ffj_t_Spec_Root - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Spec_Process, kn) { - currentKey = ffj_t_Spec_Process - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Spec_Platform, kn) { - currentKey = ffj_t_Spec_Platform - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_Spec_Version, kn) { - currentKey = ffj_t_Spec_Version - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Specno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Spec_Version: - goto handle_Version - - case ffj_t_Spec_Platform: - goto handle_Platform - - case ffj_t_Spec_Process: - goto handle_Process - - case ffj_t_Spec_Root: - goto handle_Root - - case ffj_t_Spec_Hostname: - goto handle_Hostname - - case ffj_t_Spec_Mounts: - goto handle_Mounts - - case ffj_t_Spec_Hooks: - goto handle_Hooks - - case ffj_t_Spec_Annotations: - goto handle_Annotations - - case ffj_t_Spec_Linux: - goto handle_Linux - - case ffj_t_Specno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Version: - - /* handler: uj.Version type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Version = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Platform: - - /* handler: uj.Platform type=specs.Platform kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = uj.Platform.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Process: - - /* handler: uj.Process type=specs.Process kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = uj.Process.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Root: - - /* handler: uj.Root type=specs.Root kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = uj.Root.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Hostname: - - /* handler: uj.Hostname type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Hostname = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Mounts: - - /* handler: uj.Mounts type=[]specs.Mount kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Mounts = nil - } else { - - uj.Mounts = make([]Mount, 0) - - wantVal := true - - for { - - var tmp_uj__Mounts Mount - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Mounts type=specs.Mount kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__Mounts.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.Mounts = append(uj.Mounts, tmp_uj__Mounts) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Hooks: - - /* handler: uj.Hooks type=specs.Hooks kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = uj.Hooks.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Annotations: - - /* handler: uj.Annotations type=map[string]string kind=map quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_bracket && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Annotations = nil - } else { - - uj.Annotations = make(map[string]string, 0) - - wantVal := true - - for { - - var k string - - var tmp_uj__Annotations string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_bracket { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: k type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - k = string(string(outBuf)) - - } - } - - // Expect ':' after key - tok = fs.Scan() - if tok != fflib.FFTok_colon { - return fs.WrapErr(fmt.Errorf("wanted colon token, but got token: %v", tok)) - } - - tok = fs.Scan() - /* handler: tmp_uj__Annotations type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmp_uj__Annotations = string(string(outBuf)) - - } - } - - uj.Annotations[k] = tmp_uj__Annotations - - wantVal = false - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Linux: - - /* handler: uj.Linux type=specs.Linux kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = uj.Linux.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *Syscall) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *Syscall) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ "name":`) - fflib.WriteJsonString(buf, string(mj.Name)) - buf.WriteString(`,"action":`) - fflib.WriteJsonString(buf, string(mj.Action)) - buf.WriteByte(',') - if len(mj.Args) != 0 { - buf.WriteString(`"args":`) - if mj.Args != nil { - buf.WriteString(`[`) - for i, v := range mj.Args { - if i != 0 { - buf.WriteString(`,`) - } - - { - - err = v.MarshalJSONBuf(buf) - if err != nil { - return err - } - - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Syscallbase = iota - ffj_t_Syscallno_such_key - - ffj_t_Syscall_Name - - ffj_t_Syscall_Action - - ffj_t_Syscall_Args -) - -var ffj_key_Syscall_Name = []byte("name") - -var ffj_key_Syscall_Action = []byte("action") - -var ffj_key_Syscall_Args = []byte("args") - -func (uj *Syscall) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *Syscall) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Syscallbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Syscallno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'a': - - if bytes.Equal(ffj_key_Syscall_Action, kn) { - currentKey = ffj_t_Syscall_Action - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_Syscall_Args, kn) { - currentKey = ffj_t_Syscall_Args - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'n': - - if bytes.Equal(ffj_key_Syscall_Name, kn) { - currentKey = ffj_t_Syscall_Name - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffj_key_Syscall_Args, kn) { - currentKey = ffj_t_Syscall_Args - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Syscall_Action, kn) { - currentKey = ffj_t_Syscall_Action - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_Syscall_Name, kn) { - currentKey = ffj_t_Syscall_Name - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Syscallno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_Syscall_Name: - goto handle_Name - - case ffj_t_Syscall_Action: - goto handle_Action - - case ffj_t_Syscall_Args: - goto handle_Args - - case ffj_t_Syscallno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Name: - - /* handler: uj.Name type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Name = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Action: - - /* handler: uj.Action type=specs.Action kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for Action", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Action = Action(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Args: - - /* handler: uj.Args type=[]specs.Arg kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.Args = nil - } else { - - uj.Args = make([]Arg, 0) - - wantVal := true - - for { - - var tmp_uj__Args Arg - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__Args type=specs.Arg kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - state = fflib.FFParse_after_value - goto mainparse - } - - err = tmp_uj__Args.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - state = fflib.FFParse_after_value - } - - uj.Args = append(uj.Args, tmp_uj__Args) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *ThrottleDevice) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *ThrottleDevice) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ `) - if mj.Rate != nil { - if true { - buf.WriteString(`"rate":`) - fflib.FormatBits2(buf, uint64(*mj.Rate), 10, false) - buf.WriteByte(',') - } - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_ThrottleDevicebase = iota - ffj_t_ThrottleDeviceno_such_key - - ffj_t_ThrottleDevice_Rate -) - -var ffj_key_ThrottleDevice_Rate = []byte("rate") - -func (uj *ThrottleDevice) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *ThrottleDevice) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_ThrottleDevicebase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_ThrottleDeviceno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'r': - - if bytes.Equal(ffj_key_ThrottleDevice_Rate, kn) { - currentKey = ffj_t_ThrottleDevice_Rate - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.SimpleLetterEqualFold(ffj_key_ThrottleDevice_Rate, kn) { - currentKey = ffj_t_ThrottleDevice_Rate - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_ThrottleDeviceno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_ThrottleDevice_Rate: - goto handle_Rate - - case ffj_t_ThrottleDeviceno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Rate: - - /* handler: uj.Rate type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.Rate = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint64(tval) - uj.Rate = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *User) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *User) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ `) - if mj.UID != 0 { - buf.WriteString(`"uid":`) - fflib.FormatBits2(buf, uint64(mj.UID), 10, false) - buf.WriteByte(',') - } - if mj.GID != 0 { - buf.WriteString(`"gid":`) - fflib.FormatBits2(buf, uint64(mj.GID), 10, false) - buf.WriteByte(',') - } - if len(mj.AdditionalGids) != 0 { - buf.WriteString(`"additionalGids":`) - if mj.AdditionalGids != nil { - buf.WriteString(`[`) - for i, v := range mj.AdditionalGids { - if i != 0 { - buf.WriteString(`,`) - } - fflib.FormatBits2(buf, uint64(v), 10, false) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Userbase = iota - ffj_t_Userno_such_key - - ffj_t_User_UID - - ffj_t_User_GID - - ffj_t_User_AdditionalGids -) - -var ffj_key_User_UID = []byte("uid") - -var ffj_key_User_GID = []byte("gid") - -var ffj_key_User_AdditionalGids = []byte("additionalGids") - -func (uj *User) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *User) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Userbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Userno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'a': - - if bytes.Equal(ffj_key_User_AdditionalGids, kn) { - currentKey = ffj_t_User_AdditionalGids - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'g': - - if bytes.Equal(ffj_key_User_GID, kn) { - currentKey = ffj_t_User_GID - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'u': - - if bytes.Equal(ffj_key_User_UID, kn) { - currentKey = ffj_t_User_UID - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffj_key_User_AdditionalGids, kn) { - currentKey = ffj_t_User_AdditionalGids - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_User_GID, kn) { - currentKey = ffj_t_User_GID - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_User_UID, kn) { - currentKey = ffj_t_User_UID - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Userno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_User_UID: - goto handle_UID - - case ffj_t_User_GID: - goto handle_GID - - case ffj_t_User_AdditionalGids: - goto handle_AdditionalGids - - case ffj_t_Userno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_UID: - - /* handler: uj.UID type=uint32 kind=uint32 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint32", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 32) - - if err != nil { - return fs.WrapErr(err) - } - - uj.UID = uint32(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_GID: - - /* handler: uj.GID type=uint32 kind=uint32 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint32", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 32) - - if err != nil { - return fs.WrapErr(err) - } - - uj.GID = uint32(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_AdditionalGids: - - /* handler: uj.AdditionalGids type=[]uint32 kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - uj.AdditionalGids = nil - } else { - - uj.AdditionalGids = make([]uint32, 0) - - wantVal := true - - for { - - var tmp_uj__AdditionalGids uint32 - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmp_uj__AdditionalGids type=uint32 kind=uint32 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint32", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 32) - - if err != nil { - return fs.WrapErr(err) - } - - tmp_uj__AdditionalGids = uint32(tval) - - } - } - - uj.AdditionalGids = append(uj.AdditionalGids, tmp_uj__AdditionalGids) - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *WeightDevice) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *WeightDevice) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ `) - if mj.Weight != nil { - if true { - buf.WriteString(`"weight":`) - fflib.FormatBits2(buf, uint64(*mj.Weight), 10, false) - buf.WriteByte(',') - } - } - if mj.LeafWeight != nil { - if true { - buf.WriteString(`"leafWeight":`) - fflib.FormatBits2(buf, uint64(*mj.LeafWeight), 10, false) - buf.WriteByte(',') - } - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_WeightDevicebase = iota - ffj_t_WeightDeviceno_such_key - - ffj_t_WeightDevice_Weight - - ffj_t_WeightDevice_LeafWeight -) - -var ffj_key_WeightDevice_Weight = []byte("weight") - -var ffj_key_WeightDevice_LeafWeight = []byte("leafWeight") - -func (uj *WeightDevice) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *WeightDevice) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_WeightDevicebase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_WeightDeviceno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'l': - - if bytes.Equal(ffj_key_WeightDevice_LeafWeight, kn) { - currentKey = ffj_t_WeightDevice_LeafWeight - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'w': - - if bytes.Equal(ffj_key_WeightDevice_Weight, kn) { - currentKey = ffj_t_WeightDevice_Weight - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.SimpleLetterEqualFold(ffj_key_WeightDevice_LeafWeight, kn) { - currentKey = ffj_t_WeightDevice_LeafWeight - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_WeightDevice_Weight, kn) { - currentKey = ffj_t_WeightDevice_Weight - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_WeightDeviceno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_WeightDevice_Weight: - goto handle_Weight - - case ffj_t_WeightDevice_LeafWeight: - goto handle_LeafWeight - - case ffj_t_WeightDeviceno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Weight: - - /* handler: uj.Weight type=uint16 kind=uint16 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint16", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.Weight = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 16) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint16(tval) - uj.Weight = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_LeafWeight: - - /* handler: uj.LeafWeight type=uint16 kind=uint16 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint16", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - uj.LeafWeight = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 16) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := uint16(tval) - uj.LeafWeight = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} - -func (mj *blockIODevice) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *blockIODevice) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{"major":`) - fflib.FormatBits2(buf, uint64(mj.Major), 10, mj.Major < 0) - buf.WriteString(`,"minor":`) - fflib.FormatBits2(buf, uint64(mj.Minor), 10, mj.Minor < 0) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_blockIODevicebase = iota - ffj_t_blockIODeviceno_such_key - - ffj_t_blockIODevice_Major - - ffj_t_blockIODevice_Minor -) - -var ffj_key_blockIODevice_Major = []byte("major") - -var ffj_key_blockIODevice_Minor = []byte("minor") - -func (uj *blockIODevice) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *blockIODevice) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_blockIODevicebase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_blockIODeviceno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'm': - - if bytes.Equal(ffj_key_blockIODevice_Major, kn) { - currentKey = ffj_t_blockIODevice_Major - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffj_key_blockIODevice_Minor, kn) { - currentKey = ffj_t_blockIODevice_Minor - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.SimpleLetterEqualFold(ffj_key_blockIODevice_Minor, kn) { - currentKey = ffj_t_blockIODevice_Minor - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_blockIODevice_Major, kn) { - currentKey = ffj_t_blockIODevice_Major - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_blockIODeviceno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_blockIODevice_Major: - goto handle_Major - - case ffj_t_blockIODevice_Minor: - goto handle_Minor - - case ffj_t_blockIODeviceno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Major: - - /* handler: uj.Major type=int64 kind=int64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - uj.Major = int64(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Minor: - - /* handler: uj.Minor type=int64 kind=int64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - uj.Minor = int64(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -} diff --git a/Godeps/_workspace/src/github.com/opencontainers/specs/specs-go/state_ffjson.go b/Godeps/_workspace/src/github.com/opencontainers/specs/specs-go/state_ffjson.go deleted file mode 100644 index be3a36ee..00000000 --- a/Godeps/_workspace/src/github.com/opencontainers/specs/specs-go/state_ffjson.go +++ /dev/null @@ -1,351 +0,0 @@ -// DO NOT EDIT! -// Code generated by ffjson -// source: state.go -// DO NOT EDIT! - -package specs - -import ( - "bytes" - "fmt" - fflib "github.com/pquerna/ffjson/fflib/v1" -) - -func (mj *State) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if mj == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := mj.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} -func (mj *State) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if mj == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{"version":`) - fflib.WriteJsonString(buf, string(mj.Version)) - buf.WriteString(`,"id":`) - fflib.WriteJsonString(buf, string(mj.ID)) - buf.WriteString(`,"pid":`) - fflib.FormatBits2(buf, uint64(mj.Pid), 10, mj.Pid < 0) - buf.WriteString(`,"bundlePath":`) - fflib.WriteJsonString(buf, string(mj.BundlePath)) - buf.WriteByte('}') - return nil -} - -const ( - ffj_t_Statebase = iota - ffj_t_Stateno_such_key - - ffj_t_State_Version - - ffj_t_State_ID - - ffj_t_State_Pid - - ffj_t_State_BundlePath -) - -var ffj_key_State_Version = []byte("version") - -var ffj_key_State_ID = []byte("id") - -var ffj_key_State_Pid = []byte("pid") - -var ffj_key_State_BundlePath = []byte("bundlePath") - -func (uj *State) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -func (uj *State) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error = nil - currentKey := ffj_t_Statebase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffj_t_Stateno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'b': - - if bytes.Equal(ffj_key_State_BundlePath, kn) { - currentKey = ffj_t_State_BundlePath - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'i': - - if bytes.Equal(ffj_key_State_ID, kn) { - currentKey = ffj_t_State_ID - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'p': - - if bytes.Equal(ffj_key_State_Pid, kn) { - currentKey = ffj_t_State_Pid - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'v': - - if bytes.Equal(ffj_key_State_Version, kn) { - currentKey = ffj_t_State_Version - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.SimpleLetterEqualFold(ffj_key_State_BundlePath, kn) { - currentKey = ffj_t_State_BundlePath - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_State_Pid, kn) { - currentKey = ffj_t_State_Pid - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffj_key_State_ID, kn) { - currentKey = ffj_t_State_ID - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffj_key_State_Version, kn) { - currentKey = ffj_t_State_Version - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffj_t_Stateno_such_key - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffj_t_State_Version: - goto handle_Version - - case ffj_t_State_ID: - goto handle_ID - - case ffj_t_State_Pid: - goto handle_Pid - - case ffj_t_State_BundlePath: - goto handle_BundlePath - - case ffj_t_Stateno_such_key: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Version: - - /* handler: uj.Version type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.Version = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_ID: - - /* handler: uj.ID type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.ID = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Pid: - - /* handler: uj.Pid type=int kind=int quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - uj.Pid = int(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_BundlePath: - - /* handler: uj.BundlePath type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - uj.BundlePath = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - return nil -}