diff options
author | Matthew Heon <matthew.heon@pm.me> | 2019-01-10 15:40:56 -0500 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2019-01-10 15:41:19 -0500 |
commit | 76c57f55cacb7916ca451e378d181b1c30c94032 (patch) | |
tree | 775fafbd2dcefae1b1731744219dc2410e985800 | |
parent | 6e8aeab472154e2b1eff92683803d16af06d2b30 (diff) | |
download | podman-76c57f55cacb7916ca451e378d181b1c30c94032.tar.gz podman-76c57f55cacb7916ca451e378d181b1c30c94032.tar.bz2 podman-76c57f55cacb7916ca451e378d181b1c30c94032.zip |
Revert "Merge pull request #1235 from mheon/shm_locking"
This reverts commit bf5f779331870d31863c486619daae3fcea458eb, reversing
changes made to 6868b5aa1444404113bc6a4582203fbbf89490c2.
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
-rw-r--r-- | .cirrus.yml | 2 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | libpod/boltdb_state_internal.go | 14 | ||||
-rw-r--r-- | libpod/common_test.go | 46 | ||||
-rw-r--r-- | libpod/container.go | 5 | ||||
-rw-r--r-- | libpod/container_easyjson.go | 8211 | ||||
-rw-r--r-- | libpod/container_graph_test.go | 160 | ||||
-rw-r--r-- | libpod/container_internal.go | 12 | ||||
-rw-r--r-- | libpod/lock/in_memory_locks.go | 91 | ||||
-rw-r--r-- | libpod/lock/lock.go | 58 | ||||
-rw-r--r-- | libpod/lock/shm/shm_lock.c | 452 | ||||
-rw-r--r-- | libpod/lock/shm/shm_lock.go | 216 | ||||
-rw-r--r-- | libpod/lock/shm/shm_lock.h | 46 | ||||
-rw-r--r-- | libpod/lock/shm/shm_lock_test.go | 278 | ||||
-rw-r--r-- | libpod/lock/shm_lock_manager_linux.go | 94 | ||||
-rw-r--r-- | libpod/lock/shm_lock_manager_unsupported.go | 29 | ||||
-rw-r--r-- | libpod/pod.go | 7 | ||||
-rw-r--r-- | libpod/pod_easyjson.go | 12 | ||||
-rw-r--r-- | libpod/pod_internal.go | 21 | ||||
-rw-r--r-- | libpod/runtime.go | 90 | ||||
-rw-r--r-- | libpod/runtime_ctr.go | 32 | ||||
-rw-r--r-- | libpod/runtime_pod_linux.go | 15 | ||||
-rw-r--r-- | libpod/runtime_volume_linux.go | 9 | ||||
-rw-r--r-- | libpod/state_test.go | 908 | ||||
-rw-r--r-- | libpod/volume.go | 10 |
25 files changed, 639 insertions, 10181 deletions
diff --git a/.cirrus.yml b/.cirrus.yml index 199c2a533..d1029d554 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -115,7 +115,7 @@ build_each_commit_task: matrix: image_name: "fedora-29-libpod-9afa57a9" - timeout_in: 30m + timeout_in: 20m script: - $SCRIPT_BASE/setup_environment.sh @@ -168,7 +168,7 @@ localunit: test/goecho/goecho varlink_generate ginkgo: ginkgo -v -tags "$(BUILDTAGS)" -cover -flakeAttempts 3 -progress -trace -noColor test/e2e/. -localintegration: varlink_generate test-binaries ginkgo +localintegration: varlink_generate test-binaries clientintegration ginkgo localsystem: .install.ginkgo .install.gomega ginkgo -v -noColor test/system/ diff --git a/libpod/boltdb_state_internal.go b/libpod/boltdb_state_internal.go index 29a7184c9..06f8dcb24 100644 --- a/libpod/boltdb_state_internal.go +++ b/libpod/boltdb_state_internal.go @@ -3,6 +3,7 @@ package libpod import ( "bytes" "encoding/json" + "path/filepath" "runtime" "strings" @@ -287,9 +288,10 @@ func (s *BoltState) getContainerFromDB(id []byte, ctr *Container, ctrsBkt *bolt. } // Get the lock - lock, err := s.runtime.lockManager.RetrieveLock(ctr.config.LockID) + lockPath := filepath.Join(s.runtime.lockDir, string(id)) + lock, err := storage.GetLockfile(lockPath) if err != nil { - return errors.Wrapf(err, "error retrieving lock for container %s", string(id)) + return errors.Wrapf(err, "error retrieving lockfile for container %s", string(id)) } ctr.lock = lock @@ -322,9 +324,10 @@ func (s *BoltState) getPodFromDB(id []byte, pod *Pod, podBkt *bolt.Bucket) error } // Get the lock - lock, err := s.runtime.lockManager.RetrieveLock(pod.config.LockID) + lockPath := filepath.Join(s.runtime.lockDir, string(id)) + lock, err := storage.GetLockfile(lockPath) if err != nil { - return errors.Wrapf(err, "error retrieving lock for pod %s", string(id)) + return errors.Wrapf(err, "error retrieving lockfile for pod %s", string(id)) } pod.lock = lock @@ -350,7 +353,8 @@ func (s *BoltState) getVolumeFromDB(name []byte, volume *Volume, volBkt *bolt.Bu } // Get the lock - lock, err := s.runtime.lockManager.RetrieveLock(volume.config.LockID) + lockPath := filepath.Join(s.runtime.lockDir, string(name)) + lock, err := storage.GetLockfile(lockPath) if err != nil { return errors.Wrapf(err, "error retrieving lockfile for volume %s", string(name)) } diff --git a/libpod/common_test.go b/libpod/common_test.go index efbb5f404..81c8f1920 100644 --- a/libpod/common_test.go +++ b/libpod/common_test.go @@ -3,19 +3,20 @@ package libpod import ( "encoding/json" "net" + "path/filepath" "reflect" "strings" "testing" "time" - "github.com/containers/libpod/libpod/lock" + "github.com/containers/storage" "github.com/cri-o/ocicni/pkg/ocicni" "github.com/opencontainers/runtime-tools/generate" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func getTestContainer(id, name string, manager lock.Manager) (*Container, error) { +func getTestContainer(id, name, locksDir string) (*Container, error) { ctr := &Container{ config: &ContainerConfig{ ID: id, @@ -89,18 +90,18 @@ func getTestContainer(id, name string, manager lock.Manager) (*Container, error) ctr.config.Labels["test"] = "testing" - // Allocate a lock for the container - lock, err := manager.AllocateLock() + // Must make lockfile or container will error on being retrieved from DB + lockPath := filepath.Join(locksDir, id) + lock, err := storage.GetLockfile(lockPath) if err != nil { return nil, err } ctr.lock = lock - ctr.config.LockID = lock.ID() return ctr, nil } -func getTestPod(id, name string, manager lock.Manager) (*Pod, error) { +func getTestPod(id, name, locksDir string) (*Pod, error) { pod := &Pod{ config: &PodConfig{ ID: id, @@ -114,39 +115,38 @@ func getTestPod(id, name string, manager lock.Manager) (*Pod, error) { valid: true, } - // Allocate a lock for the pod - lock, err := manager.AllocateLock() + lockPath := filepath.Join(locksDir, id) + lock, err := storage.GetLockfile(lockPath) if err != nil { return nil, err } pod.lock = lock - pod.config.LockID = lock.ID() return pod, nil } -func getTestCtrN(n string, manager lock.Manager) (*Container, error) { - return getTestContainer(strings.Repeat(n, 32), "test"+n, manager) +func getTestCtrN(n, lockPath string) (*Container, error) { + return getTestContainer(strings.Repeat(n, 32), "test"+n, lockPath) } -func getTestCtr1(manager lock.Manager) (*Container, error) { - return getTestCtrN("1", manager) +func getTestCtr1(lockPath string) (*Container, error) { + return getTestCtrN("1", lockPath) } -func getTestCtr2(manager lock.Manager) (*Container, error) { - return getTestCtrN("2", manager) +func getTestCtr2(lockPath string) (*Container, error) { + return getTestCtrN("2", lockPath) } -func getTestPodN(n string, manager lock.Manager) (*Pod, error) { - return getTestPod(strings.Repeat(n, 32), "test"+n, manager) +func getTestPodN(n, lockPath string) (*Pod, error) { + return getTestPod(strings.Repeat(n, 32), "test"+n, lockPath) } -func getTestPod1(manager lock.Manager) (*Pod, error) { - return getTestPodN("1", manager) +func getTestPod1(lockPath string) (*Pod, error) { + return getTestPodN("1", lockPath) } -func getTestPod2(manager lock.Manager) (*Pod, error) { - return getTestPodN("2", manager) +func getTestPod2(lockPath string) (*Pod, error) { + return getTestPodN("2", lockPath) } // This horrible hack tests if containers are equal in a way that should handle @@ -174,8 +174,6 @@ func testContainersEqual(t *testing.T, a, b *Container, allowedEmpty bool) { assert.Equal(t, a.valid, b.valid) - assert.Equal(t, a.lock.ID(), b.lock.ID()) - aConfigJSON, err := json.Marshal(a.config) assert.NoError(t, err) err = json.Unmarshal(aConfigJSON, aConfig) @@ -225,8 +223,6 @@ func testPodsEqual(t *testing.T, a, b *Pod, allowedEmpty bool) { assert.Equal(t, a.valid, b.valid) - assert.Equal(t, a.lock.ID(), b.lock.ID()) - assert.EqualValues(t, a.config, b.config) if allowedEmpty { diff --git a/libpod/container.go b/libpod/container.go index 026eb1c4f..f18f36160 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -11,7 +11,6 @@ import ( "github.com/containernetworking/cni/pkg/types" cnitypes "github.com/containernetworking/cni/pkg/types/current" - "github.com/containers/libpod/libpod/lock" "github.com/containers/libpod/pkg/namespaces" "github.com/containers/storage" "github.com/cri-o/ocicni/pkg/ocicni" @@ -125,7 +124,7 @@ type Container struct { batched bool valid bool - lock lock.Locker + lock storage.Locker runtime *Runtime rootlessSlirpSyncR *os.File @@ -219,8 +218,6 @@ type ContainerConfig struct { Pod string `json:"pod,omitempty"` // Namespace the container is in Namespace string `json:"namespace,omitempty"` - // ID of this container's lock - LockID uint32 `json:"lockID"` // TODO consider breaking these subsections up into smaller structs diff --git a/libpod/container_easyjson.go b/libpod/container_easyjson.go index 50741df11..61fa33a30 100644 --- a/libpod/container_easyjson.go +++ b/libpod/container_easyjson.go @@ -1,8203 +1,32 @@ // +build seccomp ostree selinux varlink exclude_graphdriver_devicemapper -// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. +// TEMPORARY AUTOGENERATED FILE: easyjson stub code to make the package +// compilable during generation. -package libpod +package libpod import ( - json "encoding/json" - types "github.com/containernetworking/cni/pkg/types" - current "github.com/containernetworking/cni/pkg/types/current" - namespaces "github.com/containers/libpod/pkg/namespaces" - storage "github.com/containers/storage" - idtools "github.com/containers/storage/pkg/idtools" - ocicni "github.com/cri-o/ocicni/pkg/ocicni" - easyjson "github.com/mailru/easyjson" - jlexer "github.com/mailru/easyjson/jlexer" - jwriter "github.com/mailru/easyjson/jwriter" - specs_go "github.com/opencontainers/runtime-spec/specs-go" - net "net" - os "os" + "github.com/mailru/easyjson/jwriter" + "github.com/mailru/easyjson/jlexer" ) -// suppress unused package warning -var ( - _ *json.RawMessage - _ *jlexer.Lexer - _ *jwriter.Writer - _ easyjson.Marshaler -) - -func easyjson1dbef17bDecodeGithubComContainersLibpodLibpod(in *jlexer.Lexer, out *containerState) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "state": - out.State = ContainerStatus(in.Int()) - case "configPath": - out.ConfigPath = string(in.String()) - case "runDir": - out.RunDir = string(in.String()) - case "destinationRunDir": - out.DestinationRunDir = string(in.String()) - case "mounted": - out.Mounted = bool(in.Bool()) - case "mountPoint": - out.Mountpoint = string(in.String()) - case "realMountPoint": - out.RealMountpoint = string(in.String()) - case "startedTime": - if data := in.Raw(); in.Ok() { - in.AddError((out.StartedTime).UnmarshalJSON(data)) - } - case "finishedTime": - if data := in.Raw(); in.Ok() { - in.AddError((out.FinishedTime).UnmarshalJSON(data)) - } - case "exitCode": - out.ExitCode = int32(in.Int32()) - case "exited": - out.Exited = bool(in.Bool()) - case "oomKilled": - out.OOMKilled = bool(in.Bool()) - case "pid": - out.PID = int(in.Int()) - case "execSessions": - if in.IsNull() { - in.Skip() - } else { - in.Delim('{') - if !in.IsDelim('}') { - out.ExecSessions = make(map[string]*ExecSession) - } else { - out.ExecSessions = nil - } - for !in.IsDelim('}') { - key := string(in.String()) - in.WantColon() - var v1 *ExecSession - if in.IsNull() { - in.Skip() - v1 = nil - } else { - if v1 == nil { - v1 = new(ExecSession) - } - if data := in.Raw(); in.Ok() { - in.AddError((*v1).UnmarshalJSON(data)) - } - } - (out.ExecSessions)[key] = v1 - in.WantComma() - } - in.Delim('}') - } - case "networkResults": - if in.IsNull() { - in.Skip() - out.NetworkStatus = nil - } else { - in.Delim('[') - if out.NetworkStatus == nil { - if !in.IsDelim(']') { - out.NetworkStatus = make([]*current.Result, 0, 8) - } else { - out.NetworkStatus = []*current.Result{} - } - } else { - out.NetworkStatus = (out.NetworkStatus)[:0] - } - for !in.IsDelim(']') { - var v2 *current.Result - if in.IsNull() { - in.Skip() - v2 = nil - } else { - if v2 == nil { - v2 = new(current.Result) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComContainernetworkingCniPkgTypesCurrent(in, &*v2) - } - out.NetworkStatus = append(out.NetworkStatus, v2) - in.WantComma() - } - in.Delim(']') - } - case "bindMounts": - if in.IsNull() { - in.Skip() - } else { - in.Delim('{') - if !in.IsDelim('}') { - out.BindMounts = make(map[string]string) - } else { - out.BindMounts = nil - } - for !in.IsDelim('}') { - key := string(in.String()) - in.WantColon() - var v3 string - v3 = string(in.String()) - (out.BindMounts)[key] = v3 - in.WantComma() - } - in.Delim('}') - } - case "userNSRoot": - out.UserNSRoot = string(in.String()) - case "extensionStageHooks": - if in.IsNull() { - in.Skip() - } else { - in.Delim('{') - if !in.IsDelim('}') { - out.ExtensionStageHooks = make(map[string][]specs_go.Hook) - } else { - out.ExtensionStageHooks = nil - } - for !in.IsDelim('}') { - key := string(in.String()) - in.WantColon() - var v4 []specs_go.Hook - if in.IsNull() { - in.Skip() - v4 = nil - } else { - in.Delim('[') - if v4 == nil { - if !in.IsDelim(']') { - v4 = make([]specs_go.Hook, 0, 1) - } else { - v4 = []specs_go.Hook{} - } - } else { - v4 = (v4)[:0] - } - for !in.IsDelim(']') { - var v5 specs_go.Hook - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo(in, &v5) - v4 = append(v4, v5) - in.WantComma() - } - in.Delim(']') - } - (out.ExtensionStageHooks)[key] = v4 - in.WantComma() - } - in.Delim('}') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodLibpod(out *jwriter.Writer, in containerState) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"state\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int(int(in.State)) - } - if in.ConfigPath != "" { - const prefix string = ",\"configPath\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.ConfigPath)) - } - if in.RunDir != "" { - const prefix string = ",\"runDir\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.RunDir)) - } - if in.DestinationRunDir != "" { - const prefix string = ",\"destinationRunDir\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.DestinationRunDir)) - } - if in.Mounted { - const prefix string = ",\"mounted\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.Mounted)) - } - if in.Mountpoint != "" { - const prefix string = ",\"mountPoint\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Mountpoint)) - } - if in.RealMountpoint != "" { - const prefix string = ",\"realMountPoint\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.RealMountpoint)) - } - if true { - const prefix string = ",\"startedTime\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Raw((in.StartedTime).MarshalJSON()) - } - if true { - const prefix string = ",\"finishedTime\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Raw((in.FinishedTime).MarshalJSON()) - } - if in.ExitCode != 0 { - const prefix string = ",\"exitCode\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int32(int32(in.ExitCode)) - } - if in.Exited { - const prefix string = ",\"exited\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.Exited)) - } - if in.OOMKilled { - const prefix string = ",\"oomKilled\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.OOMKilled)) - } - if in.PID != 0 { - const prefix string = ",\"pid\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int(int(in.PID)) - } - if len(in.ExecSessions) != 0 { - const prefix string = ",\"execSessions\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('{') - v6First := true - for v6Name, v6Value := range in.ExecSessions { - if v6First { - v6First = false - } else { - out.RawByte(',') - } - out.String(string(v6Name)) - out.RawByte(':') - if v6Value == nil { - out.RawString("null") - } else { - out.Raw((*v6Value).MarshalJSON()) - } - } - out.RawByte('}') - } - } - if len(in.NetworkStatus) != 0 { - const prefix string = ",\"networkResults\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v7, v8 := range in.NetworkStatus { - if v7 > 0 { - out.RawByte(',') - } - if v8 == nil { - out.RawString("null") - } else { - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComContainernetworkingCniPkgTypesCurrent(out, *v8) - } - } - out.RawByte(']') - } - } - if len(in.BindMounts) != 0 { - const prefix string = ",\"bindMounts\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('{') - v9First := true - for v9Name, v9Value := range in.BindMounts { - if v9First { - v9First = false - } else { - out.RawByte(',') - } - out.String(string(v9Name)) - out.RawByte(':') - out.String(string(v9Value)) - } - out.RawByte('}') - } - } - if in.UserNSRoot != "" { - const prefix string = ",\"userNSRoot\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.UserNSRoot)) - } - if len(in.ExtensionStageHooks) != 0 { - const prefix string = ",\"extensionStageHooks\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('{') - v10First := true - for v10Name, v10Value := range in.ExtensionStageHooks { - if v10First { - v10First = false - } else { - out.RawByte(',') - } - out.String(string(v10Name)) - out.RawByte(':') - if v10Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v11, v12 := range v10Value { - if v11 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo(out, v12) - } - out.RawByte(']') - } - } - out.RawByte('}') - } - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v containerState) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson1dbef17bEncodeGithubComContainersLibpodLibpod(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v containerState) MarshalEasyJSON(w *jwriter.Writer) { - easyjson1dbef17bEncodeGithubComContainersLibpodLibpod(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *containerState) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson1dbef17bDecodeGithubComContainersLibpodLibpod(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *containerState) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson1dbef17bDecodeGithubComContainersLibpodLibpod(l, v) -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo(in *jlexer.Lexer, out *specs_go.Hook) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "path": - out.Path = string(in.String()) - case "args": - if in.IsNull() { - in.Skip() - out.Args = nil - } else { - in.Delim('[') - if out.Args == nil { - if !in.IsDelim(']') { - out.Args = make([]string, 0, 4) - } else { - out.Args = []string{} - } - } else { - out.Args = (out.Args)[:0] - } - for !in.IsDelim(']') { - var v13 string - v13 = string(in.String()) - out.Args = append(out.Args, v13) - in.WantComma() - } - in.Delim(']') - } - case "env": - if in.IsNull() { - in.Skip() - out.Env = nil - } else { - in.Delim('[') - if out.Env == nil { - if !in.IsDelim(']') { - out.Env = make([]string, 0, 4) - } else { - out.Env = []string{} - } - } else { - out.Env = (out.Env)[:0] - } - for !in.IsDelim(']') { - var v14 string - v14 = string(in.String()) - out.Env = append(out.Env, v14) - in.WantComma() - } - in.Delim(']') - } - case "timeout": - if in.IsNull() { - in.Skip() - out.Timeout = nil - } else { - if out.Timeout == nil { - out.Timeout = new(int) - } - *out.Timeout = int(in.Int()) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo(out *jwriter.Writer, in specs_go.Hook) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"path\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Path)) - } - if len(in.Args) != 0 { - const prefix string = ",\"args\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v15, v16 := range in.Args { - if v15 > 0 { - out.RawByte(',') - } - out.String(string(v16)) - } - out.RawByte(']') - } - } - if len(in.Env) != 0 { - const prefix string = ",\"env\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v17, v18 := range in.Env { - if v17 > 0 { - out.RawByte(',') - } - out.String(string(v18)) - } - out.RawByte(']') - } - } - if in.Timeout != nil { - const prefix string = ",\"timeout\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int(int(*in.Timeout)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComContainernetworkingCniPkgTypesCurrent(in *jlexer.Lexer, out *current.Result) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "cniVersion": - out.CNIVersion = string(in.String()) - case "interfaces": - if in.IsNull() { - in.Skip() - out.Interfaces = nil - } else { - in.Delim('[') - if out.Interfaces == nil { - if !in.IsDelim(']') { - out.Interfaces = make([]*current.Interface, 0, 8) - } else { - out.Interfaces = []*current.Interface{} - } - } else { - out.Interfaces = (out.Interfaces)[:0] - } - for !in.IsDelim(']') { - var v19 *current.Interface - if in.IsNull() { - in.Skip() - v19 = nil - } else { - if v19 == nil { - v19 = new(current.Interface) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComContainernetworkingCniPkgTypesCurrent1(in, &*v19) - } - out.Interfaces = append(out.Interfaces, v19) - in.WantComma() - } - in.Delim(']') - } - case "ips": - if in.IsNull() { - in.Skip() - out.IPs = nil - } else { - in.Delim('[') - if out.IPs == nil { - if !in.IsDelim(']') { - out.IPs = make([]*current.IPConfig, 0, 8) - } else { - out.IPs = []*current.IPConfig{} - } - } else { - out.IPs = (out.IPs)[:0] - } - for !in.IsDelim(']') { - var v20 *current.IPConfig - if in.IsNull() { - in.Skip() - v20 = nil - } else { - if v20 == nil { - v20 = new(current.IPConfig) - } - if data := in.Raw(); in.Ok() { - in.AddError((*v20).UnmarshalJSON(data)) - } - } - out.IPs = append(out.IPs, v20) - in.WantComma() - } - in.Delim(']') - } - case "routes": - if in.IsNull() { - in.Skip() - out.Routes = nil - } else { - in.Delim('[') - if out.Routes == nil { - if !in.IsDelim(']') { - out.Routes = make([]*types.Route, 0, 8) - } else { - out.Routes = []*types.Route{} - } - } else { - out.Routes = (out.Routes)[:0] - } - for !in.IsDelim(']') { - var v21 *types.Route - if in.IsNull() { - in.Skip() - v21 = nil - } else { - if v21 == nil { - v21 = new(types.Route) - } - if data := in.Raw(); in.Ok() { - in.AddError((*v21).UnmarshalJSON(data)) - } - } - out.Routes = append(out.Routes, v21) - in.WantComma() - } - in.Delim(']') - } - case "dns": - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComContainernetworkingCniPkgTypes(in, &out.DNS) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComContainernetworkingCniPkgTypesCurrent(out *jwriter.Writer, in current.Result) { - out.RawByte('{') - first := true - _ = first - if in.CNIVersion != "" { - const prefix string = ",\"cniVersion\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.CNIVersion)) - } - if len(in.Interfaces) != 0 { - const prefix string = ",\"interfaces\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v22, v23 := range in.Interfaces { - if v22 > 0 { - out.RawByte(',') - } - if v23 == nil { - out.RawString("null") - } else { - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComContainernetworkingCniPkgTypesCurrent1(out, *v23) - } - } - out.RawByte(']') - } - } - if len(in.IPs) != 0 { - const prefix string = ",\"ips\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v24, v25 := range in.IPs { - if v24 > 0 { - out.RawByte(',') - } - if v25 == nil { - out.RawString("null") - } else { - out.Raw((*v25).MarshalJSON()) - } - } - out.RawByte(']') - } - } - if len(in.Routes) != 0 { - const prefix string = ",\"routes\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v26, v27 := range in.Routes { - if v26 > 0 { - out.RawByte(',') - } - if v27 == nil { - out.RawString("null") - } else { - out.Raw((*v27).MarshalJSON()) - } - } - out.RawByte(']') - } - } - if true { - const prefix string = ",\"dns\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComContainernetworkingCniPkgTypes(out, in.DNS) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComContainernetworkingCniPkgTypes(in *jlexer.Lexer, out *types.DNS) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "nameservers": - if in.IsNull() { - in.Skip() - out.Nameservers = nil - } else { - in.Delim('[') - if out.Nameservers == nil { - if !in.IsDelim(']') { - out.Nameservers = make([]string, 0, 4) - } else { - out.Nameservers = []string{} - } - } else { - out.Nameservers = (out.Nameservers)[:0] - } - for !in.IsDelim(']') { - var v28 string - v28 = string(in.String()) - out.Nameservers = append(out.Nameservers, v28) - in.WantComma() - } - in.Delim(']') - } - case "domain": - out.Domain = string(in.String()) - case "search": - if in.IsNull() { - in.Skip() - out.Search = nil - } else { - in.Delim('[') - if out.Search == nil { - if !in.IsDelim(']') { - out.Search = make([]string, 0, 4) - } else { - out.Search = []string{} - } - } else { - out.Search = (out.Search)[:0] - } - for !in.IsDelim(']') { - var v29 string - v29 = string(in.String()) - out.Search = append(out.Search, v29) - in.WantComma() - } - in.Delim(']') - } - case "options": - if in.IsNull() { - in.Skip() - out.Options = nil - } else { - in.Delim('[') - if out.Options == nil { - if !in.IsDelim(']') { - out.Options = make([]string, 0, 4) - } else { - out.Options = []string{} - } - } else { - out.Options = (out.Options)[:0] - } - for !in.IsDelim(']') { - var v30 string - v30 = string(in.String()) - out.Options = append(out.Options, v30) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComContainernetworkingCniPkgTypes(out *jwriter.Writer, in types.DNS) { - out.RawByte('{') - first := true - _ = first - if len(in.Nameservers) != 0 { - const prefix string = ",\"nameservers\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v31, v32 := range in.Nameservers { - if v31 > 0 { - out.RawByte(',') - } - out.String(string(v32)) - } - out.RawByte(']') - } - } - if in.Domain != "" { - const prefix string = ",\"domain\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Domain)) - } - if len(in.Search) != 0 { - const prefix string = ",\"search\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v33, v34 := range in.Search { - if v33 > 0 { - out.RawByte(',') - } - out.String(string(v34)) - } - out.RawByte(']') - } - } - if len(in.Options) != 0 { - const prefix string = ",\"options\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v35, v36 := range in.Options { - if v35 > 0 { - out.RawByte(',') - } - out.String(string(v36)) - } - out.RawByte(']') - } - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComContainernetworkingCniPkgTypesCurrent1(in *jlexer.Lexer, out *current.Interface) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "name": - out.Name = string(in.String()) - case "mac": - out.Mac = string(in.String()) - case "sandbox": - out.Sandbox = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComContainernetworkingCniPkgTypesCurrent1(out *jwriter.Writer, in current.Interface) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"name\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Name)) - } - if in.Mac != "" { - const prefix string = ",\"mac\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Mac)) - } - if in.Sandbox != "" { - const prefix string = ",\"sandbox\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Sandbox)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodLibpod1(in *jlexer.Lexer, out *ExecSession) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "id": - out.ID = string(in.String()) - case "command": - if in.IsNull() { - in.Skip() - out.Command = nil - } else { - in.Delim('[') - if out.Command == nil { - if !in.IsDelim(']') { - out.Command = make([]string, 0, 4) - } else { - out.Command = []string{} - } - } else { - out.Command = (out.Command)[:0] - } - for !in.IsDelim(']') { - var v37 string - v37 = string(in.String()) - out.Command = append(out.Command, v37) - in.WantComma() - } - in.Delim(']') - } - case "pid": - out.PID = int(in.Int()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodLibpod1(out *jwriter.Writer, in ExecSession) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"id\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.ID)) - } - { - const prefix string = ",\"command\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - if in.Command == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v38, v39 := range in.Command { - if v38 > 0 { - out.RawByte(',') - } - out.String(string(v39)) - } - out.RawByte(']') - } - } - { - const prefix string = ",\"pid\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int(int(in.PID)) - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v ExecSession) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson1dbef17bEncodeGithubComContainersLibpodLibpod1(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v ExecSession) MarshalEasyJSON(w *jwriter.Writer) { - easyjson1dbef17bEncodeGithubComContainersLibpodLibpod1(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *ExecSession) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson1dbef17bDecodeGithubComContainersLibpodLibpod1(&r, v) - return r.Error() -} +func ( ContainerConfig ) MarshalJSON() ([]byte, error) { return nil, nil } +func (* ContainerConfig ) UnmarshalJSON([]byte) error { return nil } +func ( ContainerConfig ) MarshalEasyJSON(w *jwriter.Writer) {} +func (* ContainerConfig ) UnmarshalEasyJSON(l *jlexer.Lexer) {} -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *ExecSession) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson1dbef17bDecodeGithubComContainersLibpodLibpod1(l, v) -} -func easyjson1dbef17bDecodeGithubComContainersLibpodLibpod2(in *jlexer.Lexer, out *ContainerConfig) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "spec": - if in.IsNull() { - in.Skip() - out.Spec = nil - } else { - if out.Spec == nil { - out.Spec = new(specs_go.Spec) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo1(in, &*out.Spec) - } - case "id": - out.ID = string(in.String()) - case "name": - out.Name = string(in.String()) - case "pod": - out.Pod = string(in.String()) - case "namespace": - out.Namespace = string(in.String()) - case "lockID": - out.LockID = uint32(in.Uint32()) - case "idMappingsOptions": - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComContainersStorage(in, &out.IDMappings) - case "rootfsImageID": - out.RootfsImageID = string(in.String()) - case "rootfsImageName": - out.RootfsImageName = string(in.String()) - case "rootfs": - out.Rootfs = string(in.String()) - case "imageVolumes": - out.ImageVolumes = bool(in.Bool()) - case "ShmDir": - out.ShmDir = string(in.String()) - case "shmSize": - out.ShmSize = int64(in.Int64()) - case "staticDir": - out.StaticDir = string(in.String()) - case "mounts": - if in.IsNull() { - in.Skip() - out.Mounts = nil - } else { - in.Delim('[') - if out.Mounts == nil { - if !in.IsDelim(']') { - out.Mounts = make([]string, 0, 4) - } else { - out.Mounts = []string{} - } - } else { - out.Mounts = (out.Mounts)[:0] - } - for !in.IsDelim(']') { - var v40 string - v40 = string(in.String()) - out.Mounts = append(out.Mounts, v40) - in.WantComma() - } - in.Delim(']') - } - case "privileged": - out.Privileged = bool(in.Bool()) - case "ProcessLabel": - out.ProcessLabel = string(in.String()) - case "MountLabel": - out.MountLabel = string(in.String()) - case "labelopts": - if in.IsNull() { - in.Skip() - out.LabelOpts = nil - } else { - in.Delim('[') - if out.LabelOpts == nil { - if !in.IsDelim(']') { - out.LabelOpts = make([]string, 0, 4) - } else { - out.LabelOpts = []string{} - } - } else { - out.LabelOpts = (out.LabelOpts)[:0] - } - for !in.IsDelim(']') { - var v41 string - v41 = string(in.String()) - out.LabelOpts = append(out.LabelOpts, v41) - in.WantComma() - } - in.Delim(']') - } - case "user": - out.User = string(in.String()) - case "groups": - if in.IsNull() { - in.Skip() - out.Groups = nil - } else { - in.Delim('[') - if out.Groups == nil { - if !in.IsDelim(']') { - out.Groups = make([]string, 0, 4) - } else { - out.Groups = []string{} - } - } else { - out.Groups = (out.Groups)[:0] - } - for !in.IsDelim(']') { - var v42 string - v42 = string(in.String()) - out.Groups = append(out.Groups, v42) - in.WantComma() - } - in.Delim(']') - } - case "ipcNsCtr": - out.IPCNsCtr = string(in.String()) - case "mountNsCtr": - out.MountNsCtr = string(in.String()) - case "netNsCtr": - out.NetNsCtr = string(in.String()) - case "pidNsCtr": - out.PIDNsCtr = string(in.String()) - case "userNsCtr": - out.UserNsCtr = string(in.String()) - case "utsNsCtr": - out.UTSNsCtr = string(in.String()) - case "cgroupNsCtr": - out.CgroupNsCtr = string(in.String()) - case "Dependencies": - if in.IsNull() { - in.Skip() - out.Dependencies = nil - } else { - in.Delim('[') - if out.Dependencies == nil { - if !in.IsDelim(']') { - out.Dependencies = make([]string, 0, 4) - } else { - out.Dependencies = []string{} - } - } else { - out.Dependencies = (out.Dependencies)[:0] - } - for !in.IsDelim(']') { - var v43 string - v43 = string(in.String()) - out.Dependencies = append(out.Dependencies, v43) - in.WantComma() - } - in.Delim(']') - } - case "createNetNS": - out.CreateNetNS = bool(in.Bool()) - case "staticIP": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.StaticIP).UnmarshalText(data)) - } - case "portMappings": - if in.IsNull() { - in.Skip() - out.PortMappings = nil - } else { - in.Delim('[') - if out.PortMappings == nil { - if !in.IsDelim(']') { - out.PortMappings = make([]ocicni.PortMapping, 0, 1) - } else { - out.PortMappings = []ocicni.PortMapping{} - } - } else { - out.PortMappings = (out.PortMappings)[:0] - } - for !in.IsDelim(']') { - var v44 ocicni.PortMapping - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComCriOOcicniPkgOcicni(in, &v44) - out.PortMappings = append(out.PortMappings, v44) - in.WantComma() - } - in.Delim(']') - } - case "dnsServer": - if in.IsNull() { - in.Skip() - out.DNSServer = nil - } else { - in.Delim('[') - if out.DNSServer == nil { - if !in.IsDelim(']') { - out.DNSServer = make([]net.IP, 0, 2) - } else { - out.DNSServer = []net.IP{} - } - } else { - out.DNSServer = (out.DNSServer)[:0] - } - for !in.IsDelim(']') { - var v45 net.IP - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((v45).UnmarshalText(data)) - } - out.DNSServer = append(out.DNSServer, v45) - in.WantComma() - } - in.Delim(']') - } - case "dnsSearch": - if in.IsNull() { - in.Skip() - out.DNSSearch = nil - } else { - in.Delim('[') - if out.DNSSearch == nil { - if !in.IsDelim(']') { - out.DNSSearch = make([]string, 0, 4) - } else { - out.DNSSearch = []string{} - } - } else { - out.DNSSearch = (out.DNSSearch)[:0] - } - for !in.IsDelim(']') { - var v46 string - v46 = string(in.String()) - out.DNSSearch = append(out.DNSSearch, v46) - in.WantComma() - } - in.Delim(']') - } - case "dnsOption": - if in.IsNull() { - in.Skip() - out.DNSOption = nil - } else { - in.Delim('[') - if out.DNSOption == nil { - if !in.IsDelim(']') { - out.DNSOption = make([]string, 0, 4) - } else { - out.DNSOption = []string{} - } - } else { - out.DNSOption = (out.DNSOption)[:0] - } - for !in.IsDelim(']') { - var v47 string - v47 = string(in.String()) - out.DNSOption = append(out.DNSOption, v47) - in.WantComma() - } - in.Delim(']') - } - case "hostsAdd": - if in.IsNull() { - in.Skip() - out.HostAdd = nil - } else { - in.Delim('[') - if out.HostAdd == nil { - if !in.IsDelim(']') { - out.HostAdd = make([]string, 0, 4) - } else { - out.HostAdd = []string{} - } - } else { - out.HostAdd = (out.HostAdd)[:0] - } - for !in.IsDelim(']') { - var v48 string - v48 = string(in.String()) - out.HostAdd = append(out.HostAdd, v48) - in.WantComma() - } - in.Delim(']') - } - case "networks": - if in.IsNull() { - in.Skip() - out.Networks = nil - } else { - in.Delim('[') - if out.Networks == nil { - if !in.IsDelim(']') { - out.Networks = make([]string, 0, 4) - } else { - out.Networks = []string{} - } - } else { - out.Networks = (out.Networks)[:0] - } - for !in.IsDelim(']') { - var v49 string - v49 = string(in.String()) - out.Networks = append(out.Networks, v49) - in.WantComma() - } - in.Delim(']') - } - case "networkMode": - out.NetMode = namespaces.NetworkMode(in.String()) - case "userVolumes": - if in.IsNull() { - in.Skip() - out.UserVolumes = nil - } else { - in.Delim('[') - if out.UserVolumes == nil { - if !in.IsDelim(']') { - out.UserVolumes = make([]string, 0, 4) - } else { - out.UserVolumes = []string{} - } - } else { - out.UserVolumes = (out.UserVolumes)[:0] - } - for !in.IsDelim(']') { - var v50 string - v50 = string(in.String()) - out.UserVolumes = append(out.UserVolumes, v50) - in.WantComma() - } - in.Delim(']') - } - case "entrypoint": - if in.IsNull() { - in.Skip() - out.Entrypoint = nil - } else { - in.Delim('[') - if out.Entrypoint == nil { - if !in.IsDelim(']') { - out.Entrypoint = make([]string, 0, 4) - } else { - out.Entrypoint = []string{} - } - } else { - out.Entrypoint = (out.Entrypoint)[:0] - } - for !in.IsDelim(']') { - var v51 string - v51 = string(in.String()) - out.Entrypoint = append(out.Entrypoint, v51) - in.WantComma() - } - in.Delim(']') - } - case "command": - if in.IsNull() { - in.Skip() - out.Command = nil - } else { - in.Delim('[') - if out.Command == nil { - if !in.IsDelim(']') { - out.Command = make([]string, 0, 4) - } else { - out.Command = []string{} - } - } else { - out.Command = (out.Command)[:0] - } - for !in.IsDelim(']') { - var v52 string - v52 = string(in.String()) - out.Command = append(out.Command, v52) - in.WantComma() - } - in.Delim(']') - } - case "stdin": - out.Stdin = bool(in.Bool()) - case "labels": - if in.IsNull() { - in.Skip() - } else { - in.Delim('{') - if !in.IsDelim('}') { - out.Labels = make(map[string]string) - } else { - out.Labels = nil - } - for !in.IsDelim('}') { - key := string(in.String()) - in.WantColon() - var v53 string - v53 = string(in.String()) - (out.Labels)[key] = v53 - in.WantComma() - } - in.Delim('}') - } - case "stopSignal": - out.StopSignal = uint(in.Uint()) - case "stopTimeout": - out.StopTimeout = uint(in.Uint()) - case "createdTime": - if data := in.Raw(); in.Ok() { - in.AddError((out.CreatedTime).UnmarshalJSON(data)) - } - case "cgroupParent": - out.CgroupParent = string(in.String()) - case "logPath": - out.LogPath = string(in.String()) - case "conmonPidFile": - out.ConmonPidFile = string(in.String()) - case "postConfigureNetNS": - out.PostConfigureNetNS = bool(in.Bool()) - case "exitCommand": - if in.IsNull() { - in.Skip() - out.ExitCommand = nil - } else { - in.Delim('[') - if out.ExitCommand == nil { - if !in.IsDelim(']') { - out.ExitCommand = make([]string, 0, 4) - } else { - out.ExitCommand = []string{} - } - } else { - out.ExitCommand = (out.ExitCommand)[:0] - } - for !in.IsDelim(']') { - var v54 string - v54 = string(in.String()) - out.ExitCommand = append(out.ExitCommand, v54) - in.WantComma() - } - in.Delim(']') - } - case "LocalVolumes": - if in.IsNull() { - in.Skip() - out.LocalVolumes = nil - } else { - in.Delim('[') - if out.LocalVolumes == nil { - if !in.IsDelim(']') { - out.LocalVolumes = make([]string, 0, 4) - } else { - out.LocalVolumes = []string{} - } - } else { - out.LocalVolumes = (out.LocalVolumes)[:0] - } - for !in.IsDelim(']') { - var v55 string - v55 = string(in.String()) - out.LocalVolumes = append(out.LocalVolumes, v55) - in.WantComma() - } - in.Delim(']') - } - case "pause": - out.IsInfra = bool(in.Bool()) - case "systemd": - out.Systemd = bool(in.Bool()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodLibpod2(out *jwriter.Writer, in ContainerConfig) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"spec\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - if in.Spec == nil { - out.RawString("null") - } else { - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo1(out, *in.Spec) - } - } - { - const prefix string = ",\"id\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.ID)) - } - { - const prefix string = ",\"name\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Name)) - } - if in.Pod != "" { - const prefix string = ",\"pod\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Pod)) - } - if in.Namespace != "" { - const prefix string = ",\"namespace\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Namespace)) - } - { - const prefix string = ",\"lockID\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint32(uint32(in.LockID)) - } - if true { - const prefix string = ",\"idMappingsOptions\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComContainersStorage(out, in.IDMappings) - } - if in.RootfsImageID != "" { - const prefix string = ",\"rootfsImageID\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.RootfsImageID)) - } - if in.RootfsImageName != "" { - const prefix string = ",\"rootfsImageName\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.RootfsImageName)) - } - if in.Rootfs != "" { - const prefix string = ",\"rootfs\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Rootfs)) - } - { - const prefix string = ",\"imageVolumes\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.ImageVolumes)) - } - if in.ShmDir != "" { - const prefix string = ",\"ShmDir\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.ShmDir)) - } - { - const prefix string = ",\"shmSize\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(in.ShmSize)) - } - { - const prefix string = ",\"staticDir\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.StaticDir)) - } - if len(in.Mounts) != 0 { - const prefix string = ",\"mounts\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v56, v57 := range in.Mounts { - if v56 > 0 { - out.RawByte(',') - } - out.String(string(v57)) - } - out.RawByte(']') - } - } - { - const prefix string = ",\"privileged\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.Privileged)) - } - if in.ProcessLabel != "" { - const prefix string = ",\"ProcessLabel\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.ProcessLabel)) - } - if in.MountLabel != "" { - const prefix string = ",\"MountLabel\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.MountLabel)) - } - if len(in.LabelOpts) != 0 { - const prefix string = ",\"labelopts\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v58, v59 := range in.LabelOpts { - if v58 > 0 { - out.RawByte(',') - } - out.String(string(v59)) - } - out.RawByte(']') - } - } - if in.User != "" { - const prefix string = ",\"user\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.User)) - } - if len(in.Groups) != 0 { - const prefix string = ",\"groups\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v60, v61 := range in.Groups { - if v60 > 0 { - out.RawByte(',') - } - out.String(string(v61)) - } - out.RawByte(']') - } - } - if in.IPCNsCtr != "" { - const prefix string = ",\"ipcNsCtr\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.IPCNsCtr)) - } - if in.MountNsCtr != "" { - const prefix string = ",\"mountNsCtr\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.MountNsCtr)) - } - if in.NetNsCtr != "" { - const prefix string = ",\"netNsCtr\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.NetNsCtr)) - } - if in.PIDNsCtr != "" { - const prefix string = ",\"pidNsCtr\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.PIDNsCtr)) - } - if in.UserNsCtr != "" { - const prefix string = ",\"userNsCtr\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.UserNsCtr)) - } - if in.UTSNsCtr != "" { - const prefix string = ",\"utsNsCtr\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.UTSNsCtr)) - } - if in.CgroupNsCtr != "" { - const prefix string = ",\"cgroupNsCtr\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.CgroupNsCtr)) - } - { - const prefix string = ",\"Dependencies\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - if in.Dependencies == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v62, v63 := range in.Dependencies { - if v62 > 0 { - out.RawByte(',') - } - out.String(string(v63)) - } - out.RawByte(']') - } - } - { - const prefix string = ",\"createNetNS\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.CreateNetNS)) - } - { - const prefix string = ",\"staticIP\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.RawText((in.StaticIP).MarshalText()) - } - if len(in.PortMappings) != 0 { - const prefix string = ",\"portMappings\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v64, v65 := range in.PortMappings { - if v64 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComCriOOcicniPkgOcicni(out, v65) - } - out.RawByte(']') - } - } - if len(in.DNSServer) != 0 { - const prefix string = ",\"dnsServer\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v66, v67 := range in.DNSServer { - if v66 > 0 { - out.RawByte(',') - } - out.RawText((v67).MarshalText()) - } - out.RawByte(']') - } - } - if len(in.DNSSearch) != 0 { - const prefix string = ",\"dnsSearch\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v68, v69 := range in.DNSSearch { - if v68 > 0 { - out.RawByte(',') - } - out.String(string(v69)) - } - out.RawByte(']') - } - } - if len(in.DNSOption) != 0 { - const prefix string = ",\"dnsOption\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v70, v71 := range in.DNSOption { - if v70 > 0 { - out.RawByte(',') - } - out.String(string(v71)) - } - out.RawByte(']') - } - } - if len(in.HostAdd) != 0 { - const prefix string = ",\"hostsAdd\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v72, v73 := range in.HostAdd { - if v72 > 0 { - out.RawByte(',') - } - out.String(string(v73)) - } - out.RawByte(']') - } - } - if len(in.Networks) != 0 { - const prefix string = ",\"networks\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v74, v75 := range in.Networks { - if v74 > 0 { - out.RawByte(',') - } - out.String(string(v75)) - } - out.RawByte(']') - } - } - if in.NetMode != "" { - const prefix string = ",\"networkMode\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.NetMode)) - } - if len(in.UserVolumes) != 0 { - const prefix string = ",\"userVolumes\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v76, v77 := range in.UserVolumes { - if v76 > 0 { - out.RawByte(',') - } - out.String(string(v77)) - } - out.RawByte(']') - } - } - if len(in.Entrypoint) != 0 { - const prefix string = ",\"entrypoint\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v78, v79 := range in.Entrypoint { - if v78 > 0 { - out.RawByte(',') - } - out.String(string(v79)) - } - out.RawByte(']') - } - } - if len(in.Command) != 0 { - const prefix string = ",\"command\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v80, v81 := range in.Command { - if v80 > 0 { - out.RawByte(',') - } - out.String(string(v81)) - } - out.RawByte(']') - } - } - if in.Stdin { - const prefix string = ",\"stdin\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.Stdin)) - } - if len(in.Labels) != 0 { - const prefix string = ",\"labels\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('{') - v82First := true - for v82Name, v82Value := range in.Labels { - if v82First { - v82First = false - } else { - out.RawByte(',') - } - out.String(string(v82Name)) - out.RawByte(':') - out.String(string(v82Value)) - } - out.RawByte('}') - } - } - if in.StopSignal != 0 { - const prefix string = ",\"stopSignal\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint(uint(in.StopSignal)) - } - if in.StopTimeout != 0 { - const prefix string = ",\"stopTimeout\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint(uint(in.StopTimeout)) - } - { - const prefix string = ",\"createdTime\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Raw((in.CreatedTime).MarshalJSON()) - } - { - const prefix string = ",\"cgroupParent\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.CgroupParent)) - } - { - const prefix string = ",\"logPath\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.LogPath)) - } - if in.ConmonPidFile != "" { - const prefix string = ",\"conmonPidFile\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.ConmonPidFile)) - } - { - const prefix string = ",\"postConfigureNetNS\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.PostConfigureNetNS)) - } - if len(in.ExitCommand) != 0 { - const prefix string = ",\"exitCommand\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v83, v84 := range in.ExitCommand { - if v83 > 0 { - out.RawByte(',') - } - out.String(string(v84)) - } - out.RawByte(']') - } - } - { - const prefix string = ",\"LocalVolumes\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - if in.LocalVolumes == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v85, v86 := range in.LocalVolumes { - if v85 > 0 { - out.RawByte(',') - } - out.String(string(v86)) - } - out.RawByte(']') - } - } - { - const prefix string = ",\"pause\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.IsInfra)) - } - { - const prefix string = ",\"systemd\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.Systemd)) - } - out.RawByte('}') -} +type EasyJSON_exporter_ContainerConfig *ContainerConfig -// MarshalJSON supports json.Marshaler interface -func (v ContainerConfig) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson1dbef17bEncodeGithubComContainersLibpodLibpod2(&w, v) - return w.Buffer.BuildBytes(), w.Error -} +func ( ExecSession ) MarshalJSON() ([]byte, error) { return nil, nil } +func (* ExecSession ) UnmarshalJSON([]byte) error { return nil } +func ( ExecSession ) MarshalEasyJSON(w *jwriter.Writer) {} +func (* ExecSession ) UnmarshalEasyJSON(l *jlexer.Lexer) {} -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v ContainerConfig) MarshalEasyJSON(w *jwriter.Writer) { - easyjson1dbef17bEncodeGithubComContainersLibpodLibpod2(w, v) -} +type EasyJSON_exporter_ExecSession *ExecSession -// UnmarshalJSON supports json.Unmarshaler interface -func (v *ContainerConfig) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson1dbef17bDecodeGithubComContainersLibpodLibpod2(&r, v) - return r.Error() -} +func ( containerState ) MarshalJSON() ([]byte, error) { return nil, nil } +func (* containerState ) UnmarshalJSON([]byte) error { return nil } +func ( containerState ) MarshalEasyJSON(w *jwriter.Writer) {} +func (* containerState ) UnmarshalEasyJSON(l *jlexer.Lexer) {} -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *ContainerConfig) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson1dbef17bDecodeGithubComContainersLibpodLibpod2(l, v) -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComCriOOcicniPkgOcicni(in *jlexer.Lexer, out *ocicni.PortMapping) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "hostPort": - out.HostPort = int32(in.Int32()) - case "containerPort": - out.ContainerPort = int32(in.Int32()) - case "protocol": - out.Protocol = string(in.String()) - case "hostIP": - out.HostIP = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComCriOOcicniPkgOcicni(out *jwriter.Writer, in ocicni.PortMapping) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"hostPort\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int32(int32(in.HostPort)) - } - { - const prefix string = ",\"containerPort\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int32(int32(in.ContainerPort)) - } - { - const prefix string = ",\"protocol\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Protocol)) - } - { - const prefix string = ",\"hostIP\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.HostIP)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComContainersStorage(in *jlexer.Lexer, out *storage.IDMappingOptions) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "HostUIDMapping": - out.HostUIDMapping = bool(in.Bool()) - case "HostGIDMapping": - out.HostGIDMapping = bool(in.Bool()) - case "UIDMap": - if in.IsNull() { - in.Skip() - out.UIDMap = nil - } else { - in.Delim('[') - if out.UIDMap == nil { - if !in.IsDelim(']') { - out.UIDMap = make([]idtools.IDMap, 0, 2) - } else { - out.UIDMap = []idtools.IDMap{} - } - } else { - out.UIDMap = (out.UIDMap)[:0] - } - for !in.IsDelim(']') { - var v87 idtools.IDMap - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComContainersStoragePkgIdtools(in, &v87) - out.UIDMap = append(out.UIDMap, v87) - in.WantComma() - } - in.Delim(']') - } - case "GIDMap": - if in.IsNull() { - in.Skip() - out.GIDMap = nil - } else { - in.Delim('[') - if out.GIDMap == nil { - if !in.IsDelim(']') { - out.GIDMap = make([]idtools.IDMap, 0, 2) - } else { - out.GIDMap = []idtools.IDMap{} - } - } else { - out.GIDMap = (out.GIDMap)[:0] - } - for !in.IsDelim(']') { - var v88 idtools.IDMap - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComContainersStoragePkgIdtools(in, &v88) - out.GIDMap = append(out.GIDMap, v88) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComContainersStorage(out *jwriter.Writer, in storage.IDMappingOptions) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"HostUIDMapping\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.HostUIDMapping)) - } - { - const prefix string = ",\"HostGIDMapping\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.HostGIDMapping)) - } - { - const prefix string = ",\"UIDMap\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - if in.UIDMap == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v89, v90 := range in.UIDMap { - if v89 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComContainersStoragePkgIdtools(out, v90) - } - out.RawByte(']') - } - } - { - const prefix string = ",\"GIDMap\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - if in.GIDMap == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v91, v92 := range in.GIDMap { - if v91 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComContainersStoragePkgIdtools(out, v92) - } - out.RawByte(']') - } - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComContainersStoragePkgIdtools(in *jlexer.Lexer, out *idtools.IDMap) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "container_id": - out.ContainerID = int(in.Int()) - case "host_id": - out.HostID = int(in.Int()) - case "size": - out.Size = int(in.Int()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComContainersStoragePkgIdtools(out *jwriter.Writer, in idtools.IDMap) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"container_id\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int(int(in.ContainerID)) - } - { - const prefix string = ",\"host_id\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int(int(in.HostID)) - } - { - const prefix string = ",\"size\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int(int(in.Size)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo1(in *jlexer.Lexer, out *specs_go.Spec) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "ociVersion": - out.Version = string(in.String()) - case "process": - if in.IsNull() { - in.Skip() - out.Process = nil - } else { - if out.Process == nil { - out.Process = new(specs_go.Process) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo2(in, &*out.Process) - } - case "root": - if in.IsNull() { - in.Skip() - out.Root = nil - } else { - if out.Root == nil { - out.Root = new(specs_go.Root) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo3(in, &*out.Root) - } - case "hostname": - out.Hostname = string(in.String()) - case "mounts": - if in.IsNull() { - in.Skip() - out.Mounts = nil - } else { - in.Delim('[') - if out.Mounts == nil { - if !in.IsDelim(']') { - out.Mounts = make([]specs_go.Mount, 0, 1) - } else { - out.Mounts = []specs_go.Mount{} - } - } else { - out.Mounts = (out.Mounts)[:0] - } - for !in.IsDelim(']') { - var v93 specs_go.Mount - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo4(in, &v93) - out.Mounts = append(out.Mounts, v93) - in.WantComma() - } - in.Delim(']') - } - case "hooks": - if in.IsNull() { - in.Skip() - out.Hooks = nil - } else { - if out.Hooks == nil { - out.Hooks = new(specs_go.Hooks) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo5(in, &*out.Hooks) - } - case "annotations": - if in.IsNull() { - in.Skip() - } else { - in.Delim('{') - if !in.IsDelim('}') { - out.Annotations = make(map[string]string) - } else { - out.Annotations = nil - } - for !in.IsDelim('}') { - key := string(in.String()) - in.WantColon() - var v94 string - v94 = string(in.String()) - (out.Annotations)[key] = v94 - in.WantComma() - } - in.Delim('}') - } - case "linux": - if in.IsNull() { - in.Skip() - out.Linux = nil - } else { - if out.Linux == nil { - out.Linux = new(specs_go.Linux) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo6(in, &*out.Linux) - } - case "solaris": - if in.IsNull() { - in.Skip() - out.Solaris = nil - } else { - if out.Solaris == nil { - out.Solaris = new(specs_go.Solaris) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo7(in, &*out.Solaris) - } - case "windows": - if in.IsNull() { - in.Skip() - out.Windows = nil - } else { - if out.Windows == nil { - out.Windows = new(specs_go.Windows) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo8(in, &*out.Windows) - } - case "vm": - if in.IsNull() { - in.Skip() - out.VM = nil - } else { - if out.VM == nil { - out.VM = new(specs_go.VM) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo9(in, &*out.VM) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo1(out *jwriter.Writer, in specs_go.Spec) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"ociVersion\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Version)) - } - if in.Process != nil { - const prefix string = ",\"process\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo2(out, *in.Process) - } - if in.Root != nil { - const prefix string = ",\"root\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo3(out, *in.Root) - } - if in.Hostname != "" { - const prefix string = ",\"hostname\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Hostname)) - } - if len(in.Mounts) != 0 { - const prefix string = ",\"mounts\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v95, v96 := range in.Mounts { - if v95 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo4(out, v96) - } - out.RawByte(']') - } - } - if in.Hooks != nil { - const prefix string = ",\"hooks\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo5(out, *in.Hooks) - } - if len(in.Annotations) != 0 { - const prefix string = ",\"annotations\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('{') - v97First := true - for v97Name, v97Value := range in.Annotations { - if v97First { - v97First = false - } else { - out.RawByte(',') - } - out.String(string(v97Name)) - out.RawByte(':') - out.String(string(v97Value)) - } - out.RawByte('}') - } - } - if in.Linux != nil { - const prefix string = ",\"linux\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo6(out, *in.Linux) - } - if in.Solaris != nil { - const prefix string = ",\"solaris\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo7(out, *in.Solaris) - } - if in.Windows != nil { - const prefix string = ",\"windows\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo8(out, *in.Windows) - } - if in.VM != nil { - const prefix string = ",\"vm\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo9(out, *in.VM) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo9(in *jlexer.Lexer, out *specs_go.VM) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "hypervisor": - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo10(in, &out.Hypervisor) - case "kernel": - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo11(in, &out.Kernel) - case "image": - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo12(in, &out.Image) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo9(out *jwriter.Writer, in specs_go.VM) { - out.RawByte('{') - first := true - _ = first - if true { - const prefix string = ",\"hypervisor\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo10(out, in.Hypervisor) - } - { - const prefix string = ",\"kernel\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo11(out, in.Kernel) - } - if true { - const prefix string = ",\"image\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo12(out, in.Image) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo12(in *jlexer.Lexer, out *specs_go.VMImage) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "path": - out.Path = string(in.String()) - case "format": - out.Format = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo12(out *jwriter.Writer, in specs_go.VMImage) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"path\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Path)) - } - { - const prefix string = ",\"format\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Format)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo11(in *jlexer.Lexer, out *specs_go.VMKernel) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "path": - out.Path = string(in.String()) - case "parameters": - out.Parameters = string(in.String()) - case "initrd": - out.InitRD = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo11(out *jwriter.Writer, in specs_go.VMKernel) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"path\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Path)) - } - if in.Parameters != "" { - const prefix string = ",\"parameters\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Parameters)) - } - if in.InitRD != "" { - const prefix string = ",\"initrd\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.InitRD)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo10(in *jlexer.Lexer, out *specs_go.VMHypervisor) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "path": - out.Path = string(in.String()) - case "parameters": - out.Parameters = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo10(out *jwriter.Writer, in specs_go.VMHypervisor) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"path\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Path)) - } - if in.Parameters != "" { - const prefix string = ",\"parameters\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Parameters)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo8(in *jlexer.Lexer, out *specs_go.Windows) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "layerFolders": - if in.IsNull() { - in.Skip() - out.LayerFolders = nil - } else { - in.Delim('[') - if out.LayerFolders == nil { - if !in.IsDelim(']') { - out.LayerFolders = make([]string, 0, 4) - } else { - out.LayerFolders = []string{} - } - } else { - out.LayerFolders = (out.LayerFolders)[:0] - } - for !in.IsDelim(']') { - var v98 string - v98 = string(in.String()) - out.LayerFolders = append(out.LayerFolders, v98) - in.WantComma() - } - in.Delim(']') - } - case "devices": - if in.IsNull() { - in.Skip() - out.Devices = nil - } else { - in.Delim('[') - if out.Devices == nil { - if !in.IsDelim(']') { - out.Devices = make([]specs_go.WindowsDevice, 0, 2) - } else { - out.Devices = []specs_go.WindowsDevice{} - } - } else { - out.Devices = (out.Devices)[:0] - } - for !in.IsDelim(']') { - var v99 specs_go.WindowsDevice - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo13(in, &v99) - out.Devices = append(out.Devices, v99) - in.WantComma() - } - in.Delim(']') - } - case "resources": - if in.IsNull() { - in.Skip() - out.Resources = nil - } else { - if out.Resources == nil { - out.Resources = new(specs_go.WindowsResources) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo14(in, &*out.Resources) - } - case "credentialSpec": - if m, ok := out.CredentialSpec.(easyjson.Unmarshaler); ok { - m.UnmarshalEasyJSON(in) - } else if m, ok := out.CredentialSpec.(json.Unmarshaler); ok { - _ = m.UnmarshalJSON(in.Raw()) - } else { - out.CredentialSpec = in.Interface() - } - case "servicing": - out.Servicing = bool(in.Bool()) - case "ignoreFlushesDuringBoot": - out.IgnoreFlushesDuringBoot = bool(in.Bool()) - case "hyperv": - if in.IsNull() { - in.Skip() - out.HyperV = nil - } else { - if out.HyperV == nil { - out.HyperV = new(specs_go.WindowsHyperV) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo15(in, &*out.HyperV) - } - case "network": - if in.IsNull() { - in.Skip() - out.Network = nil - } else { - if out.Network == nil { - out.Network = new(specs_go.WindowsNetwork) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo16(in, &*out.Network) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo8(out *jwriter.Writer, in specs_go.Windows) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"layerFolders\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - if in.LayerFolders == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v100, v101 := range in.LayerFolders { - if v100 > 0 { - out.RawByte(',') - } - out.String(string(v101)) - } - out.RawByte(']') - } - } - if len(in.Devices) != 0 { - const prefix string = ",\"devices\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v102, v103 := range in.Devices { - if v102 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo13(out, v103) - } - out.RawByte(']') - } - } - if in.Resources != nil { - const prefix string = ",\"resources\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo14(out, *in.Resources) - } - if in.CredentialSpec != nil { - const prefix string = ",\"credentialSpec\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - if m, ok := in.CredentialSpec.(easyjson.Marshaler); ok { - m.MarshalEasyJSON(out) - } else if m, ok := in.CredentialSpec.(json.Marshaler); ok { - out.Raw(m.MarshalJSON()) - } else { - out.Raw(json.Marshal(in.CredentialSpec)) - } - } - if in.Servicing { - const prefix string = ",\"servicing\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.Servicing)) - } - if in.IgnoreFlushesDuringBoot { - const prefix string = ",\"ignoreFlushesDuringBoot\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.IgnoreFlushesDuringBoot)) - } - if in.HyperV != nil { - const prefix string = ",\"hyperv\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo15(out, *in.HyperV) - } - if in.Network != nil { - const prefix string = ",\"network\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo16(out, *in.Network) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo16(in *jlexer.Lexer, out *specs_go.WindowsNetwork) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "endpointList": - if in.IsNull() { - in.Skip() - out.EndpointList = nil - } else { - in.Delim('[') - if out.EndpointList == nil { - if !in.IsDelim(']') { - out.EndpointList = make([]string, 0, 4) - } else { - out.EndpointList = []string{} - } - } else { - out.EndpointList = (out.EndpointList)[:0] - } - for !in.IsDelim(']') { - var v104 string - v104 = string(in.String()) - out.EndpointList = append(out.EndpointList, v104) - in.WantComma() - } - in.Delim(']') - } - case "allowUnqualifiedDNSQuery": - out.AllowUnqualifiedDNSQuery = bool(in.Bool()) - case "DNSSearchList": - if in.IsNull() { - in.Skip() - out.DNSSearchList = nil - } else { - in.Delim('[') - if out.DNSSearchList == nil { - if !in.IsDelim(']') { - out.DNSSearchList = make([]string, 0, 4) - } else { - out.DNSSearchList = []string{} - } - } else { - out.DNSSearchList = (out.DNSSearchList)[:0] - } - for !in.IsDelim(']') { - var v105 string - v105 = string(in.String()) - out.DNSSearchList = append(out.DNSSearchList, v105) - in.WantComma() - } - in.Delim(']') - } - case "networkSharedContainerName": - out.NetworkSharedContainerName = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo16(out *jwriter.Writer, in specs_go.WindowsNetwork) { - out.RawByte('{') - first := true - _ = first - if len(in.EndpointList) != 0 { - const prefix string = ",\"endpointList\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v106, v107 := range in.EndpointList { - if v106 > 0 { - out.RawByte(',') - } - out.String(string(v107)) - } - out.RawByte(']') - } - } - if in.AllowUnqualifiedDNSQuery { - const prefix string = ",\"allowUnqualifiedDNSQuery\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.AllowUnqualifiedDNSQuery)) - } - if len(in.DNSSearchList) != 0 { - const prefix string = ",\"DNSSearchList\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v108, v109 := range in.DNSSearchList { - if v108 > 0 { - out.RawByte(',') - } - out.String(string(v109)) - } - out.RawByte(']') - } - } - if in.NetworkSharedContainerName != "" { - const prefix string = ",\"networkSharedContainerName\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.NetworkSharedContainerName)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo15(in *jlexer.Lexer, out *specs_go.WindowsHyperV) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "utilityVMPath": - out.UtilityVMPath = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo15(out *jwriter.Writer, in specs_go.WindowsHyperV) { - out.RawByte('{') - first := true - _ = first - if in.UtilityVMPath != "" { - const prefix string = ",\"utilityVMPath\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.UtilityVMPath)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo14(in *jlexer.Lexer, out *specs_go.WindowsResources) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "memory": - if in.IsNull() { - in.Skip() - out.Memory = nil - } else { - if out.Memory == nil { - out.Memory = new(specs_go.WindowsMemoryResources) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo17(in, &*out.Memory) - } - case "cpu": - if in.IsNull() { - in.Skip() - out.CPU = nil - } else { - if out.CPU == nil { - out.CPU = new(specs_go.WindowsCPUResources) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo18(in, &*out.CPU) - } - case "storage": - if in.IsNull() { - in.Skip() - out.Storage = nil - } else { - if out.Storage == nil { - out.Storage = new(specs_go.WindowsStorageResources) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo19(in, &*out.Storage) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo14(out *jwriter.Writer, in specs_go.WindowsResources) { - out.RawByte('{') - first := true - _ = first - if in.Memory != nil { - const prefix string = ",\"memory\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo17(out, *in.Memory) - } - if in.CPU != nil { - const prefix string = ",\"cpu\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo18(out, *in.CPU) - } - if in.Storage != nil { - const prefix string = ",\"storage\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo19(out, *in.Storage) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo19(in *jlexer.Lexer, out *specs_go.WindowsStorageResources) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "iops": - if in.IsNull() { - in.Skip() - out.Iops = nil - } else { - if out.Iops == nil { - out.Iops = new(uint64) - } - *out.Iops = uint64(in.Uint64()) - } - case "bps": - if in.IsNull() { - in.Skip() - out.Bps = nil - } else { - if out.Bps == nil { - out.Bps = new(uint64) - } - *out.Bps = uint64(in.Uint64()) - } - case "sandboxSize": - if in.IsNull() { - in.Skip() - out.SandboxSize = nil - } else { - if out.SandboxSize == nil { - out.SandboxSize = new(uint64) - } - *out.SandboxSize = uint64(in.Uint64()) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo19(out *jwriter.Writer, in specs_go.WindowsStorageResources) { - out.RawByte('{') - first := true - _ = first - if in.Iops != nil { - const prefix string = ",\"iops\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(*in.Iops)) - } - if in.Bps != nil { - const prefix string = ",\"bps\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(*in.Bps)) - } - if in.SandboxSize != nil { - const prefix string = ",\"sandboxSize\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(*in.SandboxSize)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo18(in *jlexer.Lexer, out *specs_go.WindowsCPUResources) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "count": - if in.IsNull() { - in.Skip() - out.Count = nil - } else { - if out.Count == nil { - out.Count = new(uint64) - } - *out.Count = uint64(in.Uint64()) - } - case "shares": - if in.IsNull() { - in.Skip() - out.Shares = nil - } else { - if out.Shares == nil { - out.Shares = new(uint16) - } - *out.Shares = uint16(in.Uint16()) - } - case "maximum": - if in.IsNull() { - in.Skip() - out.Maximum = nil - } else { - if out.Maximum == nil { - out.Maximum = new(uint16) - } - *out.Maximum = uint16(in.Uint16()) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo18(out *jwriter.Writer, in specs_go.WindowsCPUResources) { - out.RawByte('{') - first := true - _ = first - if in.Count != nil { - const prefix string = ",\"count\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(*in.Count)) - } - if in.Shares != nil { - const prefix string = ",\"shares\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint16(uint16(*in.Shares)) - } - if in.Maximum != nil { - const prefix string = ",\"maximum\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint16(uint16(*in.Maximum)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo17(in *jlexer.Lexer, out *specs_go.WindowsMemoryResources) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "limit": - if in.IsNull() { - in.Skip() - out.Limit = nil - } else { - if out.Limit == nil { - out.Limit = new(uint64) - } - *out.Limit = uint64(in.Uint64()) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo17(out *jwriter.Writer, in specs_go.WindowsMemoryResources) { - out.RawByte('{') - first := true - _ = first - if in.Limit != nil { - const prefix string = ",\"limit\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(*in.Limit)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo13(in *jlexer.Lexer, out *specs_go.WindowsDevice) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "id": - out.ID = string(in.String()) - case "idType": - out.IDType = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo13(out *jwriter.Writer, in specs_go.WindowsDevice) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"id\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.ID)) - } - { - const prefix string = ",\"idType\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.IDType)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo7(in *jlexer.Lexer, out *specs_go.Solaris) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "milestone": - out.Milestone = string(in.String()) - case "limitpriv": - out.LimitPriv = string(in.String()) - case "maxShmMemory": - out.MaxShmMemory = string(in.String()) - case "anet": - if in.IsNull() { - in.Skip() - out.Anet = nil - } else { - in.Delim('[') - if out.Anet == nil { - if !in.IsDelim(']') { - out.Anet = make([]specs_go.SolarisAnet, 0, 1) - } else { - out.Anet = []specs_go.SolarisAnet{} - } - } else { - out.Anet = (out.Anet)[:0] - } - for !in.IsDelim(']') { - var v110 specs_go.SolarisAnet - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo20(in, &v110) - out.Anet = append(out.Anet, v110) - in.WantComma() - } - in.Delim(']') - } - case "cappedCPU": - if in.IsNull() { - in.Skip() - out.CappedCPU = nil - } else { - if out.CappedCPU == nil { - out.CappedCPU = new(specs_go.SolarisCappedCPU) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo21(in, &*out.CappedCPU) - } - case "cappedMemory": - if in.IsNull() { - in.Skip() - out.CappedMemory = nil - } else { - if out.CappedMemory == nil { - out.CappedMemory = new(specs_go.SolarisCappedMemory) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo22(in, &*out.CappedMemory) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo7(out *jwriter.Writer, in specs_go.Solaris) { - out.RawByte('{') - first := true - _ = first - if in.Milestone != "" { - const prefix string = ",\"milestone\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Milestone)) - } - if in.LimitPriv != "" { - const prefix string = ",\"limitpriv\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.LimitPriv)) - } - if in.MaxShmMemory != "" { - const prefix string = ",\"maxShmMemory\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.MaxShmMemory)) - } - if len(in.Anet) != 0 { - const prefix string = ",\"anet\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v111, v112 := range in.Anet { - if v111 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo20(out, v112) - } - out.RawByte(']') - } - } - if in.CappedCPU != nil { - const prefix string = ",\"cappedCPU\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo21(out, *in.CappedCPU) - } - if in.CappedMemory != nil { - const prefix string = ",\"cappedMemory\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo22(out, *in.CappedMemory) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo22(in *jlexer.Lexer, out *specs_go.SolarisCappedMemory) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "physical": - out.Physical = string(in.String()) - case "swap": - out.Swap = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo22(out *jwriter.Writer, in specs_go.SolarisCappedMemory) { - out.RawByte('{') - first := true - _ = first - if in.Physical != "" { - const prefix string = ",\"physical\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Physical)) - } - if in.Swap != "" { - const prefix string = ",\"swap\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Swap)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo21(in *jlexer.Lexer, out *specs_go.SolarisCappedCPU) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "ncpus": - out.Ncpus = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo21(out *jwriter.Writer, in specs_go.SolarisCappedCPU) { - out.RawByte('{') - first := true - _ = first - if in.Ncpus != "" { - const prefix string = ",\"ncpus\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Ncpus)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo20(in *jlexer.Lexer, out *specs_go.SolarisAnet) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "linkname": - out.Linkname = string(in.String()) - case "lowerLink": - out.Lowerlink = string(in.String()) - case "allowedAddress": - out.Allowedaddr = string(in.String()) - case "configureAllowedAddress": - out.Configallowedaddr = string(in.String()) - case "defrouter": - out.Defrouter = string(in.String()) - case "linkProtection": - out.Linkprotection = string(in.String()) - case "macAddress": - out.Macaddress = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo20(out *jwriter.Writer, in specs_go.SolarisAnet) { - out.RawByte('{') - first := true - _ = first - if in.Linkname != "" { - const prefix string = ",\"linkname\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Linkname)) - } - if in.Lowerlink != "" { - const prefix string = ",\"lowerLink\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Lowerlink)) - } - if in.Allowedaddr != "" { - const prefix string = ",\"allowedAddress\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Allowedaddr)) - } - if in.Configallowedaddr != "" { - const prefix string = ",\"configureAllowedAddress\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Configallowedaddr)) - } - if in.Defrouter != "" { - const prefix string = ",\"defrouter\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Defrouter)) - } - if in.Linkprotection != "" { - const prefix string = ",\"linkProtection\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Linkprotection)) - } - if in.Macaddress != "" { - const prefix string = ",\"macAddress\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Macaddress)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo6(in *jlexer.Lexer, out *specs_go.Linux) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "uidMappings": - if in.IsNull() { - in.Skip() - out.UIDMappings = nil - } else { - in.Delim('[') - if out.UIDMappings == nil { - if !in.IsDelim(']') { - out.UIDMappings = make([]specs_go.LinuxIDMapping, 0, 5) - } else { - out.UIDMappings = []specs_go.LinuxIDMapping{} - } - } else { - out.UIDMappings = (out.UIDMappings)[:0] - } - for !in.IsDelim(']') { - var v113 specs_go.LinuxIDMapping - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo23(in, &v113) - out.UIDMappings = append(out.UIDMappings, v113) - in.WantComma() - } - in.Delim(']') - } - case "gidMappings": - if in.IsNull() { - in.Skip() - out.GIDMappings = nil - } else { - in.Delim('[') - if out.GIDMappings == nil { - if !in.IsDelim(']') { - out.GIDMappings = make([]specs_go.LinuxIDMapping, 0, 5) - } else { - out.GIDMappings = []specs_go.LinuxIDMapping{} - } - } else { - out.GIDMappings = (out.GIDMappings)[:0] - } - for !in.IsDelim(']') { - var v114 specs_go.LinuxIDMapping - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo23(in, &v114) - out.GIDMappings = append(out.GIDMappings, v114) - in.WantComma() - } - in.Delim(']') - } - case "sysctl": - if in.IsNull() { - in.Skip() - } else { - in.Delim('{') - if !in.IsDelim('}') { - out.Sysctl = make(map[string]string) - } else { - out.Sysctl = nil - } - for !in.IsDelim('}') { - key := string(in.String()) - in.WantColon() - var v115 string - v115 = string(in.String()) - (out.Sysctl)[key] = v115 - in.WantComma() - } - in.Delim('}') - } - case "resources": - if in.IsNull() { - in.Skip() - out.Resources = nil - } else { - if out.Resources == nil { - out.Resources = new(specs_go.LinuxResources) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo24(in, &*out.Resources) - } - case "cgroupsPath": - out.CgroupsPath = string(in.String()) - case "namespaces": - if in.IsNull() { - in.Skip() - out.Namespaces = nil - } else { - in.Delim('[') - if out.Namespaces == nil { - if !in.IsDelim(']') { - out.Namespaces = make([]specs_go.LinuxNamespace, 0, 2) - } else { - out.Namespaces = []specs_go.LinuxNamespace{} - } - } else { - out.Namespaces = (out.Namespaces)[:0] - } - for !in.IsDelim(']') { - var v116 specs_go.LinuxNamespace - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo25(in, &v116) - out.Namespaces = append(out.Namespaces, v116) - in.WantComma() - } - in.Delim(']') - } - case "devices": - if in.IsNull() { - in.Skip() - out.Devices = nil - } else { - in.Delim('[') - if out.Devices == nil { - if !in.IsDelim(']') { - out.Devices = make([]specs_go.LinuxDevice, 0, 1) - } else { - out.Devices = []specs_go.LinuxDevice{} - } - } else { - out.Devices = (out.Devices)[:0] - } - for !in.IsDelim(']') { - var v117 specs_go.LinuxDevice - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo26(in, &v117) - out.Devices = append(out.Devices, v117) - in.WantComma() - } - in.Delim(']') - } - case "seccomp": - if in.IsNull() { - in.Skip() - out.Seccomp = nil - } else { - if out.Seccomp == nil { - out.Seccomp = new(specs_go.LinuxSeccomp) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo27(in, &*out.Seccomp) - } - case "rootfsPropagation": - out.RootfsPropagation = string(in.String()) - case "maskedPaths": - if in.IsNull() { - in.Skip() - out.MaskedPaths = nil - } else { - in.Delim('[') - if out.MaskedPaths == nil { - if !in.IsDelim(']') { - out.MaskedPaths = make([]string, 0, 4) - } else { - out.MaskedPaths = []string{} - } - } else { - out.MaskedPaths = (out.MaskedPaths)[:0] - } - for !in.IsDelim(']') { - var v118 string - v118 = string(in.String()) - out.MaskedPaths = append(out.MaskedPaths, v118) - in.WantComma() - } - in.Delim(']') - } - case "readonlyPaths": - if in.IsNull() { - in.Skip() - out.ReadonlyPaths = nil - } else { - in.Delim('[') - if out.ReadonlyPaths == nil { - if !in.IsDelim(']') { - out.ReadonlyPaths = make([]string, 0, 4) - } else { - out.ReadonlyPaths = []string{} - } - } else { - out.ReadonlyPaths = (out.ReadonlyPaths)[:0] - } - for !in.IsDelim(']') { - var v119 string - v119 = string(in.String()) - out.ReadonlyPaths = append(out.ReadonlyPaths, v119) - in.WantComma() - } - in.Delim(']') - } - case "mountLabel": - out.MountLabel = string(in.String()) - case "intelRdt": - if in.IsNull() { - in.Skip() - out.IntelRdt = nil - } else { - if out.IntelRdt == nil { - out.IntelRdt = new(specs_go.LinuxIntelRdt) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo28(in, &*out.IntelRdt) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo6(out *jwriter.Writer, in specs_go.Linux) { - out.RawByte('{') - first := true - _ = first - if len(in.UIDMappings) != 0 { - const prefix string = ",\"uidMappings\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v120, v121 := range in.UIDMappings { - if v120 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo23(out, v121) - } - out.RawByte(']') - } - } - if len(in.GIDMappings) != 0 { - const prefix string = ",\"gidMappings\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v122, v123 := range in.GIDMappings { - if v122 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo23(out, v123) - } - out.RawByte(']') - } - } - if len(in.Sysctl) != 0 { - const prefix string = ",\"sysctl\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('{') - v124First := true - for v124Name, v124Value := range in.Sysctl { - if v124First { - v124First = false - } else { - out.RawByte(',') - } - out.String(string(v124Name)) - out.RawByte(':') - out.String(string(v124Value)) - } - out.RawByte('}') - } - } - if in.Resources != nil { - const prefix string = ",\"resources\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo24(out, *in.Resources) - } - if in.CgroupsPath != "" { - const prefix string = ",\"cgroupsPath\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.CgroupsPath)) - } - if len(in.Namespaces) != 0 { - const prefix string = ",\"namespaces\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v125, v126 := range in.Namespaces { - if v125 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo25(out, v126) - } - out.RawByte(']') - } - } - if len(in.Devices) != 0 { - const prefix string = ",\"devices\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v127, v128 := range in.Devices { - if v127 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo26(out, v128) - } - out.RawByte(']') - } - } - if in.Seccomp != nil { - const prefix string = ",\"seccomp\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo27(out, *in.Seccomp) - } - if in.RootfsPropagation != "" { - const prefix string = ",\"rootfsPropagation\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.RootfsPropagation)) - } - if len(in.MaskedPaths) != 0 { - const prefix string = ",\"maskedPaths\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v129, v130 := range in.MaskedPaths { - if v129 > 0 { - out.RawByte(',') - } - out.String(string(v130)) - } - out.RawByte(']') - } - } - if len(in.ReadonlyPaths) != 0 { - const prefix string = ",\"readonlyPaths\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v131, v132 := range in.ReadonlyPaths { - if v131 > 0 { - out.RawByte(',') - } - out.String(string(v132)) - } - out.RawByte(']') - } - } - if in.MountLabel != "" { - const prefix string = ",\"mountLabel\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.MountLabel)) - } - if in.IntelRdt != nil { - const prefix string = ",\"intelRdt\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo28(out, *in.IntelRdt) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo28(in *jlexer.Lexer, out *specs_go.LinuxIntelRdt) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "l3CacheSchema": - out.L3CacheSchema = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo28(out *jwriter.Writer, in specs_go.LinuxIntelRdt) { - out.RawByte('{') - first := true - _ = first - if in.L3CacheSchema != "" { - const prefix string = ",\"l3CacheSchema\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.L3CacheSchema)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo27(in *jlexer.Lexer, out *specs_go.LinuxSeccomp) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "defaultAction": - out.DefaultAction = specs_go.LinuxSeccompAction(in.String()) - case "architectures": - if in.IsNull() { - in.Skip() - out.Architectures = nil - } else { - in.Delim('[') - if out.Architectures == nil { - if !in.IsDelim(']') { - out.Architectures = make([]specs_go.Arch, 0, 4) - } else { - out.Architectures = []specs_go.Arch{} - } - } else { - out.Architectures = (out.Architectures)[:0] - } - for !in.IsDelim(']') { - var v133 specs_go.Arch - v133 = specs_go.Arch(in.String()) - out.Architectures = append(out.Architectures, v133) - in.WantComma() - } - in.Delim(']') - } - case "syscalls": - if in.IsNull() { - in.Skip() - out.Syscalls = nil - } else { - in.Delim('[') - if out.Syscalls == nil { - if !in.IsDelim(']') { - out.Syscalls = make([]specs_go.LinuxSyscall, 0, 1) - } else { - out.Syscalls = []specs_go.LinuxSyscall{} - } - } else { - out.Syscalls = (out.Syscalls)[:0] - } - for !in.IsDelim(']') { - var v134 specs_go.LinuxSyscall - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo29(in, &v134) - out.Syscalls = append(out.Syscalls, v134) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo27(out *jwriter.Writer, in specs_go.LinuxSeccomp) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"defaultAction\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.DefaultAction)) - } - if len(in.Architectures) != 0 { - const prefix string = ",\"architectures\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v135, v136 := range in.Architectures { - if v135 > 0 { - out.RawByte(',') - } - out.String(string(v136)) - } - out.RawByte(']') - } - } - if len(in.Syscalls) != 0 { - const prefix string = ",\"syscalls\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v137, v138 := range in.Syscalls { - if v137 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo29(out, v138) - } - out.RawByte(']') - } - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo29(in *jlexer.Lexer, out *specs_go.LinuxSyscall) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "names": - if in.IsNull() { - in.Skip() - out.Names = nil - } else { - in.Delim('[') - if out.Names == nil { - if !in.IsDelim(']') { - out.Names = make([]string, 0, 4) - } else { - out.Names = []string{} - } - } else { - out.Names = (out.Names)[:0] - } - for !in.IsDelim(']') { - var v139 string - v139 = string(in.String()) - out.Names = append(out.Names, v139) - in.WantComma() - } - in.Delim(']') - } - case "action": - out.Action = specs_go.LinuxSeccompAction(in.String()) - case "args": - if in.IsNull() { - in.Skip() - out.Args = nil - } else { - in.Delim('[') - if out.Args == nil { - if !in.IsDelim(']') { - out.Args = make([]specs_go.LinuxSeccompArg, 0, 1) - } else { - out.Args = []specs_go.LinuxSeccompArg{} - } - } else { - out.Args = (out.Args)[:0] - } - for !in.IsDelim(']') { - var v140 specs_go.LinuxSeccompArg - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo30(in, &v140) - out.Args = append(out.Args, v140) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo29(out *jwriter.Writer, in specs_go.LinuxSyscall) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"names\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - if in.Names == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v141, v142 := range in.Names { - if v141 > 0 { - out.RawByte(',') - } - out.String(string(v142)) - } - out.RawByte(']') - } - } - { - const prefix string = ",\"action\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Action)) - } - if len(in.Args) != 0 { - const prefix string = ",\"args\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v143, v144 := range in.Args { - if v143 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo30(out, v144) - } - out.RawByte(']') - } - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo30(in *jlexer.Lexer, out *specs_go.LinuxSeccompArg) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "index": - out.Index = uint(in.Uint()) - case "value": - out.Value = uint64(in.Uint64()) - case "valueTwo": - out.ValueTwo = uint64(in.Uint64()) - case "op": - out.Op = specs_go.LinuxSeccompOperator(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo30(out *jwriter.Writer, in specs_go.LinuxSeccompArg) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"index\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint(uint(in.Index)) - } - { - const prefix string = ",\"value\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(in.Value)) - } - if in.ValueTwo != 0 { - const prefix string = ",\"valueTwo\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(in.ValueTwo)) - } - { - const prefix string = ",\"op\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Op)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo26(in *jlexer.Lexer, out *specs_go.LinuxDevice) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "path": - out.Path = string(in.String()) - case "type": - out.Type = string(in.String()) - case "major": - out.Major = int64(in.Int64()) - case "minor": - out.Minor = int64(in.Int64()) - case "fileMode": - if in.IsNull() { - in.Skip() - out.FileMode = nil - } else { - if out.FileMode == nil { - out.FileMode = new(os.FileMode) - } - *out.FileMode = os.FileMode(in.Uint32()) - } - case "uid": - if in.IsNull() { - in.Skip() - out.UID = nil - } else { - if out.UID == nil { - out.UID = new(uint32) - } - *out.UID = uint32(in.Uint32()) - } - case "gid": - if in.IsNull() { - in.Skip() - out.GID = nil - } else { - if out.GID == nil { - out.GID = new(uint32) - } - *out.GID = uint32(in.Uint32()) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo26(out *jwriter.Writer, in specs_go.LinuxDevice) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"path\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Path)) - } - { - const prefix string = ",\"type\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Type)) - } - { - const prefix string = ",\"major\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(in.Major)) - } - { - const prefix string = ",\"minor\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(in.Minor)) - } - if in.FileMode != nil { - const prefix string = ",\"fileMode\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint32(uint32(*in.FileMode)) - } - if in.UID != nil { - const prefix string = ",\"uid\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint32(uint32(*in.UID)) - } - if in.GID != nil { - const prefix string = ",\"gid\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint32(uint32(*in.GID)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo25(in *jlexer.Lexer, out *specs_go.LinuxNamespace) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "type": - out.Type = specs_go.LinuxNamespaceType(in.String()) - case "path": - out.Path = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo25(out *jwriter.Writer, in specs_go.LinuxNamespace) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"type\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Type)) - } - if in.Path != "" { - const prefix string = ",\"path\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Path)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo24(in *jlexer.Lexer, out *specs_go.LinuxResources) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "devices": - if in.IsNull() { - in.Skip() - out.Devices = nil - } else { - in.Delim('[') - if out.Devices == nil { - if !in.IsDelim(']') { - out.Devices = make([]specs_go.LinuxDeviceCgroup, 0, 1) - } else { - out.Devices = []specs_go.LinuxDeviceCgroup{} - } - } else { - out.Devices = (out.Devices)[:0] - } - for !in.IsDelim(']') { - var v145 specs_go.LinuxDeviceCgroup - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo31(in, &v145) - out.Devices = append(out.Devices, v145) - in.WantComma() - } - in.Delim(']') - } - case "memory": - if in.IsNull() { - in.Skip() - out.Memory = nil - } else { - if out.Memory == nil { - out.Memory = new(specs_go.LinuxMemory) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo32(in, &*out.Memory) - } - case "cpu": - if in.IsNull() { - in.Skip() - out.CPU = nil - } else { - if out.CPU == nil { - out.CPU = new(specs_go.LinuxCPU) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo33(in, &*out.CPU) - } - case "pids": - if in.IsNull() { - in.Skip() - out.Pids = nil - } else { - if out.Pids == nil { - out.Pids = new(specs_go.LinuxPids) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo34(in, &*out.Pids) - } - case "blockIO": - if in.IsNull() { - in.Skip() - out.BlockIO = nil - } else { - if out.BlockIO == nil { - out.BlockIO = new(specs_go.LinuxBlockIO) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo35(in, &*out.BlockIO) - } - case "hugepageLimits": - if in.IsNull() { - in.Skip() - out.HugepageLimits = nil - } else { - in.Delim('[') - if out.HugepageLimits == nil { - if !in.IsDelim(']') { - out.HugepageLimits = make([]specs_go.LinuxHugepageLimit, 0, 2) - } else { - out.HugepageLimits = []specs_go.LinuxHugepageLimit{} - } - } else { - out.HugepageLimits = (out.HugepageLimits)[:0] - } - for !in.IsDelim(']') { - var v146 specs_go.LinuxHugepageLimit - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo36(in, &v146) - out.HugepageLimits = append(out.HugepageLimits, v146) - in.WantComma() - } - in.Delim(']') - } - case "network": - if in.IsNull() { - in.Skip() - out.Network = nil - } else { - if out.Network == nil { - out.Network = new(specs_go.LinuxNetwork) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo37(in, &*out.Network) - } - case "rdma": - if in.IsNull() { - in.Skip() - } else { - in.Delim('{') - if !in.IsDelim('}') { - out.Rdma = make(map[string]specs_go.LinuxRdma) - } else { - out.Rdma = nil - } - for !in.IsDelim('}') { - key := string(in.String()) - in.WantColon() - var v147 specs_go.LinuxRdma - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo38(in, &v147) - (out.Rdma)[key] = v147 - in.WantComma() - } - in.Delim('}') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo24(out *jwriter.Writer, in specs_go.LinuxResources) { - out.RawByte('{') - first := true - _ = first - if len(in.Devices) != 0 { - const prefix string = ",\"devices\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v148, v149 := range in.Devices { - if v148 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo31(out, v149) - } - out.RawByte(']') - } - } - if in.Memory != nil { - const prefix string = ",\"memory\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo32(out, *in.Memory) - } - if in.CPU != nil { - const prefix string = ",\"cpu\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo33(out, *in.CPU) - } - if in.Pids != nil { - const prefix string = ",\"pids\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo34(out, *in.Pids) - } - if in.BlockIO != nil { - const prefix string = ",\"blockIO\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo35(out, *in.BlockIO) - } - if len(in.HugepageLimits) != 0 { - const prefix string = ",\"hugepageLimits\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v150, v151 := range in.HugepageLimits { - if v150 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo36(out, v151) - } - out.RawByte(']') - } - } - if in.Network != nil { - const prefix string = ",\"network\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo37(out, *in.Network) - } - if len(in.Rdma) != 0 { - const prefix string = ",\"rdma\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('{') - v152First := true - for v152Name, v152Value := range in.Rdma { - if v152First { - v152First = false - } else { - out.RawByte(',') - } - out.String(string(v152Name)) - out.RawByte(':') - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo38(out, v152Value) - } - out.RawByte('}') - } - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo38(in *jlexer.Lexer, out *specs_go.LinuxRdma) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "hcaHandles": - if in.IsNull() { - in.Skip() - out.HcaHandles = nil - } else { - if out.HcaHandles == nil { - out.HcaHandles = new(uint32) - } - *out.HcaHandles = uint32(in.Uint32()) - } - case "hcaObjects": - if in.IsNull() { - in.Skip() - out.HcaObjects = nil - } else { - if out.HcaObjects == nil { - out.HcaObjects = new(uint32) - } - *out.HcaObjects = uint32(in.Uint32()) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo38(out *jwriter.Writer, in specs_go.LinuxRdma) { - out.RawByte('{') - first := true - _ = first - if in.HcaHandles != nil { - const prefix string = ",\"hcaHandles\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint32(uint32(*in.HcaHandles)) - } - if in.HcaObjects != nil { - const prefix string = ",\"hcaObjects\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint32(uint32(*in.HcaObjects)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo37(in *jlexer.Lexer, out *specs_go.LinuxNetwork) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "classID": - if in.IsNull() { - in.Skip() - out.ClassID = nil - } else { - if out.ClassID == nil { - out.ClassID = new(uint32) - } - *out.ClassID = uint32(in.Uint32()) - } - case "priorities": - if in.IsNull() { - in.Skip() - out.Priorities = nil - } else { - in.Delim('[') - if out.Priorities == nil { - if !in.IsDelim(']') { - out.Priorities = make([]specs_go.LinuxInterfacePriority, 0, 2) - } else { - out.Priorities = []specs_go.LinuxInterfacePriority{} - } - } else { - out.Priorities = (out.Priorities)[:0] - } - for !in.IsDelim(']') { - var v153 specs_go.LinuxInterfacePriority - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo39(in, &v153) - out.Priorities = append(out.Priorities, v153) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo37(out *jwriter.Writer, in specs_go.LinuxNetwork) { - out.RawByte('{') - first := true - _ = first - if in.ClassID != nil { - const prefix string = ",\"classID\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint32(uint32(*in.ClassID)) - } - if len(in.Priorities) != 0 { - const prefix string = ",\"priorities\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v154, v155 := range in.Priorities { - if v154 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo39(out, v155) - } - out.RawByte(']') - } - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo39(in *jlexer.Lexer, out *specs_go.LinuxInterfacePriority) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "name": - out.Name = string(in.String()) - case "priority": - out.Priority = uint32(in.Uint32()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo39(out *jwriter.Writer, in specs_go.LinuxInterfacePriority) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"name\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Name)) - } - { - const prefix string = ",\"priority\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint32(uint32(in.Priority)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo36(in *jlexer.Lexer, out *specs_go.LinuxHugepageLimit) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "pageSize": - out.Pagesize = string(in.String()) - case "limit": - out.Limit = uint64(in.Uint64()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo36(out *jwriter.Writer, in specs_go.LinuxHugepageLimit) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"pageSize\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Pagesize)) - } - { - const prefix string = ",\"limit\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(in.Limit)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo35(in *jlexer.Lexer, out *specs_go.LinuxBlockIO) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "weight": - if in.IsNull() { - in.Skip() - out.Weight = nil - } else { - if out.Weight == nil { - out.Weight = new(uint16) - } - *out.Weight = uint16(in.Uint16()) - } - case "leafWeight": - if in.IsNull() { - in.Skip() - out.LeafWeight = nil - } else { - if out.LeafWeight == nil { - out.LeafWeight = new(uint16) - } - *out.LeafWeight = uint16(in.Uint16()) - } - case "weightDevice": - if in.IsNull() { - in.Skip() - out.WeightDevice = nil - } else { - in.Delim('[') - if out.WeightDevice == nil { - if !in.IsDelim(']') { - out.WeightDevice = make([]specs_go.LinuxWeightDevice, 0, 2) - } else { - out.WeightDevice = []specs_go.LinuxWeightDevice{} - } - } else { - out.WeightDevice = (out.WeightDevice)[:0] - } - for !in.IsDelim(']') { - var v156 specs_go.LinuxWeightDevice - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo40(in, &v156) - out.WeightDevice = append(out.WeightDevice, v156) - in.WantComma() - } - in.Delim(']') - } - case "throttleReadBpsDevice": - if in.IsNull() { - in.Skip() - out.ThrottleReadBpsDevice = nil - } else { - in.Delim('[') - if out.ThrottleReadBpsDevice == nil { - if !in.IsDelim(']') { - out.ThrottleReadBpsDevice = make([]specs_go.LinuxThrottleDevice, 0, 2) - } else { - out.ThrottleReadBpsDevice = []specs_go.LinuxThrottleDevice{} - } - } else { - out.ThrottleReadBpsDevice = (out.ThrottleReadBpsDevice)[:0] - } - for !in.IsDelim(']') { - var v157 specs_go.LinuxThrottleDevice - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo41(in, &v157) - out.ThrottleReadBpsDevice = append(out.ThrottleReadBpsDevice, v157) - in.WantComma() - } - in.Delim(']') - } - case "throttleWriteBpsDevice": - if in.IsNull() { - in.Skip() - out.ThrottleWriteBpsDevice = nil - } else { - in.Delim('[') - if out.ThrottleWriteBpsDevice == nil { - if !in.IsDelim(']') { - out.ThrottleWriteBpsDevice = make([]specs_go.LinuxThrottleDevice, 0, 2) - } else { - out.ThrottleWriteBpsDevice = []specs_go.LinuxThrottleDevice{} - } - } else { - out.ThrottleWriteBpsDevice = (out.ThrottleWriteBpsDevice)[:0] - } - for !in.IsDelim(']') { - var v158 specs_go.LinuxThrottleDevice - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo41(in, &v158) - out.ThrottleWriteBpsDevice = append(out.ThrottleWriteBpsDevice, v158) - in.WantComma() - } - in.Delim(']') - } - case "throttleReadIOPSDevice": - if in.IsNull() { - in.Skip() - out.ThrottleReadIOPSDevice = nil - } else { - in.Delim('[') - if out.ThrottleReadIOPSDevice == nil { - if !in.IsDelim(']') { - out.ThrottleReadIOPSDevice = make([]specs_go.LinuxThrottleDevice, 0, 2) - } else { - out.ThrottleReadIOPSDevice = []specs_go.LinuxThrottleDevice{} - } - } else { - out.ThrottleReadIOPSDevice = (out.ThrottleReadIOPSDevice)[:0] - } - for !in.IsDelim(']') { - var v159 specs_go.LinuxThrottleDevice - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo41(in, &v159) - out.ThrottleReadIOPSDevice = append(out.ThrottleReadIOPSDevice, v159) - in.WantComma() - } - in.Delim(']') - } - case "throttleWriteIOPSDevice": - if in.IsNull() { - in.Skip() - out.ThrottleWriteIOPSDevice = nil - } else { - in.Delim('[') - if out.ThrottleWriteIOPSDevice == nil { - if !in.IsDelim(']') { - out.ThrottleWriteIOPSDevice = make([]specs_go.LinuxThrottleDevice, 0, 2) - } else { - out.ThrottleWriteIOPSDevice = []specs_go.LinuxThrottleDevice{} - } - } else { - out.ThrottleWriteIOPSDevice = (out.ThrottleWriteIOPSDevice)[:0] - } - for !in.IsDelim(']') { - var v160 specs_go.LinuxThrottleDevice - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo41(in, &v160) - out.ThrottleWriteIOPSDevice = append(out.ThrottleWriteIOPSDevice, v160) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo35(out *jwriter.Writer, in specs_go.LinuxBlockIO) { - out.RawByte('{') - first := true - _ = first - if in.Weight != nil { - const prefix string = ",\"weight\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint16(uint16(*in.Weight)) - } - if in.LeafWeight != nil { - const prefix string = ",\"leafWeight\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint16(uint16(*in.LeafWeight)) - } - if len(in.WeightDevice) != 0 { - const prefix string = ",\"weightDevice\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v161, v162 := range in.WeightDevice { - if v161 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo40(out, v162) - } - out.RawByte(']') - } - } - if len(in.ThrottleReadBpsDevice) != 0 { - const prefix string = ",\"throttleReadBpsDevice\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v163, v164 := range in.ThrottleReadBpsDevice { - if v163 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo41(out, v164) - } - out.RawByte(']') - } - } - if len(in.ThrottleWriteBpsDevice) != 0 { - const prefix string = ",\"throttleWriteBpsDevice\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v165, v166 := range in.ThrottleWriteBpsDevice { - if v165 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo41(out, v166) - } - out.RawByte(']') - } - } - if len(in.ThrottleReadIOPSDevice) != 0 { - const prefix string = ",\"throttleReadIOPSDevice\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v167, v168 := range in.ThrottleReadIOPSDevice { - if v167 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo41(out, v168) - } - out.RawByte(']') - } - } - if len(in.ThrottleWriteIOPSDevice) != 0 { - const prefix string = ",\"throttleWriteIOPSDevice\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v169, v170 := range in.ThrottleWriteIOPSDevice { - if v169 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo41(out, v170) - } - out.RawByte(']') - } - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo41(in *jlexer.Lexer, out *specs_go.LinuxThrottleDevice) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "rate": - out.Rate = uint64(in.Uint64()) - case "major": - out.Major = int64(in.Int64()) - case "minor": - out.Minor = int64(in.Int64()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo41(out *jwriter.Writer, in specs_go.LinuxThrottleDevice) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"rate\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(in.Rate)) - } - { - const prefix string = ",\"major\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(in.Major)) - } - { - const prefix string = ",\"minor\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(in.Minor)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo40(in *jlexer.Lexer, out *specs_go.LinuxWeightDevice) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "weight": - if in.IsNull() { - in.Skip() - out.Weight = nil - } else { - if out.Weight == nil { - out.Weight = new(uint16) - } - *out.Weight = uint16(in.Uint16()) - } - case "leafWeight": - if in.IsNull() { - in.Skip() - out.LeafWeight = nil - } else { - if out.LeafWeight == nil { - out.LeafWeight = new(uint16) - } - *out.LeafWeight = uint16(in.Uint16()) - } - case "major": - out.Major = int64(in.Int64()) - case "minor": - out.Minor = int64(in.Int64()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo40(out *jwriter.Writer, in specs_go.LinuxWeightDevice) { - out.RawByte('{') - first := true - _ = first - if in.Weight != nil { - const prefix string = ",\"weight\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint16(uint16(*in.Weight)) - } - if in.LeafWeight != nil { - const prefix string = ",\"leafWeight\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint16(uint16(*in.LeafWeight)) - } - { - const prefix string = ",\"major\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(in.Major)) - } - { - const prefix string = ",\"minor\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(in.Minor)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo34(in *jlexer.Lexer, out *specs_go.LinuxPids) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "limit": - out.Limit = int64(in.Int64()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo34(out *jwriter.Writer, in specs_go.LinuxPids) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"limit\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(in.Limit)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo33(in *jlexer.Lexer, out *specs_go.LinuxCPU) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "shares": - if in.IsNull() { - in.Skip() - out.Shares = nil - } else { - if out.Shares == nil { - out.Shares = new(uint64) - } - *out.Shares = uint64(in.Uint64()) - } - case "quota": - if in.IsNull() { - in.Skip() - out.Quota = nil - } else { - if out.Quota == nil { - out.Quota = new(int64) - } - *out.Quota = int64(in.Int64()) - } - case "period": - if in.IsNull() { - in.Skip() - out.Period = nil - } else { - if out.Period == nil { - out.Period = new(uint64) - } - *out.Period = uint64(in.Uint64()) - } - case "realtimeRuntime": - if in.IsNull() { - in.Skip() - out.RealtimeRuntime = nil - } else { - if out.RealtimeRuntime == nil { - out.RealtimeRuntime = new(int64) - } - *out.RealtimeRuntime = int64(in.Int64()) - } - case "realtimePeriod": - if in.IsNull() { - in.Skip() - out.RealtimePeriod = nil - } else { - if out.RealtimePeriod == nil { - out.RealtimePeriod = new(uint64) - } - *out.RealtimePeriod = uint64(in.Uint64()) - } - case "cpus": - out.Cpus = string(in.String()) - case "mems": - out.Mems = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo33(out *jwriter.Writer, in specs_go.LinuxCPU) { - out.RawByte('{') - first := true - _ = first - if in.Shares != nil { - const prefix string = ",\"shares\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(*in.Shares)) - } - if in.Quota != nil { - const prefix string = ",\"quota\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(*in.Quota)) - } - if in.Period != nil { - const prefix string = ",\"period\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(*in.Period)) - } - if in.RealtimeRuntime != nil { - const prefix string = ",\"realtimeRuntime\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(*in.RealtimeRuntime)) - } - if in.RealtimePeriod != nil { - const prefix string = ",\"realtimePeriod\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(*in.RealtimePeriod)) - } - if in.Cpus != "" { - const prefix string = ",\"cpus\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Cpus)) - } - if in.Mems != "" { - const prefix string = ",\"mems\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Mems)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo32(in *jlexer.Lexer, out *specs_go.LinuxMemory) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "limit": - if in.IsNull() { - in.Skip() - out.Limit = nil - } else { - if out.Limit == nil { - out.Limit = new(int64) - } - *out.Limit = int64(in.Int64()) - } - case "reservation": - if in.IsNull() { - in.Skip() - out.Reservation = nil - } else { - if out.Reservation == nil { - out.Reservation = new(int64) - } - *out.Reservation = int64(in.Int64()) - } - case "swap": - if in.IsNull() { - in.Skip() - out.Swap = nil - } else { - if out.Swap == nil { - out.Swap = new(int64) - } - *out.Swap = int64(in.Int64()) - } - case "kernel": - if in.IsNull() { - in.Skip() - out.Kernel = nil - } else { - if out.Kernel == nil { - out.Kernel = new(int64) - } - *out.Kernel = int64(in.Int64()) - } - case "kernelTCP": - if in.IsNull() { - in.Skip() - out.KernelTCP = nil - } else { - if out.KernelTCP == nil { - out.KernelTCP = new(int64) - } - *out.KernelTCP = int64(in.Int64()) - } - case "swappiness": - if in.IsNull() { - in.Skip() - out.Swappiness = nil - } else { - if out.Swappiness == nil { - out.Swappiness = new(uint64) - } - *out.Swappiness = uint64(in.Uint64()) - } - case "disableOOMKiller": - if in.IsNull() { - in.Skip() - out.DisableOOMKiller = nil - } else { - if out.DisableOOMKiller == nil { - out.DisableOOMKiller = new(bool) - } - *out.DisableOOMKiller = bool(in.Bool()) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo32(out *jwriter.Writer, in specs_go.LinuxMemory) { - out.RawByte('{') - first := true - _ = first - if in.Limit != nil { - const prefix string = ",\"limit\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(*in.Limit)) - } - if in.Reservation != nil { - const prefix string = ",\"reservation\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(*in.Reservation)) - } - if in.Swap != nil { - const prefix string = ",\"swap\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(*in.Swap)) - } - if in.Kernel != nil { - const prefix string = ",\"kernel\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(*in.Kernel)) - } - if in.KernelTCP != nil { - const prefix string = ",\"kernelTCP\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(*in.KernelTCP)) - } - if in.Swappiness != nil { - const prefix string = ",\"swappiness\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(*in.Swappiness)) - } - if in.DisableOOMKiller != nil { - const prefix string = ",\"disableOOMKiller\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(*in.DisableOOMKiller)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo31(in *jlexer.Lexer, out *specs_go.LinuxDeviceCgroup) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "allow": - out.Allow = bool(in.Bool()) - case "type": - out.Type = string(in.String()) - case "major": - if in.IsNull() { - in.Skip() - out.Major = nil - } else { - if out.Major == nil { - out.Major = new(int64) - } - *out.Major = int64(in.Int64()) - } - case "minor": - if in.IsNull() { - in.Skip() - out.Minor = nil - } else { - if out.Minor == nil { - out.Minor = new(int64) - } - *out.Minor = int64(in.Int64()) - } - case "access": - out.Access = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo31(out *jwriter.Writer, in specs_go.LinuxDeviceCgroup) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"allow\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.Allow)) - } - if in.Type != "" { - const prefix string = ",\"type\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Type)) - } - if in.Major != nil { - const prefix string = ",\"major\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(*in.Major)) - } - if in.Minor != nil { - const prefix string = ",\"minor\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(*in.Minor)) - } - if in.Access != "" { - const prefix string = ",\"access\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Access)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo23(in *jlexer.Lexer, out *specs_go.LinuxIDMapping) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "containerID": - out.ContainerID = uint32(in.Uint32()) - case "hostID": - out.HostID = uint32(in.Uint32()) - case "size": - out.Size = uint32(in.Uint32()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo23(out *jwriter.Writer, in specs_go.LinuxIDMapping) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"containerID\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint32(uint32(in.ContainerID)) - } - { - const prefix string = ",\"hostID\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint32(uint32(in.HostID)) - } - { - const prefix string = ",\"size\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint32(uint32(in.Size)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo5(in *jlexer.Lexer, out *specs_go.Hooks) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "prestart": - if in.IsNull() { - in.Skip() - out.Prestart = nil - } else { - in.Delim('[') - if out.Prestart == nil { - if !in.IsDelim(']') { - out.Prestart = make([]specs_go.Hook, 0, 1) - } else { - out.Prestart = []specs_go.Hook{} - } - } else { - out.Prestart = (out.Prestart)[:0] - } - for !in.IsDelim(']') { - var v171 specs_go.Hook - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo(in, &v171) - out.Prestart = append(out.Prestart, v171) - in.WantComma() - } - in.Delim(']') - } - case "poststart": - if in.IsNull() { - in.Skip() - out.Poststart = nil - } else { - in.Delim('[') - if out.Poststart == nil { - if !in.IsDelim(']') { - out.Poststart = make([]specs_go.Hook, 0, 1) - } else { - out.Poststart = []specs_go.Hook{} - } - } else { - out.Poststart = (out.Poststart)[:0] - } - for !in.IsDelim(']') { - var v172 specs_go.Hook - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo(in, &v172) - out.Poststart = append(out.Poststart, v172) - in.WantComma() - } - in.Delim(']') - } - case "poststop": - if in.IsNull() { - in.Skip() - out.Poststop = nil - } else { - in.Delim('[') - if out.Poststop == nil { - if !in.IsDelim(']') { - out.Poststop = make([]specs_go.Hook, 0, 1) - } else { - out.Poststop = []specs_go.Hook{} - } - } else { - out.Poststop = (out.Poststop)[:0] - } - for !in.IsDelim(']') { - var v173 specs_go.Hook - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo(in, &v173) - out.Poststop = append(out.Poststop, v173) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo5(out *jwriter.Writer, in specs_go.Hooks) { - out.RawByte('{') - first := true - _ = first - if len(in.Prestart) != 0 { - const prefix string = ",\"prestart\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v174, v175 := range in.Prestart { - if v174 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo(out, v175) - } - out.RawByte(']') - } - } - if len(in.Poststart) != 0 { - const prefix string = ",\"poststart\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v176, v177 := range in.Poststart { - if v176 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo(out, v177) - } - out.RawByte(']') - } - } - if len(in.Poststop) != 0 { - const prefix string = ",\"poststop\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v178, v179 := range in.Poststop { - if v178 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo(out, v179) - } - out.RawByte(']') - } - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo4(in *jlexer.Lexer, out *specs_go.Mount) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "destination": - out.Destination = string(in.String()) - case "type": - out.Type = string(in.String()) - case "source": - out.Source = string(in.String()) - case "options": - if in.IsNull() { - in.Skip() - out.Options = nil - } else { - in.Delim('[') - if out.Options == nil { - if !in.IsDelim(']') { - out.Options = make([]string, 0, 4) - } else { - out.Options = []string{} - } - } else { - out.Options = (out.Options)[:0] - } - for !in.IsDelim(']') { - var v180 string - v180 = string(in.String()) - out.Options = append(out.Options, v180) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo4(out *jwriter.Writer, in specs_go.Mount) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"destination\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Destination)) - } - if in.Type != "" { - const prefix string = ",\"type\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Type)) - } - if in.Source != "" { - const prefix string = ",\"source\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Source)) - } - if len(in.Options) != 0 { - const prefix string = ",\"options\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v181, v182 := range in.Options { - if v181 > 0 { - out.RawByte(',') - } - out.String(string(v182)) - } - out.RawByte(']') - } - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo3(in *jlexer.Lexer, out *specs_go.Root) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "path": - out.Path = string(in.String()) - case "readonly": - out.Readonly = bool(in.Bool()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo3(out *jwriter.Writer, in specs_go.Root) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"path\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Path)) - } - if in.Readonly { - const prefix string = ",\"readonly\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.Readonly)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo2(in *jlexer.Lexer, out *specs_go.Process) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "terminal": - out.Terminal = bool(in.Bool()) - case "consoleSize": - if in.IsNull() { - in.Skip() - out.ConsoleSize = nil - } else { - if out.ConsoleSize == nil { - out.ConsoleSize = new(specs_go.Box) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo42(in, &*out.ConsoleSize) - } - case "user": - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo43(in, &out.User) - case "args": - if in.IsNull() { - in.Skip() - out.Args = nil - } else { - in.Delim('[') - if out.Args == nil { - if !in.IsDelim(']') { - out.Args = make([]string, 0, 4) - } else { - out.Args = []string{} - } - } else { - out.Args = (out.Args)[:0] - } - for !in.IsDelim(']') { - var v183 string - v183 = string(in.String()) - out.Args = append(out.Args, v183) - in.WantComma() - } - in.Delim(']') - } - case "env": - if in.IsNull() { - in.Skip() - out.Env = nil - } else { - in.Delim('[') - if out.Env == nil { - if !in.IsDelim(']') { - out.Env = make([]string, 0, 4) - } else { - out.Env = []string{} - } - } else { - out.Env = (out.Env)[:0] - } - for !in.IsDelim(']') { - var v184 string - v184 = string(in.String()) - out.Env = append(out.Env, v184) - in.WantComma() - } - in.Delim(']') - } - case "cwd": - out.Cwd = string(in.String()) - case "capabilities": - if in.IsNull() { - in.Skip() - out.Capabilities = nil - } else { - if out.Capabilities == nil { - out.Capabilities = new(specs_go.LinuxCapabilities) - } - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo44(in, &*out.Capabilities) - } - case "rlimits": - if in.IsNull() { - in.Skip() - out.Rlimits = nil - } else { - in.Delim('[') - if out.Rlimits == nil { - if !in.IsDelim(']') { - out.Rlimits = make([]specs_go.POSIXRlimit, 0, 2) - } else { - out.Rlimits = []specs_go.POSIXRlimit{} - } - } else { - out.Rlimits = (out.Rlimits)[:0] - } - for !in.IsDelim(']') { - var v185 specs_go.POSIXRlimit - easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo45(in, &v185) - out.Rlimits = append(out.Rlimits, v185) - in.WantComma() - } - in.Delim(']') - } - case "noNewPrivileges": - out.NoNewPrivileges = bool(in.Bool()) - case "apparmorProfile": - out.ApparmorProfile = string(in.String()) - case "oomScoreAdj": - if in.IsNull() { - in.Skip() - out.OOMScoreAdj = nil - } else { - if out.OOMScoreAdj == nil { - out.OOMScoreAdj = new(int) - } - *out.OOMScoreAdj = int(in.Int()) - } - case "selinuxLabel": - out.SelinuxLabel = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo2(out *jwriter.Writer, in specs_go.Process) { - out.RawByte('{') - first := true - _ = first - if in.Terminal { - const prefix string = ",\"terminal\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.Terminal)) - } - if in.ConsoleSize != nil { - const prefix string = ",\"consoleSize\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo42(out, *in.ConsoleSize) - } - { - const prefix string = ",\"user\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo43(out, in.User) - } - { - const prefix string = ",\"args\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - if in.Args == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v186, v187 := range in.Args { - if v186 > 0 { - out.RawByte(',') - } - out.String(string(v187)) - } - out.RawByte(']') - } - } - if len(in.Env) != 0 { - const prefix string = ",\"env\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v188, v189 := range in.Env { - if v188 > 0 { - out.RawByte(',') - } - out.String(string(v189)) - } - out.RawByte(']') - } - } - { - const prefix string = ",\"cwd\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Cwd)) - } - if in.Capabilities != nil { - const prefix string = ",\"capabilities\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo44(out, *in.Capabilities) - } - if len(in.Rlimits) != 0 { - const prefix string = ",\"rlimits\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v190, v191 := range in.Rlimits { - if v190 > 0 { - out.RawByte(',') - } - easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo45(out, v191) - } - out.RawByte(']') - } - } - if in.NoNewPrivileges { - const prefix string = ",\"noNewPrivileges\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Bool(bool(in.NoNewPrivileges)) - } - if in.ApparmorProfile != "" { - const prefix string = ",\"apparmorProfile\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.ApparmorProfile)) - } - if in.OOMScoreAdj != nil { - const prefix string = ",\"oomScoreAdj\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int(int(*in.OOMScoreAdj)) - } - if in.SelinuxLabel != "" { - const prefix string = ",\"selinuxLabel\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.SelinuxLabel)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo45(in *jlexer.Lexer, out *specs_go.POSIXRlimit) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "type": - out.Type = string(in.String()) - case "hard": - out.Hard = uint64(in.Uint64()) - case "soft": - out.Soft = uint64(in.Uint64()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo45(out *jwriter.Writer, in specs_go.POSIXRlimit) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"type\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Type)) - } - { - const prefix string = ",\"hard\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(in.Hard)) - } - { - const prefix string = ",\"soft\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(in.Soft)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo44(in *jlexer.Lexer, out *specs_go.LinuxCapabilities) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "bounding": - if in.IsNull() { - in.Skip() - out.Bounding = nil - } else { - in.Delim('[') - if out.Bounding == nil { - if !in.IsDelim(']') { - out.Bounding = make([]string, 0, 4) - } else { - out.Bounding = []string{} - } - } else { - out.Bounding = (out.Bounding)[:0] - } - for !in.IsDelim(']') { - var v192 string - v192 = string(in.String()) - out.Bounding = append(out.Bounding, v192) - in.WantComma() - } - in.Delim(']') - } - case "effective": - if in.IsNull() { - in.Skip() - out.Effective = nil - } else { - in.Delim('[') - if out.Effective == nil { - if !in.IsDelim(']') { - out.Effective = make([]string, 0, 4) - } else { - out.Effective = []string{} - } - } else { - out.Effective = (out.Effective)[:0] - } - for !in.IsDelim(']') { - var v193 string - v193 = string(in.String()) - out.Effective = append(out.Effective, v193) - in.WantComma() - } - in.Delim(']') - } - case "inheritable": - if in.IsNull() { - in.Skip() - out.Inheritable = nil - } else { - in.Delim('[') - if out.Inheritable == nil { - if !in.IsDelim(']') { - out.Inheritable = make([]string, 0, 4) - } else { - out.Inheritable = []string{} - } - } else { - out.Inheritable = (out.Inheritable)[:0] - } - for !in.IsDelim(']') { - var v194 string - v194 = string(in.String()) - out.Inheritable = append(out.Inheritable, v194) - in.WantComma() - } - in.Delim(']') - } - case "permitted": - if in.IsNull() { - in.Skip() - out.Permitted = nil - } else { - in.Delim('[') - if out.Permitted == nil { - if !in.IsDelim(']') { - out.Permitted = make([]string, 0, 4) - } else { - out.Permitted = []string{} - } - } else { - out.Permitted = (out.Permitted)[:0] - } - for !in.IsDelim(']') { - var v195 string - v195 = string(in.String()) - out.Permitted = append(out.Permitted, v195) - in.WantComma() - } - in.Delim(']') - } - case "ambient": - if in.IsNull() { - in.Skip() - out.Ambient = nil - } else { - in.Delim('[') - if out.Ambient == nil { - if !in.IsDelim(']') { - out.Ambient = make([]string, 0, 4) - } else { - out.Ambient = []string{} - } - } else { - out.Ambient = (out.Ambient)[:0] - } - for !in.IsDelim(']') { - var v196 string - v196 = string(in.String()) - out.Ambient = append(out.Ambient, v196) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo44(out *jwriter.Writer, in specs_go.LinuxCapabilities) { - out.RawByte('{') - first := true - _ = first - if len(in.Bounding) != 0 { - const prefix string = ",\"bounding\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v197, v198 := range in.Bounding { - if v197 > 0 { - out.RawByte(',') - } - out.String(string(v198)) - } - out.RawByte(']') - } - } - if len(in.Effective) != 0 { - const prefix string = ",\"effective\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v199, v200 := range in.Effective { - if v199 > 0 { - out.RawByte(',') - } - out.String(string(v200)) - } - out.RawByte(']') - } - } - if len(in.Inheritable) != 0 { - const prefix string = ",\"inheritable\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v201, v202 := range in.Inheritable { - if v201 > 0 { - out.RawByte(',') - } - out.String(string(v202)) - } - out.RawByte(']') - } - } - if len(in.Permitted) != 0 { - const prefix string = ",\"permitted\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v203, v204 := range in.Permitted { - if v203 > 0 { - out.RawByte(',') - } - out.String(string(v204)) - } - out.RawByte(']') - } - } - if len(in.Ambient) != 0 { - const prefix string = ",\"ambient\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v205, v206 := range in.Ambient { - if v205 > 0 { - out.RawByte(',') - } - out.String(string(v206)) - } - out.RawByte(']') - } - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo43(in *jlexer.Lexer, out *specs_go.User) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "uid": - out.UID = uint32(in.Uint32()) - case "gid": - out.GID = uint32(in.Uint32()) - case "additionalGids": - if in.IsNull() { - in.Skip() - out.AdditionalGids = nil - } else { - in.Delim('[') - if out.AdditionalGids == nil { - if !in.IsDelim(']') { - out.AdditionalGids = make([]uint32, 0, 16) - } else { - out.AdditionalGids = []uint32{} - } - } else { - out.AdditionalGids = (out.AdditionalGids)[:0] - } - for !in.IsDelim(']') { - var v207 uint32 - v207 = uint32(in.Uint32()) - out.AdditionalGids = append(out.AdditionalGids, v207) - in.WantComma() - } - in.Delim(']') - } - case "username": - out.Username = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo43(out *jwriter.Writer, in specs_go.User) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"uid\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint32(uint32(in.UID)) - } - { - const prefix string = ",\"gid\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint32(uint32(in.GID)) - } - if len(in.AdditionalGids) != 0 { - const prefix string = ",\"additionalGids\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - { - out.RawByte('[') - for v208, v209 := range in.AdditionalGids { - if v208 > 0 { - out.RawByte(',') - } - out.Uint32(uint32(v209)) - } - out.RawByte(']') - } - } - if in.Username != "" { - const prefix string = ",\"username\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(in.Username)) - } - out.RawByte('}') -} -func easyjson1dbef17bDecodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo42(in *jlexer.Lexer, out *specs_go.Box) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "height": - out.Height = uint(in.Uint()) - case "width": - out.Width = uint(in.Uint()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson1dbef17bEncodeGithubComContainersLibpodVendorGithubComOpencontainersRuntimeSpecSpecsGo42(out *jwriter.Writer, in specs_go.Box) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"height\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint(uint(in.Height)) - } - { - const prefix string = ",\"width\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint(uint(in.Width)) - } - out.RawByte('}') -} +type EasyJSON_exporter_containerState *containerState diff --git a/libpod/container_graph_test.go b/libpod/container_graph_test.go index d1a52658d..25461f1f4 100644 --- a/libpod/container_graph_test.go +++ b/libpod/container_graph_test.go @@ -1,9 +1,10 @@ package libpod import ( + "io/ioutil" + "os" "testing" - "github.com/containers/libpod/libpod/lock" "github.com/stretchr/testify/assert" ) @@ -16,12 +17,11 @@ func TestBuildContainerGraphNoCtrsIsEmpty(t *testing.T) { } func TestBuildContainerGraphOneCtr(t *testing.T) { - manager, err := lock.NewInMemoryManager(16) - if err != nil { - t.Fatalf("Error setting up locks: %v", err) - } + tmpDir, err := ioutil.TempDir("", tmpDirPrefix) + assert.NoError(t, err) + defer os.RemoveAll(tmpDir) - ctr1, err := getTestCtr1(manager) + ctr1, err := getTestCtr1(tmpDir) assert.NoError(t, err) graph, err := buildContainerGraph([]*Container{ctr1}) @@ -39,14 +39,13 @@ func TestBuildContainerGraphOneCtr(t *testing.T) { } func TestBuildContainerGraphTwoCtrNoEdge(t *testing.T) { - manager, err := lock.NewInMemoryManager(16) - if err != nil { - t.Fatalf("Error setting up locks: %v", err) - } + tmpDir, err := ioutil.TempDir("", tmpDirPrefix) + assert.NoError(t, err) + defer os.RemoveAll(tmpDir) - ctr1, err := getTestCtr1(manager) + ctr1, err := getTestCtr1(tmpDir) assert.NoError(t, err) - ctr2, err := getTestCtr2(manager) + ctr2, err := getTestCtr2(tmpDir) assert.NoError(t, err) graph, err := buildContainerGraph([]*Container{ctr1, ctr2}) @@ -65,14 +64,13 @@ func TestBuildContainerGraphTwoCtrNoEdge(t *testing.T) { } func TestBuildContainerGraphTwoCtrOneEdge(t *testing.T) { - manager, err := lock.NewInMemoryManager(16) - if err != nil { - t.Fatalf("Error setting up locks: %v", err) - } + tmpDir, err := ioutil.TempDir("", tmpDirPrefix) + assert.NoError(t, err) + defer os.RemoveAll(tmpDir) - ctr1, err := getTestCtr1(manager) + ctr1, err := getTestCtr1(tmpDir) assert.NoError(t, err) - ctr2, err := getTestCtr2(manager) + ctr2, err := getTestCtr2(tmpDir) assert.NoError(t, err) ctr2.config.UserNsCtr = ctr1.config.ID @@ -87,14 +85,13 @@ func TestBuildContainerGraphTwoCtrOneEdge(t *testing.T) { } func TestBuildContainerGraphTwoCtrCycle(t *testing.T) { - manager, err := lock.NewInMemoryManager(16) - if err != nil { - t.Fatalf("Error setting up locks: %v", err) - } + tmpDir, err := ioutil.TempDir("", tmpDirPrefix) + assert.NoError(t, err) + defer os.RemoveAll(tmpDir) - ctr1, err := getTestCtr1(manager) + ctr1, err := getTestCtr1(tmpDir) assert.NoError(t, err) - ctr2, err := getTestCtr2(manager) + ctr2, err := getTestCtr2(tmpDir) assert.NoError(t, err) ctr2.config.UserNsCtr = ctr1.config.ID ctr1.config.NetNsCtr = ctr2.config.ID @@ -104,16 +101,15 @@ func TestBuildContainerGraphTwoCtrCycle(t *testing.T) { } func TestBuildContainerGraphThreeCtrNoEdges(t *testing.T) { - manager, err := lock.NewInMemoryManager(16) - if err != nil { - t.Fatalf("Error setting up locks: %v", err) - } + tmpDir, err := ioutil.TempDir("", tmpDirPrefix) + assert.NoError(t, err) + defer os.RemoveAll(tmpDir) - ctr1, err := getTestCtr1(manager) + ctr1, err := getTestCtr1(tmpDir) assert.NoError(t, err) - ctr2, err := getTestCtr2(manager) + ctr2, err := getTestCtr2(tmpDir) assert.NoError(t, err) - ctr3, err := getTestCtrN("3", manager) + ctr3, err := getTestCtrN("3", tmpDir) assert.NoError(t, err) graph, err := buildContainerGraph([]*Container{ctr1, ctr2, ctr3}) @@ -136,16 +132,15 @@ func TestBuildContainerGraphThreeCtrNoEdges(t *testing.T) { } func TestBuildContainerGraphThreeContainersTwoInCycle(t *testing.T) { - manager, err := lock.NewInMemoryManager(16) - if err != nil { - t.Fatalf("Error setting up locks: %v", err) - } + tmpDir, err := ioutil.TempDir("", tmpDirPrefix) + assert.NoError(t, err) + defer os.RemoveAll(tmpDir) - ctr1, err := getTestCtr1(manager) + ctr1, err := getTestCtr1(tmpDir) assert.NoError(t, err) - ctr2, err := getTestCtr2(manager) + ctr2, err := getTestCtr2(tmpDir) assert.NoError(t, err) - ctr3, err := getTestCtrN("3", manager) + ctr3, err := getTestCtrN("3", tmpDir) assert.NoError(t, err) ctr1.config.UserNsCtr = ctr2.config.ID ctr2.config.IPCNsCtr = ctr1.config.ID @@ -155,16 +150,15 @@ func TestBuildContainerGraphThreeContainersTwoInCycle(t *testing.T) { } func TestBuildContainerGraphThreeContainersCycle(t *testing.T) { - manager, err := lock.NewInMemoryManager(16) - if err != nil { - t.Fatalf("Error setting up locks: %v", err) - } + tmpDir, err := ioutil.TempDir("", tmpDirPrefix) + assert.NoError(t, err) + defer os.RemoveAll(tmpDir) - ctr1, err := getTestCtr1(manager) + ctr1, err := getTestCtr1(tmpDir) assert.NoError(t, err) - ctr2, err := getTestCtr2(manager) + ctr2, err := getTestCtr2(tmpDir) assert.NoError(t, err) - ctr3, err := getTestCtrN("3", manager) + ctr3, err := getTestCtrN("3", tmpDir) assert.NoError(t, err) ctr1.config.UserNsCtr = ctr2.config.ID ctr2.config.IPCNsCtr = ctr3.config.ID @@ -175,16 +169,15 @@ func TestBuildContainerGraphThreeContainersCycle(t *testing.T) { } func TestBuildContainerGraphThreeContainersNoCycle(t *testing.T) { - manager, err := lock.NewInMemoryManager(16) - if err != nil { - t.Fatalf("Error setting up locks: %v", err) - } + tmpDir, err := ioutil.TempDir("", tmpDirPrefix) + assert.NoError(t, err) + defer os.RemoveAll(tmpDir) - ctr1, err := getTestCtr1(manager) + ctr1, err := getTestCtr1(tmpDir) assert.NoError(t, err) - ctr2, err := getTestCtr2(manager) + ctr2, err := getTestCtr2(tmpDir) assert.NoError(t, err) - ctr3, err := getTestCtrN("3", manager) + ctr3, err := getTestCtrN("3", tmpDir) assert.NoError(t, err) ctr1.config.UserNsCtr = ctr2.config.ID ctr1.config.NetNsCtr = ctr3.config.ID @@ -201,18 +194,17 @@ func TestBuildContainerGraphThreeContainersNoCycle(t *testing.T) { } func TestBuildContainerGraphFourContainersNoEdges(t *testing.T) { - manager, err := lock.NewInMemoryManager(16) - if err != nil { - t.Fatalf("Error setting up locks: %v", err) - } + tmpDir, err := ioutil.TempDir("", tmpDirPrefix) + assert.NoError(t, err) + defer os.RemoveAll(tmpDir) - ctr1, err := getTestCtr1(manager) + ctr1, err := getTestCtr1(tmpDir) assert.NoError(t, err) - ctr2, err := getTestCtr2(manager) + ctr2, err := getTestCtr2(tmpDir) assert.NoError(t, err) - ctr3, err := getTestCtrN("3", manager) + ctr3, err := getTestCtrN("3", tmpDir) assert.NoError(t, err) - ctr4, err := getTestCtrN("4", manager) + ctr4, err := getTestCtrN("4", tmpDir) assert.NoError(t, err) graph, err := buildContainerGraph([]*Container{ctr1, ctr2, ctr3, ctr4}) @@ -239,20 +231,18 @@ func TestBuildContainerGraphFourContainersNoEdges(t *testing.T) { } func TestBuildContainerGraphFourContainersTwoInCycle(t *testing.T) { - manager, err := lock.NewInMemoryManager(16) - if err != nil { - t.Fatalf("Error setting up locks: %v", err) - } + tmpDir, err := ioutil.TempDir("", tmpDirPrefix) + assert.NoError(t, err) + defer os.RemoveAll(tmpDir) - ctr1, err := getTestCtr1(manager) + ctr1, err := getTestCtr1(tmpDir) assert.NoError(t, err) - ctr2, err := getTestCtr2(manager) + ctr2, err := getTestCtr2(tmpDir) assert.NoError(t, err) - ctr3, err := getTestCtrN("3", manager) + ctr3, err := getTestCtrN("3", tmpDir) assert.NoError(t, err) - ctr4, err := getTestCtrN("4", manager) + ctr4, err := getTestCtrN("4", tmpDir) assert.NoError(t, err) - ctr1.config.IPCNsCtr = ctr2.config.ID ctr2.config.UserNsCtr = ctr1.config.ID @@ -261,20 +251,18 @@ func TestBuildContainerGraphFourContainersTwoInCycle(t *testing.T) { } func TestBuildContainerGraphFourContainersAllInCycle(t *testing.T) { - manager, err := lock.NewInMemoryManager(16) - if err != nil { - t.Fatalf("Error setting up locks: %v", err) - } + tmpDir, err := ioutil.TempDir("", tmpDirPrefix) + assert.NoError(t, err) + defer os.RemoveAll(tmpDir) - ctr1, err := getTestCtr1(manager) + ctr1, err := getTestCtr1(tmpDir) assert.NoError(t, err) - ctr2, err := getTestCtr2(manager) + ctr2, err := getTestCtr2(tmpDir) assert.NoError(t, err) - ctr3, err := getTestCtrN("3", manager) + ctr3, err := getTestCtrN("3", tmpDir) assert.NoError(t, err) - ctr4, err := getTestCtrN("4", manager) + ctr4, err := getTestCtrN("4", tmpDir) assert.NoError(t, err) - ctr1.config.IPCNsCtr = ctr2.config.ID ctr2.config.UserNsCtr = ctr3.config.ID ctr3.config.NetNsCtr = ctr4.config.ID @@ -285,20 +273,18 @@ func TestBuildContainerGraphFourContainersAllInCycle(t *testing.T) { } func TestBuildContainerGraphFourContainersNoneInCycle(t *testing.T) { - manager, err := lock.NewInMemoryManager(16) - if err != nil { - t.Fatalf("Error setting up locks: %v", err) - } + tmpDir, err := ioutil.TempDir("", tmpDirPrefix) + assert.NoError(t, err) + defer os.RemoveAll(tmpDir) - ctr1, err := getTestCtr1(manager) + ctr1, err := getTestCtr1(tmpDir) assert.NoError(t, err) - ctr2, err := getTestCtr2(manager) + ctr2, err := getTestCtr2(tmpDir) assert.NoError(t, err) - ctr3, err := getTestCtrN("3", manager) + ctr3, err := getTestCtrN("3", tmpDir) assert.NoError(t, err) - ctr4, err := getTestCtrN("4", manager) + ctr4, err := getTestCtrN("4", tmpDir) assert.NoError(t, err) - ctr1.config.IPCNsCtr = ctr2.config.ID ctr1.config.NetNsCtr = ctr3.config.ID ctr2.config.UserNsCtr = ctr3.config.ID diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 69df33bc9..04d67b1aa 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -401,10 +401,7 @@ func resetState(state *containerState) error { return nil } -// Refresh refreshes the container's state after a restart. -// Refresh cannot perform any operations that would lock another container. -// We cannot guarantee any other container has a valid lock at the time it is -// running. +// Refresh refreshes the container's state after a restart func (c *Container) refresh() error { // Don't need a full sync, but we do need to update from the database to // pick up potentially-missing container state @@ -450,13 +447,6 @@ func (c *Container) refresh() error { c.state.DestinationRunDir = filepath.Join(c.state.UserNSRoot, "rundir") } - // We need to pick up a new lock - lock, err := c.runtime.lockManager.RetrieveLock(c.config.LockID) - if err != nil { - return errors.Wrapf(err, "error acquiring lock for container %s", c.ID()) - } - c.lock = lock - if err := c.save(); err != nil { return errors.Wrapf(err, "error refreshing state for container %s", c.ID()) } diff --git a/libpod/lock/in_memory_locks.go b/libpod/lock/in_memory_locks.go deleted file mode 100644 index db8f20e95..000000000 --- a/libpod/lock/in_memory_locks.go +++ /dev/null @@ -1,91 +0,0 @@ -package lock - -import ( - "sync" - - "github.com/pkg/errors" -) - -// Mutex holds a single mutex and whether it has been allocated. -type Mutex struct { - id uint32 - lock sync.Mutex - allocated bool -} - -// ID retrieves the ID of the mutex -func (m *Mutex) ID() uint32 { - return m.id -} - -// Lock locks the mutex -func (m *Mutex) Lock() { - m.lock.Lock() -} - -// Unlock unlocks the mutex -func (m *Mutex) Unlock() { - m.lock.Unlock() -} - -// Free deallocates the mutex to allow its reuse -func (m *Mutex) Free() error { - m.allocated = false - - return nil -} - -// InMemoryManager is a lock manager that allocates and retrieves local-only -// locks - that is, they are not multiprocess. This lock manager is intended -// purely for unit and integration testing and should not be used in production -// deployments. -type InMemoryManager struct { - locks []*Mutex - numLocks uint32 - localLock sync.Mutex -} - -// NewInMemoryManager creates a new in-memory lock manager with the given number -// of locks. -func NewInMemoryManager(numLocks uint32) (Manager, error) { - if numLocks == 0 { - return nil, errors.Errorf("must provide a non-zero number of locks!") - } - - manager := new(InMemoryManager) - manager.numLocks = numLocks - manager.locks = make([]*Mutex, numLocks) - - var i uint32 - for i = 0; i < numLocks; i++ { - lock := new(Mutex) - lock.id = i - manager.locks[i] = lock - } - - return manager, nil -} - -// AllocateLock allocates a lock from the manager. -func (m *InMemoryManager) AllocateLock() (Locker, error) { - m.localLock.Lock() - defer m.localLock.Unlock() - - for _, lock := range m.locks { - if !lock.allocated { - lock.allocated = true - return lock, nil - } - } - - return nil, errors.Errorf("all locks have been allocated") -} - -// RetrieveLock retrieves a lock from the manager. -func (m *InMemoryManager) RetrieveLock(id uint32) (Locker, error) { - if id >= m.numLocks { - return nil, errors.Errorf("given lock ID %d is too large - this manager only supports lock indexes up to %d", id, m.numLocks-1) - } - - return m.locks[id], nil -} diff --git a/libpod/lock/lock.go b/libpod/lock/lock.go deleted file mode 100644 index 73c1fdcf7..000000000 --- a/libpod/lock/lock.go +++ /dev/null @@ -1,58 +0,0 @@ -package lock - -// Manager provides an interface for allocating multiprocess locks. -// Locks returned by Manager MUST be multiprocess - allocating a lock in -// process A and retrieving that lock's ID in process B must return handles for -// the same lock, and locking the lock in A should exclude B from the lock until -// it is unlocked in A. -// All locks must be identified by a UUID (retrieved with Locker's ID() method). -// All locks with a given UUID must refer to the same underlying lock, and it -// must be possible to retrieve the lock given its UUID. -// Each UUID should refer to a unique underlying lock. -// Calls to AllocateLock() must return a unique, unallocated UUID. -// AllocateLock() must fail once all available locks have been allocated. -// Locks are returned to use by calls to Free(), and can subsequently be -// reallocated. -type Manager interface { - // AllocateLock returns an unallocated lock. - // It is guaranteed that the same lock will not be returned again by - // AllocateLock until the returned lock has Free() called on it. - // If all available locks are allocated, AllocateLock will return an - // error. - AllocateLock() (Locker, error) - // RetrieveLock retrieves a lock given its UUID. - // The underlying lock MUST be the same as another other lock with the - // same UUID. - RetrieveLock(id uint32) (Locker, error) -} - -// Locker is similar to sync.Locker, but provides a method for freeing the lock -// to allow its reuse. -// All Locker implementations must maintain mutex semantics - the lock only -// allows one caller in the critical section at a time. -// All locks with the same ID must refer to the same underlying lock, even -// if they are within multiple processes. -type Locker interface { - // ID retrieves the lock's ID. - // ID is guaranteed to uniquely identify the lock within the - // Manager - that is, calling RetrieveLock with this ID will return - // another instance of the same lock. - ID() uint32 - // Lock locks the lock. - // This call MUST block until it successfully acquires the lock or - // encounters a fatal error. - // All errors must be handled internally, as they are not returned. For - // the most part, panicking should be appropriate. - Lock() - // Unlock unlocks the lock. - // All errors must be handled internally, as they are not returned. For - // the most part, panicking should be appropriate. - // This includes unlocking locks which are already unlocked. - Unlock() - // Free deallocates the underlying lock, allowing its reuse by other - // pods and containers. - // The lock MUST still be usable after a Free() - some libpod instances - // may still retain Container structs with the old lock. This simply - // advises the manager that the lock may be reallocated. - Free() error -} diff --git a/libpod/lock/shm/shm_lock.c b/libpod/lock/shm/shm_lock.c deleted file mode 100644 index 4af58d857..000000000 --- a/libpod/lock/shm/shm_lock.c +++ /dev/null @@ -1,452 +0,0 @@ -#include <errno.h> -#include <fcntl.h> -#include <pthread.h> -#include <stdbool.h> -#include <stdint.h> -#include <stdlib.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -#include "shm_lock.h" - -// Compute the size of the SHM struct -static size_t compute_shm_size(uint32_t num_bitmaps) { - return sizeof(shm_struct_t) + (num_bitmaps * sizeof(lock_group_t)); -} - -// Take the given mutex. -// Handles exceptional conditions, including a mutex locked by a process that -// died holding it. -// Returns 0 on success, or positive errno on failure. -static int take_mutex(pthread_mutex_t *mutex) { - int ret_code; - - do { - ret_code = pthread_mutex_lock(mutex); - } while(ret_code == EAGAIN); - - if (ret_code == EOWNERDEAD) { - // The previous owner of the mutex died while holding it - // Take it for ourselves - ret_code = pthread_mutex_consistent(mutex); - if (ret_code != 0) { - // Someone else may have gotten here first and marked the state consistent - // However, the mutex could also be invalid. - // Fail here instead of looping back to trying to lock the mutex. - return ret_code; - } - } else if (ret_code != 0) { - return ret_code; - } - - return 0; -} - -// Release the given mutex. -// Returns 0 on success, or positive errno on failure. -static int release_mutex(pthread_mutex_t *mutex) { - int ret_code; - - do { - ret_code = pthread_mutex_unlock(mutex); - } while(ret_code == EAGAIN); - - if (ret_code != 0) { - return ret_code; - } - - return 0; -} - -// Set up an SHM segment holding locks for libpod. -// num_locks must not be 0. -// Path is the path to the SHM segment. It must begin with a single / and -// container no other / characters, and be at most 255 characters including -// terminating NULL byte. -// Returns a valid pointer on success or NULL on error. -// If an error occurs, negative ERRNO values will be written to error_code. -shm_struct_t *setup_lock_shm(char *path, uint32_t num_locks, int *error_code) { - int shm_fd, i, j, ret_code; - uint32_t num_bitmaps; - size_t shm_size; - shm_struct_t *shm; - pthread_mutexattr_t attr; - - // If error_code doesn't point to anything, we can't reasonably return errors - // So fail immediately - if (error_code == NULL) { - return NULL; - } - - // We need a nonzero number of locks - if (num_locks == 0) { - *error_code = -1 * EINVAL; - return NULL; - } - - if (path == NULL) { - *error_code = -1 * EINVAL; - return NULL; - } - - // Calculate the number of bitmaps required - num_bitmaps = num_locks / BITMAP_SIZE; - if (num_locks % BITMAP_SIZE != 0) { - // The actual number given is not an even multiple of our bitmap size - // So round up - num_bitmaps += 1; - } - - // Calculate size of the shm segment - shm_size = compute_shm_size(num_bitmaps); - - // Create a new SHM segment for us - shm_fd = shm_open(path, O_RDWR | O_CREAT | O_EXCL, 0600); - if (shm_fd < 0) { - *error_code = -1 * errno; - return NULL; - } - - // Increase its size to what we need - ret_code = ftruncate(shm_fd, shm_size); - if (ret_code < 0) { - *error_code = -1 * errno; - goto CLEANUP_UNLINK; - } - - // Map the shared memory in - shm = mmap(NULL, shm_size, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0); - if (shm == MAP_FAILED) { - *error_code = -1 * errno; - goto CLEANUP_UNLINK; - } - - // We have successfully mapped the memory, now initialize the region - shm->magic = MAGIC; - shm->unused = 0; - shm->num_locks = num_bitmaps * BITMAP_SIZE; - shm->num_bitmaps = num_bitmaps; - - // Create an initializer for our pthread mutexes - ret_code = pthread_mutexattr_init(&attr); - if (ret_code != 0) { - *error_code = -1 * ret_code; - goto CLEANUP_UNMAP; - } - - // Set mutexes to pshared - multiprocess-safe - ret_code = pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); - if (ret_code != 0) { - *error_code = -1 * ret_code; - goto CLEANUP_FREEATTR; - } - - // Set mutexes to robust - if a process dies while holding a mutex, we'll get - // a special error code on the next attempt to lock it. - // This should prevent panicing processes from leaving the state unusable. - ret_code = pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST); - if (ret_code != 0) { - *error_code = -1 * ret_code; - goto CLEANUP_FREEATTR; - } - - // Initialize the mutex that protects the bitmaps using the mutex attributes - ret_code = pthread_mutex_init(&(shm->segment_lock), &attr); - if (ret_code != 0) { - *error_code = -1 * ret_code; - goto CLEANUP_FREEATTR; - } - - // Initialize all bitmaps to 0 initially - // And initialize all semaphores they use - for (i = 0; i < num_bitmaps; i++) { - shm->locks[i].bitmap = 0; - for (j = 0; j < BITMAP_SIZE; j++) { - // Initialize each mutex - ret_code = pthread_mutex_init(&(shm->locks[i].locks[j]), &attr); - if (ret_code != 0) { - *error_code = -1 * ret_code; - goto CLEANUP_FREEATTR; - } - } - } - - // Close the file descriptor, we're done with it - // Ignore errors, it's ok if we leak a single FD and this should only run once - close(shm_fd); - - // Destroy the pthread initializer attribute. - // Again, ignore errors, this will only run once and we might leak a tiny bit - // of memory at worst. - pthread_mutexattr_destroy(&attr); - - return shm; - - // Cleanup after an error - CLEANUP_FREEATTR: - pthread_mutexattr_destroy(&attr); - CLEANUP_UNMAP: - munmap(shm, shm_size); - CLEANUP_UNLINK: - close(shm_fd); - shm_unlink(path); - return NULL; -} - -// Open an existing SHM segment holding libpod locks. -// num_locks is the number of locks that will be configured in the SHM segment. -// num_locks cannot be 0. -// Path is the path to the SHM segment. It must begin with a single / and -// container no other / characters, and be at most 255 characters including -// terminating NULL byte. -// Returns a valid pointer on success or NULL on error. -// If an error occurs, negative ERRNO values will be written to error_code. -shm_struct_t *open_lock_shm(char *path, uint32_t num_locks, int *error_code) { - int shm_fd; - shm_struct_t *shm; - size_t shm_size; - uint32_t num_bitmaps; - - if (error_code == NULL) { - return NULL; - } - - // We need a nonzero number of locks - if (num_locks == 0) { - *error_code = -1 * EINVAL; - return NULL; - } - - if (path == NULL) { - *error_code = -1 * EINVAL; - return NULL; - } - - // Calculate the number of bitmaps required - num_bitmaps = num_locks / BITMAP_SIZE; - if (num_locks % BITMAP_SIZE != 0) { - num_bitmaps += 1; - } - - // Calculate size of the shm segment - shm_size = compute_shm_size(num_bitmaps); - - shm_fd = shm_open(path, O_RDWR, 0600); - if (shm_fd < 0) { - *error_code = -1 * errno; - return NULL; - } - - // Map the shared memory in - shm = mmap(NULL, shm_size, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0); - if (shm == MAP_FAILED) { - *error_code = -1 * errno; - } - - // Ignore errors, it's ok if we leak a single FD since this only runs once - close(shm_fd); - - // Check if we successfully mmap'd - if (shm == MAP_FAILED) { - return NULL; - } - - // Need to check the SHM to see if it's actually our locks - if (shm->magic != MAGIC) { - *error_code = -1 * errno; - goto CLEANUP; - } - if (shm->num_locks != (num_bitmaps * BITMAP_SIZE)) { - *error_code = -1 * errno; - goto CLEANUP; - } - - return shm; - - CLEANUP: - munmap(shm, shm_size); - return NULL; -} - -// Close an open SHM lock struct, unmapping the backing memory. -// The given shm_struct_t will be rendered unusable as a result. -// On success, 0 is returned. On failure, negative ERRNO values are returned. -int32_t close_lock_shm(shm_struct_t *shm) { - int ret_code; - size_t shm_size; - - // We can't unmap null... - if (shm == NULL) { - return -1 * EINVAL; - } - - shm_size = compute_shm_size(shm->num_bitmaps); - - ret_code = munmap(shm, shm_size); - - if (ret_code != 0) { - return -1 * errno; - } - - return 0; -} - -// Allocate the first available semaphore -// Returns a positive integer guaranteed to be less than UINT32_MAX on success, -// or negative errno values on failure -// On sucess, the returned integer is the number of the semaphore allocated -int64_t allocate_semaphore(shm_struct_t *shm) { - int ret_code, i; - bitmap_t test_map; - int64_t sem_number, num_within_bitmap; - - if (shm == NULL) { - return -1 * EINVAL; - } - - // Lock the semaphore controlling access to our shared memory - ret_code = take_mutex(&(shm->segment_lock)); - if (ret_code != 0) { - return -1 * ret_code; - } - - // Loop through our bitmaps to search for one that is not full - for (i = 0; i < shm->num_bitmaps; i++) { - if (shm->locks[i].bitmap != 0xFFFFFFFF) { - test_map = 0x1; - num_within_bitmap = 0; - while (test_map != 0) { - if ((test_map & shm->locks[i].bitmap) == 0) { - // Compute the number of the semaphore we are allocating - sem_number = (BITMAP_SIZE * i) + num_within_bitmap; - // OR in the bitmap - shm->locks[i].bitmap = shm->locks[i].bitmap | test_map; - - // Clear the mutex - ret_code = release_mutex(&(shm->segment_lock)); - if (ret_code != 0) { - return -1 * ret_code; - } - - // Return the semaphore we've allocated - return sem_number; - } - test_map = test_map << 1; - num_within_bitmap++; - } - // We should never fall through this loop - // TODO maybe an assert() here to panic if we do? - } - } - - // Clear the mutex - ret_code = release_mutex(&(shm->segment_lock)); - if (ret_code != 0) { - return -1 * ret_code; - } - - // All bitmaps are full - // We have no available semaphores, report allocation failure - return -1 * ENOSPC; -} - -// Deallocate a given semaphore -// Returns 0 on success, negative ERRNO values on failure -int32_t deallocate_semaphore(shm_struct_t *shm, uint32_t sem_index) { - bitmap_t test_map; - int bitmap_index, index_in_bitmap, ret_code, i; - - if (shm == NULL) { - return -1 * EINVAL; - } - - // Check if the lock index is valid - if (sem_index >= shm->num_locks) { - return -1 * EINVAL; - } - - bitmap_index = sem_index / BITMAP_SIZE; - index_in_bitmap = sem_index % BITMAP_SIZE; - - // This should never happen if the sem_index test above succeeded, but better - // safe than sorry - if (bitmap_index >= shm->num_bitmaps) { - return -1 * EFAULT; - } - - test_map = 0x1 << index_in_bitmap; - - // Lock the mutex controlling access to our shared memory - ret_code = take_mutex(&(shm->segment_lock)); - if (ret_code != 0) { - return -1 * ret_code; - } - - // Check if the semaphore is allocated - if ((test_map & shm->locks[bitmap_index].bitmap) == 0) { - ret_code = release_mutex(&(shm->segment_lock)); - if (ret_code != 0) { - return -1 * ret_code; - } - - return -1 * ENOENT; - } - - // The semaphore is allocated, clear it - // Invert the bitmask we used to test to clear the bit - test_map = ~test_map; - shm->locks[bitmap_index].bitmap = shm->locks[bitmap_index].bitmap & test_map; - - ret_code = release_mutex(&(shm->segment_lock)); - if (ret_code != 0) { - return -1 * ret_code; - } - - return 0; -} - -// Lock a given semaphore -// Does not check if the semaphore is allocated - this ensures that, even for -// removed containers, we can still successfully lock to check status (and -// subsequently realize they have been removed). -// Returns 0 on success, -1 on failure -int32_t lock_semaphore(shm_struct_t *shm, uint32_t sem_index) { - int bitmap_index, index_in_bitmap, ret_code; - - if (shm == NULL) { - return -1 * EINVAL; - } - - if (sem_index >= shm->num_locks) { - return -1 * EINVAL; - } - - bitmap_index = sem_index / BITMAP_SIZE; - index_in_bitmap = sem_index % BITMAP_SIZE; - - return -1 * take_mutex(&(shm->locks[bitmap_index].locks[index_in_bitmap])); -} - -// Unlock a given semaphore -// Does not check if the semaphore is allocated - this ensures that, even for -// removed containers, we can still successfully lock to check status (and -// subsequently realize they have been removed). -// Returns 0 on success, -1 on failure -int32_t unlock_semaphore(shm_struct_t *shm, uint32_t sem_index) { - int bitmap_index, index_in_bitmap, ret_code; - - if (shm == NULL) { - return -1 * EINVAL; - } - - if (sem_index >= shm->num_locks) { - return -1 * EINVAL; - } - - bitmap_index = sem_index / BITMAP_SIZE; - index_in_bitmap = sem_index % BITMAP_SIZE; - - return -1 * release_mutex(&(shm->locks[bitmap_index].locks[index_in_bitmap])); -} diff --git a/libpod/lock/shm/shm_lock.go b/libpod/lock/shm/shm_lock.go deleted file mode 100644 index be5e5148f..000000000 --- a/libpod/lock/shm/shm_lock.go +++ /dev/null @@ -1,216 +0,0 @@ -package shm - -// #cgo LDFLAGS: -lrt -lpthread -// #include <stdlib.h> -// #include "shm_lock.h" -// const uint32_t bitmap_size_c = BITMAP_SIZE; -import "C" - -import ( - "runtime" - "syscall" - "unsafe" - - "github.com/pkg/errors" - "github.com/sirupsen/logrus" -) - -var ( - // BitmapSize is the size of the bitmap used when managing SHM locks. - // an SHM lock manager's max locks will be rounded up to a multiple of - // this number. - BitmapSize uint32 = uint32(C.bitmap_size_c) -) - -// SHMLocks is a struct enabling POSIX semaphore locking in a shared memory -// segment. -type SHMLocks struct { // nolint - lockStruct *C.shm_struct_t - maxLocks uint32 - valid bool -} - -// CreateSHMLock sets up a shared-memory segment holding a given number of POSIX -// semaphores, and returns a struct that can be used to operate on those locks. -// numLocks must not be 0, and may be rounded up to a multiple of the bitmap -// size used by the underlying implementation. -func CreateSHMLock(path string, numLocks uint32) (*SHMLocks, error) { - if numLocks == 0 { - return nil, errors.Wrapf(syscall.EINVAL, "number of locks must greater than 0 0") - } - - locks := new(SHMLocks) - - cPath := C.CString(path) - defer C.free(unsafe.Pointer(cPath)) - - var errCode C.int - lockStruct := C.setup_lock_shm(cPath, C.uint32_t(numLocks), &errCode) - if lockStruct == nil { - // We got a null pointer, so something errored - return nil, errors.Wrapf(syscall.Errno(-1*errCode), "failed to create %d locks in %s", numLocks, path) - } - - locks.lockStruct = lockStruct - locks.maxLocks = uint32(lockStruct.num_locks) - locks.valid = true - - logrus.Debugf("Initialized SHM lock manager at path %s", path) - - return locks, nil -} - -// OpenSHMLock opens an existing shared-memory segment holding a given number of -// POSIX semaphores. numLocks must match the number of locks the shared memory -// segment was created with. -func OpenSHMLock(path string, numLocks uint32) (*SHMLocks, error) { - if numLocks == 0 { - return nil, errors.Wrapf(syscall.EINVAL, "number of locks must greater than 0") - } - - locks := new(SHMLocks) - - cPath := C.CString(path) - defer C.free(unsafe.Pointer(cPath)) - - var errCode C.int - lockStruct := C.open_lock_shm(cPath, C.uint32_t(numLocks), &errCode) - if lockStruct == nil { - // We got a null pointer, so something errored - return nil, errors.Wrapf(syscall.Errno(-1*errCode), "failed to open %d locks in %s", numLocks, path) - } - - locks.lockStruct = lockStruct - locks.maxLocks = numLocks - locks.valid = true - - return locks, nil -} - -// GetMaxLocks returns the maximum number of locks in the SHM -func (locks *SHMLocks) GetMaxLocks() uint32 { - return locks.maxLocks -} - -// Close closes an existing shared-memory segment. -// The segment will be rendered unusable after closing. -// WARNING: If you Close() while there are still locks locked, these locks may -// fail to release, causing a program freeze. -// Close() is only intended to be used while testing the locks. -func (locks *SHMLocks) Close() error { - if !locks.valid { - return errors.Wrapf(syscall.EINVAL, "locks have already been closed") - } - - locks.valid = false - - retCode := C.close_lock_shm(locks.lockStruct) - if retCode < 0 { - // Negative errno returned - return syscall.Errno(-1 * retCode) - } - - return nil -} - -// AllocateSemaphore allocates a semaphore from a shared-memory segment for use -// by a container or pod. -// Returns the index of the semaphore that was allocated. -// Allocations past the maximum number of locks given when the SHM segment was -// created will result in an error, and no semaphore will be allocated. -func (locks *SHMLocks) AllocateSemaphore() (uint32, error) { - if !locks.valid { - return 0, errors.Wrapf(syscall.EINVAL, "locks have already been closed") - } - - // This returns a U64, so we have the full u32 range available for - // semaphore indexes, and can still return error codes. - retCode := C.allocate_semaphore(locks.lockStruct) - if retCode < 0 { - // Negative errno returned - return 0, syscall.Errno(-1 * retCode) - } - - return uint32(retCode), nil -} - -// DeallocateSemaphore frees a semaphore in a shared-memory segment so it can be -// reallocated to another container or pod. -// The given semaphore must be already allocated, or an error will be returned. -func (locks *SHMLocks) DeallocateSemaphore(sem uint32) error { - if !locks.valid { - return errors.Wrapf(syscall.EINVAL, "locks have already been closed") - } - - if sem > locks.maxLocks { - return errors.Wrapf(syscall.EINVAL, "given semaphore %d is higher than maximum locks count %d", sem, locks.maxLocks) - } - - retCode := C.deallocate_semaphore(locks.lockStruct, C.uint32_t(sem)) - if retCode < 0 { - // Negative errno returned - return syscall.Errno(-1 * retCode) - } - - return nil -} - -// LockSemaphore locks the given semaphore. -// If the semaphore is already locked, LockSemaphore will block until the lock -// can be acquired. -// There is no requirement that the given semaphore be allocated. -// This ensures that attempts to lock a container after it has been deleted, -// but before the caller has queried the database to determine this, will -// succeed. -func (locks *SHMLocks) LockSemaphore(sem uint32) error { - if !locks.valid { - return errors.Wrapf(syscall.EINVAL, "locks have already been closed") - } - - if sem > locks.maxLocks { - return errors.Wrapf(syscall.EINVAL, "given semaphore %d is higher than maximum locks count %d", sem, locks.maxLocks) - } - - // For pthread mutexes, we have to guarantee lock and unlock happen in - // the same thread. - runtime.LockOSThread() - - retCode := C.lock_semaphore(locks.lockStruct, C.uint32_t(sem)) - if retCode < 0 { - // Negative errno returned - return syscall.Errno(-1 * retCode) - } - - return nil -} - -// UnlockSemaphore unlocks the given semaphore. -// Unlocking a semaphore that is already unlocked with return EBUSY. -// There is no requirement that the given semaphore be allocated. -// This ensures that attempts to lock a container after it has been deleted, -// but before the caller has queried the database to determine this, will -// succeed. -func (locks *SHMLocks) UnlockSemaphore(sem uint32) error { - if !locks.valid { - return errors.Wrapf(syscall.EINVAL, "locks have already been closed") - } - - if sem > locks.maxLocks { - return errors.Wrapf(syscall.EINVAL, "given semaphore %d is higher than maximum locks count %d", sem, locks.maxLocks) - } - - retCode := C.unlock_semaphore(locks.lockStruct, C.uint32_t(sem)) - if retCode < 0 { - // Negative errno returned - return syscall.Errno(-1 * retCode) - } - - // For pthread mutexes, we have to guarantee lock and unlock happen in - // the same thread. - // OK if we take multiple locks - UnlockOSThread() won't actually unlock - // until the number of calls equals the number of calls to - // LockOSThread() - runtime.UnlockOSThread() - - return nil -} diff --git a/libpod/lock/shm/shm_lock.h b/libpod/lock/shm/shm_lock.h deleted file mode 100644 index 8e7e23fb7..000000000 --- a/libpod/lock/shm/shm_lock.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef shm_locks_h_ -#define shm_locks_h_ - -#include <pthread.h> -#include <stdint.h> - -// Magic number to ensure we open the right SHM segment -#define MAGIC 0x87D1 - -// Type for our bitmaps -typedef uint32_t bitmap_t; - -// bitmap size -#define BITMAP_SIZE (sizeof(bitmap_t) * 8) - -// Struct to hold a single bitmap and associated locks -typedef struct lock_group { - bitmap_t bitmap; - pthread_mutex_t locks[BITMAP_SIZE]; -} lock_group_t; - -// Struct to hold our SHM locks. -// Unused is required to be 0 in the current implementation. If we ever make -// changes to this structure in the future, this will be repurposed as a version -// field. -typedef struct shm_struct { - uint16_t magic; - uint16_t unused; - pthread_mutex_t segment_lock; - uint32_t num_bitmaps; - uint32_t num_locks; - lock_group_t locks[]; -} shm_struct_t; - -static size_t compute_shm_size(uint32_t num_bitmaps); -static int take_mutex(pthread_mutex_t *mutex); -static int release_mutex(pthread_mutex_t *mutex); -shm_struct_t *setup_lock_shm(char *path, uint32_t num_locks, int *error_code); -shm_struct_t *open_lock_shm(char *path, uint32_t num_locks, int *error_code); -int32_t close_lock_shm(shm_struct_t *shm); -int64_t allocate_semaphore(shm_struct_t *shm); -int32_t deallocate_semaphore(shm_struct_t *shm, uint32_t sem_index); -int32_t lock_semaphore(shm_struct_t *shm, uint32_t sem_index); -int32_t unlock_semaphore(shm_struct_t *shm, uint32_t sem_index); - -#endif diff --git a/libpod/lock/shm/shm_lock_test.go b/libpod/lock/shm/shm_lock_test.go deleted file mode 100644 index 0f3a96cca..000000000 --- a/libpod/lock/shm/shm_lock_test.go +++ /dev/null @@ -1,278 +0,0 @@ -package shm - -import ( - "fmt" - "os" - "runtime" - "syscall" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -// All tests here are in the same process, which somewhat limits their utility -// The big intent of this package it multiprocess locking, which is really hard -// to test without actually having multiple processes... -// We can at least verify that the locks work within the local process. - -var ( - // 4 * BITMAP_SIZE to ensure we have to traverse bitmaps - numLocks = 4 * BitmapSize -) - -const lockPath = "/libpod_test" - -// We need a test main to ensure that the SHM is created before the tests run -func TestMain(m *testing.M) { - shmLock, err := CreateSHMLock(lockPath, numLocks) - if err != nil { - fmt.Fprintf(os.Stderr, "Error creating SHM for tests: %v\n", err) - os.Exit(-1) - } - - // Close the SHM - every subsequent test will reopen - if err := shmLock.Close(); err != nil { - fmt.Fprintf(os.Stderr, "Error closing SHM locks: %v\n", err) - os.Exit(-1) - } - - exitCode := m.Run() - - // We need to remove the SHM segment to clean up after ourselves - os.RemoveAll("/dev/shm/libpod_lock") - - os.Exit(exitCode) -} - -func runLockTest(t *testing.T, testFunc func(*testing.T, *SHMLocks)) { - locks, err := OpenSHMLock(lockPath, numLocks) - if err != nil { - t.Fatalf("Error opening locks: %v", err) - } - defer func() { - // Deallocate all locks - // Ignore ENOENT (lock is not allocated) - var i uint32 - for i = 0; i < numLocks; i++ { - if err := locks.DeallocateSemaphore(i); err != nil && err != syscall.ENOENT { - t.Fatalf("Error deallocating semaphore %d: %v", i, err) - } - } - - if err := locks.Close(); err != nil { - t.Fatalf("Error closing locks: %v", err) - } - }() - - success := t.Run("locks", func(t *testing.T) { - testFunc(t, locks) - }) - if !success { - t.Fail() - } -} - -// Test that creating an SHM with a bad size rounds up to a good size -func TestCreateNewSHMBadSizeRoundsUp(t *testing.T) { - // Odd number, not a power of 2, should never be a word size on a system - lock, err := CreateSHMLock("/test1", 7) - assert.NoError(t, err) - - assert.Equal(t, lock.GetMaxLocks(), BitmapSize) - - if err := lock.Close(); err != nil { - t.Fatalf("Error closing locks: %v", err) - } -} - -// Test that creating an SHM with 0 size fails -func TestCreateNewSHMZeroSize(t *testing.T) { - _, err := CreateSHMLock("/test2", 0) - assert.Error(t, err) -} - -// Test that deallocating an unallocated lock errors -func TestDeallocateUnallocatedLockErrors(t *testing.T) { - runLockTest(t, func(t *testing.T, locks *SHMLocks) { - err := locks.DeallocateSemaphore(0) - assert.Error(t, err) - }) -} - -// Test that unlocking an unlocked lock fails -func TestUnlockingUnlockedLockFails(t *testing.T) { - runLockTest(t, func(t *testing.T, locks *SHMLocks) { - err := locks.UnlockSemaphore(0) - assert.Error(t, err) - }) -} - -// Test that locking and double-unlocking fails -func TestDoubleUnlockFails(t *testing.T) { - runLockTest(t, func(t *testing.T, locks *SHMLocks) { - err := locks.LockSemaphore(0) - assert.NoError(t, err) - - err = locks.UnlockSemaphore(0) - assert.NoError(t, err) - - err = locks.UnlockSemaphore(0) - assert.Error(t, err) - }) -} - -// Test allocating - lock - unlock - deallocate cycle, single lock -func TestLockLifecycleSingleLock(t *testing.T) { - runLockTest(t, func(t *testing.T, locks *SHMLocks) { - sem, err := locks.AllocateSemaphore() - require.NoError(t, err) - - err = locks.LockSemaphore(sem) - assert.NoError(t, err) - - err = locks.UnlockSemaphore(sem) - assert.NoError(t, err) - - err = locks.DeallocateSemaphore(sem) - assert.NoError(t, err) - }) -} - -// Test allocate two locks returns different locks -func TestAllocateTwoLocksGetsDifferentLocks(t *testing.T) { - runLockTest(t, func(t *testing.T, locks *SHMLocks) { - sem1, err := locks.AllocateSemaphore() - assert.NoError(t, err) - - sem2, err := locks.AllocateSemaphore() - assert.NoError(t, err) - - assert.NotEqual(t, sem1, sem2) - }) -} - -// Test allocate all locks successful and all are unique -func TestAllocateAllLocksSucceeds(t *testing.T) { - runLockTest(t, func(t *testing.T, locks *SHMLocks) { - sems := make(map[uint32]bool) - var i uint32 - for i = 0; i < numLocks; i++ { - sem, err := locks.AllocateSemaphore() - assert.NoError(t, err) - - // Ensure the allocate semaphore is unique - _, ok := sems[sem] - assert.False(t, ok) - - sems[sem] = true - } - }) -} - -// Test allocating more than the given max fails -func TestAllocateTooManyLocksFails(t *testing.T) { - runLockTest(t, func(t *testing.T, locks *SHMLocks) { - // Allocate all locks - var i uint32 - for i = 0; i < numLocks; i++ { - _, err := locks.AllocateSemaphore() - assert.NoError(t, err) - } - - // Try and allocate one more - _, err := locks.AllocateSemaphore() - assert.Error(t, err) - }) -} - -// Test allocating max locks, deallocating one, and then allocating again succeeds -func TestAllocateDeallocateCycle(t *testing.T) { - runLockTest(t, func(t *testing.T, locks *SHMLocks) { - // Allocate all locks - var i uint32 - for i = 0; i < numLocks; i++ { - _, err := locks.AllocateSemaphore() - assert.NoError(t, err) - } - - // Now loop through again, deallocating and reallocating. - // Each time we free 1 semaphore, allocate again, and make sure - // we get the same semaphore back. - var j uint32 - for j = 0; j < numLocks; j++ { - err := locks.DeallocateSemaphore(j) - assert.NoError(t, err) - - newSem, err := locks.AllocateSemaphore() - assert.NoError(t, err) - assert.Equal(t, j, newSem) - } - }) -} - -// Test that locks actually lock -func TestLockSemaphoreActuallyLocks(t *testing.T) { - runLockTest(t, func(t *testing.T, locks *SHMLocks) { - // This entire test is very ugly - lots of sleeps to try and get - // things to occur in the right order. - // It also doesn't even exercise the multiprocess nature of the - // locks. - - // Get the current time - startTime := time.Now() - - // Start a goroutine to take the lock and then release it after - // a second. - go func() { - err := locks.LockSemaphore(0) - assert.NoError(t, err) - - time.Sleep(1 * time.Second) - - err = locks.UnlockSemaphore(0) - assert.NoError(t, err) - }() - - // Sleep for a quarter of a second to give the goroutine time - // to kick off and grab the lock - time.Sleep(250 * time.Millisecond) - - // Take the lock - err := locks.LockSemaphore(0) - assert.NoError(t, err) - - // Get the current time - endTime := time.Now() - - // Verify that at least 1 second has passed since start - duration := endTime.Sub(startTime) - assert.True(t, duration.Seconds() > 1.0) - }) -} - -// Test that locking and unlocking two semaphores succeeds -// Ensures that runtime.LockOSThread() is doing its job -func TestLockAndUnlockTwoSemaphore(t *testing.T) { - runLockTest(t, func(t *testing.T, locks *SHMLocks) { - err := locks.LockSemaphore(0) - assert.NoError(t, err) - - err = locks.LockSemaphore(1) - assert.NoError(t, err) - - err = locks.UnlockSemaphore(1) - assert.NoError(t, err) - - // Now yield scheduling - // To try and get us on another OS thread - runtime.Gosched() - - // And unlock the last semaphore - // If we are in a different OS thread, this should fail. - // However, runtime.UnlockOSThread() should guarantee we are not - err = locks.UnlockSemaphore(0) - assert.NoError(t, err) - }) -} diff --git a/libpod/lock/shm_lock_manager_linux.go b/libpod/lock/shm_lock_manager_linux.go deleted file mode 100644 index 3e8f4f3d2..000000000 --- a/libpod/lock/shm_lock_manager_linux.go +++ /dev/null @@ -1,94 +0,0 @@ -// +build linux - -package lock - -import ( - "github.com/containers/libpod/libpod/lock/shm" -) - -// SHMLockManager manages shared memory locks. -type SHMLockManager struct { - locks *shm.SHMLocks -} - -// NewSHMLockManager makes a new SHMLockManager with the given number of locks. -// Due to the underlying implementation, the exact number of locks created may -// be greater than the number given here. -func NewSHMLockManager(path string, numLocks uint32) (Manager, error) { - locks, err := shm.CreateSHMLock(path, numLocks) - if err != nil { - return nil, err - } - - manager := new(SHMLockManager) - manager.locks = locks - - return manager, nil -} - -// OpenSHMLockManager opens an existing SHMLockManager with the given number of -// locks. -func OpenSHMLockManager(path string, numLocks uint32) (Manager, error) { - locks, err := shm.OpenSHMLock(path, numLocks) - if err != nil { - return nil, err - } - - manager := new(SHMLockManager) - manager.locks = locks - - return manager, nil -} - -// AllocateLock allocates a new lock from the manager. -func (m *SHMLockManager) AllocateLock() (Locker, error) { - semIndex, err := m.locks.AllocateSemaphore() - if err != nil { - return nil, err - } - - lock := new(SHMLock) - lock.lockID = semIndex - lock.manager = m - - return lock, nil -} - -// RetrieveLock retrieves a lock from the manager given its ID. -func (m *SHMLockManager) RetrieveLock(id uint32) (Locker, error) { - lock := new(SHMLock) - lock.lockID = id - lock.manager = m - - return lock, nil -} - -// SHMLock is an individual shared memory lock. -type SHMLock struct { - lockID uint32 - manager *SHMLockManager -} - -// ID returns the ID of the lock. -func (l *SHMLock) ID() uint32 { - return l.lockID -} - -// Lock acquires the lock. -func (l *SHMLock) Lock() { - if err := l.manager.locks.LockSemaphore(l.lockID); err != nil { - panic(err.Error()) - } -} - -// Unlock releases the lock. -func (l *SHMLock) Unlock() { - if err := l.manager.locks.UnlockSemaphore(l.lockID); err != nil { - panic(err.Error()) - } -} - -// Free releases the lock, allowing it to be reused. -func (l *SHMLock) Free() error { - return l.manager.locks.DeallocateSemaphore(l.lockID) -} diff --git a/libpod/lock/shm_lock_manager_unsupported.go b/libpod/lock/shm_lock_manager_unsupported.go deleted file mode 100644 index a1340fcd1..000000000 --- a/libpod/lock/shm_lock_manager_unsupported.go +++ /dev/null @@ -1,29 +0,0 @@ -// +build !linux - -package lock - -import "fmt" - -// SHMLockManager is a shared memory lock manager. -// It is not supported on non-Unix platforms. -type SHMLockManager struct{} - -// NewSHMLockManager is not supported on this platform -func NewSHMLockManager(numLocks uint32) (Manager, error) { - return nil, fmt.Errorf("not supported") -} - -// OpenSHMLockManager is not supported on this platform -func OpenSHMLockManager(numLocks uint32) (Manager, error) { - return nil, fmt.Errorf("not supported") -} - -// AllocateLock is not supported on this platform -func (m *SHMLockManager) AllocateLock() (Locker, error) { - return nil, fmt.Errorf("not supported") -} - -// RetrieveLock is not supported on this platform -func (m *SHMLockManager) RetrieveLock(id string) (Locker, error) { - return nil, fmt.Errorf("not supported") -} diff --git a/libpod/pod.go b/libpod/pod.go index 4ce697402..07f41f5c6 100644 --- a/libpod/pod.go +++ b/libpod/pod.go @@ -3,7 +3,7 @@ package libpod import ( "time" - "github.com/containers/libpod/libpod/lock" + "github.com/containers/storage" "github.com/cri-o/ocicni/pkg/ocicni" "github.com/pkg/errors" ) @@ -26,7 +26,7 @@ type Pod struct { valid bool runtime *Runtime - lock lock.Locker + lock storage.Locker } // PodConfig represents a pod's static configuration @@ -60,9 +60,6 @@ type PodConfig struct { // Time pod was created CreatedTime time.Time `json:"created"` - - // ID of the pod's lock - LockID uint32 `json:"lockID"` } // podState represents a pod's state diff --git a/libpod/pod_easyjson.go b/libpod/pod_easyjson.go index 71862dad0..8ea9a5e72 100644 --- a/libpod/pod_easyjson.go +++ b/libpod/pod_easyjson.go @@ -501,8 +501,6 @@ func easyjsonBe091417DecodeGithubComContainersLibpodLibpod4(in *jlexer.Lexer, ou if data := in.Raw(); in.Ok() { in.AddError((out.CreatedTime).UnmarshalJSON(data)) } - case "lockID": - out.LockID = uint32(in.Uint32()) default: in.SkipRecursive() } @@ -677,16 +675,6 @@ func easyjsonBe091417EncodeGithubComContainersLibpodLibpod4(out *jwriter.Writer, } out.Raw((in.CreatedTime).MarshalJSON()) } - { - const prefix string = ",\"lockID\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint32(uint32(in.LockID)) - } out.RawByte('}') } diff --git a/libpod/pod_internal.go b/libpod/pod_internal.go index 0f1f115e8..39a25c004 100644 --- a/libpod/pod_internal.go +++ b/libpod/pod_internal.go @@ -7,13 +7,14 @@ import ( "strings" "time" + "github.com/containers/storage" "github.com/containers/storage/pkg/stringid" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) // Creates a new, empty pod -func newPod(runtime *Runtime) (*Pod, error) { +func newPod(lockDir string, runtime *Runtime) (*Pod, error) { pod := new(Pod) pod.config = new(PodConfig) pod.config.ID = stringid.GenerateNonCryptoID() @@ -23,6 +24,15 @@ func newPod(runtime *Runtime) (*Pod, error) { pod.state = new(podState) pod.runtime = runtime + // Path our lock file will reside at + lockPath := filepath.Join(lockDir, pod.config.ID) + // Grab a lockfile at the given path + lock, err := storage.GetLockfile(lockPath) + if err != nil { + return nil, errors.Wrapf(err, "error creating lockfile for new pod") + } + pod.lock = lock + return pod, nil } @@ -45,8 +55,6 @@ func (p *Pod) save() error { } // Refresh a pod's state after restart -// This cannot lock any other pod, but may lock individual containers, as those -// will have refreshed by the time pod refresh runs. func (p *Pod) refresh() error { // Need to to an update from the DB to pull potentially-missing state if err := p.runtime.state.UpdatePod(p); err != nil { @@ -57,13 +65,6 @@ func (p *Pod) refresh() error { return ErrPodRemoved } - // Retrieve the pod's lock - lock, err := p.runtime.lockManager.RetrieveLock(p.config.LockID) - if err != nil { - return errors.Wrapf(err, "error retrieving lock for pod %s", p.ID()) - } - p.lock = lock - // We need to recreate the pod's cgroup if p.config.UsePodCgroup { switch p.runtime.config.CgroupManager { diff --git a/libpod/runtime.go b/libpod/runtime.go index ab8d02a4f..facbe5d66 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -1,7 +1,6 @@ package libpod import ( - "fmt" "io/ioutil" "os" "os/exec" @@ -12,7 +11,6 @@ import ( is "github.com/containers/image/storage" "github.com/containers/image/types" "github.com/containers/libpod/libpod/image" - "github.com/containers/libpod/libpod/lock" "github.com/containers/libpod/pkg/firewall" sysreg "github.com/containers/libpod/pkg/registries" "github.com/containers/libpod/pkg/rootless" @@ -66,11 +64,6 @@ const ( // DefaultInitPath is the default path to the container-init binary DefaultInitPath = "/usr/libexec/podman/catatonit" - - // DefaultSHMLockPath is the default path for SHM locks - DefaultSHMLockPath = "/libpod_lock" - // DefaultRootlessSHMLockPath is the default path for rootless SHM locks - DefaultRootlessSHMLockPath = "/libpod_rootless_lock" ) // A RuntimeOption is a functional option which alters the Runtime created by @@ -85,6 +78,7 @@ type Runtime struct { storageService *storageService imageContext *types.SystemContext ociRuntime *OCIRuntime + lockDir string netPlugin ocicni.CNIPlugin ociRuntimePath string conmonPath string @@ -92,7 +86,6 @@ type Runtime struct { lock sync.RWMutex imageRuntime *image.Runtime firewallBackend firewall.FirewallBackend - lockManager lock.Manager configuredFrom *runtimeConfiguredFrom } @@ -172,7 +165,6 @@ type RuntimeConfig struct { // and all containers and pods will be visible. // The default namespace is "". Namespace string `toml:"namespace,omitempty"` - // InfraImage is the image a pod infra container will use to manage namespaces InfraImage string `toml:"infra_image"` // InfraCommand is the command run to start up a pod infra container @@ -187,10 +179,6 @@ type RuntimeConfig struct { EnablePortReservation bool `toml:"enable_port_reservation"` // EnableLabeling indicates wether libpod will support container labeling EnableLabeling bool `toml:"label"` - - // NumLocks is the number of locks to make available for containers and - // pods. - NumLocks uint32 `toml:"num_locks,omitempty"` } // runtimeConfiguredFrom is a struct used during early runtime init to help @@ -246,7 +234,6 @@ var ( InfraImage: DefaultInfraImage, EnablePortReservation: true, EnableLabeling: true, - NumLocks: 2048, } ) @@ -629,6 +616,17 @@ func makeRuntime(runtime *Runtime) (err error) { } runtime.ociRuntime = ociRuntime + // Make a directory to hold container lockfiles + lockDir := filepath.Join(runtime.config.TmpDir, "lock") + if err := os.MkdirAll(lockDir, 0755); err != nil { + // The directory is allowed to exist + if !os.IsExist(err) { + return errors.Wrapf(err, "error creating runtime lockfiles directory %s", + lockDir) + } + } + runtime.lockDir = lockDir + // Make the per-boot files directory if it does not exist if err := os.MkdirAll(runtime.config.TmpDir, 0755); err != nil { // The directory is allowed to exist @@ -673,7 +671,6 @@ func makeRuntime(runtime *Runtime) (err error) { // and use it to lock important operations aliveLock.Lock() locked := true - doRefresh := false defer func() { if locked { aliveLock.Unlock() @@ -686,49 +683,19 @@ func makeRuntime(runtime *Runtime) (err error) { // empty state only creates a single file // As such, it's not really a performance concern if os.IsNotExist(err) { - doRefresh = true - } else { - return errors.Wrapf(err, "error reading runtime status file %s", runtimeAliveFile) - } - } - - // Set up the lock manager - var manager lock.Manager - lockPath := DefaultSHMLockPath - if rootless.IsRootless() { - lockPath = fmt.Sprintf("%s_%d", DefaultRootlessSHMLockPath, rootless.GetRootlessUID()) - } - if doRefresh { - // If SHM locks already exist, delete them and reinitialize - if err := os.Remove(filepath.Join("/dev/shm", lockPath)); err != nil && !os.IsNotExist(err) { - return errors.Wrapf(err, "error deleting existing libpod SHM segment %s", lockPath) - } - - manager, err = lock.NewSHMLockManager(lockPath, runtime.config.NumLocks) - if err != nil { - return err - } - } else { - manager, err = lock.OpenSHMLockManager(lockPath, runtime.config.NumLocks) - if err != nil { - return err - } - } - runtime.lockManager = manager - - // If we need to refresh the state, do it now - things are guaranteed to - // be set up by now. - if doRefresh { - if os.Geteuid() != 0 { - aliveLock.Unlock() - locked = false - if err2 := runtime.refreshRootless(); err2 != nil { - return err2 + if os.Geteuid() != 0 { + aliveLock.Unlock() + locked = false + if err2 := runtime.refreshRootless(); err2 != nil { + return err2 + } + } else { + if err2 := runtime.refresh(runtimeAliveFile); err2 != nil { + return err2 + } } } else { - if err2 := runtime.refresh(runtimeAliveFile); err2 != nil { - return err2 - } + return errors.Wrapf(err, "error reading runtime status file %s", runtimeAliveFile) } } @@ -827,22 +794,19 @@ func (r *Runtime) refresh(alivePath string) error { if err != nil { return errors.Wrapf(err, "error retrieving all pods from state") } - // No locks are taken during pod and container refresh. - // Furthermore, the pod and container refresh() functions are not - // allowed to take locks themselves. - // We cannot assume that any pod or container has a valid lock until - // after this function has returned. - // The runtime alive lock should suffice to provide mutual exclusion - // until this has run. for _, ctr := range ctrs { + ctr.lock.Lock() if err := ctr.refresh(); err != nil { logrus.Errorf("Error refreshing container %s: %v", ctr.ID(), err) } + ctr.lock.Unlock() } for _, pod := range pods { + pod.lock.Lock() if err := pod.refresh(); err != nil { logrus.Errorf("Error refreshing pod %s: %v", pod.ID(), err) } + pod.lock.Unlock() } // Create a file indicating the runtime is alive and ready diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index ab79fe5fb..038b7ed3b 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -9,6 +9,7 @@ import ( "time" "github.com/containers/libpod/pkg/rootless" + "github.com/containers/storage" "github.com/containers/storage/pkg/stringid" spec "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" @@ -60,6 +61,15 @@ func (r *Runtime) newContainer(ctx context.Context, rSpec *spec.Spec, options .. ctr.state.BindMounts = make(map[string]string) + // Path our lock file will reside at + lockPath := filepath.Join(r.lockDir, ctr.config.ID) + // Grab a lockfile at the given path + lock, err := storage.GetLockfile(lockPath) + if err != nil { + return nil, errors.Wrapf(err, "error creating lockfile for new container") + } + ctr.lock = lock + ctr.config.StopTimeout = CtrRemoveTimeout // Set namespace based on current runtime namespace @@ -75,19 +85,6 @@ func (r *Runtime) newContainer(ctx context.Context, rSpec *spec.Spec, options .. } } - // Allocate a lock for the container - lock, err := r.lockManager.AllocateLock() - if err != nil { - return nil, errors.Wrapf(err, "error allocating lock for new container") - } - ctr.lock = lock - ctr.config.LockID = ctr.lock.ID() - logrus.Debugf("Allocated lock %d for container %s", ctr.lock.ID(), ctr.ID()) - - ctr.valid = true - ctr.state.State = ContainerStateConfigured - ctr.runtime = r - ctr.valid = true ctr.state.State = ContainerStateConfigured @@ -382,15 +379,6 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force bool) } } - // Deallocate the container's lock - if err := c.lock.Free(); err != nil { - if cleanupErr == nil { - cleanupErr = err - } else { - logrus.Errorf("free container lock: %v", err) - } - } - return cleanupErr } diff --git a/libpod/runtime_pod_linux.go b/libpod/runtime_pod_linux.go index c6d497c0c..3d6fad52f 100644 --- a/libpod/runtime_pod_linux.go +++ b/libpod/runtime_pod_linux.go @@ -23,7 +23,7 @@ func (r *Runtime) NewPod(ctx context.Context, options ...PodCreateOption) (*Pod, return nil, ErrRuntimeStopped } - pod, err := newPod(r) + pod, err := newPod(r.lockDir, r) if err != nil { return nil, errors.Wrapf(err, "error creating pod") } @@ -48,14 +48,6 @@ func (r *Runtime) NewPod(ctx context.Context, options ...PodCreateOption) (*Pod, pod.config.Name = name } - // Allocate a lock for the pod - lock, err := r.lockManager.AllocateLock() - if err != nil { - return nil, errors.Wrapf(err, "error allocating lock for new pod") - } - pod.lock = lock - pod.config.LockID = pod.lock.ID() - pod.valid = true // Check CGroup parent sanity, and set it if it was not set @@ -247,11 +239,6 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool) return err } } - - // Free the container's lock - if err := ctr.lock.Free(); err != nil { - return err - } } // Remove containers from the state diff --git a/libpod/runtime_volume_linux.go b/libpod/runtime_volume_linux.go index 0727cfedf..5cc0938f0 100644 --- a/libpod/runtime_volume_linux.go +++ b/libpod/runtime_volume_linux.go @@ -8,6 +8,7 @@ import ( "path/filepath" "strings" + "github.com/containers/storage" "github.com/containers/storage/pkg/stringid" "github.com/opencontainers/selinux/go-selinux/label" "github.com/pkg/errors" @@ -67,12 +68,14 @@ func (r *Runtime) newVolume(ctx context.Context, options ...VolumeCreateOption) } volume.config.MountPoint = fullVolPath - lock, err := r.lockManager.AllocateLock() + // Path our lock file will reside at + lockPath := filepath.Join(r.lockDir, volume.config.Name) + // Grab a lockfile at the given path + lock, err := storage.GetLockfile(lockPath) if err != nil { - return nil, errors.Wrapf(err, "error allocating lock for new volume") + return nil, errors.Wrapf(err, "error creating lockfile for new volume") } volume.lock = lock - volume.config.LockID = volume.lock.ID() volume.valid = true diff --git a/libpod/state_test.go b/libpod/state_test.go index 4bd00ab55..d93a371f3 100644 --- a/libpod/state_test.go +++ b/libpod/state_test.go @@ -8,17 +8,16 @@ import ( "testing" "time" - "github.com/containers/libpod/libpod/lock" "github.com/containers/storage" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -// Returns state, tmp directory containing all state files, lock manager, and -// error. +// Returns state, tmp directory containing all state files, locks directory +// (subdirectory of tmp dir), and error // Closing the state and removing the given tmp directory should be sufficient -// to clean up. -type emptyStateFunc func() (State, string, lock.Manager, error) +// to clean up +type emptyStateFunc func() (State, string, string, error) const ( tmpDirPrefix = "libpod_state_test_" @@ -32,10 +31,10 @@ var ( ) // Get an empty BoltDB state for use in tests -func getEmptyBoltState() (s State, p string, m lock.Manager, err error) { +func getEmptyBoltState() (s State, p string, p2 string, err error) { tmpDir, err := ioutil.TempDir("", tmpDirPrefix) if err != nil { - return nil, "", nil, err + return nil, "", "", err } defer func() { if err != nil { @@ -44,30 +43,30 @@ func getEmptyBoltState() (s State, p string, m lock.Manager, err error) { }() dbPath := filepath.Join(tmpDir, "db.sql") + lockDir := filepath.Join(tmpDir, "locks") - lockManager, err := lock.NewInMemoryManager(16) - if err != nil { - return nil, "", nil, err + if err := os.Mkdir(lockDir, 0755); err != nil { + return nil, "", "", err } runtime := new(Runtime) runtime.config = new(RuntimeConfig) runtime.config.StorageConfig = storage.StoreOptions{} - runtime.lockManager = lockManager + runtime.lockDir = lockDir state, err := NewBoltState(dbPath, runtime) if err != nil { - return nil, "", nil, err + return nil, "", "", err } - return state, tmpDir, lockManager, nil + return state, tmpDir, lockDir, nil } // Get an empty in-memory state for use in tests -func getEmptyInMemoryState() (s State, p string, m lock.Manager, err error) { +func getEmptyInMemoryState() (s State, p string, p2 string, err error) { tmpDir, err := ioutil.TempDir("", tmpDirPrefix) if err != nil { - return nil, "", nil, err + return nil, "", "", err } defer func() { if err != nil { @@ -77,20 +76,17 @@ func getEmptyInMemoryState() (s State, p string, m lock.Manager, err error) { state, err := NewInMemoryState() if err != nil { - return nil, "", nil, err - } - - lockManager, err := lock.NewInMemoryManager(16) - if err != nil { - return nil, "", nil, err + return nil, "", "", err } - return state, tmpDir, lockManager, nil + // Don't need a separate locks dir as InMemoryState stores nothing on + // disk + return state, tmpDir, tmpDir, nil } -func runForAllStates(t *testing.T, testFunc func(*testing.T, State, lock.Manager)) { +func runForAllStates(t *testing.T, testFunc func(*testing.T, State, string)) { for stateName, stateFunc := range testedStates { - state, path, manager, err := stateFunc() + state, path, lockPath, err := stateFunc() if err != nil { t.Fatalf("Error initializing state %s: %v", stateName, err) } @@ -98,7 +94,7 @@ func runForAllStates(t *testing.T, testFunc func(*testing.T, State, lock.Manager defer state.Close() success := t.Run(stateName, func(t *testing.T) { - testFunc(t, state, manager) + testFunc(t, state, lockPath) }) if !success { t.Fail() @@ -107,8 +103,8 @@ func runForAllStates(t *testing.T, testFunc func(*testing.T, State, lock.Manager } func TestAddAndGetContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -122,10 +118,10 @@ func TestAddAndGetContainer(t *testing.T) { } func TestAddAndGetContainerFromMultiple(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr1) @@ -142,8 +138,8 @@ func TestAddAndGetContainerFromMultiple(t *testing.T) { } func TestGetContainerPodSameIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -155,17 +151,17 @@ func TestGetContainerPodSameIDFails(t *testing.T) { } func TestAddInvalidContainerFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { err := state.AddContainer(&Container{config: &ContainerConfig{ID: "1234"}}) assert.Error(t, err) }) } func TestAddDuplicateCtrIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestContainer(testCtr1.ID(), "test2", manager) + testCtr2, err := getTestContainer(testCtr1.ID(), "test2", lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr1) @@ -181,10 +177,10 @@ func TestAddDuplicateCtrIDFails(t *testing.T) { } func TestAddDuplicateCtrNameFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestContainer(strings.Repeat("2", 32), testCtr1.Name(), manager) + testCtr2, err := getTestContainer(strings.Repeat("2", 32), testCtr1.Name(), lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr1) @@ -200,10 +196,10 @@ func TestAddDuplicateCtrNameFails(t *testing.T) { } func TestAddCtrPodDupIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestContainer(testPod.ID(), "testCtr", manager) + testCtr, err := getTestContainer(testPod.ID(), "testCtr", lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -219,10 +215,10 @@ func TestAddCtrPodDupIDFails(t *testing.T) { } func TestAddCtrPodDupNameFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestContainer(strings.Repeat("2", 32), testPod.Name(), manager) + testCtr, err := getTestContainer(strings.Repeat("2", 32), testPod.Name(), lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -238,11 +234,11 @@ func TestAddCtrPodDupNameFails(t *testing.T) { } func TestAddCtrInPodFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -260,16 +256,16 @@ func TestAddCtrInPodFails(t *testing.T) { } func TestAddCtrDepInPodFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.ID() @@ -292,10 +288,10 @@ func TestAddCtrDepInPodFails(t *testing.T) { } func TestAddCtrDepInSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.config.ID @@ -316,10 +312,10 @@ func TestAddCtrDepInSameNamespaceSucceeds(t *testing.T) { } func TestAddCtrDepInDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.config.ID @@ -342,8 +338,8 @@ func TestAddCtrDepInDifferentNamespaceFails(t *testing.T) { } func TestAddCtrSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -361,8 +357,8 @@ func TestAddCtrSameNamespaceSucceeds(t *testing.T) { } func TestAddCtrDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -381,22 +377,22 @@ func TestAddCtrDifferentNamespaceFails(t *testing.T) { } func TestGetNonexistentContainerFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.Container("does not exist") assert.Error(t, err) }) } func TestGetContainerWithEmptyIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.Container("") assert.Error(t, err) }) } func TestGetContainerInDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test2" @@ -412,8 +408,8 @@ func TestGetContainerInDifferentNamespaceFails(t *testing.T) { } func TestGetContainerInSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -431,8 +427,8 @@ func TestGetContainerInSameNamespaceSucceeds(t *testing.T) { } func TestGetContainerInNamespaceWhileNotInNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -448,22 +444,22 @@ func TestGetContainerInNamespaceWhileNotInNamespaceSucceeds(t *testing.T) { } func TestLookupContainerWithEmptyIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.LookupContainer("") assert.Error(t, err) }) } func TestLookupNonexistentContainerFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.LookupContainer("does not exist") assert.Error(t, err) }) } func TestLookupContainerByFullID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -477,8 +473,8 @@ func TestLookupContainerByFullID(t *testing.T) { } func TestLookupContainerByUniquePartialID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -492,10 +488,10 @@ func TestLookupContainerByUniquePartialID(t *testing.T) { } func TestLookupContainerByNonUniquePartialIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestContainer(strings.Repeat("0", 32), "test1", manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestContainer(strings.Repeat("0", 32), "test1", lockPath) assert.NoError(t, err) - testCtr2, err := getTestContainer(strings.Repeat("0", 31)+"1", "test2", manager) + testCtr2, err := getTestContainer(strings.Repeat("0", 31)+"1", "test2", lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr1) @@ -510,8 +506,8 @@ func TestLookupContainerByNonUniquePartialIDFails(t *testing.T) { } func TestLookupContainerByName(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -525,8 +521,8 @@ func TestLookupContainerByName(t *testing.T) { } func TestLookupCtrByPodNameFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -538,8 +534,8 @@ func TestLookupCtrByPodNameFails(t *testing.T) { } func TestLookupCtrByPodIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -551,8 +547,8 @@ func TestLookupCtrByPodIDFails(t *testing.T) { } func TestLookupCtrInSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -570,8 +566,8 @@ func TestLookupCtrInSameNamespaceSucceeds(t *testing.T) { } func TestLookupCtrInDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -587,11 +583,11 @@ func TestLookupCtrInDifferentNamespaceFails(t *testing.T) { } func TestLookupContainerMatchInDifferentNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestContainer(strings.Repeat("0", 32), "test1", manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestContainer(strings.Repeat("0", 32), "test1", lockPath) assert.NoError(t, err) testCtr1.config.Namespace = "test2" - testCtr2, err := getTestContainer(strings.Repeat("0", 31)+"1", "test2", manager) + testCtr2, err := getTestContainer(strings.Repeat("0", 31)+"1", "test2", lockPath) assert.NoError(t, err) testCtr2.config.Namespace = "test1" @@ -611,14 +607,14 @@ func TestLookupContainerMatchInDifferentNamespaceSucceeds(t *testing.T) { } func TestHasContainerEmptyIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.HasContainer("") assert.Error(t, err) }) } func TestHasContainerNoSuchContainerReturnsFalse(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { exists, err := state.HasContainer("does not exist") assert.NoError(t, err) assert.False(t, exists) @@ -626,8 +622,8 @@ func TestHasContainerNoSuchContainerReturnsFalse(t *testing.T) { } func TestHasContainerFindsContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -640,8 +636,8 @@ func TestHasContainerFindsContainer(t *testing.T) { } func TestHasContainerPodIDIsFalse(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -654,8 +650,8 @@ func TestHasContainerPodIDIsFalse(t *testing.T) { } func TestHasContainerSameNamespaceIsTrue(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -672,8 +668,8 @@ func TestHasContainerSameNamespaceIsTrue(t *testing.T) { } func TestHasContainerDifferentNamespaceIsFalse(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -690,8 +686,8 @@ func TestHasContainerDifferentNamespaceIsFalse(t *testing.T) { } func TestSaveAndUpdateContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -715,8 +711,8 @@ func TestSaveAndUpdateContainer(t *testing.T) { } func TestSaveAndUpdateContainerSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -744,8 +740,8 @@ func TestSaveAndUpdateContainerSameNamespaceSucceeds(t *testing.T) { } func TestUpdateContainerNotInDatabaseReturnsError(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.UpdateContainer(testCtr) @@ -755,15 +751,15 @@ func TestUpdateContainerNotInDatabaseReturnsError(t *testing.T) { } func TestUpdateInvalidContainerReturnsError(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { err := state.UpdateContainer(&Container{config: &ContainerConfig{ID: "1234"}}) assert.Error(t, err) }) } func TestUpdateContainerNotInNamespaceReturnsError(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -779,15 +775,15 @@ func TestUpdateContainerNotInNamespaceReturnsError(t *testing.T) { } func TestSaveInvalidContainerReturnsError(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { err := state.SaveContainer(&Container{config: &ContainerConfig{ID: "1234"}}) assert.Error(t, err) }) } func TestSaveContainerNotInStateReturnsError(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.SaveContainer(testCtr) @@ -797,8 +793,8 @@ func TestSaveContainerNotInStateReturnsError(t *testing.T) { } func TestSaveContainerNotInNamespaceReturnsError(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -814,8 +810,8 @@ func TestSaveContainerNotInNamespaceReturnsError(t *testing.T) { } func TestRemoveContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -835,8 +831,8 @@ func TestRemoveContainer(t *testing.T) { } func TestRemoveNonexistantContainerFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.RemoveContainer(testCtr) @@ -846,8 +842,8 @@ func TestRemoveNonexistantContainerFails(t *testing.T) { } func TestRemoveContainerNotInNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -873,7 +869,7 @@ func TestRemoveContainerNotInNamespaceFails(t *testing.T) { } func TestGetAllContainersOnNewStateIsEmpty(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { ctrs, err := state.AllContainers() assert.NoError(t, err) assert.Equal(t, 0, len(ctrs)) @@ -881,8 +877,8 @@ func TestGetAllContainersOnNewStateIsEmpty(t *testing.T) { } func TestGetAllContainersWithOneContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -897,10 +893,10 @@ func TestGetAllContainersWithOneContainer(t *testing.T) { } func TestGetAllContainersTwoContainers(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr1) @@ -916,8 +912,8 @@ func TestGetAllContainersTwoContainers(t *testing.T) { } func TestGetAllContainersNoContainerInNamespace(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -934,13 +930,13 @@ func TestGetAllContainersNoContainerInNamespace(t *testing.T) { } func TestGetContainerOneContainerInNamespace(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr1.config.Namespace = "test1" - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr1) @@ -960,15 +956,15 @@ func TestGetContainerOneContainerInNamespace(t *testing.T) { } func TestContainerInUseInvalidContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.ContainerInUse(&Container{}) assert.Error(t, err) }) } func TestContainerInUseCtrNotInState(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) _, err = state.ContainerInUse(testCtr) assert.Error(t, err) @@ -976,8 +972,8 @@ func TestContainerInUseCtrNotInState(t *testing.T) { } func TestContainerInUseCtrNotInNamespace(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -993,10 +989,10 @@ func TestContainerInUseCtrNotInNamespace(t *testing.T) { } func TestContainerInUseOneContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.config.ID @@ -1015,12 +1011,12 @@ func TestContainerInUseOneContainer(t *testing.T) { } func TestContainerInUseTwoContainers(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) - testCtr3, err := getTestCtrN("3", manager) + testCtr3, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.config.ID @@ -1042,10 +1038,10 @@ func TestContainerInUseTwoContainers(t *testing.T) { } func TestContainerInUseOneContainerMultipleDependencies(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.config.ID @@ -1065,10 +1061,10 @@ func TestContainerInUseOneContainerMultipleDependencies(t *testing.T) { } func TestContainerInUseGenericDependency(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.Dependencies = []string{testCtr1.config.ID} @@ -1087,12 +1083,12 @@ func TestContainerInUseGenericDependency(t *testing.T) { } func TestContainerInUseMultipleGenericDependencies(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) - testCtr3, err := getTestCtrN("3", manager) + testCtr3, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr3.config.Dependencies = []string{testCtr1.config.ID, testCtr2.config.ID} @@ -1119,10 +1115,10 @@ func TestContainerInUseMultipleGenericDependencies(t *testing.T) { } func TestContainerInUseGenericAndNamespaceDependencies(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.Dependencies = []string{testCtr1.config.ID} @@ -1142,10 +1138,10 @@ func TestContainerInUseGenericAndNamespaceDependencies(t *testing.T) { } func TestCannotRemoveContainerWithDependency(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.config.ID @@ -1166,10 +1162,10 @@ func TestCannotRemoveContainerWithDependency(t *testing.T) { } func TestCannotRemoveContainerWithGenericDependency(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.Dependencies = []string{testCtr1.config.ID} @@ -1190,10 +1186,10 @@ func TestCannotRemoveContainerWithGenericDependency(t *testing.T) { } func TestCanRemoveContainerAfterDependencyRemoved(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.ID() @@ -1217,10 +1213,10 @@ func TestCanRemoveContainerAfterDependencyRemoved(t *testing.T) { } func TestCanRemoveContainerAfterDependencyRemovedDuplicate(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.ID() @@ -1245,11 +1241,11 @@ func TestCanRemoveContainerAfterDependencyRemovedDuplicate(t *testing.T) { } func TestCannotUsePodAsDependency(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) - testPod, err := getTestPod2(manager) + testPod, err := getTestPod2(lockPath) assert.NoError(t, err) testCtr.config.UserNsCtr = testPod.ID() @@ -1267,8 +1263,8 @@ func TestCannotUsePodAsDependency(t *testing.T) { } func TestCannotUseBadIDAsDependency(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.UserNsCtr = strings.Repeat("5", 32) @@ -1283,8 +1279,8 @@ func TestCannotUseBadIDAsDependency(t *testing.T) { } func TestCannotUseBadIDAsGenericDependency(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Dependencies = []string{strings.Repeat("5", 32)} @@ -1299,22 +1295,22 @@ func TestCannotUseBadIDAsGenericDependency(t *testing.T) { } func TestGetPodDoesNotExist(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.Pod("doesnotexist") assert.Error(t, err) }) } func TestGetPodEmptyID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.Pod("") assert.Error(t, err) }) } func TestGetPodOnePod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1328,11 +1324,11 @@ func TestGetPodOnePod(t *testing.T) { } func TestGetOnePodFromTwo(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod1(lockPath) assert.NoError(t, err) - testPod2, err := getTestPod2(manager) + testPod2, err := getTestPod2(lockPath) assert.NoError(t, err) err = state.AddPod(testPod1) @@ -1349,11 +1345,11 @@ func TestGetOnePodFromTwo(t *testing.T) { } func TestGetNotExistPodWithPods(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod1(lockPath) assert.NoError(t, err) - testPod2, err := getTestPod2(manager) + testPod2, err := getTestPod2(lockPath) assert.NoError(t, err) err = state.AddPod(testPod1) @@ -1368,8 +1364,8 @@ func TestGetNotExistPodWithPods(t *testing.T) { } func TestGetPodByCtrID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -1381,8 +1377,8 @@ func TestGetPodByCtrID(t *testing.T) { } func TestGetPodInNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1400,8 +1396,8 @@ func TestGetPodInNamespaceSucceeds(t *testing.T) { } func TestGetPodPodNotInNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1417,22 +1413,22 @@ func TestGetPodPodNotInNamespaceFails(t *testing.T) { } func TestLookupPodEmptyID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.LookupPod("") assert.Error(t, err) }) } func TestLookupNotExistPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.LookupPod("doesnotexist") assert.Error(t, err) }) } func TestLookupPodFullID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1446,8 +1442,8 @@ func TestLookupPodFullID(t *testing.T) { } func TestLookupPodUniquePartialID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1461,11 +1457,11 @@ func TestLookupPodUniquePartialID(t *testing.T) { } func TestLookupPodNonUniquePartialID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod(strings.Repeat("1", 32), "test1", manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod(strings.Repeat("1", 32), "test1", lockPath) assert.NoError(t, err) - testPod2, err := getTestPod(strings.Repeat("1", 31)+"2", "test2", manager) + testPod2, err := getTestPod(strings.Repeat("1", 31)+"2", "test2", lockPath) assert.NoError(t, err) err = state.AddPod(testPod1) @@ -1480,8 +1476,8 @@ func TestLookupPodNonUniquePartialID(t *testing.T) { } func TestLookupPodByName(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1495,8 +1491,8 @@ func TestLookupPodByName(t *testing.T) { } func TestLookupPodByCtrID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -1508,8 +1504,8 @@ func TestLookupPodByCtrID(t *testing.T) { } func TestLookupPodByCtrName(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -1521,8 +1517,8 @@ func TestLookupPodByCtrName(t *testing.T) { } func TestLookupPodInSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1540,8 +1536,8 @@ func TestLookupPodInSameNamespaceSucceeds(t *testing.T) { } func TestLookupPodInDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1557,13 +1553,13 @@ func TestLookupPodInDifferentNamespaceFails(t *testing.T) { } func TestLookupPodOneInDifferentNamespaceFindsRightPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod(strings.Repeat("1", 32), "test1", manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod(strings.Repeat("1", 32), "test1", lockPath) assert.NoError(t, err) testPod1.config.Namespace = "test1" - testPod2, err := getTestPod(strings.Repeat("1", 31)+"2", "test2", manager) + testPod2, err := getTestPod(strings.Repeat("1", 31)+"2", "test2", lockPath) assert.NoError(t, err) testPod2.config.Namespace = "test2" @@ -1584,14 +1580,14 @@ func TestLookupPodOneInDifferentNamespaceFindsRightPod(t *testing.T) { } func TestHasPodEmptyIDErrors(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.HasPod("") assert.Error(t, err) }) } func TestHasPodNoSuchPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { exist, err := state.HasPod("notexist") assert.NoError(t, err) assert.False(t, exist) @@ -1599,8 +1595,8 @@ func TestHasPodNoSuchPod(t *testing.T) { } func TestHasPodWrongIDFalse(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1613,8 +1609,8 @@ func TestHasPodWrongIDFalse(t *testing.T) { } func TestHasPodRightIDTrue(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1627,8 +1623,8 @@ func TestHasPodRightIDTrue(t *testing.T) { } func TestHasPodCtrIDFalse(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -1641,8 +1637,8 @@ func TestHasPodCtrIDFalse(t *testing.T) { } func TestHasPodSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1659,8 +1655,8 @@ func TestHasPodSameNamespaceSucceeds(t *testing.T) { } func TestHasPodDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1677,15 +1673,15 @@ func TestHasPodDifferentNamespaceFails(t *testing.T) { } func TestAddPodInvalidPodErrors(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { err := state.AddPod(&Pod{config: &PodConfig{}}) assert.Error(t, err) }) } func TestAddPodValidPodSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1700,11 +1696,11 @@ func TestAddPodValidPodSucceeds(t *testing.T) { } func TestAddPodDuplicateIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod1(lockPath) assert.NoError(t, err) - testPod2, err := getTestPod(testPod1.ID(), "testpod2", manager) + testPod2, err := getTestPod(testPod1.ID(), "testpod2", lockPath) assert.NoError(t, err) err = state.AddPod(testPod1) @@ -1720,11 +1716,11 @@ func TestAddPodDuplicateIDFails(t *testing.T) { } func TestAddPodDuplicateNameFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod1(lockPath) assert.NoError(t, err) - testPod2, err := getTestPod(strings.Repeat("2", 32), testPod1.Name(), manager) + testPod2, err := getTestPod(strings.Repeat("2", 32), testPod1.Name(), lockPath) assert.NoError(t, err) err = state.AddPod(testPod1) @@ -1740,11 +1736,11 @@ func TestAddPodDuplicateNameFails(t *testing.T) { } func TestAddPodNonDuplicateSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod1(lockPath) assert.NoError(t, err) - testPod2, err := getTestPod2(manager) + testPod2, err := getTestPod2(lockPath) assert.NoError(t, err) err = state.AddPod(testPod1) @@ -1760,11 +1756,11 @@ func TestAddPodNonDuplicateSucceeds(t *testing.T) { } func TestAddPodCtrIDConflictFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) - testPod, err := getTestPod(testCtr.ID(), "testpod1", manager) + testPod, err := getTestPod(testCtr.ID(), "testpod1", lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -1780,11 +1776,11 @@ func TestAddPodCtrIDConflictFails(t *testing.T) { } func TestAddPodCtrNameConflictFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) - testPod, err := getTestPod(strings.Repeat("3", 32), testCtr.Name(), manager) + testPod, err := getTestPod(strings.Repeat("3", 32), testCtr.Name(), lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -1800,8 +1796,8 @@ func TestAddPodCtrNameConflictFails(t *testing.T) { } func TestAddPodSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1820,8 +1816,8 @@ func TestAddPodSameNamespaceSucceeds(t *testing.T) { } func TestAddPodDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1840,15 +1836,15 @@ func TestAddPodDifferentNamespaceFails(t *testing.T) { } func TestRemovePodInvalidPodErrors(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { err := state.RemovePod(&Pod{config: &PodConfig{}}) assert.Error(t, err) }) } func TestRemovePodNotInStateFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.RemovePod(testPod) @@ -1858,8 +1854,8 @@ func TestRemovePodNotInStateFails(t *testing.T) { } func TestRemovePodSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1875,11 +1871,11 @@ func TestRemovePodSucceeds(t *testing.T) { } func TestRemovePodFromPods(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod1(lockPath) assert.NoError(t, err) - testPod2, err := getTestPod2(manager) + testPod2, err := getTestPod2(lockPath) assert.NoError(t, err) err = state.AddPod(testPod1) @@ -1900,11 +1896,11 @@ func TestRemovePodFromPods(t *testing.T) { } func TestRemovePodNotEmptyFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -1924,11 +1920,11 @@ func TestRemovePodNotEmptyFails(t *testing.T) { } func TestRemovePodAfterEmptySucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -1951,8 +1947,8 @@ func TestRemovePodAfterEmptySucceeds(t *testing.T) { } func TestRemovePodNotInNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1974,7 +1970,7 @@ func TestRemovePodNotInNamespaceFails(t *testing.T) { } func TestAllPodsEmptyOnEmptyState(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { allPods, err := state.AllPods() assert.NoError(t, err) assert.Equal(t, 0, len(allPods)) @@ -1982,8 +1978,8 @@ func TestAllPodsEmptyOnEmptyState(t *testing.T) { } func TestAllPodsFindsPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1998,14 +1994,14 @@ func TestAllPodsFindsPod(t *testing.T) { } func TestAllPodsMultiplePods(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod1(lockPath) assert.NoError(t, err) - testPod2, err := getTestPod2(manager) + testPod2, err := getTestPod2(lockPath) assert.NoError(t, err) - testPod3, err := getTestPodN("3", manager) + testPod3, err := getTestPodN("3", lockPath) assert.NoError(t, err) allPods1, err := state.AllPods() @@ -2036,8 +2032,8 @@ func TestAllPodsMultiplePods(t *testing.T) { } func TestAllPodsPodInDifferentNamespaces(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -2054,13 +2050,13 @@ func TestAllPodsPodInDifferentNamespaces(t *testing.T) { } func TestAllPodsOnePodInDifferentNamespace(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod1(lockPath) assert.NoError(t, err) testPod1.config.Namespace = "test1" - testPod2, err := getTestPod2(manager) + testPod2, err := getTestPod2(lockPath) assert.NoError(t, err) testPod2.config.Namespace = "test2" @@ -2082,15 +2078,15 @@ func TestAllPodsOnePodInDifferentNamespace(t *testing.T) { } func TestPodHasContainerNoSuchPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.PodHasContainer(&Pod{config: &PodConfig{}}, strings.Repeat("0", 32)) assert.Error(t, err) }) } func TestPodHasContainerEmptyCtrID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2102,8 +2098,8 @@ func TestPodHasContainerEmptyCtrID(t *testing.T) { } func TestPodHasContainerNoSuchCtr(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2116,11 +2112,11 @@ func TestPodHasContainerNoSuchCtr(t *testing.T) { } func TestPodHasContainerCtrNotInPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2136,11 +2132,11 @@ func TestPodHasContainerCtrNotInPod(t *testing.T) { } func TestPodHasContainerSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -2158,8 +2154,8 @@ func TestPodHasContainerSucceeds(t *testing.T) { } func TestPodHasContainerPodNotInNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -2175,15 +2171,15 @@ func TestPodHasContainerPodNotInNamespaceFails(t *testing.T) { } func TestPodContainersByIDInvalidPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.PodContainersByID(&Pod{config: &PodConfig{}}) assert.Error(t, err) }) } func TestPodContainerdByIDPodNotInState(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) _, err = state.PodContainersByID(testPod) @@ -2193,8 +2189,8 @@ func TestPodContainerdByIDPodNotInState(t *testing.T) { } func TestPodContainersByIDEmptyPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2207,11 +2203,11 @@ func TestPodContainersByIDEmptyPod(t *testing.T) { } func TestPodContainersByIDOneContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -2230,19 +2226,19 @@ func TestPodContainersByIDOneContainer(t *testing.T) { } func TestPodContainersByIDMultipleContainers(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() - testCtr3, err := getTestCtrN("4", manager) + testCtr3, err := getTestCtrN("4", lockPath) assert.NoError(t, err) testCtr3.config.Pod = testPod.ID() @@ -2277,8 +2273,8 @@ func TestPodContainersByIDMultipleContainers(t *testing.T) { } func TestPodContainerByIDPodNotInNamespace(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -2294,15 +2290,15 @@ func TestPodContainerByIDPodNotInNamespace(t *testing.T) { } func TestPodContainersInvalidPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.PodContainers(&Pod{config: &PodConfig{}}) assert.Error(t, err) }) } func TestPodContainersPodNotInState(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) _, err = state.PodContainers(testPod) @@ -2312,8 +2308,8 @@ func TestPodContainersPodNotInState(t *testing.T) { } func TestPodContainersEmptyPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2326,11 +2322,11 @@ func TestPodContainersEmptyPod(t *testing.T) { } func TestPodContainersOneContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -2350,19 +2346,19 @@ func TestPodContainersOneContainer(t *testing.T) { } func TestPodContainersMultipleContainers(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() - testCtr3, err := getTestCtrN("4", manager) + testCtr3, err := getTestCtrN("4", lockPath) assert.NoError(t, err) testCtr3.config.Pod = testPod.ID() @@ -2397,8 +2393,8 @@ func TestPodContainersMultipleContainers(t *testing.T) { } func TestPodContainersPodNotInNamespace(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -2414,15 +2410,15 @@ func TestPodContainersPodNotInNamespace(t *testing.T) { } func TestRemovePodContainersInvalidPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { err := state.RemovePodContainers(&Pod{config: &PodConfig{}}) assert.Error(t, err) }) } func TestRemovePodContainersPodNotInState(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.RemovePodContainers(testPod) @@ -2432,8 +2428,8 @@ func TestRemovePodContainersPodNotInState(t *testing.T) { } func TestRemovePodContainersNoContainers(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2449,11 +2445,11 @@ func TestRemovePodContainersNoContainers(t *testing.T) { } func TestRemovePodContainersOneContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -2473,15 +2469,15 @@ func TestRemovePodContainersOneContainer(t *testing.T) { } func TestRemovePodContainersPreservesCtrOutsidePod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2507,15 +2503,15 @@ func TestRemovePodContainersPreservesCtrOutsidePod(t *testing.T) { } func TestRemovePodContainersTwoContainers(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() @@ -2538,15 +2534,15 @@ func TestRemovePodContainersTwoContainers(t *testing.T) { } func TestRemovePodContainerDependencyInPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() testCtr2.config.IPCNsCtr = testCtr1.ID() @@ -2570,8 +2566,8 @@ func TestRemovePodContainerDependencyInPod(t *testing.T) { } func TestRemoveContainersNotInNamespace(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -2587,8 +2583,8 @@ func TestRemoveContainersNotInNamespace(t *testing.T) { } func TestAddContainerToPodInvalidPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainerToPod(&Pod{config: &PodConfig{}}, testCtr) @@ -2597,8 +2593,8 @@ func TestAddContainerToPodInvalidPod(t *testing.T) { } func TestAddContainerToPodInvalidCtr(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2614,11 +2610,11 @@ func TestAddContainerToPodInvalidCtr(t *testing.T) { } func TestAddContainerToPodPodNotInState(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -2629,11 +2625,11 @@ func TestAddContainerToPodPodNotInState(t *testing.T) { } func TestAddContainerToPodSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -2657,15 +2653,15 @@ func TestAddContainerToPodSucceeds(t *testing.T) { } func TestAddContainerToPodTwoContainers(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() @@ -2689,15 +2685,15 @@ func TestAddContainerToPodTwoContainers(t *testing.T) { } func TestAddContainerToPodWithAddContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2722,14 +2718,14 @@ func TestAddContainerToPodWithAddContainer(t *testing.T) { } func TestAddContainerToPodCtrIDConflict(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) - testCtr2, err := getTestContainer(testCtr1.ID(), "testCtr3", manager) + testCtr2, err := getTestContainer(testCtr1.ID(), "testCtr3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() @@ -2753,14 +2749,14 @@ func TestAddContainerToPodCtrIDConflict(t *testing.T) { } func TestAddContainerToPodCtrNameConflict(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) - testCtr2, err := getTestContainer(strings.Repeat("4", 32), testCtr1.Name(), manager) + testCtr2, err := getTestContainer(strings.Repeat("4", 32), testCtr1.Name(), lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() @@ -2784,11 +2780,11 @@ func TestAddContainerToPodCtrNameConflict(t *testing.T) { } func TestAddContainerToPodPodIDConflict(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestContainer(testPod.ID(), "testCtr", manager) + testCtr, err := getTestContainer(testPod.ID(), "testCtr", lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -2809,11 +2805,11 @@ func TestAddContainerToPodPodIDConflict(t *testing.T) { } func TestAddContainerToPodPodNameConflict(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestContainer(strings.Repeat("2", 32), testPod.Name(), manager) + testCtr, err := getTestContainer(strings.Repeat("2", 32), testPod.Name(), lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -2834,15 +2830,15 @@ func TestAddContainerToPodPodNameConflict(t *testing.T) { } func TestAddContainerToPodAddsDependencies(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() testCtr2.config.IPCNsCtr = testCtr1.ID() @@ -2864,11 +2860,11 @@ func TestAddContainerToPodAddsDependencies(t *testing.T) { } func TestAddContainerToPodPodDependencyFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() testCtr.config.IPCNsCtr = testPod.ID() @@ -2886,11 +2882,11 @@ func TestAddContainerToPodPodDependencyFails(t *testing.T) { } func TestAddContainerToPodBadDependencyFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() testCtr.config.IPCNsCtr = strings.Repeat("8", 32) @@ -2908,14 +2904,14 @@ func TestAddContainerToPodBadDependencyFails(t *testing.T) { } func TestAddContainerToPodDependencyOutsidePodFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() testCtr2.config.IPCNsCtr = testCtr1.ID() @@ -2944,17 +2940,17 @@ func TestAddContainerToPodDependencyOutsidePodFails(t *testing.T) { } func TestAddContainerToPodDependencyInSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() testCtr1.config.Namespace = "test1" - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() testCtr2.config.IPCNsCtr = testCtr1.ID() @@ -2977,17 +2973,17 @@ func TestAddContainerToPodDependencyInSameNamespaceSucceeds(t *testing.T) { } func TestAddContainerToPodDependencyInSeparateNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() testCtr1.config.Namespace = "test1" - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() testCtr2.config.IPCNsCtr = testCtr1.ID() @@ -3017,12 +3013,12 @@ func TestAddContainerToPodDependencyInSeparateNamespaceFails(t *testing.T) { } func TestAddContainerToPodSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" testCtr.config.Pod = testPod.ID() @@ -3041,12 +3037,12 @@ func TestAddContainerToPodSameNamespaceSucceeds(t *testing.T) { } func TestAddContainerToPodDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test2" testCtr.config.Pod = testPod.ID() @@ -3064,11 +3060,11 @@ func TestAddContainerToPodDifferentNamespaceFails(t *testing.T) { } func TestAddContainerToPodNamespaceOnCtrFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" testCtr.config.Pod = testPod.ID() @@ -3086,12 +3082,12 @@ func TestAddContainerToPodNamespaceOnCtrFails(t *testing.T) { } func TestAddContainerToPodNamespaceOnPodFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -3108,11 +3104,11 @@ func TestAddContainerToPodNamespaceOnPodFails(t *testing.T) { } func TestAddCtrToPodSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) - testPod, err := getTestPod2(manager) + testPod, err := getTestPod2(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -3135,11 +3131,11 @@ func TestAddCtrToPodSameNamespaceSucceeds(t *testing.T) { } func TestAddCtrToPodDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) - testPod, err := getTestPod2(manager) + testPod, err := getTestPod2(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -3163,8 +3159,8 @@ func TestAddCtrToPodDifferentNamespaceFails(t *testing.T) { } func TestRemoveContainerFromPodBadPodFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.RemoveContainerFromPod(&Pod{config: &PodConfig{}}, testCtr) @@ -3173,11 +3169,11 @@ func TestRemoveContainerFromPodBadPodFails(t *testing.T) { } func TestRemoveContainerFromPodPodNotInStateFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -3189,11 +3185,11 @@ func TestRemoveContainerFromPodPodNotInStateFails(t *testing.T) { } func TestRemoveContainerFromPodCtrNotInStateFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -3208,11 +3204,11 @@ func TestRemoveContainerFromPodCtrNotInStateFails(t *testing.T) { } func TestRemoveContainerFromPodCtrNotInPodFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -3233,11 +3229,11 @@ func TestRemoveContainerFromPodCtrNotInPodFails(t *testing.T) { } func TestRemoveContainerFromPodSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -3261,15 +3257,15 @@ func TestRemoveContainerFromPodSucceeds(t *testing.T) { } func TestRemoveContainerFromPodWithDependencyFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() testCtr2.config.IPCNsCtr = testCtr1.ID() @@ -3297,15 +3293,15 @@ func TestRemoveContainerFromPodWithDependencyFails(t *testing.T) { } func TestRemoveContainerFromPodWithDependencySucceedsAfterDepRemoved(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() testCtr2.config.IPCNsCtr = testCtr1.ID() @@ -3336,13 +3332,13 @@ func TestRemoveContainerFromPodWithDependencySucceedsAfterDepRemoved(t *testing. } func TestRemoveContainerFromPodSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -3370,13 +3366,13 @@ func TestRemoveContainerFromPodSameNamespaceSucceeds(t *testing.T) { } func TestRemoveContainerFromPodDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -3406,15 +3402,15 @@ func TestRemoveContainerFromPodDifferentNamespaceFails(t *testing.T) { } func TestUpdatePodInvalidPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { err := state.UpdatePod(&Pod{config: &PodConfig{}}) assert.Error(t, err) }) } func TestUpdatePodPodNotInStateFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.UpdatePod(testPod) @@ -3423,8 +3419,8 @@ func TestUpdatePodPodNotInStateFails(t *testing.T) { } func TestUpdatePodNotInNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -3440,15 +3436,15 @@ func TestUpdatePodNotInNamespaceFails(t *testing.T) { } func TestSavePodInvalidPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { err := state.SavePod(&Pod{config: &PodConfig{}}) assert.Error(t, err) }) } func TestSavePodPodNotInStateFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.SavePod(testPod) @@ -3457,8 +3453,8 @@ func TestSavePodPodNotInStateFails(t *testing.T) { } func TestSavePodNotInNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -3474,8 +3470,8 @@ func TestSavePodNotInNamespaceFails(t *testing.T) { } func TestSaveAndUpdatePod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -3499,8 +3495,8 @@ func TestSaveAndUpdatePod(t *testing.T) { } func TestSaveAndUpdatePodSameNamespace(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" diff --git a/libpod/volume.go b/libpod/volume.go index 026a3bf49..b732e8aa7 100644 --- a/libpod/volume.go +++ b/libpod/volume.go @@ -1,6 +1,6 @@ package libpod -import "github.com/containers/libpod/libpod/lock" +import "github.com/containers/storage" // Volume is the type used to create named volumes // TODO: all volumes should be created using this and the Volume API @@ -9,17 +9,13 @@ type Volume struct { valid bool runtime *Runtime - lock lock.Locker + lock storage.Locker } // VolumeConfig holds the volume's config information //easyjson:json type VolumeConfig struct { - // Name of the volume - Name string `json:"name"` - // ID of this volume's lock - LockID uint32 `json:"lockID"` - + Name string `json:"name"` Labels map[string]string `json:"labels"` MountPoint string `json:"mountPoint"` Driver string `json:"driver"` |