From 6af7e544636ae66ce237489ce6948123e1b3249d Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Mon, 26 Oct 2020 17:17:45 -0400 Subject: Add network aliases for containers to DB This adds the database backend for network aliases. Aliases are additional names for a container that are used with the CNI dnsname plugin - the container will be accessible by these names in addition to its name. Aliases are allowed to change over time as the container connects to and disconnects from networks. Aliases are implemented as another bucket in the database to register all aliases, plus two buckets for each container (one to hold connected CNI networks, a second to hold its aliases). The aliases are only unique per-network, to the global and per-container aliases buckets have a sub-bucket for each CNI network that has aliases, and the aliases are stored within that sub-bucket. Aliases are formatted as alias (key) to container ID (value) in both cases. Three DB functions are defined for aliases: retrieving current aliases for a given network, setting aliases for a given network, and removing all aliases for a given network. Signed-off-by: Matthew Heon --- libpod/state.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libpod/state.go') diff --git a/libpod/state.go b/libpod/state.go index 44632b02f..fca0548c4 100644 --- a/libpod/state.go +++ b/libpod/state.go @@ -98,6 +98,13 @@ type State interface { // returned. AllContainers() ([]*Container, error) + // Get network aliases for the given container in the given network. + GetNetworkAliases(ctr *Container, network string) ([]string, error) + // Set network aliases for the given container in the given network. + SetNetworkAliases(ctr *Container, network string, aliases []string) error + // Remove network aliases for the given container in the given network. + RemoveNetworkAliases(ctr *Container, network string) error + // Return a container config from the database by full ID GetContainerConfig(id string) (*ContainerConfig, error) -- cgit v1.2.3-54-g00ecf