github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/libpod/define/container_inspect.go (about)

     1  package define
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/containers/image/v5/manifest"
     7  	"github.com/containers/libpod/libpod/driver"
     8  	"github.com/cri-o/ocicni/pkg/ocicni"
     9  )
    10  
    11  // InspectContainerConfig holds further data about how a container was initially
    12  // configured.
    13  type InspectContainerConfig struct {
    14  	// Container hostname
    15  	Hostname string `json:"Hostname"`
    16  	// Container domain name - unused at present
    17  	DomainName string `json:"Domainname"`
    18  	// User the container was launched with
    19  	User string `json:"User"`
    20  	// Unused, at present
    21  	AttachStdin bool `json:"AttachStdin"`
    22  	// Unused, at present
    23  	AttachStdout bool `json:"AttachStdout"`
    24  	// Unused, at present
    25  	AttachStderr bool `json:"AttachStderr"`
    26  	// Whether the container creates a TTY
    27  	Tty bool `json:"Tty"`
    28  	// Whether the container leaves STDIN open
    29  	OpenStdin bool `json:"OpenStdin"`
    30  	// Whether STDIN is only left open once.
    31  	// Presently not supported by Podman, unused.
    32  	StdinOnce bool `json:"StdinOnce"`
    33  	// Container environment variables
    34  	Env []string `json:"Env"`
    35  	// Container command
    36  	Cmd []string `json:"Cmd"`
    37  	// Container image
    38  	Image string `json:"Image"`
    39  	// Unused, at present. I've never seen this field populated.
    40  	Volumes map[string]struct{} `json:"Volumes"`
    41  	// Container working directory
    42  	WorkingDir string `json:"WorkingDir"`
    43  	// Container entrypoint
    44  	Entrypoint string `json:"Entrypoint"`
    45  	// On-build arguments - presently unused. More of Buildah's domain.
    46  	OnBuild *string `json:"OnBuild"`
    47  	// Container labels
    48  	Labels map[string]string `json:"Labels"`
    49  	// Container annotations
    50  	Annotations map[string]string `json:"Annotations"`
    51  	// Container stop signal
    52  	StopSignal uint `json:"StopSignal"`
    53  	// Configured healthcheck for the container
    54  	Healthcheck *manifest.Schema2HealthConfig `json:"Healthcheck,omitempty"`
    55  	// CreateCommand is the full command plus arguments of the process the
    56  	// container has been created with.
    57  	CreateCommand []string `json:"CreateCommand,omitempty"`
    58  }
    59  
    60  // InspectRestartPolicy holds information about the container's restart policy.
    61  type InspectRestartPolicy struct {
    62  	// Name contains the container's restart policy.
    63  	// Allowable values are "no" or "" (take no action),
    64  	// "on-failure" (restart on non-zero exit code, with an optional max
    65  	// retry count), and "always" (always restart on container stop, unless
    66  	// explicitly requested by API).
    67  	// Note that this is NOT actually a name of any sort - the poor naming
    68  	// is for Docker compatibility.
    69  	Name string `json:"Name"`
    70  	// MaximumRetryCount is the maximum number of retries allowed if the
    71  	// "on-failure" restart policy is in use. Not used if "on-failure" is
    72  	// not set.
    73  	MaximumRetryCount uint `json:"MaximumRetryCount"`
    74  }
    75  
    76  // InspectLogConfig holds information about a container's configured log driver
    77  // and is presently unused. It is retained for Docker compatibility.
    78  type InspectLogConfig struct {
    79  	Type   string            `json:"Type"`
    80  	Config map[string]string `json:"Config"` //idk type, TODO
    81  }
    82  
    83  // InspectBlkioWeightDevice holds information about the relative weight
    84  // of an individual device node. Weights are used in the I/O scheduler to give
    85  // relative priority to some accesses.
    86  type InspectBlkioWeightDevice struct {
    87  	// Path is the path to the device this applies to.
    88  	Path string `json:"Path"`
    89  	// Weight is the relative weight the scheduler will use when scheduling
    90  	// I/O.
    91  	Weight uint16 `json:"Weight"`
    92  }
    93  
    94  // InspectBlkioThrottleDevice holds information about a speed cap for a device
    95  // node. This cap applies to a specific operation (read, write, etc) on the given
    96  // node.
    97  type InspectBlkioThrottleDevice struct {
    98  	// Path is the path to the device this applies to.
    99  	Path string `json:"Path"`
   100  	// Rate is the maximum rate. It is in either bytes per second or iops
   101  	// per second, determined by where it is used - documentation will
   102  	// indicate which is appropriate.
   103  	Rate uint64 `json:"Rate"`
   104  }
   105  
   106  // InspectUlimit is a ulimit that will be applied to the container.
   107  type InspectUlimit struct {
   108  	// Name is the name (type) of the ulimit.
   109  	Name string `json:"Name"`
   110  	// Soft is the soft limit that will be applied.
   111  	Soft uint64 `json:"Soft"`
   112  	// Hard is the hard limit that will be applied.
   113  	Hard uint64 `json:"Hard"`
   114  }
   115  
   116  // InspectDevice is a single device that will be mounted into the container.
   117  type InspectDevice struct {
   118  	// PathOnHost is the path of the device on the host.
   119  	PathOnHost string `json:"PathOnHost"`
   120  	// PathInContainer is the path of the device within the container.
   121  	PathInContainer string `json:"PathInContainer"`
   122  	// CgroupPermissions is the permissions of the mounted device.
   123  	// Presently not populated.
   124  	// TODO.
   125  	CgroupPermissions string `json:"CgroupPermissions"`
   126  }
   127  
   128  // InspectHostPort provides information on a port on the host that a container's
   129  // port is bound to.
   130  type InspectHostPort struct {
   131  	// IP on the host we are bound to. "" if not specified (binding to all
   132  	// IPs).
   133  	HostIP string `json:"HostIp"`
   134  	// Port on the host we are bound to. No special formatting - just an
   135  	// integer stuffed into a string.
   136  	HostPort string `json:"HostPort"`
   137  }
   138  
   139  // InspectMount provides a record of a single mount in a container. It contains
   140  // fields for both named and normal volumes. Only user-specified volumes will be
   141  // included, and tmpfs volumes are not included even if the user specified them.
   142  type InspectMount struct {
   143  	// Whether the mount is a volume or bind mount. Allowed values are
   144  	// "volume" and "bind".
   145  	Type string `json:"Type"`
   146  	// The name of the volume. Empty for bind mounts.
   147  	Name string `json:"Name,omptempty"`
   148  	// The source directory for the volume.
   149  	Source string `json:"Source"`
   150  	// The destination directory for the volume. Specified as a path within
   151  	// the container, as it would be passed into the OCI runtime.
   152  	Destination string `json:"Destination"`
   153  	// The driver used for the named volume. Empty for bind mounts.
   154  	Driver string `json:"Driver"`
   155  	// Contains SELinux :z/:Z mount options. Unclear what, if anything, else
   156  	// goes in here.
   157  	Mode string `json:"Mode"`
   158  	// All remaining mount options. Additional data, not present in the
   159  	// original output.
   160  	Options []string `json:"Options"`
   161  	// Whether the volume is read-write
   162  	RW bool `json:"RW"`
   163  	// Mount propagation for the mount. Can be empty if not specified, but
   164  	// is always printed - no omitempty.
   165  	Propagation string `json:"Propagation"`
   166  }
   167  
   168  // InspectContainerState provides a detailed record of a container's current
   169  // state. It is returned as part of InspectContainerData.
   170  // As with InspectContainerData, many portions of this struct are matched to
   171  // Docker, but here we see more fields that are unused (nonsensical in the
   172  // context of Libpod).
   173  type InspectContainerState struct {
   174  	OciVersion  string             `json:"OciVersion"`
   175  	Status      string             `json:"Status"`
   176  	Running     bool               `json:"Running"`
   177  	Paused      bool               `json:"Paused"`
   178  	Restarting  bool               `json:"Restarting"` // TODO
   179  	OOMKilled   bool               `json:"OOMKilled"`
   180  	Dead        bool               `json:"Dead"`
   181  	Pid         int                `json:"Pid"`
   182  	ConmonPid   int                `json:"ConmonPid,omitempty"`
   183  	ExitCode    int32              `json:"ExitCode"`
   184  	Error       string             `json:"Error"` // TODO
   185  	StartedAt   time.Time          `json:"StartedAt"`
   186  	FinishedAt  time.Time          `json:"FinishedAt"`
   187  	Healthcheck HealthCheckResults `json:"Healthcheck,omitempty"`
   188  }
   189  
   190  // HealthCheckResults describes the results/logs from a healthcheck
   191  type HealthCheckResults struct {
   192  	// Status healthy or unhealthy
   193  	Status string `json:"Status"`
   194  	// FailingStreak is the number of consecutive failed healthchecks
   195  	FailingStreak int `json:"FailingStreak"`
   196  	// Log describes healthcheck attempts and results
   197  	Log []HealthCheckLog `json:"Log"`
   198  }
   199  
   200  // HealthCheckLog describes the results of a single healthcheck
   201  type HealthCheckLog struct {
   202  	// Start time as string
   203  	Start string `json:"Start"`
   204  	// End time as a string
   205  	End string `json:"End"`
   206  	// Exitcode is 0 or 1
   207  	ExitCode int `json:"ExitCode"`
   208  	// Output is the stdout/stderr from the healthcheck command
   209  	Output string `json:"Output"`
   210  }
   211  
   212  // InspectContainerHostConfig holds information used when the container was
   213  // created.
   214  // It's very much a Docker-specific struct, retained (mostly) as-is for
   215  // compatibility. We fill individual fields as best as we can, inferring as much
   216  // as possible from the spec and container config.
   217  // Some things cannot be inferred. These will be populated by spec annotations
   218  // (if available).
   219  // Field names are fixed for compatibility and cannot be changed.
   220  // As such, silence lint warnings about them.
   221  //nolint
   222  type InspectContainerHostConfig struct {
   223  	// Binds contains an array of user-added mounts.
   224  	// Both volume mounts and named volumes are included.
   225  	// Tmpfs mounts are NOT included.
   226  	// In 'docker inspect' this is separated into 'Binds' and 'Mounts' based
   227  	// on how a mount was added. We do not make this distinction and do not
   228  	// include a Mounts field in inspect.
   229  	// Format: <src>:<destination>[:<comma-separated options>]
   230  	Binds []string `json:"Binds"`
   231  	// ContainerIDFile is a file created during container creation to hold
   232  	// the ID of the created container.
   233  	// This is not handled within libpod and is stored in an annotation.
   234  	ContainerIDFile string `json:"ContainerIDFile"`
   235  	// LogConfig contains information on the container's logging backend
   236  	LogConfig *InspectLogConfig `json:"LogConfig"`
   237  	// NetworkMode is the configuration of the container's network
   238  	// namespace.
   239  	// Populated as follows:
   240  	// default - A network namespace is being created and configured via CNI
   241  	// none - A network namespace is being created, not configured via CNI
   242  	// host - No network namespace created
   243  	// container:<id> - Using another container's network namespace
   244  	// ns:<path> - A path to a network namespace has been specified
   245  	NetworkMode string `json:"NetworkMode"`
   246  	// PortBindings contains the container's port bindings.
   247  	// It is formatted as map[string][]InspectHostPort.
   248  	// The string key here is formatted as <integer port number>/<protocol>
   249  	// and represents the container port. A single container port may be
   250  	// bound to multiple host ports (on different IPs).
   251  	PortBindings map[string][]InspectHostPort `json:"PortBindings"`
   252  	// RestartPolicy contains the container's restart policy.
   253  	RestartPolicy *InspectRestartPolicy `json:"RestartPolicy"`
   254  	// AutoRemove is whether the container will be automatically removed on
   255  	// exiting.
   256  	// It is not handled directly within libpod and is stored in an
   257  	// annotation.
   258  	AutoRemove bool `json:"AutoRemove"`
   259  	// VolumeDriver is presently unused and is retained for Docker
   260  	// compatibility.
   261  	VolumeDriver string `json:"VolumeDriver"`
   262  	// VolumesFrom is a list of containers which this container uses volumes
   263  	// from. This is not handled directly within libpod and is stored in an
   264  	// annotation.
   265  	// It is formatted as an array of container names and IDs.
   266  	VolumesFrom []string `json:"VolumesFrom"`
   267  	// CapAdd is a list of capabilities added to the container.
   268  	// It is not directly stored by Libpod, and instead computed from the
   269  	// capabilities listed in the container's spec, compared against a set
   270  	// of default capabilities.
   271  	CapAdd []string `json:"CapAdd"`
   272  	// CapDrop is a list of capabilities removed from the container.
   273  	// It is not directly stored by libpod, and instead computed from the
   274  	// capabilities listed in the container's spec, compared against a set
   275  	// of default capabilities.
   276  	CapDrop []string `json:"CapDrop"`
   277  	// Dns is a list of DNS nameservers that will be added to the
   278  	// container's resolv.conf
   279  	Dns []string `json:"Dns"`
   280  	// DnsOptions is a list of DNS options that will be set in the
   281  	// container's resolv.conf
   282  	DnsOptions []string `json:"DnsOptions"`
   283  	// DnsSearch is a list of DNS search domains that will be set in the
   284  	// container's resolv.conf
   285  	DnsSearch []string `json:"DnsSearch"`
   286  	// ExtraHosts contains hosts that will be aded to the container's
   287  	// /etc/hosts.
   288  	ExtraHosts []string `json:"ExtraHosts"`
   289  	// GroupAdd contains groups that the user inside the container will be
   290  	// added to.
   291  	GroupAdd []string `json:"GroupAdd"`
   292  	// IpcMode represents the configuration of the container's IPC
   293  	// namespace.
   294  	// Populated as follows:
   295  	// "" (empty string) - Default, an IPC namespace will be created
   296  	// host - No IPC namespace created
   297  	// container:<id> - Using another container's IPC namespace
   298  	// ns:<path> - A path to an IPC namespace has been specified
   299  	IpcMode string `json:"IpcMode"`
   300  	// Cgroup contains the container's cgroup. It is presently not
   301  	// populated.
   302  	// TODO.
   303  	Cgroup string `json:"Cgroup"`
   304  	// Cgroups contains the container's CGroup mode.
   305  	// Allowed values are "default" (container is creating CGroups) and
   306  	// "disabled" (container is not creating CGroups).
   307  	// This is Libpod-specific and not included in `docker inspect`.
   308  	Cgroups string `json:"Cgroups"`
   309  	// Links is unused, and provided purely for Docker compatibility.
   310  	Links []string `json:"Links"`
   311  	// OOMScoreAdj is an adjustment that will be made to the container's OOM
   312  	// score.
   313  	OomScoreAdj int `json:"OomScoreAdj"`
   314  	// PidMode represents the configuration of the container's PID
   315  	// namespace.
   316  	// Populated as follows:
   317  	// "" (empty string) - Default, a PID namespace will be created
   318  	// host - No PID namespace created
   319  	// container:<id> - Using another container's PID namespace
   320  	// ns:<path> - A path to a PID namespace has been specified
   321  	PidMode string `json:"PidMode"`
   322  	// Privileged indicates whether the container is running with elevated
   323  	// privileges.
   324  	// This has a very specific meaning in the Docker sense, so it's very
   325  	// difficult to decode from the spec and config, and so is stored as an
   326  	// annotation.
   327  	Privileged bool `json:"Privileged"`
   328  	// PublishAllPorts indicates whether image ports are being published.
   329  	// This is not directly stored in libpod and is saved as an annotation.
   330  	PublishAllPorts bool `json:"PublishAllPorts"`
   331  	// ReadonlyRootfs is whether the container will be mounted read-only.
   332  	ReadonlyRootfs bool `json:"ReadonlyRootfs"`
   333  	// SecurityOpt is a list of security-related options that are set in the
   334  	// container.
   335  	SecurityOpt []string `json:"SecurityOpt"`
   336  	// Tmpfs is a list of tmpfs filesystems that will be mounted into the
   337  	// container.
   338  	// It is a map of destination path to options for the mount.
   339  	Tmpfs map[string]string `json:"Tmpfs"`
   340  	// UTSMode represents the configuration of the container's UID
   341  	// namespace.
   342  	// Populated as follows:
   343  	// "" (empty string) - Default, a UTS namespace will be created
   344  	// host - no UTS namespace created
   345  	// container:<id> - Using another container's UTS namespace
   346  	// ns:<path> - A path to a UTS namespace has been specified
   347  	UTSMode string `json:"UTSMode"`
   348  	// UsernsMode represents the configuration of the container's user
   349  	// namespace.
   350  	// When running rootless, a user namespace is created outside of libpod
   351  	// to allow some privileged operations. This will not be reflected here.
   352  	// Populated as follows:
   353  	// "" (empty string) - No user namespace will be created
   354  	// private - The container will be run in a user namespace
   355  	// container:<id> - Using another container's user namespace
   356  	// ns:<path> - A path to a user namespace has been specified
   357  	// TODO Rootless has an additional 'keep-id' option, presently not
   358  	// reflected here.
   359  	UsernsMode string `json:"UsernsMode"`
   360  	// ShmSize is the size of the container's SHM device.
   361  	ShmSize int64 `json:"ShmSize"`
   362  	// Runtime is provided purely for Docker compatibility.
   363  	// It is set unconditionally to "oci" as Podman does not presently
   364  	// support non-OCI runtimes.
   365  	Runtime string `json:"Runtime"`
   366  	// ConsoleSize is an array of 2 integers showing the size of the
   367  	// container's console.
   368  	// It is only set if the container is creating a terminal.
   369  	// TODO.
   370  	ConsoleSize []uint `json:"ConsoleSize"`
   371  	// Isolation is presently unused and provided solely for Docker
   372  	// compatibility.
   373  	Isolation string `json:"Isolation"`
   374  	// CpuShares indicates the CPU resources allocated to the container.
   375  	// It is a relative weight in the scheduler for assigning CPU time
   376  	// versus other CGroups.
   377  	CpuShares uint64 `json:"CpuShares"`
   378  	// Memory indicates the memory resources allocated to the container.
   379  	// This is the limit (in bytes) of RAM the container may use.
   380  	Memory int64 `json:"Memory"`
   381  	// NanoCpus indicates number of CPUs allocated to the container.
   382  	// It is an integer where one full CPU is indicated by 1000000000 (one
   383  	// billion).
   384  	// Thus, 2.5 CPUs (fractional portions of CPUs are allowed) would be
   385  	// 2500000000 (2.5 billion).
   386  	// In 'docker inspect' this is set exclusively of two further options in
   387  	// the output (CpuPeriod and CpuQuota) which are both used to implement
   388  	// this functionality.
   389  	// We can't distinguish here, so if CpuQuota is set to the default of
   390  	// 100000, we will set both CpuQuota, CpuPeriod, and NanoCpus. If
   391  	// CpuQuota is not the default, we will not set NanoCpus.
   392  	NanoCpus int64 `json:"NanoCpus"`
   393  	// CgroupParent is the CGroup parent of the container.
   394  	// Only set if not default.
   395  	CgroupParent string `json:"CgroupParent"`
   396  	// BlkioWeight indicates the I/O resources allocated to the container.
   397  	// It is a relative weight in the scheduler for assigning I/O time
   398  	// versus other CGroups.
   399  	BlkioWeight uint16 `json:"BlkioWeight"`
   400  	// BlkioWeightDevice is an array of I/O resource priorities for
   401  	// individual device nodes.
   402  	// Unfortunately, the spec only stores the device's Major/Minor numbers
   403  	// and not the path, which is used here.
   404  	// Fortunately, the kernel provides an interface for retrieving the path
   405  	// of a given node by major:minor at /sys/dev/. However, the exact path
   406  	// in use may not be what was used in the original CLI invocation -
   407  	// though it is guaranteed that the device node will be the same, and
   408  	// using the given path will be functionally identical.
   409  	BlkioWeightDevice []InspectBlkioWeightDevice `json:"BlkioWeightDevice"`
   410  	// BlkioDeviceReadBps is an array of I/O throttle parameters for
   411  	// individual device nodes.
   412  	// This specifically sets read rate cap in bytes per second for device
   413  	// nodes.
   414  	// As with BlkioWeightDevice, we pull the path from /sys/dev, and we
   415  	// don't guarantee the path will be identical to the original (though
   416  	// the node will be).
   417  	BlkioDeviceReadBps []InspectBlkioThrottleDevice `json:"BlkioDeviceReadBps"`
   418  	// BlkioDeviceWriteBps is an array of I/O throttle parameters for
   419  	// individual device nodes.
   420  	// this specifically sets write rate cap in bytes per second for device
   421  	// nodes.
   422  	// as with BlkioWeightDevice, we pull the path from /sys/dev, and we
   423  	// don't guarantee the path will be identical to the original (though
   424  	// the node will be).
   425  	BlkioDeviceWriteBps []InspectBlkioThrottleDevice `json:"BlkioDeviceWriteBps"`
   426  	// BlkioDeviceReadIOps is an array of I/O throttle parameters for
   427  	// individual device nodes.
   428  	// This specifically sets the read rate cap in iops per second for
   429  	// device nodes.
   430  	// As with BlkioWeightDevice, we pull the path from /sys/dev, and we
   431  	// don't guarantee the path will be identical to the original (though
   432  	// the node will be).
   433  	BlkioDeviceReadIOps []InspectBlkioThrottleDevice `json:"BlkioDeviceReadIOps"`
   434  	// BlkioDeviceWriteIOps is an array of I/O throttle parameters for
   435  	// individual device nodes.
   436  	// This specifically sets the write rate cap in iops per second for
   437  	// device nodes.
   438  	// As with BlkioWeightDevice, we pull the path from /sys/dev, and we
   439  	// don't guarantee the path will be identical to the original (though
   440  	// the node will be).
   441  	BlkioDeviceWriteIOps []InspectBlkioThrottleDevice `json:"BlkioDeviceWriteIOps"`
   442  	// CpuPeriod is the length of a CPU period in microseconds.
   443  	// It relates directly to CpuQuota.
   444  	CpuPeriod uint64 `json:"CpuPeriod"`
   445  	// CpuPeriod is the amount of time (in microseconds) that a container
   446  	// can use the CPU in every CpuPeriod.
   447  	CpuQuota int64 `json:"CpuQuota"`
   448  	// CpuRealtimePeriod is the length of time (in microseconds) of the CPU
   449  	// realtime period. If set to 0, no time will be allocated to realtime
   450  	// tasks.
   451  	CpuRealtimePeriod uint64 `json:"CpuRealtimePeriod"`
   452  	// CpuRealtimeRuntime is the length of time (in microseconds) allocated
   453  	// for realtime tasks within every CpuRealtimePeriod.
   454  	CpuRealtimeRuntime int64 `json:"CpuRealtimeRuntime"`
   455  	// CpusetCpus is the is the set of CPUs that the container will execute
   456  	// on. Formatted as `0-3` or `0,2`. Default (if unset) is all CPUs.
   457  	CpusetCpus string `json:"CpusetCpus"`
   458  	// CpusetMems is the set of memory nodes the container will use.
   459  	// Formatted as `0-3` or `0,2`. Default (if unset) is all memory nodes.
   460  	CpusetMems string `json:"CpusetMems"`
   461  	// Devices is a list of device nodes that will be added to the
   462  	// container.
   463  	// These are stored in the OCI spec only as type, major, minor while we
   464  	// display the host path. We convert this with /sys/dev, but we cannot
   465  	// guarantee that the host path will be identical - only that the actual
   466  	// device will be.
   467  	Devices []InspectDevice `json:"Devices"`
   468  	// DiskQuota is the maximum amount of disk space the container may use
   469  	// (in bytes).
   470  	// Presently not populated.
   471  	// TODO.
   472  	DiskQuota uint64 `json:"DiskQuota"`
   473  	// KernelMemory is the maximum amount of memory the kernel will devote
   474  	// to the container.
   475  	KernelMemory int64 `json:"KernelMemory"`
   476  	// MemoryReservation is the reservation (soft limit) of memory available
   477  	// to the container. Soft limits are warnings only and can be exceeded.
   478  	MemoryReservation int64 `json:"MemoryReservation"`
   479  	// MemorySwap is the total limit for all memory available to the
   480  	// container, including swap. 0 indicates that there is no limit to the
   481  	// amount of memory available.
   482  	MemorySwap int64 `json:"MemorySwap"`
   483  	// MemorySwappiness is the willingness of the kernel to page container
   484  	// memory to swap. It is an integer from 0 to 100, with low numbers
   485  	// being more likely to be put into swap.
   486  	// -1, the default, will not set swappiness and use the system defaults.
   487  	MemorySwappiness int64 `json:"MemorySwappiness"`
   488  	// OomKillDisable indicates whether the kernel OOM killer is disabled
   489  	// for the container.
   490  	OomKillDisable bool `json:"OomKillDisable"`
   491  	// Init indicates whether the container has an init mounted into it.
   492  	Init bool `json:"Init,omitempty"`
   493  	// PidsLimit is the maximum number of PIDs what may be created within
   494  	// the container. 0, the default, indicates no limit.
   495  	PidsLimit int64 `json:"PidsLimit"`
   496  	// Ulimits is a set of ulimits that will be set within the container.
   497  	Ulimits []InspectUlimit `json:"Ulimits"`
   498  	// CpuCount is Windows-only and not presently implemented.
   499  	CpuCount uint64 `json:"CpuCount"`
   500  	// CpuPercent is Windows-only and not presently implemented.
   501  	CpuPercent uint64 `json:"CpuPercent"`
   502  	// IOMaximumIOps is Windows-only and not presently implemented.
   503  	IOMaximumIOps uint64 `json:"IOMaximumIOps"`
   504  	// IOMaximumBandwidth is Windows-only and not presently implemented.
   505  	IOMaximumBandwidth uint64 `json:"IOMaximumBandwidth"`
   506  }
   507  
   508  // InspectBasicNetworkConfig holds basic configuration information (e.g. IP
   509  // addresses, MAC address, subnet masks, etc) that are common for all networks
   510  // (both additional and main).
   511  type InspectBasicNetworkConfig struct {
   512  	// EndpointID is unused, maintained exclusively for compatibility.
   513  	EndpointID string `json:"EndpointID"`
   514  	// Gateway is the IP address of the gateway this network will use.
   515  	Gateway string `json:"Gateway"`
   516  	// IPAddress is the IP address for this network.
   517  	IPAddress string `json:"IPAddress"`
   518  	// IPPrefixLen is the length of the subnet mask of this network.
   519  	IPPrefixLen int `json:"IPPrefixLen"`
   520  	// SecondaryIPAddresses is a list of extra IP Addresses that the
   521  	// container has been assigned in this network.
   522  	SecondaryIPAddresses []string `json:"SecondaryIPAddresses,omitempty"`
   523  	// IPv6Gateway is the IPv6 gateway this network will use.
   524  	IPv6Gateway string `json:"IPv6Gateway"`
   525  	// GlobalIPv6Address is the global-scope IPv6 Address for this network.
   526  	GlobalIPv6Address string `json:"GlobalIPv6Address"`
   527  	// GlobalIPv6PrefixLen is the length of the subnet mask of this network.
   528  	GlobalIPv6PrefixLen int `json:"GlobalIPv6PrefixLen"`
   529  	// SecondaryIPv6Addresses is a list of extra IPv6 Addresses that the
   530  	// container has been assigned in this networ.
   531  	SecondaryIPv6Addresses []string `json:"SecondaryIPv6Addresses,omitempty"`
   532  	// MacAddress is the MAC address for the interface in this network.
   533  	MacAddress string `json:"MacAddress"`
   534  	// AdditionalMacAddresses is a set of additional MAC Addresses beyond
   535  	// the first. CNI may configure more than one interface for a single
   536  	// network, which can cause this.
   537  	AdditionalMacAddresses []string `json:"AdditionalMACAddresses,omitempty"`
   538  }
   539  
   540  // InspectAdditionalNetwork holds information about non-default CNI networks the
   541  // container has been connected to.
   542  // As with InspectNetworkSettings, many fields are unused and maintained only
   543  // for compatibility with Docker.
   544  type InspectAdditionalNetwork struct {
   545  	InspectBasicNetworkConfig
   546  
   547  	// Name of the network we're connecting to.
   548  	NetworkID string `json:"NetworkID,omitempty"`
   549  	// DriverOpts is presently unused and maintained exclusively for
   550  	// compatibility.
   551  	DriverOpts map[string]string `json:"DriverOpts"`
   552  	// IPAMConfig is presently unused and maintained exclusively for
   553  	// compatibility.
   554  	IPAMConfig map[string]string `json:"IPAMConfig"`
   555  	// Links is presently unused and maintained exclusively for
   556  	// compatibility.
   557  	Links []string `json:"Links"`
   558  }
   559  
   560  // InspectNetworkSettings holds information about the network settings of the
   561  // container.
   562  // Many fields are maintained only for compatibility with `docker inspect` and
   563  // are unused within Libpod.
   564  type InspectNetworkSettings struct {
   565  	InspectBasicNetworkConfig
   566  
   567  	Bridge                 string               `json:"Bridge"`
   568  	SandboxID              string               `json:"SandboxID"`
   569  	HairpinMode            bool                 `json:"HairpinMode"`
   570  	LinkLocalIPv6Address   string               `json:"LinkLocalIPv6Address"`
   571  	LinkLocalIPv6PrefixLen int                  `json:"LinkLocalIPv6PrefixLen"`
   572  	Ports                  []ocicni.PortMapping `json:"Ports"`
   573  	SandboxKey             string               `json:"SandboxKey"`
   574  	// Networks contains information on non-default CNI networks this
   575  	// container has joined.
   576  	// It is a map of network name to network information.
   577  	Networks map[string]*InspectAdditionalNetwork `json:"Networks,omitempty"`
   578  }
   579  
   580  // InspectContainerData provides a detailed record of a container's configuration
   581  // and state as viewed by Libpod.
   582  // Large portions of this structure are defined such that the output is
   583  // compatible with `docker inspect` JSON, but additional fields have been added
   584  // as required to share information not in the original output.
   585  type InspectContainerData struct {
   586  	ID              string                      `json:"Id"`
   587  	Created         time.Time                   `json:"Created"`
   588  	Path            string                      `json:"Path"`
   589  	Args            []string                    `json:"Args"`
   590  	State           *InspectContainerState      `json:"State"`
   591  	Image           string                      `json:"Image"`
   592  	ImageName       string                      `json:"ImageName"`
   593  	Rootfs          string                      `json:"Rootfs"`
   594  	Pod             string                      `json:"Pod"`
   595  	ResolvConfPath  string                      `json:"ResolvConfPath"`
   596  	HostnamePath    string                      `json:"HostnamePath"`
   597  	HostsPath       string                      `json:"HostsPath"`
   598  	StaticDir       string                      `json:"StaticDir"`
   599  	OCIConfigPath   string                      `json:"OCIConfigPath,omitempty"`
   600  	OCIRuntime      string                      `json:"OCIRuntime,omitempty"`
   601  	LogPath         string                      `json:"LogPath"`
   602  	LogTag          string                      `json:"LogTag"`
   603  	ConmonPidFile   string                      `json:"ConmonPidFile"`
   604  	Name            string                      `json:"Name"`
   605  	RestartCount    int32                       `json:"RestartCount"`
   606  	Driver          string                      `json:"Driver"`
   607  	MountLabel      string                      `json:"MountLabel"`
   608  	ProcessLabel    string                      `json:"ProcessLabel"`
   609  	AppArmorProfile string                      `json:"AppArmorProfile"`
   610  	EffectiveCaps   []string                    `json:"EffectiveCaps"`
   611  	BoundingCaps    []string                    `json:"BoundingCaps"`
   612  	ExecIDs         []string                    `json:"ExecIDs"`
   613  	GraphDriver     *driver.Data                `json:"GraphDriver"`
   614  	SizeRw          *int64                      `json:"SizeRw,omitempty"`
   615  	SizeRootFs      int64                       `json:"SizeRootFs,omitempty"`
   616  	Mounts          []InspectMount              `json:"Mounts"`
   617  	Dependencies    []string                    `json:"Dependencies"`
   618  	NetworkSettings *InspectNetworkSettings     `json:"NetworkSettings"` //TODO
   619  	ExitCommand     []string                    `json:"ExitCommand"`
   620  	Namespace       string                      `json:"Namespace"`
   621  	IsInfra         bool                        `json:"IsInfra"`
   622  	Config          *InspectContainerConfig     `json:"Config"`
   623  	HostConfig      *InspectContainerHostConfig `json:"HostConfig"`
   624  }