summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-02-12 11:48:20 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-16 16:46:09 +0000
commitf2041b51f39855f288f8feb486c5726587ebe90a (patch)
treee7b059b851c3cf3b46630f2ef778844322d74765 /libpod
parent445aaf87fae22fb38e68f2bc158e833fa58141bc (diff)
downloadpodman-f2041b51f39855f288f8feb486c5726587ebe90a.tar.gz
podman-f2041b51f39855f288f8feb486c5726587ebe90a.tar.bz2
podman-f2041b51f39855f288f8feb486c5726587ebe90a.zip
Add FFJSON encoding/decoding for our container structs
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #323 Approved by: mheon
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container.go1
-rw-r--r--libpod/container_ffjson.go3278
-rw-r--r--libpod/pod.go1
-rw-r--r--libpod/pod_ffjson.go392
-rw-r--r--libpod/state_test.go64
-rw-r--r--libpod/test_common.go50
6 files changed, 3709 insertions, 77 deletions
diff --git a/libpod/container.go b/libpod/container.go
index 4d28c1b59..d3a58d904 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -88,6 +88,7 @@ func (ns LinuxNS) String() string {
}
// Container is a single OCI container
+// ffjson: skip
type Container struct {
config *ContainerConfig
diff --git a/libpod/container_ffjson.go b/libpod/container_ffjson.go
new file mode 100644
index 000000000..20cf69ba1
--- /dev/null
+++ b/libpod/container_ffjson.go
@@ -0,0 +1,3278 @@
+// Code generated by ffjson <https://github.com/pquerna/ffjson>. DO NOT EDIT.
+// source: libpod/container.go
+
+package libpod
+
+import (
+ "bytes"
+ "encoding/base64"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "github.com/cri-o/ocicni/pkg/ocicni"
+ fflib "github.com/pquerna/ffjson/fflib/v1"
+ "net"
+ "reflect"
+)
+
+// MarshalJSON marshal bytes to json - template
+func (j *ContainerConfig) MarshalJSON() ([]byte, error) {
+ var buf fflib.Buffer
+ if j == nil {
+ buf.WriteString("null")
+ return buf.Bytes(), nil
+ }
+ err := j.MarshalJSONBuf(&buf)
+ if err != nil {
+ return nil, err
+ }
+ return buf.Bytes(), nil
+}
+
+// MarshalJSONBuf marshal buff to json - template
+func (j *ContainerConfig) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
+ if j == nil {
+ buf.WriteString("null")
+ return nil
+ }
+ var err error
+ var obj []byte
+ _ = obj
+ _ = err
+ if j.Spec != nil {
+ /* Struct fall back. type=specs.Spec kind=struct */
+ buf.WriteString(`{"spec":`)
+ err = buf.Encode(j.Spec)
+ if err != nil {
+ return err
+ }
+ } else {
+ buf.WriteString(`{"spec":null`)
+ }
+ buf.WriteString(`,"id":`)
+ fflib.WriteJsonString(buf, string(j.ID))
+ buf.WriteString(`,"name":`)
+ fflib.WriteJsonString(buf, string(j.Name))
+ buf.WriteByte(',')
+ if len(j.Pod) != 0 {
+ buf.WriteString(`"pod":`)
+ fflib.WriteJsonString(buf, string(j.Pod))
+ buf.WriteByte(',')
+ }
+ if len(j.RootfsImageID) != 0 {
+ buf.WriteString(`"rootfsImageID":`)
+ fflib.WriteJsonString(buf, string(j.RootfsImageID))
+ buf.WriteByte(',')
+ }
+ if len(j.RootfsImageName) != 0 {
+ buf.WriteString(`"rootfsImageName":`)
+ fflib.WriteJsonString(buf, string(j.RootfsImageName))
+ buf.WriteByte(',')
+ }
+ if j.ImageVolumes {
+ buf.WriteString(`"imageVolumes":true`)
+ } else {
+ buf.WriteString(`"imageVolumes":false`)
+ }
+ buf.WriteByte(',')
+ if len(j.ShmDir) != 0 {
+ buf.WriteString(`"ShmDir":`)
+ fflib.WriteJsonString(buf, string(j.ShmDir))
+ buf.WriteByte(',')
+ }
+ buf.WriteString(`"shmSize":`)
+ fflib.FormatBits2(buf, uint64(j.ShmSize), 10, j.ShmSize < 0)
+ buf.WriteString(`,"staticDir":`)
+ fflib.WriteJsonString(buf, string(j.StaticDir))
+ buf.WriteByte(',')
+ if len(j.Mounts) != 0 {
+ buf.WriteString(`"mounts":`)
+ if j.Mounts != nil {
+ buf.WriteString(`[`)
+ for i, v := range j.Mounts {
+ if i != 0 {
+ buf.WriteString(`,`)
+ }
+ fflib.WriteJsonString(buf, string(v))
+ }
+ buf.WriteString(`]`)
+ } else {
+ buf.WriteString(`null`)
+ }
+ buf.WriteByte(',')
+ }
+ if j.Privileged {
+ buf.WriteString(`"privileged":true`)
+ } else {
+ buf.WriteString(`"privileged":false`)
+ }
+ if j.NoNewPrivs {
+ buf.WriteString(`,"noNewPrivs":true`)
+ } else {
+ buf.WriteString(`,"noNewPrivs":false`)
+ }
+ buf.WriteByte(',')
+ if len(j.ProcessLabel) != 0 {
+ buf.WriteString(`"ProcessLabel":`)
+ fflib.WriteJsonString(buf, string(j.ProcessLabel))
+ buf.WriteByte(',')
+ }
+ if len(j.MountLabel) != 0 {
+ buf.WriteString(`"MountLabel":`)
+ fflib.WriteJsonString(buf, string(j.MountLabel))
+ buf.WriteByte(',')
+ }
+ if len(j.User) != 0 {
+ buf.WriteString(`"user":`)
+ fflib.WriteJsonString(buf, string(j.User))
+ buf.WriteByte(',')
+ }
+ if len(j.IPCNsCtr) != 0 {
+ buf.WriteString(`"ipcNsCtr":`)
+ fflib.WriteJsonString(buf, string(j.IPCNsCtr))
+ buf.WriteByte(',')
+ }
+ if len(j.MountNsCtr) != 0 {
+ buf.WriteString(`"mountNsCtr":`)
+ fflib.WriteJsonString(buf, string(j.MountNsCtr))
+ buf.WriteByte(',')
+ }
+ if len(j.NetNsCtr) != 0 {
+ buf.WriteString(`"netNsCtr":`)
+ fflib.WriteJsonString(buf, string(j.NetNsCtr))
+ buf.WriteByte(',')
+ }
+ if len(j.PIDNsCtr) != 0 {
+ buf.WriteString(`"pidNsCtr":`)
+ fflib.WriteJsonString(buf, string(j.PIDNsCtr))
+ buf.WriteByte(',')
+ }
+ if len(j.UserNsCtr) != 0 {
+ buf.WriteString(`"userNsCtr":`)
+ fflib.WriteJsonString(buf, string(j.UserNsCtr))
+ buf.WriteByte(',')
+ }
+ if len(j.UTSNsCtr) != 0 {
+ buf.WriteString(`"utsNsCtr":`)
+ fflib.WriteJsonString(buf, string(j.UTSNsCtr))
+ buf.WriteByte(',')
+ }
+ if len(j.CgroupNsCtr) != 0 {
+ buf.WriteString(`"cgroupNsCtr":`)
+ fflib.WriteJsonString(buf, string(j.CgroupNsCtr))
+ buf.WriteByte(',')
+ }
+ if j.CreateNetNS {
+ buf.WriteString(`"createNetNS":true`)
+ } else {
+ buf.WriteString(`"createNetNS":false`)
+ }
+ buf.WriteByte(',')
+ if len(j.PortMappings) != 0 {
+ buf.WriteString(`"portMappings":`)
+ if j.PortMappings != nil {
+ buf.WriteString(`[`)
+ for i, v := range j.PortMappings {
+ if i != 0 {
+ buf.WriteString(`,`)
+ }
+ /* Struct fall back. type=ocicni.PortMapping kind=struct */
+ err = buf.Encode(&v)
+ if err != nil {
+ return err
+ }
+ }
+ buf.WriteString(`]`)
+ } else {
+ buf.WriteString(`null`)
+ }
+ buf.WriteByte(',')
+ }
+ if len(j.DNSServer) != 0 {
+ buf.WriteString(`"dnsServer":`)
+ if j.DNSServer != nil {
+ buf.WriteString(`[`)
+ for i, v := range j.DNSServer {
+ if i != 0 {
+ buf.WriteString(`,`)
+ }
+ if v != nil {
+ buf.WriteString(`"`)
+ {
+ enc := base64.NewEncoder(base64.StdEncoding, buf)
+ enc.Write(reflect.Indirect(reflect.ValueOf(v)).Bytes())
+ enc.Close()
+ }
+ buf.WriteString(`"`)
+ } else {
+ buf.WriteString(`null`)
+ }
+ }
+ buf.WriteString(`]`)
+ } else {
+ buf.WriteString(`null`)
+ }
+ buf.WriteByte(',')
+ }
+ if len(j.DNSSearch) != 0 {
+ buf.WriteString(`"dnsSearch":`)
+ if j.DNSSearch != nil {
+ buf.WriteString(`[`)
+ for i, v := range j.DNSSearch {
+ if i != 0 {
+ buf.WriteString(`,`)
+ }
+ fflib.WriteJsonString(buf, string(v))
+ }
+ buf.WriteString(`]`)
+ } else {
+ buf.WriteString(`null`)
+ }
+ buf.WriteByte(',')
+ }
+ if len(j.DNSOption) != 0 {
+ buf.WriteString(`"dnsOption":`)
+ if j.DNSOption != nil {
+ buf.WriteString(`[`)
+ for i, v := range j.DNSOption {
+ if i != 0 {
+ buf.WriteString(`,`)
+ }
+ fflib.WriteJsonString(buf, string(v))
+ }
+ buf.WriteString(`]`)
+ } else {
+ buf.WriteString(`null`)
+ }
+ buf.WriteByte(',')
+ }
+ if len(j.HostAdd) != 0 {
+ buf.WriteString(`"hostsAdd":`)
+ if j.HostAdd != nil {
+ buf.WriteString(`[`)
+ for i, v := range j.HostAdd {
+ if i != 0 {
+ buf.WriteString(`,`)
+ }
+ fflib.WriteJsonString(buf, string(v))
+ }
+ buf.WriteString(`]`)
+ } else {
+ buf.WriteString(`null`)
+ }
+ buf.WriteByte(',')
+ }
+ if j.Stdin != false {
+ if j.Stdin {
+ buf.WriteString(`"stdin":true`)
+ } else {
+ buf.WriteString(`"stdin":false`)
+ }
+ buf.WriteByte(',')
+ }
+ if len(j.Labels) != 0 {
+ if j.Labels == nil {
+ buf.WriteString(`"labels":null`)
+ } else {
+ buf.WriteString(`"labels":{ `)
+ for key, value := range j.Labels {
+ fflib.WriteJsonString(buf, key)
+ buf.WriteString(`:`)
+ fflib.WriteJsonString(buf, string(value))
+ buf.WriteByte(',')
+ }
+ buf.Rewind(1)
+ buf.WriteByte('}')
+ }
+ buf.WriteByte(',')
+ }
+ if j.StopSignal != 0 {
+ buf.WriteString(`"stopSignal":`)
+ fflib.FormatBits2(buf, uint64(j.StopSignal), 10, false)
+ buf.WriteByte(',')
+ }
+ if j.StopTimeout != 0 {
+ buf.WriteString(`"stopTimeout":`)
+ fflib.FormatBits2(buf, uint64(j.StopTimeout), 10, false)
+ buf.WriteByte(',')
+ }
+ buf.WriteString(`"createdTime":`)
+
+ {
+
+ obj, err = j.CreatedTime.MarshalJSON()
+ if err != nil {
+ return err
+ }
+ buf.Write(obj)
+
+ }
+ buf.WriteString(`,"cgroupParent":`)
+ fflib.WriteJsonString(buf, string(j.CgroupParent))
+ buf.WriteString(`,"logPath":`)
+ fflib.WriteJsonString(buf, string(j.LogPath))
+ buf.WriteByte('}')
+ return nil
+}
+
+const (
+ ffjtContainerConfigbase = iota
+ ffjtContainerConfignosuchkey
+
+ ffjtContainerConfigSpec
+
+ ffjtContainerConfigID
+
+ ffjtContainerConfigName
+
+ ffjtContainerConfigPod
+
+ ffjtContainerConfigRootfsImageID
+
+ ffjtContainerConfigRootfsImageName
+
+ ffjtContainerConfigImageVolumes
+
+ ffjtContainerConfigShmDir
+
+ ffjtContainerConfigShmSize
+
+ ffjtContainerConfigStaticDir
+
+ ffjtContainerConfigMounts
+
+ ffjtContainerConfigPrivileged
+
+ ffjtContainerConfigNoNewPrivs
+
+ ffjtContainerConfigProcessLabel
+
+ ffjtContainerConfigMountLabel
+
+ ffjtContainerConfigUser
+
+ ffjtContainerConfigIPCNsCtr
+
+ ffjtContainerConfigMountNsCtr
+
+ ffjtContainerConfigNetNsCtr
+
+ ffjtContainerConfigPIDNsCtr
+
+ ffjtContainerConfigUserNsCtr
+
+ ffjtContainerConfigUTSNsCtr
+
+ ffjtContainerConfigCgroupNsCtr
+
+ ffjtContainerConfigCreateNetNS
+
+ ffjtContainerConfigPortMappings
+
+ ffjtContainerConfigDNSServer
+
+ ffjtContainerConfigDNSSearch
+
+ ffjtContainerConfigDNSOption
+
+ ffjtContainerConfigHostAdd
+
+ ffjtContainerConfigStdin
+
+ ffjtContainerConfigLabels
+
+ ffjtContainerConfigStopSignal
+
+ ffjtContainerConfigStopTimeout
+
+ ffjtContainerConfigCreatedTime
+
+ ffjtContainerConfigCgroupParent
+
+ ffjtContainerConfigLogPath
+)
+
+var ffjKeyContainerConfigSpec = []byte("spec")
+
+var ffjKeyContainerConfigID = []byte("id")
+
+var ffjKeyContainerConfigName = []byte("name")
+
+var ffjKeyContainerConfigPod = []byte("pod")
+
+var ffjKeyContainerConfigRootfsImageID = []byte("rootfsImageID")
+
+var ffjKeyContainerConfigRootfsImageName = []byte("rootfsImageName")
+
+var ffjKeyContainerConfigImageVolumes = []byte("imageVolumes")
+
+var ffjKeyContainerConfigShmDir = []byte("ShmDir")
+
+var ffjKeyContainerConfigShmSize = []byte("shmSize")
+
+var ffjKeyContainerConfigStaticDir = []byte("staticDir")
+
+var ffjKeyContainerConfigMounts = []byte("mounts")
+
+var ffjKeyContainerConfigPrivileged = []byte("privileged")
+
+var ffjKeyContainerConfigNoNewPrivs = []byte("noNewPrivs")
+
+var ffjKeyContainerConfigProcessLabel = []byte("ProcessLabel")
+
+var ffjKeyContainerConfigMountLabel = []byte("MountLabel")
+
+var ffjKeyContainerConfigUser = []byte("user")
+
+var ffjKeyContainerConfigIPCNsCtr = []byte("ipcNsCtr")
+
+var ffjKeyContainerConfigMountNsCtr = []byte("mountNsCtr")
+
+var ffjKeyContainerConfigNetNsCtr = []byte("netNsCtr")
+
+var ffjKeyContainerConfigPIDNsCtr = []byte("pidNsCtr")
+
+var ffjKeyContainerConfigUserNsCtr = []byte("userNsCtr")
+
+var ffjKeyContainerConfigUTSNsCtr = []byte("utsNsCtr")
+
+var ffjKeyContainerConfigCgroupNsCtr = []byte("cgroupNsCtr")
+
+var ffjKeyContainerConfigCreateNetNS = []byte("createNetNS")
+
+var ffjKeyContainerConfigPortMappings = []byte("portMappings")
+
+var ffjKeyContainerConfigDNSServer = []byte("dnsServer")
+
+var ffjKeyContainerConfigDNSSearch = []byte("dnsSearch")
+
+var ffjKeyContainerConfigDNSOption = []byte("dnsOption")
+
+var ffjKeyContainerConfigHostAdd = []byte("hostsAdd")
+
+var ffjKeyContainerConfigStdin = []byte("stdin")
+
+var ffjKeyContainerConfigLabels = []byte("labels")
+
+var ffjKeyContainerConfigStopSignal = []byte("stopSignal")
+
+var ffjKeyContainerConfigStopTimeout = []byte("stopTimeout")
+
+var ffjKeyContainerConfigCreatedTime = []byte("createdTime")
+
+var ffjKeyContainerConfigCgroupParent = []byte("cgroupParent")
+
+var ffjKeyContainerConfigLogPath = []byte("logPath")
+
+// UnmarshalJSON umarshall json - template of ffjson
+func (j *ContainerConfig) UnmarshalJSON(input []byte) error {
+ fs := fflib.NewFFLexer(input)
+ return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start)
+}
+
+// UnmarshalJSONFFLexer fast json unmarshall - template ffjson
+func (j *ContainerConfig) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error {
+ var err error
+ currentKey := ffjtContainerConfigbase
+ _ = 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 = ffjtContainerConfignosuchkey
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ } else {
+ switch kn[0] {
+
+ case 'M':
+
+ if bytes.Equal(ffjKeyContainerConfigMountLabel, kn) {
+ currentKey = ffjtContainerConfigMountLabel
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'P':
+
+ if bytes.Equal(ffjKeyContainerConfigProcessLabel, kn) {
+ currentKey = ffjtContainerConfigProcessLabel
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'S':
+
+ if bytes.Equal(ffjKeyContainerConfigShmDir, kn) {
+ currentKey = ffjtContainerConfigShmDir
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'c':
+
+ if bytes.Equal(ffjKeyContainerConfigCgroupNsCtr, kn) {
+ currentKey = ffjtContainerConfigCgroupNsCtr
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigCreateNetNS, kn) {
+ currentKey = ffjtContainerConfigCreateNetNS
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigCreatedTime, kn) {
+ currentKey = ffjtContainerConfigCreatedTime
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigCgroupParent, kn) {
+ currentKey = ffjtContainerConfigCgroupParent
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'd':
+
+ if bytes.Equal(ffjKeyContainerConfigDNSServer, kn) {
+ currentKey = ffjtContainerConfigDNSServer
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigDNSSearch, kn) {
+ currentKey = ffjtContainerConfigDNSSearch
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigDNSOption, kn) {
+ currentKey = ffjtContainerConfigDNSOption
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'h':
+
+ if bytes.Equal(ffjKeyContainerConfigHostAdd, kn) {
+ currentKey = ffjtContainerConfigHostAdd
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'i':
+
+ if bytes.Equal(ffjKeyContainerConfigID, kn) {
+ currentKey = ffjtContainerConfigID
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigImageVolumes, kn) {
+ currentKey = ffjtContainerConfigImageVolumes
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigIPCNsCtr, kn) {
+ currentKey = ffjtContainerConfigIPCNsCtr
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'l':
+
+ if bytes.Equal(ffjKeyContainerConfigLabels, kn) {
+ currentKey = ffjtContainerConfigLabels
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigLogPath, kn) {
+ currentKey = ffjtContainerConfigLogPath
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'm':
+
+ if bytes.Equal(ffjKeyContainerConfigMounts, kn) {
+ currentKey = ffjtContainerConfigMounts
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigMountNsCtr, kn) {
+ currentKey = ffjtContainerConfigMountNsCtr
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'n':
+
+ if bytes.Equal(ffjKeyContainerConfigName, kn) {
+ currentKey = ffjtContainerConfigName
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigNoNewPrivs, kn) {
+ currentKey = ffjtContainerConfigNoNewPrivs
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigNetNsCtr, kn) {
+ currentKey = ffjtContainerConfigNetNsCtr
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'p':
+
+ if bytes.Equal(ffjKeyContainerConfigPod, kn) {
+ currentKey = ffjtContainerConfigPod
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigPrivileged, kn) {
+ currentKey = ffjtContainerConfigPrivileged
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigPIDNsCtr, kn) {
+ currentKey = ffjtContainerConfigPIDNsCtr
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigPortMappings, kn) {
+ currentKey = ffjtContainerConfigPortMappings
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'r':
+
+ if bytes.Equal(ffjKeyContainerConfigRootfsImageID, kn) {
+ currentKey = ffjtContainerConfigRootfsImageID
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigRootfsImageName, kn) {
+ currentKey = ffjtContainerConfigRootfsImageName
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 's':
+
+ if bytes.Equal(ffjKeyContainerConfigSpec, kn) {
+ currentKey = ffjtContainerConfigSpec
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigShmSize, kn) {
+ currentKey = ffjtContainerConfigShmSize
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigStaticDir, kn) {
+ currentKey = ffjtContainerConfigStaticDir
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigStdin, kn) {
+ currentKey = ffjtContainerConfigStdin
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigStopSignal, kn) {
+ currentKey = ffjtContainerConfigStopSignal
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigStopTimeout, kn) {
+ currentKey = ffjtContainerConfigStopTimeout
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'u':
+
+ if bytes.Equal(ffjKeyContainerConfigUser, kn) {
+ currentKey = ffjtContainerConfigUser
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigUserNsCtr, kn) {
+ currentKey = ffjtContainerConfigUserNsCtr
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeyContainerConfigUTSNsCtr, kn) {
+ currentKey = ffjtContainerConfigUTSNsCtr
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ }
+
+ if fflib.SimpleLetterEqualFold(ffjKeyContainerConfigLogPath, kn) {
+ currentKey = ffjtContainerConfigLogPath
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.SimpleLetterEqualFold(ffjKeyContainerConfigCgroupParent, kn) {
+ currentKey = ffjtContainerConfigCgroupParent
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.SimpleLetterEqualFold(ffjKeyContainerConfigCreatedTime, kn) {
+ currentKey = ffjtContainerConfigCreatedTime
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigStopTimeout, kn) {
+ currentKey = ffjtContainerConfigStopTimeout
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigStopSignal, kn) {
+ currentKey = ffjtContainerConfigStopSignal
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigLabels, kn) {
+ currentKey = ffjtContainerConfigLabels
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigStdin, kn) {
+ currentKey = ffjtContainerConfigStdin
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigHostAdd, kn) {
+ currentKey = ffjtContainerConfigHostAdd
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigDNSOption, kn) {
+ currentKey = ffjtContainerConfigDNSOption
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigDNSSearch, kn) {
+ currentKey = ffjtContainerConfigDNSSearch
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigDNSServer, kn) {
+ currentKey = ffjtContainerConfigDNSServer
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigPortMappings, kn) {
+ currentKey = ffjtContainerConfigPortMappings
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigCreateNetNS, kn) {
+ currentKey = ffjtContainerConfigCreateNetNS
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigCgroupNsCtr, kn) {
+ currentKey = ffjtContainerConfigCgroupNsCtr
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigUTSNsCtr, kn) {
+ currentKey = ffjtContainerConfigUTSNsCtr
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigUserNsCtr, kn) {
+ currentKey = ffjtContainerConfigUserNsCtr
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigPIDNsCtr, kn) {
+ currentKey = ffjtContainerConfigPIDNsCtr
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigNetNsCtr, kn) {
+ currentKey = ffjtContainerConfigNetNsCtr
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigMountNsCtr, kn) {
+ currentKey = ffjtContainerConfigMountNsCtr
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigIPCNsCtr, kn) {
+ currentKey = ffjtContainerConfigIPCNsCtr
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigUser, kn) {
+ currentKey = ffjtContainerConfigUser
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.SimpleLetterEqualFold(ffjKeyContainerConfigMountLabel, kn) {
+ currentKey = ffjtContainerConfigMountLabel
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigProcessLabel, kn) {
+ currentKey = ffjtContainerConfigProcessLabel
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigNoNewPrivs, kn) {
+ currentKey = ffjtContainerConfigNoNewPrivs
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.SimpleLetterEqualFold(ffjKeyContainerConfigPrivileged, kn) {
+ currentKey = ffjtContainerConfigPrivileged
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigMounts, kn) {
+ currentKey = ffjtContainerConfigMounts
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigStaticDir, kn) {
+ currentKey = ffjtContainerConfigStaticDir
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigShmSize, kn) {
+ currentKey = ffjtContainerConfigShmSize
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigShmDir, kn) {
+ currentKey = ffjtContainerConfigShmDir
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigImageVolumes, kn) {
+ currentKey = ffjtContainerConfigImageVolumes
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigRootfsImageName, kn) {
+ currentKey = ffjtContainerConfigRootfsImageName
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigRootfsImageID, kn) {
+ currentKey = ffjtContainerConfigRootfsImageID
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.SimpleLetterEqualFold(ffjKeyContainerConfigPod, kn) {
+ currentKey = ffjtContainerConfigPod
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.SimpleLetterEqualFold(ffjKeyContainerConfigName, kn) {
+ currentKey = ffjtContainerConfigName
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.SimpleLetterEqualFold(ffjKeyContainerConfigID, kn) {
+ currentKey = ffjtContainerConfigID
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeyContainerConfigSpec, kn) {
+ currentKey = ffjtContainerConfigSpec
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ currentKey = ffjtContainerConfignosuchkey
+ 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 ffjtContainerConfigSpec:
+ goto handle_Spec
+
+ case ffjtContainerConfigID:
+ goto handle_ID
+
+ case ffjtContainerConfigName:
+ goto handle_Name
+
+ case ffjtContainerConfigPod:
+ goto handle_Pod
+
+ case ffjtContainerConfigRootfsImageID:
+ goto handle_RootfsImageID
+
+ case ffjtContainerConfigRootfsImageName:
+ goto handle_RootfsImageName
+
+ case ffjtContainerConfigImageVolumes:
+ goto handle_ImageVolumes
+
+ case ffjtContainerConfigShmDir:
+ goto handle_ShmDir
+
+ case ffjtContainerConfigShmSize:
+ goto handle_ShmSize
+
+ case ffjtContainerConfigStaticDir:
+ goto handle_StaticDir
+
+ case ffjtContainerConfigMounts:
+ goto handle_Mounts
+
+ case ffjtContainerConfigPrivileged:
+ goto handle_Privileged
+
+ case ffjtContainerConfigNoNewPrivs:
+ goto handle_NoNewPrivs
+
+ case ffjtContainerConfigProcessLabel:
+ goto handle_ProcessLabel
+
+ case ffjtContainerConfigMountLabel:
+ goto handle_MountLabel
+
+ case ffjtContainerConfigUser:
+ goto handle_User
+
+ case ffjtContainerConfigIPCNsCtr:
+ goto handle_IPCNsCtr
+
+ case ffjtContainerConfigMountNsCtr:
+ goto handle_MountNsCtr
+
+ case ffjtContainerConfigNetNsCtr:
+ goto handle_NetNsCtr
+
+ case ffjtContainerConfigPIDNsCtr:
+ goto handle_PIDNsCtr
+
+ case ffjtContainerConfigUserNsCtr:
+ goto handle_UserNsCtr
+
+ case ffjtContainerConfigUTSNsCtr:
+ goto handle_UTSNsCtr
+
+ case ffjtContainerConfigCgroupNsCtr:
+ goto handle_CgroupNsCtr
+
+ case ffjtContainerConfigCreateNetNS:
+ goto handle_CreateNetNS
+
+ case ffjtContainerConfigPortMappings:
+ goto handle_PortMappings
+
+ case ffjtContainerConfigDNSServer:
+ goto handle_DNSServer
+
+ case ffjtContainerConfigDNSSearch:
+ goto handle_DNSSearch
+
+ case ffjtContainerConfigDNSOption:
+ goto handle_DNSOption
+
+ case ffjtContainerConfigHostAdd:
+ goto handle_HostAdd
+
+ case ffjtContainerConfigStdin:
+ goto handle_Stdin
+
+ case ffjtContainerConfigLabels:
+ goto handle_Labels
+
+ case ffjtContainerConfigStopSignal:
+ goto handle_StopSignal
+
+ case ffjtContainerConfigStopTimeout:
+ goto handle_StopTimeout
+
+ case ffjtContainerConfigCreatedTime:
+ goto handle_CreatedTime
+
+ case ffjtContainerConfigCgroupParent:
+ goto handle_CgroupParent
+
+ case ffjtContainerConfigLogPath:
+ goto handle_LogPath
+
+ case ffjtContainerConfignosuchkey:
+ err = fs.SkipField(tok)
+ if err != nil {
+ return fs.WrapErr(err)
+ }
+ state = fflib.FFParse_after_value
+ goto mainparse
+ }
+ } else {
+ goto wantedvalue
+ }
+ }
+ }
+
+handle_Spec:
+
+ /* handler: j.Spec type=specs.Spec kind=struct quoted=false*/
+
+ {
+ /* Falling back. type=specs.Spec kind=struct */
+ tbuf, err := fs.CaptureField(tok)
+ if err != nil {
+ return fs.WrapErr(err)
+ }
+
+ err = json.Unmarshal(tbuf, &j.Spec)
+ if err != nil {
+ return fs.WrapErr(err)
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_ID:
+
+ /* handler: j.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()
+
+ j.ID = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_Name:
+
+ /* handler: j.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()
+
+ j.Name = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_Pod:
+
+ /* handler: j.Pod 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()
+
+ j.Pod = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_RootfsImageID:
+
+ /* handler: j.RootfsImageID 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()
+
+ j.RootfsImageID = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_RootfsImageName:
+
+ /* handler: j.RootfsImageName 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()
+
+ j.RootfsImageName = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_ImageVolumes:
+
+ /* handler: j.ImageVolumes 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 {
+
+ j.ImageVolumes = true
+
+ } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 {
+
+ j.ImageVolumes = false
+
+ } else {
+ err = errors.New("unexpected bytes for true/false value")
+ return fs.WrapErr(err)
+ }
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_ShmDir:
+
+ /* handler: j.ShmDir 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()
+
+ j.ShmDir = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_ShmSize:
+
+ /* handler: j.ShmSize 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)
+ }
+
+ j.ShmSize = int64(tval)
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_StaticDir:
+
+ /* handler: j.StaticDir 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()
+
+ j.StaticDir = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_Mounts:
+
+ /* handler: j.Mounts 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 {
+ j.Mounts = nil
+ } else {
+
+ j.Mounts = []string{}
+
+ wantVal := true
+
+ for {
+
+ var tmpJMounts 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: tmpJMounts 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()
+
+ tmpJMounts = string(string(outBuf))
+
+ }
+ }
+
+ j.Mounts = append(j.Mounts, tmpJMounts)
+
+ wantVal = false
+ }
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_Privileged:
+
+ /* handler: j.Privileged 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 {
+
+ j.Privileged = true
+
+ } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 {
+
+ j.Privileged = false
+
+ } else {
+ err = errors.New("unexpected bytes for true/false value")
+ return fs.WrapErr(err)
+ }
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_NoNewPrivs:
+
+ /* handler: j.NoNewPrivs 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 {
+
+ j.NoNewPrivs = true
+
+ } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 {
+
+ j.NoNewPrivs = false
+
+ } else {
+ err = errors.New("unexpected bytes for true/false value")
+ return fs.WrapErr(err)
+ }
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_ProcessLabel:
+
+ /* handler: j.ProcessLabel 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()
+
+ j.ProcessLabel = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_MountLabel:
+
+ /* handler: j.MountLabel 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()
+
+ j.MountLabel = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_User:
+
+ /* handler: j.User 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()
+
+ j.User = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_IPCNsCtr:
+
+ /* handler: j.IPCNsCtr 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()
+
+ j.IPCNsCtr = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_MountNsCtr:
+
+ /* handler: j.MountNsCtr 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()
+
+ j.MountNsCtr = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_NetNsCtr:
+
+ /* handler: j.NetNsCtr 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()
+
+ j.NetNsCtr = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_PIDNsCtr:
+
+ /* handler: j.PIDNsCtr 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()
+
+ j.PIDNsCtr = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_UserNsCtr:
+
+ /* handler: j.UserNsCtr 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()
+
+ j.UserNsCtr = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_UTSNsCtr:
+
+ /* handler: j.UTSNsCtr 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()
+
+ j.UTSNsCtr = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_CgroupNsCtr:
+
+ /* handler: j.CgroupNsCtr 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()
+
+ j.CgroupNsCtr = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_CreateNetNS:
+
+ /* handler: j.CreateNetNS 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 {
+
+ j.CreateNetNS = true
+
+ } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 {
+
+ j.CreateNetNS = false
+
+ } else {
+ err = errors.New("unexpected bytes for true/false value")
+ return fs.WrapErr(err)
+ }
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_PortMappings:
+
+ /* handler: j.PortMappings type=[]ocicni.PortMapping 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 {
+ j.PortMappings = nil
+ } else {
+
+ j.PortMappings = []ocicni.PortMapping{}
+
+ wantVal := true
+
+ for {
+
+ var tmpJPortMappings ocicni.PortMapping
+
+ 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: tmpJPortMappings type=ocicni.PortMapping kind=struct quoted=false*/
+
+ {
+ /* Falling back. type=ocicni.PortMapping kind=struct */
+ tbuf, err := fs.CaptureField(tok)
+ if err != nil {
+ return fs.WrapErr(err)
+ }
+
+ err = json.Unmarshal(tbuf, &tmpJPortMappings)
+ if err != nil {
+ return fs.WrapErr(err)
+ }
+ }
+
+ j.PortMappings = append(j.PortMappings, tmpJPortMappings)
+
+ wantVal = false
+ }
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_DNSServer:
+
+ /* handler: j.DNSServer type=[]net.IP 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 {
+ j.DNSServer = nil
+ } else {
+
+ j.DNSServer = []net.IP{}
+
+ wantVal := true
+
+ for {
+
+ var tmpJDNSServer net.IP
+
+ 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: tmpJDNSServer type=net.IP kind=slice quoted=false*/
+
+ {
+
+ {
+ if tok != fflib.FFTok_string && tok != fflib.FFTok_null {
+ return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for IP", tok))
+ }
+ }
+
+ if tok == fflib.FFTok_null {
+ tmpJDNSServer = nil
+ } else {
+ b := make([]byte, base64.StdEncoding.DecodedLen(fs.Output.Len()))
+ n, err := base64.StdEncoding.Decode(b, fs.Output.Bytes())
+ if err != nil {
+ return fs.WrapErr(err)
+ }
+
+ v := reflect.ValueOf(&tmpJDNSServer).Elem()
+ v.SetBytes(b[0:n])
+
+ }
+ }
+
+ j.DNSServer = append(j.DNSServer, tmpJDNSServer)
+
+ wantVal = false
+ }
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_DNSSearch:
+
+ /* handler: j.DNSSearch 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 {
+ j.DNSSearch = nil
+ } else {
+
+ j.DNSSearch = []string{}
+
+ wantVal := true
+
+ for {
+
+ var tmpJDNSSearch 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: tmpJDNSSearch 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()
+
+ tmpJDNSSearch = string(string(outBuf))
+
+ }
+ }
+
+ j.DNSSearch = append(j.DNSSearch, tmpJDNSSearch)
+
+ wantVal = false
+ }
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_DNSOption:
+
+ /* handler: j.DNSOption 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 {
+ j.DNSOption = nil
+ } else {
+
+ j.DNSOption = []string{}
+
+ wantVal := true
+
+ for {
+
+ var tmpJDNSOption 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: tmpJDNSOption 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()
+
+ tmpJDNSOption = string(string(outBuf))
+
+ }
+ }
+
+ j.DNSOption = append(j.DNSOption, tmpJDNSOption)
+
+ wantVal = false
+ }
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_HostAdd:
+
+ /* handler: j.HostAdd 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 {
+ j.HostAdd = nil
+ } else {
+
+ j.HostAdd = []string{}
+
+ wantVal := true
+
+ for {
+
+ var tmpJHostAdd 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: tmpJHostAdd 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()
+
+ tmpJHostAdd = string(string(outBuf))
+
+ }
+ }
+
+ j.HostAdd = append(j.HostAdd, tmpJHostAdd)
+
+ wantVal = false
+ }
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_Stdin:
+
+ /* handler: j.Stdin 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 {
+
+ j.Stdin = true
+
+ } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 {
+
+ j.Stdin = false
+
+ } else {
+ err = errors.New("unexpected bytes for true/false value")
+ return fs.WrapErr(err)
+ }
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_Labels:
+
+ /* handler: j.Labels 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 {
+ j.Labels = nil
+ } else {
+
+ j.Labels = make(map[string]string, 0)
+
+ wantVal := true
+
+ for {
+
+ var k string
+
+ var tmpJLabels 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: tmpJLabels 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()
+
+ tmpJLabels = string(string(outBuf))
+
+ }
+ }
+
+ j.Labels[k] = tmpJLabels
+
+ wantVal = false
+ }
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_StopSignal:
+
+ /* handler: j.StopSignal 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)
+ }
+
+ j.StopSignal = uint(tval)
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_StopTimeout:
+
+ /* handler: j.StopTimeout 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)
+ }
+
+ j.StopTimeout = uint(tval)
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_CreatedTime:
+
+ /* handler: j.CreatedTime type=time.Time kind=struct quoted=false*/
+
+ {
+ if tok == fflib.FFTok_null {
+
+ } else {
+
+ tbuf, err := fs.CaptureField(tok)
+ if err != nil {
+ return fs.WrapErr(err)
+ }
+
+ err = j.CreatedTime.UnmarshalJSON(tbuf)
+ if err != nil {
+ return fs.WrapErr(err)
+ }
+ }
+ state = fflib.FFParse_after_value
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_CgroupParent:
+
+ /* handler: j.CgroupParent 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()
+
+ j.CgroupParent = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_LogPath:
+
+ /* handler: j.LogPath 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()
+
+ j.LogPath = 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
+}
+
+// MarshalJSON marshal bytes to json - template
+func (j *containerState) MarshalJSON() ([]byte, error) {
+ var buf fflib.Buffer
+ if j == nil {
+ buf.WriteString("null")
+ return buf.Bytes(), nil
+ }
+ err := j.MarshalJSONBuf(&buf)
+ if err != nil {
+ return nil, err
+ }
+ return buf.Bytes(), nil
+}
+
+// MarshalJSONBuf marshal buff to json - template
+func (j *containerState) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
+ if j == nil {
+ buf.WriteString("null")
+ return nil
+ }
+ var err error
+ var obj []byte
+ _ = obj
+ _ = err
+ buf.WriteString(`{"state":`)
+ fflib.FormatBits2(buf, uint64(j.State), 10, j.State < 0)
+ buf.WriteByte(',')
+ if len(j.ConfigPath) != 0 {
+ buf.WriteString(`"configPath":`)
+ fflib.WriteJsonString(buf, string(j.ConfigPath))
+ buf.WriteByte(',')
+ }
+ if len(j.RunDir) != 0 {
+ buf.WriteString(`"runDir":`)
+ fflib.WriteJsonString(buf, string(j.RunDir))
+ buf.WriteByte(',')
+ }
+ if j.Mounted != false {
+ if j.Mounted {
+ buf.WriteString(`"mounted":true`)
+ } else {
+ buf.WriteString(`"mounted":false`)
+ }
+ buf.WriteByte(',')
+ }
+ if len(j.Mountpoint) != 0 {
+ buf.WriteString(`"mountPoint":`)
+ fflib.WriteJsonString(buf, string(j.Mountpoint))
+ buf.WriteByte(',')
+ }
+ if true {
+ buf.WriteString(`"startedTime":`)
+
+ {
+
+ obj, err = j.StartedTime.MarshalJSON()
+ if err != nil {
+ return err
+ }
+ buf.Write(obj)
+
+ }
+ buf.WriteByte(',')
+ }
+ if true {
+ buf.WriteString(`"finishedTime":`)
+
+ {
+
+ obj, err = j.FinishedTime.MarshalJSON()
+ if err != nil {
+ return err
+ }
+ buf.Write(obj)
+
+ }
+ buf.WriteByte(',')
+ }
+ if j.ExitCode != 0 {
+ buf.WriteString(`"exitCode":`)
+ fflib.FormatBits2(buf, uint64(j.ExitCode), 10, j.ExitCode < 0)
+ buf.WriteByte(',')
+ }
+ if j.OOMKilled != false {
+ if j.OOMKilled {
+ buf.WriteString(`"oomKilled":true`)
+ } else {
+ buf.WriteString(`"oomKilled":false`)
+ }
+ buf.WriteByte(',')
+ }
+ if j.PID != 0 {
+ buf.WriteString(`"pid":`)
+ fflib.FormatBits2(buf, uint64(j.PID), 10, j.PID < 0)
+ buf.WriteByte(',')
+ }
+ buf.WriteString(`"ipAddress":`)
+ fflib.WriteJsonString(buf, string(j.IPAddress))
+ buf.WriteString(`,"subnetMask":`)
+ fflib.WriteJsonString(buf, string(j.SubnetMask))
+ buf.WriteByte('}')
+ return nil
+}
+
+const (
+ ffjtcontainerStatebase = iota
+ ffjtcontainerStatenosuchkey
+
+ ffjtcontainerStateState
+
+ ffjtcontainerStateConfigPath
+
+ ffjtcontainerStateRunDir
+
+ ffjtcontainerStateMounted
+
+ ffjtcontainerStateMountpoint
+
+ ffjtcontainerStateStartedTime
+
+ ffjtcontainerStateFinishedTime
+
+ ffjtcontainerStateExitCode
+
+ ffjtcontainerStateOOMKilled
+
+ ffjtcontainerStatePID
+
+ ffjtcontainerStateIPAddress
+
+ ffjtcontainerStateSubnetMask
+)
+
+var ffjKeycontainerStateState = []byte("state")
+
+var ffjKeycontainerStateConfigPath = []byte("configPath")
+
+var ffjKeycontainerStateRunDir = []byte("runDir")
+
+var ffjKeycontainerStateMounted = []byte("mounted")
+
+var ffjKeycontainerStateMountpoint = []byte("mountPoint")
+
+var ffjKeycontainerStateStartedTime = []byte("startedTime")
+
+var ffjKeycontainerStateFinishedTime = []byte("finishedTime")
+
+var ffjKeycontainerStateExitCode = []byte("exitCode")
+
+var ffjKeycontainerStateOOMKilled = []byte("oomKilled")
+
+var ffjKeycontainerStatePID = []byte("pid")
+
+var ffjKeycontainerStateIPAddress = []byte("ipAddress")
+
+var ffjKeycontainerStateSubnetMask = []byte("subnetMask")
+
+// UnmarshalJSON umarshall json - template of ffjson
+func (j *containerState) UnmarshalJSON(input []byte) error {
+ fs := fflib.NewFFLexer(input)
+ return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start)
+}
+
+// UnmarshalJSONFFLexer fast json unmarshall - template ffjson
+func (j *containerState) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error {
+ var err error
+ currentKey := ffjtcontainerStatebase
+ _ = 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 = ffjtcontainerStatenosuchkey
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ } else {
+ switch kn[0] {
+
+ case 'c':
+
+ if bytes.Equal(ffjKeycontainerStateConfigPath, kn) {
+ currentKey = ffjtcontainerStateConfigPath
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'e':
+
+ if bytes.Equal(ffjKeycontainerStateExitCode, kn) {
+ currentKey = ffjtcontainerStateExitCode
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'f':
+
+ if bytes.Equal(ffjKeycontainerStateFinishedTime, kn) {
+ currentKey = ffjtcontainerStateFinishedTime
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'i':
+
+ if bytes.Equal(ffjKeycontainerStateIPAddress, kn) {
+ currentKey = ffjtcontainerStateIPAddress
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'm':
+
+ if bytes.Equal(ffjKeycontainerStateMounted, kn) {
+ currentKey = ffjtcontainerStateMounted
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeycontainerStateMountpoint, kn) {
+ currentKey = ffjtcontainerStateMountpoint
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'o':
+
+ if bytes.Equal(ffjKeycontainerStateOOMKilled, kn) {
+ currentKey = ffjtcontainerStateOOMKilled
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'p':
+
+ if bytes.Equal(ffjKeycontainerStatePID, kn) {
+ currentKey = ffjtcontainerStatePID
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'r':
+
+ if bytes.Equal(ffjKeycontainerStateRunDir, kn) {
+ currentKey = ffjtcontainerStateRunDir
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 's':
+
+ if bytes.Equal(ffjKeycontainerStateState, kn) {
+ currentKey = ffjtcontainerStateState
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeycontainerStateStartedTime, kn) {
+ currentKey = ffjtcontainerStateStartedTime
+ state = fflib.FFParse_want_colon
+ goto mainparse
+
+ } else if bytes.Equal(ffjKeycontainerStateSubnetMask, kn) {
+ currentKey = ffjtcontainerStateSubnetMask
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ }
+
+ if fflib.EqualFoldRight(ffjKeycontainerStateSubnetMask, kn) {
+ currentKey = ffjtcontainerStateSubnetMask
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeycontainerStateIPAddress, kn) {
+ currentKey = ffjtcontainerStateIPAddress
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.SimpleLetterEqualFold(ffjKeycontainerStatePID, kn) {
+ currentKey = ffjtcontainerStatePID
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeycontainerStateOOMKilled, kn) {
+ currentKey = ffjtcontainerStateOOMKilled
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.SimpleLetterEqualFold(ffjKeycontainerStateExitCode, kn) {
+ currentKey = ffjtcontainerStateExitCode
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeycontainerStateFinishedTime, kn) {
+ currentKey = ffjtcontainerStateFinishedTime
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeycontainerStateStartedTime, kn) {
+ currentKey = ffjtcontainerStateStartedTime
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.SimpleLetterEqualFold(ffjKeycontainerStateMountpoint, kn) {
+ currentKey = ffjtcontainerStateMountpoint
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.SimpleLetterEqualFold(ffjKeycontainerStateMounted, kn) {
+ currentKey = ffjtcontainerStateMounted
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.SimpleLetterEqualFold(ffjKeycontainerStateRunDir, kn) {
+ currentKey = ffjtcontainerStateRunDir
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.SimpleLetterEqualFold(ffjKeycontainerStateConfigPath, kn) {
+ currentKey = ffjtcontainerStateConfigPath
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.EqualFoldRight(ffjKeycontainerStateState, kn) {
+ currentKey = ffjtcontainerStateState
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ currentKey = ffjtcontainerStatenosuchkey
+ 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 ffjtcontainerStateState:
+ goto handle_State
+
+ case ffjtcontainerStateConfigPath:
+ goto handle_ConfigPath
+
+ case ffjtcontainerStateRunDir:
+ goto handle_RunDir
+
+ case ffjtcontainerStateMounted:
+ goto handle_Mounted
+
+ case ffjtcontainerStateMountpoint:
+ goto handle_Mountpoint
+
+ case ffjtcontainerStateStartedTime:
+ goto handle_StartedTime
+
+ case ffjtcontainerStateFinishedTime:
+ goto handle_FinishedTime
+
+ case ffjtcontainerStateExitCode:
+ goto handle_ExitCode
+
+ case ffjtcontainerStateOOMKilled:
+ goto handle_OOMKilled
+
+ case ffjtcontainerStatePID:
+ goto handle_PID
+
+ case ffjtcontainerStateIPAddress:
+ goto handle_IPAddress
+
+ case ffjtcontainerStateSubnetMask:
+ goto handle_SubnetMask
+
+ case ffjtcontainerStatenosuchkey:
+ err = fs.SkipField(tok)
+ if err != nil {
+ return fs.WrapErr(err)
+ }
+ state = fflib.FFParse_after_value
+ goto mainparse
+ }
+ } else {
+ goto wantedvalue
+ }
+ }
+ }
+
+handle_State:
+
+ /* handler: j.State type=libpod.ContainerStatus 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 ContainerStatus", tok))
+ }
+ }
+
+ {
+
+ if tok == fflib.FFTok_null {
+
+ } else {
+
+ tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64)
+
+ if err != nil {
+ return fs.WrapErr(err)
+ }
+
+ j.State = ContainerStatus(tval)
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_ConfigPath:
+
+ /* handler: j.ConfigPath 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()
+
+ j.ConfigPath = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_RunDir:
+
+ /* handler: j.RunDir 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()
+
+ j.RunDir = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_Mounted:
+
+ /* handler: j.Mounted 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 {
+
+ j.Mounted = true
+
+ } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 {
+
+ j.Mounted = false
+
+ } else {
+ err = errors.New("unexpected bytes for true/false value")
+ return fs.WrapErr(err)
+ }
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_Mountpoint:
+
+ /* handler: j.Mountpoint 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()
+
+ j.Mountpoint = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_StartedTime:
+
+ /* handler: j.StartedTime type=time.Time kind=struct quoted=false*/
+
+ {
+ if tok == fflib.FFTok_null {
+
+ } else {
+
+ tbuf, err := fs.CaptureField(tok)
+ if err != nil {
+ return fs.WrapErr(err)
+ }
+
+ err = j.StartedTime.UnmarshalJSON(tbuf)
+ if err != nil {
+ return fs.WrapErr(err)
+ }
+ }
+ state = fflib.FFParse_after_value
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_FinishedTime:
+
+ /* handler: j.FinishedTime type=time.Time kind=struct quoted=false*/
+
+ {
+ if tok == fflib.FFTok_null {
+
+ } else {
+
+ tbuf, err := fs.CaptureField(tok)
+ if err != nil {
+ return fs.WrapErr(err)
+ }
+
+ err = j.FinishedTime.UnmarshalJSON(tbuf)
+ if err != nil {
+ return fs.WrapErr(err)
+ }
+ }
+ state = fflib.FFParse_after_value
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_ExitCode:
+
+ /* handler: j.ExitCode type=int32 kind=int32 quoted=false*/
+
+ {
+ if tok != fflib.FFTok_integer && tok != fflib.FFTok_null {
+ return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int32", tok))
+ }
+ }
+
+ {
+
+ if tok == fflib.FFTok_null {
+
+ } else {
+
+ tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 32)
+
+ if err != nil {
+ return fs.WrapErr(err)
+ }
+
+ j.ExitCode = int32(tval)
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_OOMKilled:
+
+ /* handler: j.OOMKilled 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 {
+
+ j.OOMKilled = true
+
+ } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 {
+
+ j.OOMKilled = false
+
+ } else {
+ err = errors.New("unexpected bytes for true/false value")
+ return fs.WrapErr(err)
+ }
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_PID:
+
+ /* handler: j.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)
+ }
+
+ j.PID = int(tval)
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_IPAddress:
+
+ /* handler: j.IPAddress 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()
+
+ j.IPAddress = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_SubnetMask:
+
+ /* handler: j.SubnetMask 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()
+
+ j.SubnetMask = 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
+}
diff --git a/libpod/pod.go b/libpod/pod.go
index d1e53f415..8af76d5cb 100644
--- a/libpod/pod.go
+++ b/libpod/pod.go
@@ -10,6 +10,7 @@ import (
)
// Pod represents a group of containers that may share namespaces
+// ffjson: skip
type Pod struct {
config *PodConfig
diff --git a/libpod/pod_ffjson.go b/libpod/pod_ffjson.go
new file mode 100644
index 000000000..2409aaefd
--- /dev/null
+++ b/libpod/pod_ffjson.go
@@ -0,0 +1,392 @@
+// Code generated by ffjson <https://github.com/pquerna/ffjson>. DO NOT EDIT.
+// source: libpod/pod.go
+
+package libpod
+
+import (
+ "bytes"
+ "fmt"
+ fflib "github.com/pquerna/ffjson/fflib/v1"
+)
+
+// MarshalJSON marshal bytes to json - template
+func (j *PodConfig) MarshalJSON() ([]byte, error) {
+ var buf fflib.Buffer
+ if j == nil {
+ buf.WriteString("null")
+ return buf.Bytes(), nil
+ }
+ err := j.MarshalJSONBuf(&buf)
+ if err != nil {
+ return nil, err
+ }
+ return buf.Bytes(), nil
+}
+
+// MarshalJSONBuf marshal buff to json - template
+func (j *PodConfig) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
+ if j == nil {
+ buf.WriteString("null")
+ return nil
+ }
+ var err error
+ var obj []byte
+ _ = obj
+ _ = err
+ buf.WriteString(`{"id":`)
+ fflib.WriteJsonString(buf, string(j.ID))
+ buf.WriteString(`,"name":`)
+ fflib.WriteJsonString(buf, string(j.Name))
+ if j.Labels == nil {
+ buf.WriteString(`,"Labels":null`)
+ } else {
+ buf.WriteString(`,"Labels":{ `)
+ for key, value := range j.Labels {
+ fflib.WriteJsonString(buf, key)
+ buf.WriteString(`:`)
+ fflib.WriteJsonString(buf, string(value))
+ buf.WriteByte(',')
+ }
+ buf.Rewind(1)
+ buf.WriteByte('}')
+ }
+ buf.WriteByte('}')
+ return nil
+}
+
+const (
+ ffjtPodConfigbase = iota
+ ffjtPodConfignosuchkey
+
+ ffjtPodConfigID
+
+ ffjtPodConfigName
+
+ ffjtPodConfigLabels
+)
+
+var ffjKeyPodConfigID = []byte("id")
+
+var ffjKeyPodConfigName = []byte("name")
+
+var ffjKeyPodConfigLabels = []byte("Labels")
+
+// UnmarshalJSON umarshall json - template of ffjson
+func (j *PodConfig) UnmarshalJSON(input []byte) error {
+ fs := fflib.NewFFLexer(input)
+ return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start)
+}
+
+// UnmarshalJSONFFLexer fast json unmarshall - template ffjson
+func (j *PodConfig) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error {
+ var err error
+ currentKey := ffjtPodConfigbase
+ _ = 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 = ffjtPodConfignosuchkey
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ } else {
+ switch kn[0] {
+
+ case 'L':
+
+ if bytes.Equal(ffjKeyPodConfigLabels, kn) {
+ currentKey = ffjtPodConfigLabels
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'i':
+
+ if bytes.Equal(ffjKeyPodConfigID, kn) {
+ currentKey = ffjtPodConfigID
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ case 'n':
+
+ if bytes.Equal(ffjKeyPodConfigName, kn) {
+ currentKey = ffjtPodConfigName
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ }
+
+ if fflib.EqualFoldRight(ffjKeyPodConfigLabels, kn) {
+ currentKey = ffjtPodConfigLabels
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.SimpleLetterEqualFold(ffjKeyPodConfigName, kn) {
+ currentKey = ffjtPodConfigName
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ if fflib.SimpleLetterEqualFold(ffjKeyPodConfigID, kn) {
+ currentKey = ffjtPodConfigID
+ state = fflib.FFParse_want_colon
+ goto mainparse
+ }
+
+ currentKey = ffjtPodConfignosuchkey
+ 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 ffjtPodConfigID:
+ goto handle_ID
+
+ case ffjtPodConfigName:
+ goto handle_Name
+
+ case ffjtPodConfigLabels:
+ goto handle_Labels
+
+ case ffjtPodConfignosuchkey:
+ err = fs.SkipField(tok)
+ if err != nil {
+ return fs.WrapErr(err)
+ }
+ state = fflib.FFParse_after_value
+ goto mainparse
+ }
+ } else {
+ goto wantedvalue
+ }
+ }
+ }
+
+handle_ID:
+
+ /* handler: j.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()
+
+ j.ID = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_Name:
+
+ /* handler: j.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()
+
+ j.Name = string(string(outBuf))
+
+ }
+ }
+
+ state = fflib.FFParse_after_value
+ goto mainparse
+
+handle_Labels:
+
+ /* handler: j.Labels 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 {
+ j.Labels = nil
+ } else {
+
+ j.Labels = make(map[string]string, 0)
+
+ wantVal := true
+
+ for {
+
+ var k string
+
+ var tmpJLabels 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: tmpJLabels 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()
+
+ tmpJLabels = string(string(outBuf))
+
+ }
+ }
+
+ j.Labels[k] = tmpJLabels
+
+ 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
+}
diff --git a/libpod/state_test.go b/libpod/state_test.go
index 53930f2d0..1b9a04d75 100644
--- a/libpod/state_test.go
+++ b/libpod/state_test.go
@@ -161,11 +161,7 @@ func TestAddAndGetContainer(t *testing.T) {
retrievedCtr, err := state.Container(testCtr.ID())
assert.NoError(t, err)
- // Use assert.EqualValues if the test fails to pretty print diff
- // between actual and expected
- if !testContainersEqual(testCtr, retrievedCtr) {
- assert.EqualValues(t, testCtr, retrievedCtr)
- }
+ testContainersEqual(t, testCtr, retrievedCtr)
})
}
@@ -185,11 +181,7 @@ func TestAddAndGetContainerFromMultiple(t *testing.T) {
retrievedCtr, err := state.Container(testCtr1.ID())
assert.NoError(t, err)
- // Use assert.EqualValues if the test fails to pretty print diff
- // between actual and expected
- if !testContainersEqual(testCtr1, retrievedCtr) {
- assert.EqualValues(t, testCtr1, retrievedCtr)
- }
+ testContainersEqual(t, testCtr1, retrievedCtr)
})
}
@@ -350,11 +342,7 @@ func TestLookupContainerByFullID(t *testing.T) {
retrievedCtr, err := state.LookupContainer(testCtr.ID())
assert.NoError(t, err)
- // Use assert.EqualValues if the test fails to pretty print diff
- // between actual and expected
- if !testContainersEqual(testCtr, retrievedCtr) {
- assert.EqualValues(t, testCtr, retrievedCtr)
- }
+ testContainersEqual(t, testCtr, retrievedCtr)
})
}
@@ -369,11 +357,7 @@ func TestLookupContainerByUniquePartialID(t *testing.T) {
retrievedCtr, err := state.LookupContainer(testCtr.ID()[0:8])
assert.NoError(t, err)
- // Use assert.EqualValues if the test fails to pretty print diff
- // between actual and expected
- if !testContainersEqual(testCtr, retrievedCtr) {
- assert.EqualValues(t, testCtr, retrievedCtr)
- }
+ testContainersEqual(t, testCtr, retrievedCtr)
})
}
@@ -406,11 +390,7 @@ func TestLookupContainerByName(t *testing.T) {
retrievedCtr, err := state.LookupContainer(testCtr.Name())
assert.NoError(t, err)
- // Use assert.EqualValues if the test fails to pretty print diff
- // between actual and expected
- if !testContainersEqual(testCtr, retrievedCtr) {
- assert.EqualValues(t, testCtr, retrievedCtr)
- }
+ testContainersEqual(t, testCtr, retrievedCtr)
})
}
@@ -504,11 +484,7 @@ func TestSaveAndUpdateContainer(t *testing.T) {
err = state.UpdateContainer(testCtr)
assert.NoError(t, err)
- // Use assert.EqualValues if the test fails to pretty print diff
- // between actual and expected
- if !testContainersEqual(testCtr, retrievedCtr) {
- assert.EqualValues(t, testCtr, retrievedCtr)
- }
+ testContainersEqual(t, testCtr, retrievedCtr)
})
}
@@ -600,11 +576,7 @@ func TestGetAllContainersWithOneContainer(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 1, len(ctrs))
- // Use assert.EqualValues if the test fails to pretty print diff
- // between actual and expected
- if !testContainersEqual(testCtr, ctrs[0]) {
- assert.EqualValues(t, testCtr, ctrs[0])
- }
+ testContainersEqual(t, testCtr, ctrs[0])
})
}
@@ -1600,11 +1572,7 @@ func TestPodContainersOneContainer(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 1, len(ctrs))
- // Use assert.EqualValues if the test fails to pretty print diff
- // between actual and expected
- if !testContainersEqual(testCtr, ctrs[0]) {
- assert.EqualValues(t, testCtr, ctrs[0])
- }
+ testContainersEqual(t, testCtr, ctrs[0])
})
}
@@ -1908,14 +1876,8 @@ func TestAddContainerToPodSucceeds(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 1, len(allCtrs))
- // Use assert.EqualValues if the test fails to pretty print diff
- // between actual and expected
- if !testContainersEqual(testCtr, ctrs[0]) {
- assert.EqualValues(t, testCtr, ctrs[0])
- }
- if !testContainersEqual(allCtrs[0], ctrs[0]) {
- assert.EqualValues(t, allCtrs[0], ctrs[0])
- }
+ testContainersEqual(t, testCtr, ctrs[0])
+ testContainersEqual(t, ctrs[0], allCtrs[0])
})
}
@@ -1980,11 +1942,7 @@ func TestAddContainerToPodWithAddContainer(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 2, len(allCtrs))
- // Use assert.EqualValues if the test fails to pretty print diff
- // between actual and expected
- if !testContainersEqual(testCtr1, ctrs[0]) {
- assert.EqualValues(t, testCtr1, ctrs[0])
- }
+ testContainersEqual(t, testCtr1, ctrs[0])
})
}
diff --git a/libpod/test_common.go b/libpod/test_common.go
index 28053eacb..9e52c74a5 100644
--- a/libpod/test_common.go
+++ b/libpod/test_common.go
@@ -4,12 +4,13 @@ import (
"encoding/json"
"net"
"path/filepath"
- "reflect"
+ "testing"
"time"
"github.com/containers/storage"
"github.com/cri-o/ocicni/pkg/ocicni"
"github.com/opencontainers/runtime-tools/generate"
+ "github.com/stretchr/testify/assert"
)
// nolint
@@ -98,40 +99,41 @@ func getTestPod(id, name, locksDir string) (*Pod, error) {
// This horrible hack tests if containers are equal in a way that should handle
// empty arrays being dropped to nil pointers in the spec JSON
// nolint
-func testContainersEqual(a, b *Container) bool {
+func testContainersEqual(t *testing.T, a, b *Container) {
if a == nil && b == nil {
- return true
- } else if a == nil || b == nil {
- return false
+ return
}
+ assert.NotNil(t, a)
+ assert.NotNil(t, b)
- if a.valid != b.valid {
- return false
- }
+ aConfig := new(ContainerConfig)
+ bConfig := new(ContainerConfig)
+ aState := new(containerState)
+ bState := new(containerState)
+
+ assert.Equal(t, a.valid, b.valid)
aConfigJSON, err := json.Marshal(a.config)
- if err != nil {
- return false
- }
+ assert.NoError(t, err)
+ err = json.Unmarshal(aConfigJSON, aConfig)
+ assert.NoError(t, err)
bConfigJSON, err := json.Marshal(b.config)
- if err != nil {
- return false
- }
+ assert.NoError(t, err)
+ err = json.Unmarshal(bConfigJSON, bConfig)
+ assert.NoError(t, err)
- if !reflect.DeepEqual(aConfigJSON, bConfigJSON) {
- return false
- }
+ assert.EqualValues(t, aConfig, bConfig)
aStateJSON, err := json.Marshal(a.state)
- if err != nil {
- return false
- }
+ assert.NoError(t, err)
+ err = json.Unmarshal(aStateJSON, aState)
+ assert.NoError(t, err)
bStateJSON, err := json.Marshal(b.state)
- if err != nil {
- return false
- }
+ assert.NoError(t, err)
+ err = json.Unmarshal(bStateJSON, bState)
+ assert.NoError(t, err)
- return reflect.DeepEqual(aStateJSON, bStateJSON)
+ assert.EqualValues(t, aState, bState)
}