/*
   Copyright The containerd Authors.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

// Code generated by tools/protoc-gen-strip. DO NOT EDIT.
// versions:
// 	protoc-gen-strip 0.0.1
// 	protoc           v3.20.1-

package api

// Strip empty fields from Hooks, reducing a fully empty
// one to nil. Strip allows comparison of two Hooks structs for semantic
// equality using go-cmp.
func (h *Hooks) Strip() *Hooks {
	if h == nil {
		return nil
	}

	empty := true

	if len(h.Prestart) == 0 {
		h.Prestart = nil
	} else {
		empty = false
	}
	if len(h.CreateRuntime) == 0 {
		h.CreateRuntime = nil
	} else {
		empty = false
	}
	if len(h.CreateContainer) == 0 {
		h.CreateContainer = nil
	} else {
		empty = false
	}
	if len(h.StartContainer) == 0 {
		h.StartContainer = nil
	} else {
		empty = false
	}
	if len(h.Poststart) == 0 {
		h.Poststart = nil
	} else {
		empty = false
	}
	if len(h.Poststop) == 0 {
		h.Poststop = nil
	} else {
		empty = false
	}

	if empty {
		return nil
	}

	return h
}

// Strip empty fields from LinuxResources, reducing a fully empty
// one to nil. Strip allows comparison of two LinuxResources structs for semantic
// equality using go-cmp.
func (r *LinuxResources) Strip() *LinuxResources {
	if r == nil {
		return nil
	}

	empty := true

	if r.Memory = r.Memory.Strip(); r.Memory != nil {
		empty = false
	}
	if r.Cpu = r.Cpu.Strip(); r.Cpu != nil {
		empty = false
	}
	if len(r.HugepageLimits) == 0 {
		r.HugepageLimits = nil
	} else {
		empty = false
	}
	if r.BlockioClass != nil {
		empty = false
	}
	if r.RdtClass != nil {
		empty = false
	}
	if len(r.Unified) == 0 {
		r.Unified = nil
	} else {
		empty = false
	}
	if len(r.Devices) == 0 {
		r.Devices = nil
	} else {
		empty = false
	}
	if r.Pids = r.Pids.Strip(); r.Pids != nil {
		empty = false
	}

	if empty {
		return nil
	}

	return r
}

// Strip empty fields from LinuxMemory, reducing a fully empty
// one to nil. Strip allows comparison of two LinuxMemory structs for semantic
// equality using go-cmp.
func (m *LinuxMemory) Strip() *LinuxMemory {
	if m == nil {
		return nil
	}

	empty := true

	if m.Limit != nil {
		empty = false
	}
	if m.Reservation != nil {
		empty = false
	}
	if m.Swap != nil {
		empty = false
	}
	if m.Kernel != nil {
		empty = false
	}
	if m.KernelTcp != nil {
		empty = false
	}
	if m.Swappiness != nil {
		empty = false
	}
	if m.DisableOomKiller != nil {
		empty = false
	}
	if m.UseHierarchy != nil {
		empty = false
	}

	if empty {
		return nil
	}

	return m
}

// Strip empty fields from LinuxCPU, reducing a fully empty
// one to nil. Strip allows comparison of two LinuxCPU structs for semantic
// equality using go-cmp.
func (c *LinuxCPU) Strip() *LinuxCPU {
	if c == nil {
		return nil
	}

	empty := true

	if c.Shares != nil {
		empty = false
	}
	if c.Quota != nil {
		empty = false
	}
	if c.Period != nil {
		empty = false
	}
	if c.RealtimeRuntime != nil {
		empty = false
	}
	if c.RealtimePeriod != nil {
		empty = false
	}
	if c.Cpus != "" {
		empty = false
	}
	if c.Mems != "" {
		empty = false
	}

	if empty {
		return nil
	}

	return c
}

// Strip empty fields from LinuxPids, reducing a fully empty
// one to nil. Strip allows comparison of two LinuxPids structs for semantic
// equality using go-cmp.
func (p *LinuxPids) Strip() *LinuxPids {
	if p == nil {
		return nil
	}

	empty := true

	if p.Limit != 0 {
		empty = false
	}

	if empty {
		return nil
	}

	return p
}

// Strip empty fields from LinuxIOPriority, reducing a fully empty
// one to nil. Strip allows comparison of two LinuxIOPriority structs for semantic
// equality using go-cmp.
func (i *LinuxIOPriority) Strip() *LinuxIOPriority {
	if i == nil {
		return nil
	}

	empty := true

	if i.Class != 0 {
		empty = false
	}
	if i.Priority != 0 {
		empty = false
	}

	if empty {
		return nil
	}

	return i
}

// Strip empty fields from LinuxScheduler, reducing a fully empty
// one to nil. Strip allows comparison of two LinuxScheduler structs for semantic
// equality using go-cmp.
func (s *LinuxScheduler) Strip() *LinuxScheduler {
	if s == nil {
		return nil
	}

	empty := true

	if s.Policy != 0 {
		empty = false
	}
	if s.Nice != 0 {
		empty = false
	}
	if s.Priority != 0 {
		empty = false
	}
	if len(s.Flags) == 0 {
		s.Flags = nil
	} else {
		empty = false
	}
	if s.Runtime != 0 {
		empty = false
	}
	if s.Deadline != 0 {
		empty = false
	}
	if s.Period != 0 {
		empty = false
	}

	if empty {
		return nil
	}

	return s
}

// Strip empty fields from ContainerAdjustment, reducing a fully empty
// one to nil. Strip allows comparison of two ContainerAdjustment structs for semantic
// equality using go-cmp.
func (a *ContainerAdjustment) Strip() *ContainerAdjustment {
	if a == nil {
		return nil
	}

	empty := true

	if len(a.Annotations) == 0 {
		a.Annotations = nil
	} else {
		empty = false
	}
	if len(a.Mounts) == 0 {
		a.Mounts = nil
	} else {
		empty = false
	}
	if len(a.Env) == 0 {
		a.Env = nil
	} else {
		empty = false
	}
	if a.Hooks = a.Hooks.Strip(); a.Hooks != nil {
		empty = false
	}
	if a.Linux = a.Linux.Strip(); a.Linux != nil {
		empty = false
	}
	if len(a.Rlimits) == 0 {
		a.Rlimits = nil
	} else {
		empty = false
	}
	if len(a.CDIDevices) == 0 {
		a.CDIDevices = nil
	} else {
		empty = false
	}
	if len(a.Args) == 0 {
		a.Args = nil
	} else {
		empty = false
	}

	if empty {
		return nil
	}

	return a
}

// Strip empty fields from LinuxContainerAdjustment, reducing a fully empty
// one to nil. Strip allows comparison of two LinuxContainerAdjustment structs for semantic
// equality using go-cmp.
func (c *LinuxContainerAdjustment) Strip() *LinuxContainerAdjustment {
	if c == nil {
		return nil
	}

	empty := true

	if len(c.Devices) == 0 {
		c.Devices = nil
	} else {
		empty = false
	}
	if c.Resources = c.Resources.Strip(); c.Resources != nil {
		empty = false
	}
	if c.CgroupsPath != "" {
		empty = false
	}
	if c.OomScoreAdj != nil {
		empty = false
	}
	if c.IoPriority = c.IoPriority.Strip(); c.IoPriority != nil {
		empty = false
	}
	if c.SeccompPolicy = c.SeccompPolicy.Strip(); c.SeccompPolicy != nil {
		empty = false
	}
	if len(c.Namespaces) == 0 {
		c.Namespaces = nil
	} else {
		empty = false
	}
	if len(c.Sysctl) == 0 {
		c.Sysctl = nil
	} else {
		empty = false
	}
	if len(c.NetDevices) == 0 {
		c.NetDevices = nil
	} else {
		empty = false
	}
	if c.Scheduler = c.Scheduler.Strip(); c.Scheduler != nil {
		empty = false
	}
	if c.Rdt = c.Rdt.Strip(); c.Rdt != nil {
		empty = false
	}
	if c.MemoryPolicy = c.MemoryPolicy.Strip(); c.MemoryPolicy != nil {
		empty = false
	}

	if empty {
		return nil
	}

	return c
}

// Strip empty fields from LinuxSeccomp, reducing a fully empty
// one to nil. Strip allows comparison of two LinuxSeccomp structs for semantic
// equality using go-cmp.
func (s *LinuxSeccomp) Strip() *LinuxSeccomp {
	if s == nil {
		return nil
	}

	empty := true

	if s.DefaultAction != "" {
		empty = false
	}
	if s.DefaultErrno != nil {
		empty = false
	}
	if len(s.Architectures) == 0 {
		s.Architectures = nil
	} else {
		empty = false
	}
	if len(s.Flags) == 0 {
		s.Flags = nil
	} else {
		empty = false
	}
	if s.ListenerPath != "" {
		empty = false
	}
	if s.ListenerMetadata != "" {
		empty = false
	}
	if len(s.Syscalls) == 0 {
		s.Syscalls = nil
	} else {
		empty = false
	}

	if empty {
		return nil
	}

	return s
}

// Strip empty fields from LinuxMemoryPolicy, reducing a fully empty
// one to nil. Strip allows comparison of two LinuxMemoryPolicy structs for semantic
// equality using go-cmp.
func (m *LinuxMemoryPolicy) Strip() *LinuxMemoryPolicy {
	if m == nil {
		return nil
	}

	empty := true

	if m.Mode != 0 {
		empty = false
	}
	if m.Nodes != "" {
		empty = false
	}
	if len(m.Flags) == 0 {
		m.Flags = nil
	} else {
		empty = false
	}

	if empty {
		return nil
	}

	return m
}

// Strip empty fields from ContainerUpdate, reducing a fully empty
// one to nil. Strip allows comparison of two ContainerUpdate structs for semantic
// equality using go-cmp.
func (u *ContainerUpdate) Strip() *ContainerUpdate {
	if u == nil {
		return nil
	}

	empty := true

	if u.ContainerId != "" {
		empty = false
	}
	if u.Linux = u.Linux.Strip(); u.Linux != nil {
		empty = false
	}
	if u.IgnoreFailure != false {
		empty = false
	}

	if empty {
		return nil
	}

	return u
}

// Strip empty fields from LinuxContainerUpdate, reducing a fully empty
// one to nil. Strip allows comparison of two LinuxContainerUpdate structs for semantic
// equality using go-cmp.
func (c *LinuxContainerUpdate) Strip() *LinuxContainerUpdate {
	if c == nil {
		return nil
	}

	empty := true

	if c.Resources = c.Resources.Strip(); c.Resources != nil {
		empty = false
	}

	if empty {
		return nil
	}

	return c
}

// Strip empty fields from LinuxRdt, reducing a fully empty
// one to nil. Strip allows comparison of two LinuxRdt structs for semantic
// equality using go-cmp.
func (r *LinuxRdt) Strip() *LinuxRdt {
	if r == nil {
		return nil
	}

	empty := true

	if r.ClosId != nil {
		empty = false
	}
	if r.Schemata != nil {
		empty = false
	}
	if r.EnableMonitoring != nil {
		empty = false
	}
	if r.Remove != false {
		empty = false
	}

	if empty {
		return nil
	}

	return r
}
