diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-11-19 16:54:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-19 16:54:29 +0100 |
commit | e239bfa15ba7e5718b511e0f949679ba5b7037c4 (patch) | |
tree | 0f95118000b8ef5bd4ddb293c9a20b0c4d5f2afa /libpod/container.go | |
parent | 70f91fb96d11adb86be955e8a39f9c9096d48638 (diff) | |
parent | a3e0b7d117251944375fd32449f6b26d65edf367 (diff) | |
download | podman-e239bfa15ba7e5718b511e0f949679ba5b7037c4.tar.gz podman-e239bfa15ba7e5718b511e0f949679ba5b7037c4.tar.bz2 podman-e239bfa15ba7e5718b511e0f949679ba5b7037c4.zip |
Merge pull request #8391 from baude/networkconnectdisconnect
add network connect|disconnect compat endpoints
Diffstat (limited to 'libpod/container.go')
-rw-r--r-- | libpod/container.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libpod/container.go b/libpod/container.go index 9009a4ec8..4b9e6a5ba 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -206,6 +206,10 @@ type ContainerState struct { // and not delegated to the OCI runtime. ExtensionStageHooks map[string][]spec.Hook `json:"extensionStageHooks,omitempty"` + // NetInterfaceDescriptions describe the relationship between a CNI + // network and an interface names + NetInterfaceDescriptions ContainerNetworkDescriptions `json:"networkDescriptions,omitempty"` + // containerPlatformState holds platform-specific container state. containerPlatformState } @@ -244,6 +248,10 @@ type ContainerImageVolume struct { ReadWrite bool `json:"rw"` } +// ContainerNetworkDescriptions describes the relationship between the CNI +// network and the ethN where N is an integer +type ContainerNetworkDescriptions map[string]int + // Config accessors // Unlocked @@ -1102,3 +1110,19 @@ func (c *Container) networksByNameIndex() (map[string]int, error) { } return networkNamesByIndex, nil } + +// add puts the new given CNI network name into the tracking map +// and assigns it a new integer based on the map length +func (d ContainerNetworkDescriptions) add(networkName string) { + d[networkName] = len(d) +} + +// getInterfaceByName returns a formatted interface name for a given +// network along with a bool as to whether the network existed +func (d ContainerNetworkDescriptions) getInterfaceByName(networkName string) (string, bool) { + val, exists := d[networkName] + if !exists { + return "", exists + } + return fmt.Sprintf("eth%d", val), exists +} |