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:
@ -101,6 +101,11 @@ func imageBuildOptionsToQuery(options types.ImageBuildOptions) (url.Values, erro
|
||||
}
|
||||
query.Set("buildargs", string(buildArgsJSON))
|
||||
|
||||
labelsJSON, err := json.Marshal(options.Labels)
|
||||
if err != nil {
|
||||
return query, err
|
||||
}
|
||||
query.Set("labels", string(labelsJSON))
|
||||
return query, nil
|
||||
}
|
||||
|
||||
|
||||
@ -142,6 +142,7 @@ type ImageBuildOptions struct {
|
||||
BuildArgs map[string]string
|
||||
AuthConfigs map[string]AuthConfig
|
||||
Context io.Reader
|
||||
Labels map[string]string
|
||||
}
|
||||
|
||||
// ImageBuildResponse holds information
|
||||
|
||||
@ -103,6 +103,13 @@ type GraphDriverData struct {
|
||||
Data map[string]string
|
||||
}
|
||||
|
||||
// RootFS returns Image's RootFS description including the layer IDs.
|
||||
type RootFS struct {
|
||||
Type string
|
||||
Layers []string `json:",omitempty"`
|
||||
BaseLayer string `json:",omitempty"`
|
||||
}
|
||||
|
||||
// ImageInspect contains response of Remote API:
|
||||
// GET "/images/{name:.*}/json"
|
||||
type ImageInspect struct {
|
||||
@ -122,6 +129,7 @@ type ImageInspect struct {
|
||||
Size int64
|
||||
VirtualSize int64
|
||||
GraphDriver GraphDriverData
|
||||
RootFS RootFS
|
||||
}
|
||||
|
||||
// Port stores open ports info of container
|
||||
@ -372,6 +380,7 @@ type Volume struct {
|
||||
Driver string // Driver is the Driver name used to create the volume
|
||||
Mountpoint string // Mountpoint is the location on disk of the volume
|
||||
Status map[string]interface{} `json:",omitempty"` // Status provides low-level status information about the volume
|
||||
Labels map[string]string // Labels is metadata specific to the volume
|
||||
}
|
||||
|
||||
// VolumesListResponse contains the response for the remote API:
|
||||
@ -387,6 +396,7 @@ type VolumeCreateRequest struct {
|
||||
Name string // Name is the requested name of the volume
|
||||
Driver string // Driver is the name of the driver that should be used to create the volume
|
||||
DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume.
|
||||
Labels map[string]string // Labels holds metadata specific to the volume being created.
|
||||
}
|
||||
|
||||
// NetworkResource is the body of the "get network" http response message
|
||||
@ -400,6 +410,7 @@ type NetworkResource struct {
|
||||
Internal bool
|
||||
Containers map[string]EndpointResource
|
||||
Options map[string]string
|
||||
Labels map[string]string
|
||||
}
|
||||
|
||||
// EndpointResource contains network resources allocated and used for a container in a network
|
||||
@ -420,6 +431,7 @@ type NetworkCreate struct {
|
||||
IPAM network.IPAM
|
||||
Internal bool
|
||||
Options map[string]string
|
||||
Labels map[string]string
|
||||
}
|
||||
|
||||
// NetworkCreateResponse is the response message sent by the server for network create call
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
# Changelog
|
||||
|
||||
## 0.7.0-dev.9 (2016-03-18)
|
||||
- Support labels on networks
|
||||
|
||||
## 0.7.0-dev.8 (2016-03-16)
|
||||
- Windows driver to respect user set MAC address.
|
||||
- Fix possible nil pointer reference in ServeDNS() with concurrent go routines.
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
FROM golang:1.4-cross
|
||||
FROM golang:1.5.3
|
||||
RUN apt-get update && apt-get -y install iptables
|
||||
|
||||
RUN cd /go/src && mkdir -p golang.org/x && \
|
||||
cd golang.org/x && git clone https://github.com/golang/tools && \
|
||||
cd tools && git checkout release-branch.go1.5
|
||||
|
||||
RUN go get github.com/tools/godep \
|
||||
github.com/golang/lint/golint \
|
||||
golang.org/x/tools/cmd/vet \
|
||||
|
||||
@ -63,6 +63,7 @@ type NetworkInfo interface {
|
||||
Scope() string
|
||||
IPv6Enabled() bool
|
||||
Internal() bool
|
||||
Labels() map[string]string
|
||||
}
|
||||
|
||||
// EndpointWalker is a client provided function which will be used to walk the Endpoints.
|
||||
@ -150,6 +151,7 @@ type network struct {
|
||||
networkType string
|
||||
id string
|
||||
scope string
|
||||
labels map[string]string
|
||||
ipamType string
|
||||
ipamOptions map[string]string
|
||||
addrSpace string
|
||||
@ -309,6 +311,14 @@ func (n *network) CopyTo(o datastore.KVObject) error {
|
||||
dstN.internal = n.internal
|
||||
dstN.inDelete = n.inDelete
|
||||
|
||||
// copy labels
|
||||
if dstN.labels == nil {
|
||||
dstN.labels = make(map[string]string, len(n.labels))
|
||||
}
|
||||
for k, v := range n.labels {
|
||||
dstN.labels[k] = v
|
||||
}
|
||||
|
||||
for _, v4conf := range n.ipamV4Config {
|
||||
dstV4Conf := &IpamConf{}
|
||||
v4conf.CopyTo(dstV4Conf)
|
||||
@ -359,6 +369,7 @@ func (n *network) MarshalJSON() ([]byte, error) {
|
||||
netMap["id"] = n.id
|
||||
netMap["networkType"] = n.networkType
|
||||
netMap["scope"] = n.scope
|
||||
netMap["labels"] = n.labels
|
||||
netMap["ipamType"] = n.ipamType
|
||||
netMap["addrSpace"] = n.addrSpace
|
||||
netMap["enableIPv6"] = n.enableIPv6
|
||||
@ -411,6 +422,15 @@ func (n *network) UnmarshalJSON(b []byte) (err error) {
|
||||
n.networkType = netMap["networkType"].(string)
|
||||
n.enableIPv6 = netMap["enableIPv6"].(bool)
|
||||
|
||||
// if we weren't unmarshaling to netMap we could simply set n.labels
|
||||
// unfortunately, we can't because map[string]interface{} != map[string]string
|
||||
if labels, ok := netMap["labels"].(map[string]interface{}); ok {
|
||||
n.labels = make(map[string]string, len(labels))
|
||||
for label, value := range labels {
|
||||
n.labels[label] = value.(string)
|
||||
}
|
||||
}
|
||||
|
||||
if v, ok := netMap["generic"]; ok {
|
||||
n.generic = v.(map[string]interface{})
|
||||
// Restore opts in their map[string]string form
|
||||
@ -539,7 +559,7 @@ func NetworkOptionIpam(ipamDriver string, addrSpace string, ipV4 []*IpamConf, ip
|
||||
}
|
||||
}
|
||||
|
||||
// NetworkOptionDriverOpts function returns an option setter for any parameter described by a map
|
||||
// NetworkOptionDriverOpts function returns an option setter for any driver parameter described by a map
|
||||
func NetworkOptionDriverOpts(opts map[string]string) NetworkOption {
|
||||
return func(n *network) {
|
||||
if n.generic == nil {
|
||||
@ -553,6 +573,13 @@ func NetworkOptionDriverOpts(opts map[string]string) NetworkOption {
|
||||
}
|
||||
}
|
||||
|
||||
// NetworkOptionLabels function returns an option setter for labels specific to a network
|
||||
func NetworkOptionLabels(labels map[string]string) NetworkOption {
|
||||
return func(n *network) {
|
||||
n.labels = labels
|
||||
}
|
||||
}
|
||||
|
||||
// NetworkOptionDeferIPv6Alloc instructs the network to defer the IPV6 address allocation until after the endpoint has been created
|
||||
// It is being provided to support the specific docker daemon flags where user can deterministically assign an IPv6 address
|
||||
// to a container as combination of fixed-cidr-v6 + mac-address
|
||||
@ -1285,3 +1312,15 @@ func (n *network) IPv6Enabled() bool {
|
||||
|
||||
return n.enableIPv6
|
||||
}
|
||||
|
||||
func (n *network) Labels() map[string]string {
|
||||
n.Lock()
|
||||
defer n.Unlock()
|
||||
|
||||
var lbls = make(map[string]string, len(n.labels))
|
||||
for k, v := range n.labels {
|
||||
lbls[k] = v
|
||||
}
|
||||
|
||||
return lbls
|
||||
}
|
||||
|
||||
@ -313,8 +313,8 @@ func configureInterface(iface netlink.Link, i *nwIface) error {
|
||||
}{
|
||||
{setInterfaceName, fmt.Sprintf("error renaming interface %q to %q", ifaceName, i.DstName())},
|
||||
{setInterfaceMAC, fmt.Sprintf("error setting interface %q MAC to %q", ifaceName, i.MacAddress())},
|
||||
{setInterfaceIP, fmt.Sprintf("error setting interface %q IP to %q", ifaceName, i.Address())},
|
||||
{setInterfaceIPv6, fmt.Sprintf("error setting interface %q IPv6 to %q", ifaceName, i.AddressIPv6())},
|
||||
{setInterfaceIP, fmt.Sprintf("error setting interface %q IP to %v", ifaceName, i.Address())},
|
||||
{setInterfaceIPv6, fmt.Sprintf("error setting interface %q IPv6 to %v", ifaceName, i.AddressIPv6())},
|
||||
{setInterfaceMaster, fmt.Sprintf("error setting interface %q master to %q", ifaceName, i.DstMaster())},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user