diff --git a/Makefile b/Makefile index e93e72c4..fe4dd2c8 100644 --- a/Makefile +++ b/Makefile @@ -66,8 +66,8 @@ endif # `go get https://github.com/pquerna/ffjson` ffjson: - cd specs-go/ && ffjson config.go - cd specs-go/ && ffjson state.go + cd specs-go/ && ffjson -force-regenerate config.go + cd specs-go/ && ffjson -force-regenerate state.go clean: rm -rf output/ *~ diff --git a/specs-go/config_ffjson.go b/specs-go/config_ffjson.go index 5e188b8b..36eacc2d 100644 --- a/specs-go/config_ffjson.go +++ b/specs-go/config_ffjson.go @@ -2741,6 +2741,13 @@ func (mj *Hook) MarshalJSONBuf(buf fflib.EncodingBuffer) error { } 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 @@ -2755,6 +2762,8 @@ const ( ffj_t_Hook_Args ffj_t_Hook_Env + + ffj_t_Hook_Timeout ) var ffj_key_Hook_Path = []byte("path") @@ -2763,6 +2772,8 @@ 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) @@ -2846,6 +2857,20 @@ mainparse: 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) { @@ -2892,6 +2917,9 @@ mainparse: 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 { @@ -3078,6 +3106,39 @@ handle_Env: 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: @@ -4476,49 +4537,54 @@ func (mj *Linux) MarshalJSONBuf(buf fflib.EncodingBuffer) error { buf.WriteByte(',') } } - 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 + 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.WriteString(`]`) - } else { - buf.WriteString(`null`) + buf.WriteByte(',') } - 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 + 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.WriteString(`]`) - } else { - buf.WriteString(`null`) + buf.WriteByte(',') } - buf.WriteByte(',') if mj.Seccomp != nil { if true { buf.WriteString(`"seccomp":`)