add label support for build, networks and volumes
build: implement --label Signed-off-by: Evan Hazlett <ejhazlett@gmail.com> network: allow adding labels on create Signed-off-by: Evan Hazlett <ejhazlett@gmail.com> volume: allow adding labels on create Signed-off-by: Evan Hazlett <ejhazlett@gmail.com> add tests for build, network, volume Signed-off-by: Evan Hazlett <ejhazlett@gmail.com> vendor: libnetwork and engine-api bump Signed-off-by: Evan Hazlett <ejhazlett@gmail.com> Upstream-commit: fc214b4408d915e3510f61c7584ca01c176d1373 Component: engine
This commit is contained in:
@ -12,7 +12,7 @@ type Backend interface {
|
||||
GetNetworkByName(idName string) (libnetwork.Network, error)
|
||||
GetNetworksByID(partialID string) []libnetwork.Network
|
||||
GetAllNetworks() []libnetwork.Network
|
||||
CreateNetwork(name, driver string, ipam network.IPAM, options map[string]string, internal bool, enableIPv6 bool) (libnetwork.Network, error)
|
||||
CreateNetwork(name, driver string, ipam network.IPAM, options map[string]string, labels map[string]string, internal bool, enableIPv6 bool) (libnetwork.Network, error)
|
||||
ConnectContainerToNetwork(containerName, networkName string, endpointConfig *network.EndpointSettings) error
|
||||
DisconnectContainerFromNetwork(containerName string, network libnetwork.Network, force bool) error
|
||||
DeleteNetwork(name string) error
|
||||
|
||||
@ -91,7 +91,7 @@ func (n *networkRouter) postNetworkCreate(ctx context.Context, w http.ResponseWr
|
||||
warning = fmt.Sprintf("Network with name %s (id : %s) already exists", nw.Name(), nw.ID())
|
||||
}
|
||||
|
||||
nw, err = n.backend.CreateNetwork(create.Name, create.Driver, create.IPAM, create.Options, create.Internal, create.EnableIPv6)
|
||||
nw, err = n.backend.CreateNetwork(create.Name, create.Driver, create.IPAM, create.Options, create.Labels, create.Internal, create.EnableIPv6)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -163,16 +163,18 @@ func buildNetworkResource(nw libnetwork.Network) *types.NetworkResource {
|
||||
return r
|
||||
}
|
||||
|
||||
info := nw.Info()
|
||||
r.Name = nw.Name()
|
||||
r.ID = nw.ID()
|
||||
r.Scope = nw.Info().Scope()
|
||||
r.Scope = info.Scope()
|
||||
r.Driver = nw.Type()
|
||||
r.EnableIPv6 = nw.Info().IPv6Enabled()
|
||||
r.Internal = nw.Info().Internal()
|
||||
r.Options = nw.Info().DriverOptions()
|
||||
r.EnableIPv6 = info.IPv6Enabled()
|
||||
r.Internal = info.Internal()
|
||||
r.Options = info.DriverOptions()
|
||||
r.Containers = make(map[string]types.EndpointResource)
|
||||
buildIpamResources(r, nw)
|
||||
r.Internal = nw.Info().Internal()
|
||||
buildIpamResources(r, info)
|
||||
r.Internal = info.Internal()
|
||||
r.Labels = info.Labels()
|
||||
|
||||
epl := nw.Endpoints()
|
||||
for _, e := range epl {
|
||||
@ -191,10 +193,10 @@ func buildNetworkResource(nw libnetwork.Network) *types.NetworkResource {
|
||||
return r
|
||||
}
|
||||
|
||||
func buildIpamResources(r *types.NetworkResource, nw libnetwork.Network) {
|
||||
id, opts, ipv4conf, ipv6conf := nw.Info().IpamConfig()
|
||||
func buildIpamResources(r *types.NetworkResource, nwInfo libnetwork.NetworkInfo) {
|
||||
id, opts, ipv4conf, ipv6conf := nwInfo.IpamConfig()
|
||||
|
||||
ipv4Info, ipv6Info := nw.Info().IpamInfo()
|
||||
ipv4Info, ipv6Info := nwInfo.IpamInfo()
|
||||
|
||||
r.IPAM.Driver = id
|
||||
|
||||
|
||||
Reference in New Issue
Block a user