aboutsummaryrefslogtreecommitdiff
path: root/libpod/pod_api.go
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2020-07-13 14:22:43 -0400
committerMatthew Heon <mheon@redhat.com>2020-07-14 12:03:11 -0400
commit41457b5a28532d410517b1afb1759e2724d03cab (patch)
tree9d0f6a2e28c8ffdb4366bd3482b2cf5fd255be9e /libpod/pod_api.go
parent210f1040d26334457803bc1da74667f70630a620 (diff)
downloadpodman-41457b5a28532d410517b1afb1759e2724d03cab.tar.gz
podman-41457b5a28532d410517b1afb1759e2724d03cab.tar.bz2
podman-41457b5a28532d410517b1afb1759e2724d03cab.zip
Include infra container information in `pod inspect`
We had a field for this in the inspect data, but it was never being populated. Because of this, `podman pod inspect` stopped showing port bindings (and other infra container settings). Add code to populate the infra container inspect data, and add a test to ensure we don't regress again. Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod/pod_api.go')
-rw-r--r--libpod/pod_api.go47
1 files changed, 46 insertions, 1 deletions
diff --git a/libpod/pod_api.go b/libpod/pod_api.go
index a02b171e1..cc10a3355 100644
--- a/libpod/pod_api.go
+++ b/libpod/pod_api.go
@@ -481,6 +481,51 @@ func (p *Pod) Inspect() (*define.InspectPodData, error) {
}
}
+ // Infra config contains detailed information on the pod's infra
+ // container.
+ var infraConfig *define.InspectPodInfraConfig
+ if p.config.InfraContainer != nil && p.config.InfraContainer.HasInfraContainer {
+ infraConfig = new(define.InspectPodInfraConfig)
+ infraConfig.HostNetwork = p.config.InfraContainer.HostNetwork
+ infraConfig.StaticIP = p.config.InfraContainer.StaticIP
+ infraConfig.StaticMAC = p.config.InfraContainer.StaticMAC
+ infraConfig.NoManageResolvConf = p.config.InfraContainer.UseImageResolvConf
+ infraConfig.NoManageHosts = p.config.InfraContainer.UseImageHosts
+
+ if len(p.config.InfraContainer.DNSServer) > 0 {
+ infraConfig.DNSServer = make([]string, 0, len(p.config.InfraContainer.DNSServer))
+ for _, i := range p.config.InfraContainer.DNSServer {
+ infraConfig.DNSServer = append(infraConfig.DNSServer, i)
+ }
+ }
+ if len(p.config.InfraContainer.DNSSearch) > 0 {
+ infraConfig.DNSSearch = make([]string, 0, len(p.config.InfraContainer.DNSSearch))
+ for _, i := range p.config.InfraContainer.DNSSearch {
+ infraConfig.DNSSearch = append(infraConfig.DNSSearch, i)
+ }
+ }
+ if len(p.config.InfraContainer.DNSOption) > 0 {
+ infraConfig.DNSOption = make([]string, 0, len(p.config.InfraContainer.DNSOption))
+ for _, i := range p.config.InfraContainer.DNSOption {
+ infraConfig.DNSOption = append(infraConfig.DNSOption, i)
+ }
+ }
+ if len(p.config.InfraContainer.HostAdd) > 0 {
+ infraConfig.HostAdd = make([]string, 0, len(p.config.InfraContainer.HostAdd))
+ for _, i := range p.config.InfraContainer.HostAdd {
+ infraConfig.HostAdd = append(infraConfig.HostAdd, i)
+ }
+ }
+ if len(p.config.InfraContainer.Networks) > 0 {
+ infraConfig.Networks = make([]string, 0, len(p.config.InfraContainer.Networks))
+ for _, i := range p.config.InfraContainer.Networks {
+ infraConfig.Networks = append(infraConfig.Networks, i)
+ }
+ }
+
+ infraConfig.PortBindings = makeInspectPortBindings(p.config.InfraContainer.PortBindings)
+ }
+
inspectData := define.InspectPodData{
ID: p.ID(),
Name: p.Name(),
@@ -495,7 +540,7 @@ func (p *Pod) Inspect() (*define.InspectPodData, error) {
CgroupPath: p.state.CgroupPath,
CreateInfra: false,
InfraContainerID: p.state.InfraContainerID,
- InfraConfig: nil,
+ InfraConfig: infraConfig,
SharedNamespaces: sharesNS,
NumContainers: uint(len(containers)),
Containers: ctrs,