repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
docker/libnetwork
ipam/structures.go
UnmarshalJSON
func (p *PoolData) UnmarshalJSON(data []byte) error { var ( err error t struct { ParentKey SubnetKey Pool string Range *AddressRange `json:",omitempty"` RefCount int } ) if err = json.Unmarshal(data, &t); err != nil { return err } p.ParentKey = t.ParentKey p.Range = t.Range p.Re...
go
func (p *PoolData) UnmarshalJSON(data []byte) error { var ( err error t struct { ParentKey SubnetKey Pool string Range *AddressRange `json:",omitempty"` RefCount int } ) if err = json.Unmarshal(data, &t); err != nil { return err } p.ParentKey = t.ParentKey p.Range = t.Range p.Re...
[ "func", "(", "p", "*", "PoolData", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "(", "err", "error", "\n", "t", "struct", "{", "ParentKey", "SubnetKey", "\n", "Pool", "string", "\n", "Range", "*", "AddressRange", "`jso...
// UnmarshalJSON decodes data into the PoolData object
[ "UnmarshalJSON", "decodes", "data", "into", "the", "PoolData", "object" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipam/structures.go#L129-L154
train
docker/libnetwork
ipam/structures.go
MarshalJSON
func (aSpace *addrSpace) MarshalJSON() ([]byte, error) { aSpace.Lock() defer aSpace.Unlock() m := map[string]interface{}{ "Scope": string(aSpace.scope), } if aSpace.subnets != nil { s := map[string]*PoolData{} for k, v := range aSpace.subnets { s[k.String()] = v } m["Subnets"] = s } return json.M...
go
func (aSpace *addrSpace) MarshalJSON() ([]byte, error) { aSpace.Lock() defer aSpace.Unlock() m := map[string]interface{}{ "Scope": string(aSpace.scope), } if aSpace.subnets != nil { s := map[string]*PoolData{} for k, v := range aSpace.subnets { s[k.String()] = v } m["Subnets"] = s } return json.M...
[ "func", "(", "aSpace", "*", "addrSpace", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "aSpace", ".", "Lock", "(", ")", "\n", "defer", "aSpace", ".", "Unlock", "(", ")", "\n\n", "m", ":=", "map", "[", "string", "]",...
// MarshalJSON returns the JSON encoding of the addrSpace object
[ "MarshalJSON", "returns", "the", "JSON", "encoding", "of", "the", "addrSpace", "object" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipam/structures.go#L157-L174
train
docker/libnetwork
ipam/structures.go
UnmarshalJSON
func (aSpace *addrSpace) UnmarshalJSON(data []byte) error { aSpace.Lock() defer aSpace.Unlock() m := map[string]interface{}{} err := json.Unmarshal(data, &m) if err != nil { return err } aSpace.scope = datastore.LocalScope s := m["Scope"].(string) if s == string(datastore.GlobalScope) { aSpace.scope = da...
go
func (aSpace *addrSpace) UnmarshalJSON(data []byte) error { aSpace.Lock() defer aSpace.Unlock() m := map[string]interface{}{} err := json.Unmarshal(data, &m) if err != nil { return err } aSpace.scope = datastore.LocalScope s := m["Scope"].(string) if s == string(datastore.GlobalScope) { aSpace.scope = da...
[ "func", "(", "aSpace", "*", "addrSpace", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "aSpace", ".", "Lock", "(", ")", "\n", "defer", "aSpace", ".", "Unlock", "(", ")", "\n\n", "m", ":=", "map", "[", "string", "]", "inter...
// UnmarshalJSON decodes data into the addrSpace object
[ "UnmarshalJSON", "decodes", "data", "into", "the", "addrSpace", "object" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipam/structures.go#L177-L208
train
docker/libnetwork
ipam/structures.go
CopyTo
func (p *PoolData) CopyTo(dstP *PoolData) error { dstP.ParentKey = p.ParentKey dstP.Pool = types.GetIPNetCopy(p.Pool) if p.Range != nil { dstP.Range = &AddressRange{} dstP.Range.Sub = types.GetIPNetCopy(p.Range.Sub) dstP.Range.Start = p.Range.Start dstP.Range.End = p.Range.End } dstP.RefCount = p.RefCoun...
go
func (p *PoolData) CopyTo(dstP *PoolData) error { dstP.ParentKey = p.ParentKey dstP.Pool = types.GetIPNetCopy(p.Pool) if p.Range != nil { dstP.Range = &AddressRange{} dstP.Range.Sub = types.GetIPNetCopy(p.Range.Sub) dstP.Range.Start = p.Range.Start dstP.Range.End = p.Range.End } dstP.RefCount = p.RefCoun...
[ "func", "(", "p", "*", "PoolData", ")", "CopyTo", "(", "dstP", "*", "PoolData", ")", "error", "{", "dstP", ".", "ParentKey", "=", "p", ".", "ParentKey", "\n", "dstP", ".", "Pool", "=", "types", ".", "GetIPNetCopy", "(", "p", ".", "Pool", ")", "\n\n...
// CopyTo deep copies the pool data to the destination pooldata
[ "CopyTo", "deep", "copies", "the", "pool", "data", "to", "the", "destination", "pooldata" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipam/structures.go#L211-L224
train
docker/libnetwork
ipam/structures.go
updatePoolDBOnAdd
func (aSpace *addrSpace) updatePoolDBOnAdd(k SubnetKey, nw *net.IPNet, ipr *AddressRange, pdf bool) (func() error, error) { aSpace.Lock() defer aSpace.Unlock() // Check if already allocated if _, ok := aSpace.subnets[k]; ok { if pdf { return nil, types.InternalMaskableErrorf("predefined pool %s is already res...
go
func (aSpace *addrSpace) updatePoolDBOnAdd(k SubnetKey, nw *net.IPNet, ipr *AddressRange, pdf bool) (func() error, error) { aSpace.Lock() defer aSpace.Unlock() // Check if already allocated if _, ok := aSpace.subnets[k]; ok { if pdf { return nil, types.InternalMaskableErrorf("predefined pool %s is already res...
[ "func", "(", "aSpace", "*", "addrSpace", ")", "updatePoolDBOnAdd", "(", "k", "SubnetKey", ",", "nw", "*", "net", ".", "IPNet", ",", "ipr", "*", "AddressRange", ",", "pdf", "bool", ")", "(", "func", "(", ")", "error", ",", "error", ")", "{", "aSpace",...
// updatePoolDBOnAdd returns a closure which will add the subnet k to the address space when executed.
[ "updatePoolDBOnAdd", "returns", "a", "closure", "which", "will", "add", "the", "subnet", "k", "to", "the", "address", "space", "when", "executed", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipam/structures.go#L261-L304
train
docker/libnetwork
ipam/structures.go
contains
func (aSpace *addrSpace) contains(space string, nw *net.IPNet) bool { for k, v := range aSpace.subnets { if space == k.AddressSpace && k.ChildSubnet == "" { if nw.Contains(v.Pool.IP) || v.Pool.Contains(nw.IP) { return true } } } return false }
go
func (aSpace *addrSpace) contains(space string, nw *net.IPNet) bool { for k, v := range aSpace.subnets { if space == k.AddressSpace && k.ChildSubnet == "" { if nw.Contains(v.Pool.IP) || v.Pool.Contains(nw.IP) { return true } } } return false }
[ "func", "(", "aSpace", "*", "addrSpace", ")", "contains", "(", "space", "string", ",", "nw", "*", "net", ".", "IPNet", ")", "bool", "{", "for", "k", ",", "v", ":=", "range", "aSpace", ".", "subnets", "{", "if", "space", "==", "k", ".", "AddressSpac...
// Checks whether the passed subnet is a superset or subset of any of the subset in this config db
[ "Checks", "whether", "the", "passed", "subnet", "is", "a", "superset", "or", "subset", "of", "any", "of", "the", "subset", "in", "this", "config", "db" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipam/structures.go#L348-L357
train
docker/libnetwork
cmd/proxy/stub_proxy.go
NewStubProxy
func NewStubProxy(frontendAddr, backendAddr net.Addr) (Proxy, error) { return &StubProxy{ frontendAddr: frontendAddr, backendAddr: backendAddr, }, nil }
go
func NewStubProxy(frontendAddr, backendAddr net.Addr) (Proxy, error) { return &StubProxy{ frontendAddr: frontendAddr, backendAddr: backendAddr, }, nil }
[ "func", "NewStubProxy", "(", "frontendAddr", ",", "backendAddr", "net", ".", "Addr", ")", "(", "Proxy", ",", "error", ")", "{", "return", "&", "StubProxy", "{", "frontendAddr", ":", "frontendAddr", ",", "backendAddr", ":", "backendAddr", ",", "}", ",", "ni...
// NewStubProxy creates a new StubProxy
[ "NewStubProxy", "creates", "a", "new", "StubProxy" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/cmd/proxy/stub_proxy.go#L26-L31
train
docker/libnetwork
netutils/utils_linux.go
CheckRouteOverlaps
func CheckRouteOverlaps(toCheck *net.IPNet) error { if networkGetRoutesFct == nil { networkGetRoutesFct = ns.NlHandle().RouteList } networks, err := networkGetRoutesFct(nil, netlink.FAMILY_V4) if err != nil { return err } for _, network := range networks { if network.Dst != nil && NetworkOverlaps(toCheck, n...
go
func CheckRouteOverlaps(toCheck *net.IPNet) error { if networkGetRoutesFct == nil { networkGetRoutesFct = ns.NlHandle().RouteList } networks, err := networkGetRoutesFct(nil, netlink.FAMILY_V4) if err != nil { return err } for _, network := range networks { if network.Dst != nil && NetworkOverlaps(toCheck, n...
[ "func", "CheckRouteOverlaps", "(", "toCheck", "*", "net", ".", "IPNet", ")", "error", "{", "if", "networkGetRoutesFct", "==", "nil", "{", "networkGetRoutesFct", "=", "ns", ".", "NlHandle", "(", ")", ".", "RouteList", "\n", "}", "\n", "networks", ",", "err"...
// CheckRouteOverlaps checks whether the passed network overlaps with any existing routes
[ "CheckRouteOverlaps", "checks", "whether", "the", "passed", "network", "overlaps", "with", "any", "existing", "routes" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/netutils/utils_linux.go#L25-L39
train
docker/libnetwork
netutils/utils_linux.go
GenerateIfaceName
func GenerateIfaceName(nlh *netlink.Handle, prefix string, len int) (string, error) { linkByName := netlink.LinkByName if nlh != nil { linkByName = nlh.LinkByName } for i := 0; i < 3; i++ { name, err := GenerateRandomName(prefix, len) if err != nil { continue } _, err = linkByName(name) if err != nil...
go
func GenerateIfaceName(nlh *netlink.Handle, prefix string, len int) (string, error) { linkByName := netlink.LinkByName if nlh != nil { linkByName = nlh.LinkByName } for i := 0; i < 3; i++ { name, err := GenerateRandomName(prefix, len) if err != nil { continue } _, err = linkByName(name) if err != nil...
[ "func", "GenerateIfaceName", "(", "nlh", "*", "netlink", ".", "Handle", ",", "prefix", "string", ",", "len", "int", ")", "(", "string", ",", "error", ")", "{", "linkByName", ":=", "netlink", ".", "LinkByName", "\n", "if", "nlh", "!=", "nil", "{", "link...
// GenerateIfaceName returns an interface name using the passed in // prefix and the length of random bytes. The api ensures that the // there are is no interface which exists with that name.
[ "GenerateIfaceName", "returns", "an", "interface", "name", "using", "the", "passed", "in", "prefix", "and", "the", "length", "of", "random", "bytes", ".", "The", "api", "ensures", "that", "the", "there", "are", "is", "no", "interface", "which", "exists", "wi...
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/netutils/utils_linux.go#L44-L63
train
docker/libnetwork
osl/namespace_linux.go
GC
func GC() { gpmLock.Lock() if len(garbagePathMap) == 0 { // No need for GC if map is empty gpmLock.Unlock() return } gpmLock.Unlock() // if content exists in the garbage paths // we can trigger GC to run, providing a // channel to be notified on completion waitGC := make(chan struct{}) gpmChan <- waitGC...
go
func GC() { gpmLock.Lock() if len(garbagePathMap) == 0 { // No need for GC if map is empty gpmLock.Unlock() return } gpmLock.Unlock() // if content exists in the garbage paths // we can trigger GC to run, providing a // channel to be notified on completion waitGC := make(chan struct{}) gpmChan <- waitGC...
[ "func", "GC", "(", ")", "{", "gpmLock", ".", "Lock", "(", ")", "\n", "if", "len", "(", "garbagePathMap", ")", "==", "0", "{", "// No need for GC if map is empty", "gpmLock", ".", "Unlock", "(", ")", "\n", "return", "\n", "}", "\n", "gpmLock", ".", "Unl...
// GC triggers garbage collection of namespace path right away // and waits for it.
[ "GC", "triggers", "garbage", "collection", "of", "namespace", "path", "right", "away", "and", "waits", "for", "it", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/osl/namespace_linux.go#L138-L154
train
docker/libnetwork
osl/namespace_linux.go
GetSandboxForExternalKey
func GetSandboxForExternalKey(basePath string, key string) (Sandbox, error) { if err := createNamespaceFile(key); err != nil { return nil, err } if err := mountNetworkNamespace(basePath, key); err != nil { return nil, err } n := &networkNamespace{path: key, nextIfIndex: make(map[string]int)} sboxNs, err := ...
go
func GetSandboxForExternalKey(basePath string, key string) (Sandbox, error) { if err := createNamespaceFile(key); err != nil { return nil, err } if err := mountNetworkNamespace(basePath, key); err != nil { return nil, err } n := &networkNamespace{path: key, nextIfIndex: make(map[string]int)} sboxNs, err := ...
[ "func", "GetSandboxForExternalKey", "(", "basePath", "string", ",", "key", "string", ")", "(", "Sandbox", ",", "error", ")", "{", "if", "err", ":=", "createNamespaceFile", "(", "key", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", ...
// GetSandboxForExternalKey returns sandbox object for the supplied path
[ "GetSandboxForExternalKey", "returns", "sandbox", "object", "for", "the", "supplied", "path" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/osl/namespace_linux.go#L261-L299
train
docker/libnetwork
osl/namespace_linux.go
InitOSContext
func InitOSContext() func() { runtime.LockOSThread() if err := ns.SetNamespace(); err != nil { logrus.Error(err) } return runtime.UnlockOSThread }
go
func InitOSContext() func() { runtime.LockOSThread() if err := ns.SetNamespace(); err != nil { logrus.Error(err) } return runtime.UnlockOSThread }
[ "func", "InitOSContext", "(", ")", "func", "(", ")", "{", "runtime", ".", "LockOSThread", "(", ")", "\n", "if", "err", ":=", "ns", ".", "SetNamespace", "(", ")", ";", "err", "!=", "nil", "{", "logrus", ".", "Error", "(", "err", ")", "\n", "}", "\...
// InitOSContext initializes OS context while configuring network resources
[ "InitOSContext", "initializes", "OS", "context", "while", "configuring", "network", "resources" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/osl/namespace_linux.go#L425-L431
train
docker/libnetwork
osl/namespace_linux.go
ApplyOSTweaks
func (n *networkNamespace) ApplyOSTweaks(types []SandboxType) { for _, t := range types { switch t { case SandboxTypeLoadBalancer: kernel.ApplyOSTweaks(loadBalancerConfig) } } }
go
func (n *networkNamespace) ApplyOSTweaks(types []SandboxType) { for _, t := range types { switch t { case SandboxTypeLoadBalancer: kernel.ApplyOSTweaks(loadBalancerConfig) } } }
[ "func", "(", "n", "*", "networkNamespace", ")", "ApplyOSTweaks", "(", "types", "[", "]", "SandboxType", ")", "{", "for", "_", ",", "t", ":=", "range", "types", "{", "switch", "t", "{", "case", "SandboxTypeLoadBalancer", ":", "kernel", ".", "ApplyOSTweaks",...
// ApplyOSTweaks applies linux configs on the sandbox
[ "ApplyOSTweaks", "applies", "linux", "configs", "on", "the", "sandbox" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/osl/namespace_linux.go#L680-L687
train
docker/libnetwork
networkdb/watch.go
Watch
func (nDB *NetworkDB) Watch(tname, nid, key string) (*events.Channel, func()) { var matcher events.Matcher if tname != "" || nid != "" || key != "" { matcher = events.MatcherFunc(func(ev events.Event) bool { var evt event switch ev := ev.(type) { case CreateEvent: evt = event(ev) case UpdateEvent: ...
go
func (nDB *NetworkDB) Watch(tname, nid, key string) (*events.Channel, func()) { var matcher events.Matcher if tname != "" || nid != "" || key != "" { matcher = events.MatcherFunc(func(ev events.Event) bool { var evt event switch ev := ev.(type) { case CreateEvent: evt = event(ev) case UpdateEvent: ...
[ "func", "(", "nDB", "*", "NetworkDB", ")", "Watch", "(", "tname", ",", "nid", ",", "key", "string", ")", "(", "*", "events", ".", "Channel", ",", "func", "(", ")", ")", "{", "var", "matcher", "events", ".", "Matcher", "\n\n", "if", "tname", "!=", ...
// Watch creates a watcher with filters for a particular table or // network or key or any combination of the tuple. If any of the // filter is an empty string it acts as a wildcard for that // field. Watch returns a channel of events, where the events will be // sent.
[ "Watch", "creates", "a", "watcher", "with", "filters", "for", "a", "particular", "table", "or", "network", "or", "key", "or", "any", "combination", "of", "the", "tuple", ".", "If", "any", "of", "the", "filter", "is", "an", "empty", "string", "it", "acts"...
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/watch.go#L46-L90
train
docker/libnetwork
cmd/proxy/tcp_proxy.go
Run
func (proxy *TCPProxy) Run() { quit := make(chan bool) defer close(quit) for { client, err := proxy.listener.Accept() if err != nil { log.Printf("Stopping proxy on tcp/%v for tcp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err) return } go proxy.clientLoop(client.(*net.TCPConn), quit) } }
go
func (proxy *TCPProxy) Run() { quit := make(chan bool) defer close(quit) for { client, err := proxy.listener.Accept() if err != nil { log.Printf("Stopping proxy on tcp/%v for tcp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err) return } go proxy.clientLoop(client.(*net.TCPConn), quit) } }
[ "func", "(", "proxy", "*", "TCPProxy", ")", "Run", "(", ")", "{", "quit", ":=", "make", "(", "chan", "bool", ")", "\n", "defer", "close", "(", "quit", ")", "\n", "for", "{", "client", ",", "err", ":=", "proxy", ".", "listener", ".", "Accept", "("...
// Run starts forwarding the traffic using TCP.
[ "Run", "starts", "forwarding", "the", "traffic", "using", "TCP", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/cmd/proxy/tcp_proxy.go#L69-L80
train
docker/libnetwork
bitseq/store.go
SetValue
func (h *Handle) SetValue(value []byte) error { return json.Unmarshal(value, h) }
go
func (h *Handle) SetValue(value []byte) error { return json.Unmarshal(value, h) }
[ "func", "(", "h", "*", "Handle", ")", "SetValue", "(", "value", "[", "]", "byte", ")", "error", "{", "return", "json", ".", "Unmarshal", "(", "value", ",", "h", ")", "\n", "}" ]
// SetValue unmarshals the data from the KV store
[ "SetValue", "unmarshals", "the", "data", "from", "the", "KV", "store" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/store.go#L35-L37
train
docker/libnetwork
bitseq/store.go
New
func (h *Handle) New() datastore.KVObject { h.Lock() defer h.Unlock() return &Handle{ app: h.app, store: h.store, } }
go
func (h *Handle) New() datastore.KVObject { h.Lock() defer h.Unlock() return &Handle{ app: h.app, store: h.store, } }
[ "func", "(", "h", "*", "Handle", ")", "New", "(", ")", "datastore", ".", "KVObject", "{", "h", ".", "Lock", "(", ")", "\n", "defer", "h", ".", "Unlock", "(", ")", "\n\n", "return", "&", "Handle", "{", "app", ":", "h", ".", "app", ",", "store", ...
// New method returns a handle based on the receiver handle
[ "New", "method", "returns", "a", "handle", "based", "on", "the", "receiver", "handle" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/store.go#L62-L70
train
docker/libnetwork
bitseq/store.go
CopyTo
func (h *Handle) CopyTo(o datastore.KVObject) error { h.Lock() defer h.Unlock() dstH := o.(*Handle) if h == dstH { return nil } dstH.Lock() dstH.bits = h.bits dstH.unselected = h.unselected dstH.head = h.head.getCopy() dstH.app = h.app dstH.id = h.id dstH.dbIndex = h.dbIndex dstH.dbExists = h.dbExists ...
go
func (h *Handle) CopyTo(o datastore.KVObject) error { h.Lock() defer h.Unlock() dstH := o.(*Handle) if h == dstH { return nil } dstH.Lock() dstH.bits = h.bits dstH.unselected = h.unselected dstH.head = h.head.getCopy() dstH.app = h.app dstH.id = h.id dstH.dbIndex = h.dbIndex dstH.dbExists = h.dbExists ...
[ "func", "(", "h", "*", "Handle", ")", "CopyTo", "(", "o", "datastore", ".", "KVObject", ")", "error", "{", "h", ".", "Lock", "(", ")", "\n", "defer", "h", ".", "Unlock", "(", ")", "\n\n", "dstH", ":=", "o", ".", "(", "*", "Handle", ")", "\n", ...
// CopyTo deep copies the handle into the passed destination object
[ "CopyTo", "deep", "copies", "the", "handle", "into", "the", "passed", "destination", "object" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/store.go#L73-L94
train
docker/libnetwork
drivers/ipvlan/ipvlan_setup.go
createIPVlan
func createIPVlan(containerIfName, parent, ipvlanMode string) (string, error) { // Set the ipvlan mode. Default is bridge mode mode, err := setIPVlanMode(ipvlanMode) if err != nil { return "", fmt.Errorf("Unsupported %s ipvlan mode: %v", ipvlanMode, err) } // verify the Docker host interface acting as the macvla...
go
func createIPVlan(containerIfName, parent, ipvlanMode string) (string, error) { // Set the ipvlan mode. Default is bridge mode mode, err := setIPVlanMode(ipvlanMode) if err != nil { return "", fmt.Errorf("Unsupported %s ipvlan mode: %v", ipvlanMode, err) } // verify the Docker host interface acting as the macvla...
[ "func", "createIPVlan", "(", "containerIfName", ",", "parent", ",", "ipvlanMode", "string", ")", "(", "string", ",", "error", ")", "{", "// Set the ipvlan mode. Default is bridge mode", "mode", ",", "err", ":=", "setIPVlanMode", "(", "ipvlanMode", ")", "\n", "if",...
// createIPVlan Create the ipvlan slave specifying the source name
[ "createIPVlan", "Create", "the", "ipvlan", "slave", "specifying", "the", "source", "name" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_setup.go#L20-L49
train
docker/libnetwork
drivers/ipvlan/ipvlan_setup.go
setIPVlanMode
func setIPVlanMode(mode string) (netlink.IPVlanMode, error) { switch mode { case modeL2: return netlink.IPVLAN_MODE_L2, nil case modeL3: return netlink.IPVLAN_MODE_L3, nil default: return 0, fmt.Errorf("Unknown ipvlan mode: %s", mode) } }
go
func setIPVlanMode(mode string) (netlink.IPVlanMode, error) { switch mode { case modeL2: return netlink.IPVLAN_MODE_L2, nil case modeL3: return netlink.IPVLAN_MODE_L3, nil default: return 0, fmt.Errorf("Unknown ipvlan mode: %s", mode) } }
[ "func", "setIPVlanMode", "(", "mode", "string", ")", "(", "netlink", ".", "IPVlanMode", ",", "error", ")", "{", "switch", "mode", "{", "case", "modeL2", ":", "return", "netlink", ".", "IPVLAN_MODE_L2", ",", "nil", "\n", "case", "modeL3", ":", "return", "...
// setIPVlanMode setter for one of the two ipvlan port types
[ "setIPVlanMode", "setter", "for", "one", "of", "the", "two", "ipvlan", "port", "types" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_setup.go#L52-L61
train
docker/libnetwork
drivers/ipvlan/ipvlan_setup.go
parentExists
func parentExists(ifaceStr string) bool { _, err := ns.NlHandle().LinkByName(ifaceStr) if err != nil { return false } return true }
go
func parentExists(ifaceStr string) bool { _, err := ns.NlHandle().LinkByName(ifaceStr) if err != nil { return false } return true }
[ "func", "parentExists", "(", "ifaceStr", "string", ")", "bool", "{", "_", ",", "err", ":=", "ns", ".", "NlHandle", "(", ")", ".", "LinkByName", "(", "ifaceStr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n\n", "return",...
// parentExists check if the specified interface exists in the default namespace
[ "parentExists", "check", "if", "the", "specified", "interface", "exists", "in", "the", "default", "namespace" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_setup.go#L64-L71
train
docker/libnetwork
drivers/ipvlan/ipvlan_setup.go
createVlanLink
func createVlanLink(parentName string) error { if strings.Contains(parentName, ".") { parent, vidInt, err := parseVlan(parentName) if err != nil { return err } // VLAN identifier or VID is a 12-bit field specifying the VLAN to which the frame belongs if vidInt > 4094 || vidInt < 1 { return fmt.Errorf("...
go
func createVlanLink(parentName string) error { if strings.Contains(parentName, ".") { parent, vidInt, err := parseVlan(parentName) if err != nil { return err } // VLAN identifier or VID is a 12-bit field specifying the VLAN to which the frame belongs if vidInt > 4094 || vidInt < 1 { return fmt.Errorf("...
[ "func", "createVlanLink", "(", "parentName", "string", ")", "error", "{", "if", "strings", ".", "Contains", "(", "parentName", ",", "\"", "\"", ")", "{", "parent", ",", "vidInt", ",", "err", ":=", "parseVlan", "(", "parentName", ")", "\n", "if", "err", ...
// createVlanLink parses sub-interfaces and vlan id for creation
[ "createVlanLink", "parses", "sub", "-", "interfaces", "and", "vlan", "id", "for", "creation" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_setup.go#L74-L109
train
docker/libnetwork
drivers/ipvlan/ipvlan_setup.go
createDummyLink
func createDummyLink(dummyName, truncNetID string) error { // create a parent interface since one was not specified parent := &netlink.Dummy{ LinkAttrs: netlink.LinkAttrs{ Name: dummyName, }, } if err := ns.NlHandle().LinkAdd(parent); err != nil { return err } parentDummyLink, err := ns.NlHandle().LinkBy...
go
func createDummyLink(dummyName, truncNetID string) error { // create a parent interface since one was not specified parent := &netlink.Dummy{ LinkAttrs: netlink.LinkAttrs{ Name: dummyName, }, } if err := ns.NlHandle().LinkAdd(parent); err != nil { return err } parentDummyLink, err := ns.NlHandle().LinkBy...
[ "func", "createDummyLink", "(", "dummyName", ",", "truncNetID", "string", ")", "error", "{", "// create a parent interface since one was not specified", "parent", ":=", "&", "netlink", ".", "Dummy", "{", "LinkAttrs", ":", "netlink", ".", "LinkAttrs", "{", "Name", ":...
// createDummyLink creates a dummy0 parent link
[ "createDummyLink", "creates", "a", "dummy0", "parent", "link" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_setup.go#L160-L180
train
docker/libnetwork
drivers/ipvlan/ipvlan_setup.go
delDummyLink
func delDummyLink(linkName string) error { // delete the vlan subinterface dummyLink, err := ns.NlHandle().LinkByName(linkName) if err != nil { return fmt.Errorf("failed to find link %s on the Docker host : %v", linkName, err) } // verify a parent interface is being deleted if dummyLink.Attrs().ParentIndex != 0...
go
func delDummyLink(linkName string) error { // delete the vlan subinterface dummyLink, err := ns.NlHandle().LinkByName(linkName) if err != nil { return fmt.Errorf("failed to find link %s on the Docker host : %v", linkName, err) } // verify a parent interface is being deleted if dummyLink.Attrs().ParentIndex != 0...
[ "func", "delDummyLink", "(", "linkName", "string", ")", "error", "{", "// delete the vlan subinterface", "dummyLink", ",", "err", ":=", "ns", ".", "NlHandle", "(", ")", ".", "LinkByName", "(", "linkName", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// delDummyLink deletes the link type dummy used when -o parent is not passed
[ "delDummyLink", "deletes", "the", "link", "type", "dummy", "used", "when", "-", "o", "parent", "is", "not", "passed" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_setup.go#L183-L200
train
docker/libnetwork
datastore/datastore.go
DefaultScopes
func DefaultScopes(dataDir string) map[string]*ScopeCfg { if dataDir != "" { defaultScopes[LocalScope].Client.Address = dataDir + "/network/files/local-kv.db" return defaultScopes } defaultScopes[LocalScope].Client.Address = defaultPrefix + "/local-kv.db" return defaultScopes }
go
func DefaultScopes(dataDir string) map[string]*ScopeCfg { if dataDir != "" { defaultScopes[LocalScope].Client.Address = dataDir + "/network/files/local-kv.db" return defaultScopes } defaultScopes[LocalScope].Client.Address = defaultPrefix + "/local-kv.db" return defaultScopes }
[ "func", "DefaultScopes", "(", "dataDir", "string", ")", "map", "[", "string", "]", "*", "ScopeCfg", "{", "if", "dataDir", "!=", "\"", "\"", "{", "defaultScopes", "[", "LocalScope", "]", ".", "Client", ".", "Address", "=", "dataDir", "+", "\"", "\"", "\...
// DefaultScopes returns a map of default scopes and its config for clients to use.
[ "DefaultScopes", "returns", "a", "map", "of", "default", "scopes", "and", "its", "config", "for", "clients", "to", "use", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L156-L164
train
docker/libnetwork
datastore/datastore.go
IsValid
func (cfg *ScopeCfg) IsValid() bool { if cfg == nil || strings.TrimSpace(cfg.Client.Provider) == "" || strings.TrimSpace(cfg.Client.Address) == "" { return false } return true }
go
func (cfg *ScopeCfg) IsValid() bool { if cfg == nil || strings.TrimSpace(cfg.Client.Provider) == "" || strings.TrimSpace(cfg.Client.Address) == "" { return false } return true }
[ "func", "(", "cfg", "*", "ScopeCfg", ")", "IsValid", "(", ")", "bool", "{", "if", "cfg", "==", "nil", "||", "strings", ".", "TrimSpace", "(", "cfg", ".", "Client", ".", "Provider", ")", "==", "\"", "\"", "||", "strings", ".", "TrimSpace", "(", "cfg...
// IsValid checks if the scope config has valid configuration.
[ "IsValid", "checks", "if", "the", "scope", "config", "has", "valid", "configuration", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L167-L175
train
docker/libnetwork
datastore/datastore.go
Key
func Key(key ...string) string { keychain := append(rootChain, key...) str := strings.Join(keychain, "/") return str + "/" }
go
func Key(key ...string) string { keychain := append(rootChain, key...) str := strings.Join(keychain, "/") return str + "/" }
[ "func", "Key", "(", "key", "...", "string", ")", "string", "{", "keychain", ":=", "append", "(", "rootChain", ",", "key", "...", ")", "\n", "str", ":=", "strings", ".", "Join", "(", "keychain", ",", "\"", "\"", ")", "\n", "return", "str", "+", "\""...
//Key provides convenient method to create a Key
[ "Key", "provides", "convenient", "method", "to", "create", "a", "Key" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L178-L182
train
docker/libnetwork
datastore/datastore.go
ParseKey
func ParseKey(key string) ([]string, error) { chain := strings.Split(strings.Trim(key, "/"), "/") // The key must at least be equal to the rootChain in order to be considered as valid if len(chain) <= len(rootChain) || !reflect.DeepEqual(chain[0:len(rootChain)], rootChain) { return nil, types.BadRequestErrorf("in...
go
func ParseKey(key string) ([]string, error) { chain := strings.Split(strings.Trim(key, "/"), "/") // The key must at least be equal to the rootChain in order to be considered as valid if len(chain) <= len(rootChain) || !reflect.DeepEqual(chain[0:len(rootChain)], rootChain) { return nil, types.BadRequestErrorf("in...
[ "func", "ParseKey", "(", "key", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "chain", ":=", "strings", ".", "Split", "(", "strings", ".", "Trim", "(", "key", ",", "\"", "\"", ")", ",", "\"", "\"", ")", "\n\n", "// The key must at...
//ParseKey provides convenient method to unpack the key to complement the Key function
[ "ParseKey", "provides", "convenient", "method", "to", "unpack", "the", "key", "to", "complement", "the", "Key", "function" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L185-L193
train
docker/libnetwork
datastore/datastore.go
newClient
func newClient(scope string, kv string, addr string, config *store.Config, cached bool) (DataStore, error) { if cached && scope != LocalScope { return nil, fmt.Errorf("caching supported only for scope %s", LocalScope) } sequential := false if scope == LocalScope { sequential = true } if config == nil { co...
go
func newClient(scope string, kv string, addr string, config *store.Config, cached bool) (DataStore, error) { if cached && scope != LocalScope { return nil, fmt.Errorf("caching supported only for scope %s", LocalScope) } sequential := false if scope == LocalScope { sequential = true } if config == nil { co...
[ "func", "newClient", "(", "scope", "string", ",", "kv", "string", ",", "addr", "string", ",", "config", "*", "store", ".", "Config", ",", "cached", "bool", ")", "(", "DataStore", ",", "error", ")", "{", "if", "cached", "&&", "scope", "!=", "LocalScope"...
// newClient used to connect to KV Store
[ "newClient", "used", "to", "connect", "to", "KV", "Store" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L196-L237
train
docker/libnetwork
datastore/datastore.go
NewDataStore
func NewDataStore(scope string, cfg *ScopeCfg) (DataStore, error) { if cfg == nil || cfg.Client.Provider == "" || cfg.Client.Address == "" { c, ok := defaultScopes[scope] if !ok || c.Client.Provider == "" || c.Client.Address == "" { return nil, fmt.Errorf("unexpected scope %s without configuration passed", scop...
go
func NewDataStore(scope string, cfg *ScopeCfg) (DataStore, error) { if cfg == nil || cfg.Client.Provider == "" || cfg.Client.Address == "" { c, ok := defaultScopes[scope] if !ok || c.Client.Provider == "" || c.Client.Address == "" { return nil, fmt.Errorf("unexpected scope %s without configuration passed", scop...
[ "func", "NewDataStore", "(", "scope", "string", ",", "cfg", "*", "ScopeCfg", ")", "(", "DataStore", ",", "error", ")", "{", "if", "cfg", "==", "nil", "||", "cfg", ".", "Client", ".", "Provider", "==", "\"", "\"", "||", "cfg", ".", "Client", ".", "A...
// NewDataStore creates a new instance of LibKV data store
[ "NewDataStore", "creates", "a", "new", "instance", "of", "LibKV", "data", "store" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L240-L256
train
docker/libnetwork
datastore/datastore.go
NewDataStoreFromConfig
func NewDataStoreFromConfig(dsc discoverapi.DatastoreConfigData) (DataStore, error) { var ( ok bool sCfgP *store.Config ) sCfgP, ok = dsc.Config.(*store.Config) if !ok && dsc.Config != nil { return nil, fmt.Errorf("cannot parse store configuration: %v", dsc.Config) } scopeCfg := &ScopeCfg{ Client: Sc...
go
func NewDataStoreFromConfig(dsc discoverapi.DatastoreConfigData) (DataStore, error) { var ( ok bool sCfgP *store.Config ) sCfgP, ok = dsc.Config.(*store.Config) if !ok && dsc.Config != nil { return nil, fmt.Errorf("cannot parse store configuration: %v", dsc.Config) } scopeCfg := &ScopeCfg{ Client: Sc...
[ "func", "NewDataStoreFromConfig", "(", "dsc", "discoverapi", ".", "DatastoreConfigData", ")", "(", "DataStore", ",", "error", ")", "{", "var", "(", "ok", "bool", "\n", "sCfgP", "*", "store", ".", "Config", "\n", ")", "\n\n", "sCfgP", ",", "ok", "=", "dsc...
// NewDataStoreFromConfig creates a new instance of LibKV data store starting from the datastore config data
[ "NewDataStoreFromConfig", "creates", "a", "new", "instance", "of", "LibKV", "data", "store", "starting", "from", "the", "datastore", "config", "data" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L259-L284
train
docker/libnetwork
datastore/datastore.go
PutObjectAtomic
func (ds *datastore) PutObjectAtomic(kvObject KVObject) error { var ( previous *store.KVPair pair *store.KVPair err error ) if ds.sequential { ds.Lock() defer ds.Unlock() } if kvObject == nil { return types.BadRequestErrorf("invalid KV Object : nil") } kvObjValue := kvObject.Value() if k...
go
func (ds *datastore) PutObjectAtomic(kvObject KVObject) error { var ( previous *store.KVPair pair *store.KVPair err error ) if ds.sequential { ds.Lock() defer ds.Unlock() } if kvObject == nil { return types.BadRequestErrorf("invalid KV Object : nil") } kvObjValue := kvObject.Value() if k...
[ "func", "(", "ds", "*", "datastore", ")", "PutObjectAtomic", "(", "kvObject", "KVObject", ")", "error", "{", "var", "(", "previous", "*", "store", ".", "KVPair", "\n", "pair", "*", "store", ".", "KVPair", "\n", "err", "error", "\n", ")", "\n", "if", ...
// PutObjectAtomic adds a new Record based on an object into the datastore
[ "PutObjectAtomic", "adds", "a", "new", "Record", "based", "on", "an", "object", "into", "the", "datastore" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L384-L433
train
docker/libnetwork
datastore/datastore.go
PutObject
func (ds *datastore) PutObject(kvObject KVObject) error { if ds.sequential { ds.Lock() defer ds.Unlock() } if kvObject == nil { return types.BadRequestErrorf("invalid KV Object : nil") } if kvObject.Skip() { goto add_cache } if err := ds.putObjectWithKey(kvObject, kvObject.Key()...); err != nil { re...
go
func (ds *datastore) PutObject(kvObject KVObject) error { if ds.sequential { ds.Lock() defer ds.Unlock() } if kvObject == nil { return types.BadRequestErrorf("invalid KV Object : nil") } if kvObject.Skip() { goto add_cache } if err := ds.putObjectWithKey(kvObject, kvObject.Key()...); err != nil { re...
[ "func", "(", "ds", "*", "datastore", ")", "PutObject", "(", "kvObject", "KVObject", ")", "error", "{", "if", "ds", ".", "sequential", "{", "ds", ".", "Lock", "(", ")", "\n", "defer", "ds", ".", "Unlock", "(", ")", "\n", "}", "\n\n", "if", "kvObject...
// PutObject adds a new Record based on an object into the datastore
[ "PutObject", "adds", "a", "new", "Record", "based", "on", "an", "object", "into", "the", "datastore" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L436-L462
train
docker/libnetwork
datastore/datastore.go
GetObject
func (ds *datastore) GetObject(key string, o KVObject) error { if ds.sequential { ds.Lock() defer ds.Unlock() } if ds.cache != nil { return ds.cache.get(key, o) } kvPair, err := ds.store.Get(key) if err != nil { return err } if err := o.SetValue(kvPair.Value); err != nil { return err } // Make s...
go
func (ds *datastore) GetObject(key string, o KVObject) error { if ds.sequential { ds.Lock() defer ds.Unlock() } if ds.cache != nil { return ds.cache.get(key, o) } kvPair, err := ds.store.Get(key) if err != nil { return err } if err := o.SetValue(kvPair.Value); err != nil { return err } // Make s...
[ "func", "(", "ds", "*", "datastore", ")", "GetObject", "(", "key", "string", ",", "o", "KVObject", ")", "error", "{", "if", "ds", ".", "sequential", "{", "ds", ".", "Lock", "(", ")", "\n", "defer", "ds", ".", "Unlock", "(", ")", "\n", "}", "\n\n"...
// GetObject returns a record matching the key
[ "GetObject", "returns", "a", "record", "matching", "the", "key" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L474-L497
train
docker/libnetwork
datastore/datastore.go
DeleteObject
func (ds *datastore) DeleteObject(kvObject KVObject) error { if ds.sequential { ds.Lock() defer ds.Unlock() } // cleanup the cache first if ds.cache != nil { // If persistent store is skipped, sequencing needs to // happen in cache. ds.cache.del(kvObject, kvObject.Skip()) } if kvObject.Skip() { retu...
go
func (ds *datastore) DeleteObject(kvObject KVObject) error { if ds.sequential { ds.Lock() defer ds.Unlock() } // cleanup the cache first if ds.cache != nil { // If persistent store is skipped, sequencing needs to // happen in cache. ds.cache.del(kvObject, kvObject.Skip()) } if kvObject.Skip() { retu...
[ "func", "(", "ds", "*", "datastore", ")", "DeleteObject", "(", "kvObject", "KVObject", ")", "error", "{", "if", "ds", ".", "sequential", "{", "ds", ".", "Lock", "(", ")", "\n", "defer", "ds", ".", "Unlock", "(", ")", "\n", "}", "\n\n", "// cleanup th...
// DeleteObject unconditionally deletes a record from the store
[ "DeleteObject", "unconditionally", "deletes", "a", "record", "from", "the", "store" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L586-L604
train
docker/libnetwork
datastore/datastore.go
DeleteObjectAtomic
func (ds *datastore) DeleteObjectAtomic(kvObject KVObject) error { if ds.sequential { ds.Lock() defer ds.Unlock() } if kvObject == nil { return types.BadRequestErrorf("invalid KV Object : nil") } previous := &store.KVPair{Key: Key(kvObject.Key()...), LastIndex: kvObject.Index()} if kvObject.Skip() { go...
go
func (ds *datastore) DeleteObjectAtomic(kvObject KVObject) error { if ds.sequential { ds.Lock() defer ds.Unlock() } if kvObject == nil { return types.BadRequestErrorf("invalid KV Object : nil") } previous := &store.KVPair{Key: Key(kvObject.Key()...), LastIndex: kvObject.Index()} if kvObject.Skip() { go...
[ "func", "(", "ds", "*", "datastore", ")", "DeleteObjectAtomic", "(", "kvObject", "KVObject", ")", "error", "{", "if", "ds", ".", "sequential", "{", "ds", ".", "Lock", "(", ")", "\n", "defer", "ds", ".", "Unlock", "(", ")", "\n", "}", "\n\n", "if", ...
// DeleteObjectAtomic performs atomic delete on a record
[ "DeleteObjectAtomic", "performs", "atomic", "delete", "on", "a", "record" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L607-L639
train
docker/libnetwork
datastore/datastore.go
DeleteTree
func (ds *datastore) DeleteTree(kvObject KVObject) error { if ds.sequential { ds.Lock() defer ds.Unlock() } // cleanup the cache first if ds.cache != nil { // If persistent store is skipped, sequencing needs to // happen in cache. ds.cache.del(kvObject, kvObject.Skip()) } if kvObject.Skip() { return...
go
func (ds *datastore) DeleteTree(kvObject KVObject) error { if ds.sequential { ds.Lock() defer ds.Unlock() } // cleanup the cache first if ds.cache != nil { // If persistent store is skipped, sequencing needs to // happen in cache. ds.cache.del(kvObject, kvObject.Skip()) } if kvObject.Skip() { return...
[ "func", "(", "ds", "*", "datastore", ")", "DeleteTree", "(", "kvObject", "KVObject", ")", "error", "{", "if", "ds", ".", "sequential", "{", "ds", ".", "Lock", "(", ")", "\n", "defer", "ds", ".", "Unlock", "(", ")", "\n", "}", "\n\n", "// cleanup the ...
// DeleteTree unconditionally deletes a record from the store
[ "DeleteTree", "unconditionally", "deletes", "a", "record", "from", "the", "store" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/datastore.go#L642-L660
train
docker/libnetwork
drivers/remote/driver.go
Init
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error { newPluginHandler := func(name string, client *plugins.Client) { // negotiate driver capability with client d := newDriver(name, client) c, err := d.(*driver).getCapabilities() if err != nil { logrus.Errorf("error getting capabilit...
go
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error { newPluginHandler := func(name string, client *plugins.Client) { // negotiate driver capability with client d := newDriver(name, client) c, err := d.(*driver).getCapabilities() if err != nil { logrus.Errorf("error getting capabilit...
[ "func", "Init", "(", "dc", "driverapi", ".", "DriverCallback", ",", "config", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "newPluginHandler", ":=", "func", "(", "name", "string", ",", "client", "*", "plugins", ".", "Client", ")",...
// Init makes sure a remote driver is registered when a network driver // plugin is activated.
[ "Init", "makes", "sure", "a", "remote", "driver", "is", "registered", "when", "a", "network", "driver", "plugin", "is", "activated", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/remote/driver.go#L33-L63
train
docker/libnetwork
drivers/remote/driver.go
getCapabilities
func (d *driver) getCapabilities() (*driverapi.Capability, error) { var capResp api.GetCapabilityResponse if err := d.call("GetCapabilities", nil, &capResp); err != nil { return nil, err } c := &driverapi.Capability{} switch capResp.Scope { case "global": c.DataScope = datastore.GlobalScope case "local": ...
go
func (d *driver) getCapabilities() (*driverapi.Capability, error) { var capResp api.GetCapabilityResponse if err := d.call("GetCapabilities", nil, &capResp); err != nil { return nil, err } c := &driverapi.Capability{} switch capResp.Scope { case "global": c.DataScope = datastore.GlobalScope case "local": ...
[ "func", "(", "d", "*", "driver", ")", "getCapabilities", "(", ")", "(", "*", "driverapi", ".", "Capability", ",", "error", ")", "{", "var", "capResp", "api", ".", "GetCapabilityResponse", "\n", "if", "err", ":=", "d", ".", "call", "(", "\"", "\"", ",...
// Get capability from client
[ "Get", "capability", "from", "client" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/remote/driver.go#L88-L116
train
docker/libnetwork
drivers/remote/driver.go
ProgramExternalConnectivity
func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error { data := &api.ProgramExternalConnectivityRequest{ NetworkID: nid, EndpointID: eid, Options: options, } err := d.call("ProgramExternalConnectivity", data, &api.ProgramExternalConnectivityResponse{}) if err ...
go
func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error { data := &api.ProgramExternalConnectivityRequest{ NetworkID: nid, EndpointID: eid, Options: options, } err := d.call("ProgramExternalConnectivity", data, &api.ProgramExternalConnectivityResponse{}) if err ...
[ "func", "(", "d", "*", "driver", ")", "ProgramExternalConnectivity", "(", "nid", ",", "eid", "string", ",", "options", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "data", ":=", "&", "api", ".", "ProgramExternalConnectivityRequest", ...
// ProgramExternalConnectivity is invoked to program the rules to allow external connectivity for the endpoint.
[ "ProgramExternalConnectivity", "is", "invoked", "to", "program", "the", "rules", "to", "allow", "external", "connectivity", "for", "the", "endpoint", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/remote/driver.go#L326-L338
train
docker/libnetwork
drivers/remote/driver.go
RevokeExternalConnectivity
func (d *driver) RevokeExternalConnectivity(nid, eid string) error { data := &api.RevokeExternalConnectivityRequest{ NetworkID: nid, EndpointID: eid, } err := d.call("RevokeExternalConnectivity", data, &api.RevokeExternalConnectivityResponse{}) if err != nil && plugins.IsNotFound(err) { // It is not mandator...
go
func (d *driver) RevokeExternalConnectivity(nid, eid string) error { data := &api.RevokeExternalConnectivityRequest{ NetworkID: nid, EndpointID: eid, } err := d.call("RevokeExternalConnectivity", data, &api.RevokeExternalConnectivityResponse{}) if err != nil && plugins.IsNotFound(err) { // It is not mandator...
[ "func", "(", "d", "*", "driver", ")", "RevokeExternalConnectivity", "(", "nid", ",", "eid", "string", ")", "error", "{", "data", ":=", "&", "api", ".", "RevokeExternalConnectivityRequest", "{", "NetworkID", ":", "nid", ",", "EndpointID", ":", "eid", ",", "...
// RevokeExternalConnectivity method is invoked to remove any external connectivity programming related to the endpoint.
[ "RevokeExternalConnectivity", "method", "is", "invoked", "to", "remove", "any", "external", "connectivity", "programming", "related", "to", "the", "endpoint", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/remote/driver.go#L341-L352
train
docker/libnetwork
drivers/remote/driver.go
parseInterface
func parseInterface(r api.CreateEndpointResponse) (*api.Interface, error) { var outIf *api.Interface inIf := r.Interface if inIf != nil { var err error outIf = &api.Interface{} if inIf.Address != "" { if outIf.Address, err = types.ParseCIDR(inIf.Address); err != nil { return nil, err } } if inIf...
go
func parseInterface(r api.CreateEndpointResponse) (*api.Interface, error) { var outIf *api.Interface inIf := r.Interface if inIf != nil { var err error outIf = &api.Interface{} if inIf.Address != "" { if outIf.Address, err = types.ParseCIDR(inIf.Address); err != nil { return nil, err } } if inIf...
[ "func", "parseInterface", "(", "r", "api", ".", "CreateEndpointResponse", ")", "(", "*", "api", ".", "Interface", ",", "error", ")", "{", "var", "outIf", "*", "api", ".", "Interface", "\n\n", "inIf", ":=", "r", ".", "Interface", "\n", "if", "inIf", "!=...
// parseInterfaces validates all the parameters of an Interface and returns them.
[ "parseInterfaces", "validates", "all", "the", "parameters", "of", "an", "Interface", "and", "returns", "them", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/remote/driver.go#L411-L436
train
docker/libnetwork
cmd/proxy/udp_proxy.go
Close
func (proxy *UDPProxy) Close() { proxy.listener.Close() proxy.connTrackLock.Lock() defer proxy.connTrackLock.Unlock() for _, conn := range proxy.connTrackTable { conn.Close() } }
go
func (proxy *UDPProxy) Close() { proxy.listener.Close() proxy.connTrackLock.Lock() defer proxy.connTrackLock.Unlock() for _, conn := range proxy.connTrackTable { conn.Close() } }
[ "func", "(", "proxy", "*", "UDPProxy", ")", "Close", "(", ")", "{", "proxy", ".", "listener", ".", "Close", "(", ")", "\n", "proxy", ".", "connTrackLock", ".", "Lock", "(", ")", "\n", "defer", "proxy", ".", "connTrackLock", ".", "Unlock", "(", ")", ...
// Close stops forwarding the traffic.
[ "Close", "stops", "forwarding", "the", "traffic", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/cmd/proxy/udp_proxy.go#L145-L152
train
docker/libnetwork
agent.go
getKeys
func (c *controller) getKeys(subsys string) ([][]byte, []uint64) { c.Lock() defer c.Unlock() sort.Sort(ByTime(c.keys)) keys := [][]byte{} tags := []uint64{} for _, key := range c.keys { if key.Subsystem == subsys { keys = append(keys, key.Key) tags = append(tags, key.LamportTime) } } keys[0], keys[...
go
func (c *controller) getKeys(subsys string) ([][]byte, []uint64) { c.Lock() defer c.Unlock() sort.Sort(ByTime(c.keys)) keys := [][]byte{} tags := []uint64{} for _, key := range c.keys { if key.Subsystem == subsys { keys = append(keys, key.Key) tags = append(tags, key.LamportTime) } } keys[0], keys[...
[ "func", "(", "c", "*", "controller", ")", "getKeys", "(", "subsys", "string", ")", "(", "[", "]", "[", "]", "byte", ",", "[", "]", "uint64", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n\n", "sort", "....
// For a given subsystem getKeys sorts the keys by lamport time and returns // slice of keys and lamport time which can used as a unique tag for the keys
[ "For", "a", "given", "subsystem", "getKeys", "sorts", "the", "keys", "by", "lamport", "time", "and", "returns", "slice", "of", "keys", "and", "lamport", "time", "which", "can", "used", "as", "a", "unique", "tag", "for", "the", "keys" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/agent.go#L241-L259
train
docker/libnetwork
agent.go
getPrimaryKeyTag
func (c *controller) getPrimaryKeyTag(subsys string) ([]byte, uint64, error) { c.Lock() defer c.Unlock() sort.Sort(ByTime(c.keys)) keys := []*types.EncryptionKey{} for _, key := range c.keys { if key.Subsystem == subsys { keys = append(keys, key) } } return keys[1].Key, keys[1].LamportTime, nil }
go
func (c *controller) getPrimaryKeyTag(subsys string) ([]byte, uint64, error) { c.Lock() defer c.Unlock() sort.Sort(ByTime(c.keys)) keys := []*types.EncryptionKey{} for _, key := range c.keys { if key.Subsystem == subsys { keys = append(keys, key) } } return keys[1].Key, keys[1].LamportTime, nil }
[ "func", "(", "c", "*", "controller", ")", "getPrimaryKeyTag", "(", "subsys", "string", ")", "(", "[", "]", "byte", ",", "uint64", ",", "error", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "sort", ".", ...
// getPrimaryKeyTag returns the primary key for a given subsystem from the // list of sorted key and the associated tag
[ "getPrimaryKeyTag", "returns", "the", "primary", "key", "for", "a", "given", "subsystem", "from", "the", "list", "of", "sorted", "key", "and", "the", "associated", "tag" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/agent.go#L263-L274
train
docker/libnetwork
drivers/ipvlan/ipvlan_joinleave.go
getSubnetforIPv4
func (n *network) getSubnetforIPv4(ip *net.IPNet) *ipv4Subnet { for _, s := range n.config.Ipv4Subnets { _, snet, err := net.ParseCIDR(s.SubnetIP) if err != nil { return nil } // first check if the mask lengths are the same i, _ := snet.Mask.Size() j, _ := ip.Mask.Size() if i != j { continue } ...
go
func (n *network) getSubnetforIPv4(ip *net.IPNet) *ipv4Subnet { for _, s := range n.config.Ipv4Subnets { _, snet, err := net.ParseCIDR(s.SubnetIP) if err != nil { return nil } // first check if the mask lengths are the same i, _ := snet.Mask.Size() j, _ := ip.Mask.Size() if i != j { continue } ...
[ "func", "(", "n", "*", "network", ")", "getSubnetforIPv4", "(", "ip", "*", "net", ".", "IPNet", ")", "*", "ipv4Subnet", "{", "for", "_", ",", "s", ":=", "range", "n", ".", "config", ".", "Ipv4Subnets", "{", "_", ",", "snet", ",", "err", ":=", "ne...
// getSubnetforIPv4 returns the ipv4 subnet to which the given IP belongs
[ "getSubnetforIPv4", "returns", "the", "ipv4", "subnet", "to", "which", "the", "given", "IP", "belongs" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_joinleave.go#L160-L178
train
docker/libnetwork
drivers/ipvlan/ipvlan_joinleave.go
getSubnetforIPv6
func (n *network) getSubnetforIPv6(ip *net.IPNet) *ipv6Subnet { for _, s := range n.config.Ipv6Subnets { _, snet, err := net.ParseCIDR(s.SubnetIP) if err != nil { return nil } // first check if the mask lengths are the same i, _ := snet.Mask.Size() j, _ := ip.Mask.Size() if i != j { continue } ...
go
func (n *network) getSubnetforIPv6(ip *net.IPNet) *ipv6Subnet { for _, s := range n.config.Ipv6Subnets { _, snet, err := net.ParseCIDR(s.SubnetIP) if err != nil { return nil } // first check if the mask lengths are the same i, _ := snet.Mask.Size() j, _ := ip.Mask.Size() if i != j { continue } ...
[ "func", "(", "n", "*", "network", ")", "getSubnetforIPv6", "(", "ip", "*", "net", ".", "IPNet", ")", "*", "ipv6Subnet", "{", "for", "_", ",", "s", ":=", "range", "n", ".", "config", ".", "Ipv6Subnets", "{", "_", ",", "snet", ",", "err", ":=", "ne...
// getSubnetforIPv6 returns the ipv6 subnet to which the given IP belongs
[ "getSubnetforIPv6", "returns", "the", "ipv6", "subnet", "to", "which", "the", "given", "IP", "belongs" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan_joinleave.go#L181-L199
train
docker/libnetwork
client/mflag/flag.go
Out
func (fs *FlagSet) Out() io.Writer { if fs.output == nil { return os.Stderr } return fs.output }
go
func (fs *FlagSet) Out() io.Writer { if fs.output == nil { return os.Stderr } return fs.output }
[ "func", "(", "fs", "*", "FlagSet", ")", "Out", "(", ")", "io", ".", "Writer", "{", "if", "fs", ".", "output", "==", "nil", "{", "return", "os", ".", "Stderr", "\n", "}", "\n", "return", "fs", ".", "output", "\n", "}" ]
// Out returns the destination for usage and error messages.
[ "Out", "returns", "the", "destination", "for", "usage", "and", "error", "messages", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L384-L389
train
docker/libnetwork
client/mflag/flag.go
IsSet
func (fs *FlagSet) IsSet(name string) bool { return fs.actual[name] != nil }
go
func (fs *FlagSet) IsSet(name string) bool { return fs.actual[name] != nil }
[ "func", "(", "fs", "*", "FlagSet", ")", "IsSet", "(", "name", "string", ")", "bool", "{", "return", "fs", ".", "actual", "[", "name", "]", "!=", "nil", "\n", "}" ]
// IsSet indicates whether the specified flag is set in the given FlagSet
[ "IsSet", "indicates", "whether", "the", "specified", "flag", "is", "set", "in", "the", "given", "FlagSet" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L431-L433
train
docker/libnetwork
client/mflag/flag.go
Set
func (fs *FlagSet) Set(name, value string) error { flag, ok := fs.formal[name] if !ok { return fmt.Errorf("no such flag -%v", name) } if err := flag.Value.Set(value); err != nil { return err } if fs.actual == nil { fs.actual = make(map[string]*Flag) } fs.actual[name] = flag return nil }
go
func (fs *FlagSet) Set(name, value string) error { flag, ok := fs.formal[name] if !ok { return fmt.Errorf("no such flag -%v", name) } if err := flag.Value.Set(value); err != nil { return err } if fs.actual == nil { fs.actual = make(map[string]*Flag) } fs.actual[name] = flag return nil }
[ "func", "(", "fs", "*", "FlagSet", ")", "Set", "(", "name", ",", "value", "string", ")", "error", "{", "flag", ",", "ok", ":=", "fs", ".", "formal", "[", "name", "]", "\n", "if", "!", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ...
// Set sets the value of the named flag.
[ "Set", "sets", "the", "value", "of", "the", "named", "flag", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L503-L516
train
docker/libnetwork
client/mflag/flag.go
PrintDefaults
func (fs *FlagSet) PrintDefaults() { writer := tabwriter.NewWriter(fs.Out(), 20, 1, 3, ' ', 0) home := homedir.Get() // Don't substitute when HOME is / if runtime.GOOS != "windows" && home == "/" { home = "" } // Add a blank line between cmd description and list of options if fs.FlagCount() > 0 { fmt.Fprin...
go
func (fs *FlagSet) PrintDefaults() { writer := tabwriter.NewWriter(fs.Out(), 20, 1, 3, ' ', 0) home := homedir.Get() // Don't substitute when HOME is / if runtime.GOOS != "windows" && home == "/" { home = "" } // Add a blank line between cmd description and list of options if fs.FlagCount() > 0 { fmt.Fprin...
[ "func", "(", "fs", "*", "FlagSet", ")", "PrintDefaults", "(", ")", "{", "writer", ":=", "tabwriter", ".", "NewWriter", "(", "fs", ".", "Out", "(", ")", ",", "20", ",", "1", ",", "3", ",", "' '", ",", "0", ")", "\n", "home", ":=", "homedir", "."...
// PrintDefaults prints, to standard error unless configured // otherwise, the default values of all defined flags in the set.
[ "PrintDefaults", "prints", "to", "standard", "error", "unless", "configured", "otherwise", "the", "default", "values", "of", "all", "defined", "flags", "in", "the", "set", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L539-L580
train
docker/libnetwork
client/mflag/flag.go
FlagCountUndeprecated
func (fs *FlagSet) FlagCountUndeprecated() int { count := 0 for _, flag := range sortFlags(fs.formal) { for _, name := range flag.Names { if name[0] != '#' { count++ break } } } return count }
go
func (fs *FlagSet) FlagCountUndeprecated() int { count := 0 for _, flag := range sortFlags(fs.formal) { for _, name := range flag.Names { if name[0] != '#' { count++ break } } } return count }
[ "func", "(", "fs", "*", "FlagSet", ")", "FlagCountUndeprecated", "(", ")", "int", "{", "count", ":=", "0", "\n", "for", "_", ",", "flag", ":=", "range", "sortFlags", "(", "fs", ".", "formal", ")", "{", "for", "_", ",", "name", ":=", "range", "flag"...
// FlagCountUndeprecated returns the number of undeprecated flags that have been defined.
[ "FlagCountUndeprecated", "returns", "the", "number", "of", "undeprecated", "flags", "that", "have", "been", "defined", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L618-L629
train
docker/libnetwork
client/mflag/flag.go
usage
func (fs *FlagSet) usage() { if fs == CommandLine { Usage() } else if fs.Usage == nil { defaultUsage(fs) } else { fs.Usage() } }
go
func (fs *FlagSet) usage() { if fs == CommandLine { Usage() } else if fs.Usage == nil { defaultUsage(fs) } else { fs.Usage() } }
[ "func", "(", "fs", "*", "FlagSet", ")", "usage", "(", ")", "{", "if", "fs", "==", "CommandLine", "{", "Usage", "(", ")", "\n", "}", "else", "if", "fs", ".", "Usage", "==", "nil", "{", "defaultUsage", "(", "fs", ")", "\n", "}", "else", "{", "fs"...
// usage calls the Usage method for the flag set, or the usage function if // the flag set is CommandLine.
[ "usage", "calls", "the", "Usage", "method", "for", "the", "flag", "set", "or", "the", "usage", "function", "if", "the", "flag", "set", "is", "CommandLine", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L952-L960
train
docker/libnetwork
client/mflag/flag.go
ReportError
func (fs *FlagSet) ReportError(str string, withHelp bool) { if withHelp { if os.Args[0] == fs.Name() { str += ".\nSee '" + os.Args[0] + " --help'" } else { str += ".\nSee '" + os.Args[0] + " " + fs.Name() + " --help'" } } fmt.Fprintf(fs.Out(), "%s: %s.\n", os.Args[0], str) }
go
func (fs *FlagSet) ReportError(str string, withHelp bool) { if withHelp { if os.Args[0] == fs.Name() { str += ".\nSee '" + os.Args[0] + " --help'" } else { str += ".\nSee '" + os.Args[0] + " " + fs.Name() + " --help'" } } fmt.Fprintf(fs.Out(), "%s: %s.\n", os.Args[0], str) }
[ "func", "(", "fs", "*", "FlagSet", ")", "ReportError", "(", "str", "string", ",", "withHelp", "bool", ")", "{", "if", "withHelp", "{", "if", "os", ".", "Args", "[", "0", "]", "==", "fs", ".", "Name", "(", ")", "{", "str", "+=", "\"", "\\n", "\"...
// ReportError is a utility method that prints a user-friendly message // containing the error that occurred during parsing and a suggestion to get help
[ "ReportError", "is", "a", "utility", "method", "that", "prints", "a", "user", "-", "friendly", "message", "containing", "the", "error", "that", "occurred", "during", "parsing", "and", "a", "suggestion", "to", "get", "help" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L1158-L1167
train
docker/libnetwork
client/mflag/flag.go
Name
func (v mergeVal) Name() string { type namedValue interface { Name() string } if nVal, ok := v.Value.(namedValue); ok { return nVal.Name() } return v.key }
go
func (v mergeVal) Name() string { type namedValue interface { Name() string } if nVal, ok := v.Value.(namedValue); ok { return nVal.Name() } return v.key }
[ "func", "(", "v", "mergeVal", ")", "Name", "(", ")", "string", "{", "type", "namedValue", "interface", "{", "Name", "(", ")", "string", "\n", "}", "\n", "if", "nVal", ",", "ok", ":=", "v", ".", "Value", ".", "(", "namedValue", ")", ";", "ok", "{"...
// Name returns the name of a mergeVal. // If the original value had a name, return the original name, // otherwise, return the key assigned to this mergeVal.
[ "Name", "returns", "the", "name", "of", "a", "mergeVal", ".", "If", "the", "original", "value", "had", "a", "name", "return", "the", "original", "name", "otherwise", "return", "the", "key", "assigned", "to", "this", "mergeVal", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L1229-L1237
train
docker/libnetwork
client/mflag/flag.go
Merge
func Merge(dest *FlagSet, flagsets ...*FlagSet) error { for _, fset := range flagsets { if fset.formal == nil { continue } for k, f := range fset.formal { if _, ok := dest.formal[k]; ok { var err error if fset.name == "" { err = fmt.Errorf("flag redefined: %s", k) } else { err = fmt.E...
go
func Merge(dest *FlagSet, flagsets ...*FlagSet) error { for _, fset := range flagsets { if fset.formal == nil { continue } for k, f := range fset.formal { if _, ok := dest.formal[k]; ok { var err error if fset.name == "" { err = fmt.Errorf("flag redefined: %s", k) } else { err = fmt.E...
[ "func", "Merge", "(", "dest", "*", "FlagSet", ",", "flagsets", "...", "*", "FlagSet", ")", "error", "{", "for", "_", ",", "fset", ":=", "range", "flagsets", "{", "if", "fset", ".", "formal", "==", "nil", "{", "continue", "\n", "}", "\n", "for", "k"...
// Merge is an helper function that merges n FlagSets into a single dest FlagSet // In case of name collision between the flagsets it will apply // the destination FlagSet's errorHandling behavior.
[ "Merge", "is", "an", "helper", "function", "that", "merges", "n", "FlagSets", "into", "a", "single", "dest", "FlagSet", "In", "case", "of", "name", "collision", "between", "the", "flagsets", "it", "will", "apply", "the", "destination", "FlagSet", "s", "error...
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/mflag/flag.go#L1242-L1275
train
docker/libnetwork
sandbox_dns_unix.go
rebuildDNS
func (sb *sandbox) rebuildDNS() error { currRC, err := resolvconf.GetSpecific(sb.config.resolvConfPath) if err != nil { return err } if len(sb.extDNS) == 0 { sb.setExternalResolvers(currRC.Content, types.IPv4, false) } var ( dnsList = []string{sb.resolver.NameServer()} dnsOptionsList = resolvconf....
go
func (sb *sandbox) rebuildDNS() error { currRC, err := resolvconf.GetSpecific(sb.config.resolvConfPath) if err != nil { return err } if len(sb.extDNS) == 0 { sb.setExternalResolvers(currRC.Content, types.IPv4, false) } var ( dnsList = []string{sb.resolver.NameServer()} dnsOptionsList = resolvconf....
[ "func", "(", "sb", "*", "sandbox", ")", "rebuildDNS", "(", ")", "error", "{", "currRC", ",", "err", ":=", "resolvconf", ".", "GetSpecific", "(", "sb", ".", "config", ".", "resolvConfPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\...
// Embedded DNS server has to be enabled for this sandbox. Rebuild the container's // resolv.conf by doing the following // - Add only the embedded server's IP to container's resolv.conf // - If the embedded server needs any resolv.conf options add it to the current list
[ "Embedded", "DNS", "server", "has", "to", "be", "enabled", "for", "this", "sandbox", ".", "Rebuild", "the", "container", "s", "resolv", ".", "conf", "by", "doing", "the", "following", "-", "Add", "only", "the", "embedded", "server", "s", "IP", "to", "con...
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox_dns_unix.go#L351-L405
train
docker/libnetwork
client/client.go
NewNetworkCli
func NewNetworkCli(out, err io.Writer, call CallFunc) *NetworkCli { return &NetworkCli{ out: out, err: err, call: call, } }
go
func NewNetworkCli(out, err io.Writer, call CallFunc) *NetworkCli { return &NetworkCli{ out: out, err: err, call: call, } }
[ "func", "NewNetworkCli", "(", "out", ",", "err", "io", ".", "Writer", ",", "call", "CallFunc", ")", "*", "NetworkCli", "{", "return", "&", "NetworkCli", "{", "out", ":", "out", ",", "err", ":", "err", ",", "call", ":", "call", ",", "}", "\n", "}" ]
// NewNetworkCli is a convenient function to create a NetworkCli object
[ "NewNetworkCli", "is", "a", "convenient", "function", "to", "create", "a", "NetworkCli", "object" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/client.go#L25-L31
train
docker/libnetwork
client/client.go
getMethod
func (cli *NetworkCli) getMethod(args ...string) (func(string, ...string) error, bool) { camelArgs := make([]string, len(args)) for i, s := range args { if len(s) == 0 { return nil, false } camelArgs[i] = strings.ToUpper(s[:1]) + strings.ToLower(s[1:]) } methodName := "Cmd" + strings.Join(camelArgs, "") m...
go
func (cli *NetworkCli) getMethod(args ...string) (func(string, ...string) error, bool) { camelArgs := make([]string, len(args)) for i, s := range args { if len(s) == 0 { return nil, false } camelArgs[i] = strings.ToUpper(s[:1]) + strings.ToLower(s[1:]) } methodName := "Cmd" + strings.Join(camelArgs, "") m...
[ "func", "(", "cli", "*", "NetworkCli", ")", "getMethod", "(", "args", "...", "string", ")", "(", "func", "(", "string", ",", "...", "string", ")", "error", ",", "bool", ")", "{", "camelArgs", ":=", "make", "(", "[", "]", "string", ",", "len", "(", ...
// getMethod is Borrowed from Docker UI which uses reflection to identify the UI Handler
[ "getMethod", "is", "Borrowed", "from", "Docker", "UI", "which", "uses", "reflection", "to", "identify", "the", "UI", "Handler" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/client.go#L34-L48
train
docker/libnetwork
client/client.go
Cmd
func (cli *NetworkCli) Cmd(chain string, args ...string) error { if len(args) > 2 { method, exists := cli.getMethod(args[:3]...) if exists { return method(chain+" "+args[0]+" "+args[1], args[3:]...) } } if len(args) > 1 { method, exists := cli.getMethod(args[:2]...) if exists { return method(chain+" ...
go
func (cli *NetworkCli) Cmd(chain string, args ...string) error { if len(args) > 2 { method, exists := cli.getMethod(args[:3]...) if exists { return method(chain+" "+args[0]+" "+args[1], args[3:]...) } } if len(args) > 1 { method, exists := cli.getMethod(args[:2]...) if exists { return method(chain+" ...
[ "func", "(", "cli", "*", "NetworkCli", ")", "Cmd", "(", "chain", "string", ",", "args", "...", "string", ")", "error", "{", "if", "len", "(", "args", ")", ">", "2", "{", "method", ",", "exists", ":=", "cli", ".", "getMethod", "(", "args", "[", ":...
// Cmd is borrowed from Docker UI and acts as the entry point for network UI commands. // network UI commands are designed to be invoked from multiple parent chains
[ "Cmd", "is", "borrowed", "from", "Docker", "UI", "and", "acts", "as", "the", "entry", "point", "for", "network", "UI", "commands", ".", "network", "UI", "commands", "are", "designed", "to", "be", "invoked", "from", "multiple", "parent", "chains" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/client.go#L52-L74
train
docker/libnetwork
client/client.go
Subcmd
func (cli *NetworkCli) Subcmd(chain, name, signature, description string, exitOnError bool) *flag.FlagSet { var errorHandling flag.ErrorHandling if exitOnError { errorHandling = flag.ExitOnError } else { errorHandling = flag.ContinueOnError } flags := flag.NewFlagSet(name, errorHandling) flags.Usage = func() ...
go
func (cli *NetworkCli) Subcmd(chain, name, signature, description string, exitOnError bool) *flag.FlagSet { var errorHandling flag.ErrorHandling if exitOnError { errorHandling = flag.ExitOnError } else { errorHandling = flag.ContinueOnError } flags := flag.NewFlagSet(name, errorHandling) flags.Usage = func() ...
[ "func", "(", "cli", "*", "NetworkCli", ")", "Subcmd", "(", "chain", ",", "name", ",", "signature", ",", "description", "string", ",", "exitOnError", "bool", ")", "*", "flag", ".", "FlagSet", "{", "var", "errorHandling", "flag", ".", "ErrorHandling", "\n", ...
// Subcmd is borrowed from Docker UI and performs the same function of configuring the subCmds
[ "Subcmd", "is", "borrowed", "from", "Docker", "UI", "and", "performs", "the", "same", "function", "of", "configuring", "the", "subCmds" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/client.go#L77-L101
train
docker/libnetwork
etchosts/etchosts.go
WriteTo
func (r Record) WriteTo(w io.Writer) (int64, error) { n, err := fmt.Fprintf(w, "%s\t%s\n", r.IP, r.Hosts) return int64(n), err }
go
func (r Record) WriteTo(w io.Writer) (int64, error) { n, err := fmt.Fprintf(w, "%s\t%s\n", r.IP, r.Hosts) return int64(n), err }
[ "func", "(", "r", "Record", ")", "WriteTo", "(", "w", "io", ".", "Writer", ")", "(", "int64", ",", "error", ")", "{", "n", ",", "err", ":=", "fmt", ".", "Fprintf", "(", "w", ",", "\"", "\\t", "\\n", "\"", ",", "r", ".", "IP", ",", "r", ".",...
// WriteTo writes record to file and returns bytes written or error
[ "WriteTo", "writes", "record", "to", "file", "and", "returns", "bytes", "written", "or", "error" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/etchosts/etchosts.go#L22-L25
train
docker/libnetwork
etchosts/etchosts.go
Drop
func Drop(path string) { pathMutex.Lock() defer pathMutex.Unlock() delete(pathMap, path) }
go
func Drop(path string) { pathMutex.Lock() defer pathMutex.Unlock() delete(pathMap, path) }
[ "func", "Drop", "(", "path", "string", ")", "{", "pathMutex", ".", "Lock", "(", ")", "\n", "defer", "pathMutex", ".", "Unlock", "(", ")", "\n\n", "delete", "(", "pathMap", ",", "path", ")", "\n", "}" ]
// Drop drops the path string from the path cache
[ "Drop", "drops", "the", "path", "string", "from", "the", "path", "cache" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/etchosts/etchosts.go#L63-L68
train
docker/libnetwork
etchosts/etchosts.go
Build
func Build(path, IP, hostname, domainname string, extraContent []Record) error { defer pathLock(path)() content := bytes.NewBuffer(nil) if IP != "" { //set main record var mainRec Record mainRec.IP = IP // User might have provided a FQDN in hostname or split it across hostname // and domainname. We want ...
go
func Build(path, IP, hostname, domainname string, extraContent []Record) error { defer pathLock(path)() content := bytes.NewBuffer(nil) if IP != "" { //set main record var mainRec Record mainRec.IP = IP // User might have provided a FQDN in hostname or split it across hostname // and domainname. We want ...
[ "func", "Build", "(", "path", ",", "IP", ",", "hostname", ",", "domainname", "string", ",", "extraContent", "[", "]", "Record", ")", "error", "{", "defer", "pathLock", "(", "path", ")", "(", ")", "\n\n", "content", ":=", "bytes", ".", "NewBuffer", "(",...
// Build function // path is path to host file string required // IP, hostname, and domainname set main record leave empty for no master record // extraContent is an array of extra host records.
[ "Build", "function", "path", "is", "path", "to", "host", "file", "string", "required", "IP", "hostname", "and", "domainname", "set", "main", "record", "leave", "empty", "for", "no", "master", "record", "extraContent", "is", "an", "array", "of", "extra", "hos...
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/etchosts/etchosts.go#L74-L112
train
docker/libnetwork
etchosts/etchosts.go
Update
func Update(path, IP, hostname string) error { defer pathLock(path)() old, err := ioutil.ReadFile(path) if err != nil { return err } var re = regexp.MustCompile(fmt.Sprintf("(\\S*)(\\t%s)(\\s|\\.)", regexp.QuoteMeta(hostname))) return ioutil.WriteFile(path, re.ReplaceAll(old, []byte(IP+"$2"+"$3")), 0644) }
go
func Update(path, IP, hostname string) error { defer pathLock(path)() old, err := ioutil.ReadFile(path) if err != nil { return err } var re = regexp.MustCompile(fmt.Sprintf("(\\S*)(\\t%s)(\\s|\\.)", regexp.QuoteMeta(hostname))) return ioutil.WriteFile(path, re.ReplaceAll(old, []byte(IP+"$2"+"$3")), 0644) }
[ "func", "Update", "(", "path", ",", "IP", ",", "hostname", "string", ")", "error", "{", "defer", "pathLock", "(", "path", ")", "(", ")", "\n\n", "old", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", ...
// Update all IP addresses where hostname matches. // path is path to host file // IP is new IP address // hostname is hostname to search for to replace IP
[ "Update", "all", "IP", "addresses", "where", "hostname", "matches", ".", "path", "is", "path", "to", "host", "file", "IP", "is", "new", "IP", "address", "hostname", "is", "hostname", "to", "search", "for", "to", "replace", "IP" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/etchosts/etchosts.go#L199-L208
train
docker/libnetwork
drivers/overlay/overlay.go
restoreEndpoints
func (d *driver) restoreEndpoints() error { if d.localStore == nil { logrus.Warn("Cannot restore overlay endpoints because local datastore is missing") return nil } kvol, err := d.localStore.List(datastore.Key(overlayEndpointPrefix), &endpoint{}) if err != nil && err != datastore.ErrKeyNotFound { return fmt.E...
go
func (d *driver) restoreEndpoints() error { if d.localStore == nil { logrus.Warn("Cannot restore overlay endpoints because local datastore is missing") return nil } kvol, err := d.localStore.List(datastore.Key(overlayEndpointPrefix), &endpoint{}) if err != nil && err != datastore.ErrKeyNotFound { return fmt.E...
[ "func", "(", "d", "*", "driver", ")", "restoreEndpoints", "(", ")", "error", "{", "if", "d", ".", "localStore", "==", "nil", "{", "logrus", ".", "Warn", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}", "\n", "kvol", ",", "err", ":=", "d", ...
// Endpoints are stored in the local store. Restore them and reconstruct the overlay sandbox
[ "Endpoints", "are", "stored", "in", "the", "local", "store", ".", "Restore", "them", "and", "reconstruct", "the", "overlay", "sandbox" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/overlay/overlay.go#L111-L160
train
docker/libnetwork
drivers/overlay/overlay.go
Fini
func Fini(drv driverapi.Driver) { d := drv.(*driver) // Notify the peer go routine to return if d.peerOpCancel != nil { d.peerOpCancel() } if d.exitCh != nil { waitCh := make(chan struct{}) d.exitCh <- waitCh <-waitCh } }
go
func Fini(drv driverapi.Driver) { d := drv.(*driver) // Notify the peer go routine to return if d.peerOpCancel != nil { d.peerOpCancel() } if d.exitCh != nil { waitCh := make(chan struct{}) d.exitCh <- waitCh <-waitCh } }
[ "func", "Fini", "(", "drv", "driverapi", ".", "Driver", ")", "{", "d", ":=", "drv", ".", "(", "*", "driver", ")", "\n\n", "// Notify the peer go routine to return", "if", "d", ".", "peerOpCancel", "!=", "nil", "{", "d", ".", "peerOpCancel", "(", ")", "\n...
// Fini cleans up the driver resources
[ "Fini", "cleans", "up", "the", "driver", "resources" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/overlay/overlay.go#L163-L178
train
docker/libnetwork
drivers/host/host.go
Init
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error { c := driverapi.Capability{ DataScope: datastore.LocalScope, ConnectivityScope: datastore.LocalScope, } return dc.RegisterDriver(networkType, &driver{}, c) }
go
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error { c := driverapi.Capability{ DataScope: datastore.LocalScope, ConnectivityScope: datastore.LocalScope, } return dc.RegisterDriver(networkType, &driver{}, c) }
[ "func", "Init", "(", "dc", "driverapi", ".", "DriverCallback", ",", "config", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "c", ":=", "driverapi", ".", "Capability", "{", "DataScope", ":", "datastore", ".", "LocalScope", ",", "Con...
// Init registers a new instance of host driver
[ "Init", "registers", "a", "new", "instance", "of", "host", "driver" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/host/host.go#L20-L26
train
docker/libnetwork
drivers/bridge/interface.go
newInterface
func newInterface(nlh *netlink.Handle, config *networkConfiguration) (*bridgeInterface, error) { var err error i := &bridgeInterface{nlh: nlh} // Initialize the bridge name to the default if unspecified. if config.BridgeName == "" { config.BridgeName = DefaultBridgeName } // Attempt to find an existing bridge...
go
func newInterface(nlh *netlink.Handle, config *networkConfiguration) (*bridgeInterface, error) { var err error i := &bridgeInterface{nlh: nlh} // Initialize the bridge name to the default if unspecified. if config.BridgeName == "" { config.BridgeName = DefaultBridgeName } // Attempt to find an existing bridge...
[ "func", "newInterface", "(", "nlh", "*", "netlink", ".", "Handle", ",", "config", "*", "networkConfiguration", ")", "(", "*", "bridgeInterface", ",", "error", ")", "{", "var", "err", "error", "\n", "i", ":=", "&", "bridgeInterface", "{", "nlh", ":", "nlh...
// newInterface creates a new bridge interface structure. It attempts to find // an already existing device identified by the configuration BridgeName field, // or the default bridge name when unspecified, but doesn't attempt to create // one when missing
[ "newInterface", "creates", "a", "new", "bridge", "interface", "structure", ".", "It", "attempts", "to", "find", "an", "already", "existing", "device", "identified", "by", "the", "configuration", "BridgeName", "field", "or", "the", "default", "bridge", "name", "w...
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/bridge/interface.go#L31-L48
train
docker/libnetwork
drivers/bridge/interface.go
addresses
func (i *bridgeInterface) addresses() ([]netlink.Addr, []netlink.Addr, error) { v4addr, err := i.nlh.AddrList(i.Link, netlink.FAMILY_V4) if err != nil { return nil, nil, fmt.Errorf("Failed to retrieve V4 addresses: %v", err) } v6addr, err := i.nlh.AddrList(i.Link, netlink.FAMILY_V6) if err != nil { return nil...
go
func (i *bridgeInterface) addresses() ([]netlink.Addr, []netlink.Addr, error) { v4addr, err := i.nlh.AddrList(i.Link, netlink.FAMILY_V4) if err != nil { return nil, nil, fmt.Errorf("Failed to retrieve V4 addresses: %v", err) } v6addr, err := i.nlh.AddrList(i.Link, netlink.FAMILY_V6) if err != nil { return nil...
[ "func", "(", "i", "*", "bridgeInterface", ")", "addresses", "(", ")", "(", "[", "]", "netlink", ".", "Addr", ",", "[", "]", "netlink", ".", "Addr", ",", "error", ")", "{", "v4addr", ",", "err", ":=", "i", ".", "nlh", ".", "AddrList", "(", "i", ...
// addresses returns all IPv4 addresses and all IPv6 addresses for the bridge interface.
[ "addresses", "returns", "all", "IPv4", "addresses", "and", "all", "IPv6", "addresses", "for", "the", "bridge", "interface", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/bridge/interface.go#L56-L71
train
docker/libnetwork
diagnostic/server.go
Init
func (s *Server) Init() { s.mux = http.NewServeMux() // Register local handlers s.RegisterHandler(s, diagPaths2Func) }
go
func (s *Server) Init() { s.mux = http.NewServeMux() // Register local handlers s.RegisterHandler(s, diagPaths2Func) }
[ "func", "(", "s", "*", "Server", ")", "Init", "(", ")", "{", "s", ".", "mux", "=", "http", ".", "NewServeMux", "(", ")", "\n\n", "// Register local handlers", "s", ".", "RegisterHandler", "(", "s", ",", "diagPaths2Func", ")", "\n", "}" ]
// Init initialize the mux for the http handling and register the base hooks
[ "Init", "initialize", "the", "mux", "for", "the", "http", "handling", "and", "register", "the", "base", "hooks" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/diagnostic/server.go#L55-L60
train
docker/libnetwork
diagnostic/server.go
RegisterHandler
func (s *Server) RegisterHandler(ctx interface{}, hdlrs map[string]HTTPHandlerFunc) { s.Lock() defer s.Unlock() for path, fun := range hdlrs { if _, ok := s.registeredHanders[path]; ok { continue } s.mux.Handle(path, httpHandlerCustom{ctx, fun}) s.registeredHanders[path] = true } }
go
func (s *Server) RegisterHandler(ctx interface{}, hdlrs map[string]HTTPHandlerFunc) { s.Lock() defer s.Unlock() for path, fun := range hdlrs { if _, ok := s.registeredHanders[path]; ok { continue } s.mux.Handle(path, httpHandlerCustom{ctx, fun}) s.registeredHanders[path] = true } }
[ "func", "(", "s", "*", "Server", ")", "RegisterHandler", "(", "ctx", "interface", "{", "}", ",", "hdlrs", "map", "[", "string", "]", "HTTPHandlerFunc", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "for", ...
// RegisterHandler allows to register new handlers to the mux and to a specific path
[ "RegisterHandler", "allows", "to", "register", "new", "handlers", "to", "the", "mux", "and", "to", "a", "specific", "path" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/diagnostic/server.go#L63-L73
train
docker/libnetwork
diagnostic/server.go
EnableDiagnostic
func (s *Server) EnableDiagnostic(ip string, port int) { s.Lock() defer s.Unlock() s.port = port if s.enable == 1 { logrus.Info("The server is already up and running") return } logrus.Infof("Starting the diagnostic server listening on %d for commands", port) srv := &http.Server{Addr: fmt.Sprintf("%s:%d", ...
go
func (s *Server) EnableDiagnostic(ip string, port int) { s.Lock() defer s.Unlock() s.port = port if s.enable == 1 { logrus.Info("The server is already up and running") return } logrus.Infof("Starting the diagnostic server listening on %d for commands", port) srv := &http.Server{Addr: fmt.Sprintf("%s:%d", ...
[ "func", "(", "s", "*", "Server", ")", "EnableDiagnostic", "(", "ip", "string", ",", "port", "int", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n\n", "s", ".", "port", "=", "port", "\n\n", "if", "s", ".",...
// EnableDiagnostic opens a TCP socket to debug the passed network DB
[ "EnableDiagnostic", "opens", "a", "TCP", "socket", "to", "debug", "the", "passed", "network", "DB" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/diagnostic/server.go#L82-L104
train
docker/libnetwork
diagnostic/server.go
DisableDiagnostic
func (s *Server) DisableDiagnostic() { s.Lock() defer s.Unlock() s.srv.Shutdown(context.Background()) s.srv = nil s.enable = 0 logrus.Info("Disabling the diagnostic server") }
go
func (s *Server) DisableDiagnostic() { s.Lock() defer s.Unlock() s.srv.Shutdown(context.Background()) s.srv = nil s.enable = 0 logrus.Info("Disabling the diagnostic server") }
[ "func", "(", "s", "*", "Server", ")", "DisableDiagnostic", "(", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n\n", "s", ".", "srv", ".", "Shutdown", "(", "context", ".", "Background", "(", ")", ")", "\n", ...
// DisableDiagnostic stop the dubug and closes the tcp socket
[ "DisableDiagnostic", "stop", "the", "dubug", "and", "closes", "the", "tcp", "socket" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/diagnostic/server.go#L107-L115
train
docker/libnetwork
diagnostic/server.go
IsDiagnosticEnabled
func (s *Server) IsDiagnosticEnabled() bool { s.Lock() defer s.Unlock() return s.enable == 1 }
go
func (s *Server) IsDiagnosticEnabled() bool { s.Lock() defer s.Unlock() return s.enable == 1 }
[ "func", "(", "s", "*", "Server", ")", "IsDiagnosticEnabled", "(", ")", "bool", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "return", "s", ".", "enable", "==", "1", "\n", "}" ]
// IsDiagnosticEnabled returns true when the debug is enabled
[ "IsDiagnosticEnabled", "returns", "true", "when", "the", "debug", "is", "enabled" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/diagnostic/server.go#L118-L122
train
docker/libnetwork
diagnostic/server.go
DebugHTTPForm
func DebugHTTPForm(r *http.Request) { for k, v := range r.Form { logrus.Debugf("Form[%q] = %q\n", k, v) } }
go
func DebugHTTPForm(r *http.Request) { for k, v := range r.Form { logrus.Debugf("Form[%q] = %q\n", k, v) } }
[ "func", "DebugHTTPForm", "(", "r", "*", "http", ".", "Request", ")", "{", "for", "k", ",", "v", ":=", "range", "r", ".", "Form", "{", "logrus", ".", "Debugf", "(", "\"", "\\n", "\"", ",", "k", ",", "v", ")", "\n", "}", "\n", "}" ]
// DebugHTTPForm helper to print the form url parameters
[ "DebugHTTPForm", "helper", "to", "print", "the", "form", "url", "parameters" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/diagnostic/server.go#L183-L187
train
docker/libnetwork
diagnostic/server.go
ParseHTTPFormOptions
func ParseHTTPFormOptions(r *http.Request) (bool, *JSONOutput) { _, unsafe := r.Form["unsafe"] v, json := r.Form["json"] var pretty bool if len(v) > 0 { pretty = v[0] == "pretty" } return unsafe, &JSONOutput{enable: json, prettyPrint: pretty} }
go
func ParseHTTPFormOptions(r *http.Request) (bool, *JSONOutput) { _, unsafe := r.Form["unsafe"] v, json := r.Form["json"] var pretty bool if len(v) > 0 { pretty = v[0] == "pretty" } return unsafe, &JSONOutput{enable: json, prettyPrint: pretty} }
[ "func", "ParseHTTPFormOptions", "(", "r", "*", "http", ".", "Request", ")", "(", "bool", ",", "*", "JSONOutput", ")", "{", "_", ",", "unsafe", ":=", "r", ".", "Form", "[", "\"", "\"", "]", "\n", "v", ",", "json", ":=", "r", ".", "Form", "[", "\...
// ParseHTTPFormOptions easily parse the JSON printing options
[ "ParseHTTPFormOptions", "easily", "parse", "the", "JSON", "printing", "options" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/diagnostic/server.go#L196-L204
train
docker/libnetwork
diagnostic/server.go
HTTPReply
func HTTPReply(w http.ResponseWriter, r *HTTPResult, j *JSONOutput) (int, error) { var response []byte if j.enable { w.Header().Set("Content-Type", "application/json") var err error if j.prettyPrint { response, err = json.MarshalIndent(r, "", " ") if err != nil { response, _ = json.MarshalIndent(Fail...
go
func HTTPReply(w http.ResponseWriter, r *HTTPResult, j *JSONOutput) (int, error) { var response []byte if j.enable { w.Header().Set("Content-Type", "application/json") var err error if j.prettyPrint { response, err = json.MarshalIndent(r, "", " ") if err != nil { response, _ = json.MarshalIndent(Fail...
[ "func", "HTTPReply", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "HTTPResult", ",", "j", "*", "JSONOutput", ")", "(", "int", ",", "error", ")", "{", "var", "response", "[", "]", "byte", "\n", "if", "j", ".", "enable", "{", "w", ".", "...
// HTTPReply helper function that takes care of sending the message out
[ "HTTPReply", "helper", "function", "that", "takes", "care", "of", "sending", "the", "message", "out" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/diagnostic/server.go#L207-L227
train
docker/libnetwork
ipams/remote/remote.go
GetDefaultAddressSpaces
func (a *allocator) GetDefaultAddressSpaces() (string, string, error) { res := &api.GetAddressSpacesResponse{} if err := a.call("GetDefaultAddressSpaces", nil, res); err != nil { return "", "", err } return res.LocalDefaultAddressSpace, res.GlobalDefaultAddressSpace, nil }
go
func (a *allocator) GetDefaultAddressSpaces() (string, string, error) { res := &api.GetAddressSpacesResponse{} if err := a.call("GetDefaultAddressSpaces", nil, res); err != nil { return "", "", err } return res.LocalDefaultAddressSpace, res.GlobalDefaultAddressSpace, nil }
[ "func", "(", "a", "*", "allocator", ")", "GetDefaultAddressSpaces", "(", ")", "(", "string", ",", "string", ",", "error", ")", "{", "res", ":=", "&", "api", ".", "GetAddressSpacesResponse", "{", "}", "\n", "if", "err", ":=", "a", ".", "call", "(", "\...
// GetDefaultAddressSpaces returns the local and global default address spaces
[ "GetDefaultAddressSpaces", "returns", "the", "local", "and", "global", "default", "address", "spaces" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipams/remote/remote.go#L111-L117
train
docker/libnetwork
ipams/remote/remote.go
RequestPool
func (a *allocator) RequestPool(addressSpace, pool, subPool string, options map[string]string, v6 bool) (string, *net.IPNet, map[string]string, error) { req := &api.RequestPoolRequest{AddressSpace: addressSpace, Pool: pool, SubPool: subPool, Options: options, V6: v6} res := &api.RequestPoolResponse{} if err := a.cal...
go
func (a *allocator) RequestPool(addressSpace, pool, subPool string, options map[string]string, v6 bool) (string, *net.IPNet, map[string]string, error) { req := &api.RequestPoolRequest{AddressSpace: addressSpace, Pool: pool, SubPool: subPool, Options: options, V6: v6} res := &api.RequestPoolResponse{} if err := a.cal...
[ "func", "(", "a", "*", "allocator", ")", "RequestPool", "(", "addressSpace", ",", "pool", ",", "subPool", "string", ",", "options", "map", "[", "string", "]", "string", ",", "v6", "bool", ")", "(", "string", ",", "*", "net", ".", "IPNet", ",", "map",...
// RequestPool requests an address pool in the specified address space
[ "RequestPool", "requests", "an", "address", "pool", "in", "the", "specified", "address", "space" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipams/remote/remote.go#L120-L128
train
docker/libnetwork
ipams/remote/remote.go
ReleasePool
func (a *allocator) ReleasePool(poolID string) error { req := &api.ReleasePoolRequest{PoolID: poolID} res := &api.ReleasePoolResponse{} return a.call("ReleasePool", req, res) }
go
func (a *allocator) ReleasePool(poolID string) error { req := &api.ReleasePoolRequest{PoolID: poolID} res := &api.ReleasePoolResponse{} return a.call("ReleasePool", req, res) }
[ "func", "(", "a", "*", "allocator", ")", "ReleasePool", "(", "poolID", "string", ")", "error", "{", "req", ":=", "&", "api", ".", "ReleasePoolRequest", "{", "PoolID", ":", "poolID", "}", "\n", "res", ":=", "&", "api", ".", "ReleasePoolResponse", "{", "...
// ReleasePool removes an address pool from the specified address space
[ "ReleasePool", "removes", "an", "address", "pool", "from", "the", "specified", "address", "space" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipams/remote/remote.go#L131-L135
train
docker/libnetwork
ipams/remote/remote.go
RequestAddress
func (a *allocator) RequestAddress(poolID string, address net.IP, options map[string]string) (*net.IPNet, map[string]string, error) { var ( prefAddress string retAddress *net.IPNet err error ) if address != nil { prefAddress = address.String() } req := &api.RequestAddressRequest{PoolID: poolID, Ad...
go
func (a *allocator) RequestAddress(poolID string, address net.IP, options map[string]string) (*net.IPNet, map[string]string, error) { var ( prefAddress string retAddress *net.IPNet err error ) if address != nil { prefAddress = address.String() } req := &api.RequestAddressRequest{PoolID: poolID, Ad...
[ "func", "(", "a", "*", "allocator", ")", "RequestAddress", "(", "poolID", "string", ",", "address", "net", ".", "IP", ",", "options", "map", "[", "string", "]", "string", ")", "(", "*", "net", ".", "IPNet", ",", "map", "[", "string", "]", "string", ...
// RequestAddress requests an address from the address pool
[ "RequestAddress", "requests", "an", "address", "from", "the", "address", "pool" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipams/remote/remote.go#L138-L158
train
docker/libnetwork
ipams/remote/remote.go
ReleaseAddress
func (a *allocator) ReleaseAddress(poolID string, address net.IP) error { var relAddress string if address != nil { relAddress = address.String() } req := &api.ReleaseAddressRequest{PoolID: poolID, Address: relAddress} res := &api.ReleaseAddressResponse{} return a.call("ReleaseAddress", req, res) }
go
func (a *allocator) ReleaseAddress(poolID string, address net.IP) error { var relAddress string if address != nil { relAddress = address.String() } req := &api.ReleaseAddressRequest{PoolID: poolID, Address: relAddress} res := &api.ReleaseAddressResponse{} return a.call("ReleaseAddress", req, res) }
[ "func", "(", "a", "*", "allocator", ")", "ReleaseAddress", "(", "poolID", "string", ",", "address", "net", ".", "IP", ")", "error", "{", "var", "relAddress", "string", "\n", "if", "address", "!=", "nil", "{", "relAddress", "=", "address", ".", "String", ...
// ReleaseAddress releases the address from the specified address pool
[ "ReleaseAddress", "releases", "the", "address", "from", "the", "specified", "address", "pool" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipams/remote/remote.go#L161-L169
train
docker/libnetwork
diagnostic/types.go
FailCommand
func FailCommand(err error) *HTTPResult { return &HTTPResult{ Message: "FAIL", Details: &ErrorCmd{Error: err.Error()}, } }
go
func FailCommand(err error) *HTTPResult { return &HTTPResult{ Message: "FAIL", Details: &ErrorCmd{Error: err.Error()}, } }
[ "func", "FailCommand", "(", "err", "error", ")", "*", "HTTPResult", "{", "return", "&", "HTTPResult", "{", "Message", ":", "\"", "\"", ",", "Details", ":", "&", "ErrorCmd", "{", "Error", ":", "err", ".", "Error", "(", ")", "}", ",", "}", "\n", "}" ...
// FailCommand creates a failure message with error
[ "FailCommand", "creates", "a", "failure", "message", "with", "error" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/diagnostic/types.go#L19-L24
train
docker/libnetwork
diagnostic/types.go
WrongCommand
func WrongCommand(message, usage string) *HTTPResult { return &HTTPResult{ Message: message, Details: &UsageCmd{Usage: usage}, } }
go
func WrongCommand(message, usage string) *HTTPResult { return &HTTPResult{ Message: message, Details: &UsageCmd{Usage: usage}, } }
[ "func", "WrongCommand", "(", "message", ",", "usage", "string", ")", "*", "HTTPResult", "{", "return", "&", "HTTPResult", "{", "Message", ":", "message", ",", "Details", ":", "&", "UsageCmd", "{", "Usage", ":", "usage", "}", ",", "}", "\n", "}" ]
// WrongCommand creates a wrong command response
[ "WrongCommand", "creates", "a", "wrong", "command", "response" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/diagnostic/types.go#L27-L32
train
docker/libnetwork
drivers/bridge/bridge.go
Init
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error { d := newDriver() if err := d.configure(config); err != nil { return err } c := driverapi.Capability{ DataScope: datastore.LocalScope, ConnectivityScope: datastore.LocalScope, } return dc.RegisterDriver(networkType, d, c) ...
go
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error { d := newDriver() if err := d.configure(config); err != nil { return err } c := driverapi.Capability{ DataScope: datastore.LocalScope, ConnectivityScope: datastore.LocalScope, } return dc.RegisterDriver(networkType, d, c) ...
[ "func", "Init", "(", "dc", "driverapi", ".", "DriverCallback", ",", "config", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "d", ":=", "newDriver", "(", ")", "\n", "if", "err", ":=", "d", ".", "configure", "(", "config", ")", ...
// Init registers a new instance of bridge driver
[ "Init", "registers", "a", "new", "instance", "of", "bridge", "driver" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/bridge/bridge.go#L159-L170
train
docker/libnetwork
drivers/bridge/bridge.go
Validate
func (c *networkConfiguration) Validate() error { if c.Mtu < 0 { return ErrInvalidMtu(c.Mtu) } // If bridge v4 subnet is specified if c.AddressIPv4 != nil { // If default gw is specified, it must be part of bridge subnet if c.DefaultGatewayIPv4 != nil { if !c.AddressIPv4.Contains(c.DefaultGatewayIPv4) { ...
go
func (c *networkConfiguration) Validate() error { if c.Mtu < 0 { return ErrInvalidMtu(c.Mtu) } // If bridge v4 subnet is specified if c.AddressIPv4 != nil { // If default gw is specified, it must be part of bridge subnet if c.DefaultGatewayIPv4 != nil { if !c.AddressIPv4.Contains(c.DefaultGatewayIPv4) { ...
[ "func", "(", "c", "*", "networkConfiguration", ")", "Validate", "(", ")", "error", "{", "if", "c", ".", "Mtu", "<", "0", "{", "return", "ErrInvalidMtu", "(", "c", ".", "Mtu", ")", "\n", "}", "\n\n", "// If bridge v4 subnet is specified", "if", "c", ".", ...
// Validate performs a static validation on the network configuration parameters. // Whatever can be assessed a priori before attempting any programming.
[ "Validate", "performs", "a", "static", "validation", "on", "the", "network", "configuration", "parameters", ".", "Whatever", "can", "be", "assessed", "a", "priori", "before", "attempting", "any", "programming", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/bridge/bridge.go#L174-L196
train
docker/libnetwork
drivers/bridge/bridge.go
Conflicts
func (c *networkConfiguration) Conflicts(o *networkConfiguration) error { if o == nil { return errors.New("same configuration") } // Also empty, because only one network with empty name is allowed if c.BridgeName == o.BridgeName { return errors.New("networks have same bridge name") } // They must be in diff...
go
func (c *networkConfiguration) Conflicts(o *networkConfiguration) error { if o == nil { return errors.New("same configuration") } // Also empty, because only one network with empty name is allowed if c.BridgeName == o.BridgeName { return errors.New("networks have same bridge name") } // They must be in diff...
[ "func", "(", "c", "*", "networkConfiguration", ")", "Conflicts", "(", "o", "*", "networkConfiguration", ")", "error", "{", "if", "o", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Also empty, because only on...
// Conflicts check if two NetworkConfiguration objects overlap
[ "Conflicts", "check", "if", "two", "NetworkConfiguration", "objects", "overlap" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/bridge/bridge.go#L199-L222
train
docker/libnetwork
drivers/bridge/bridge.go
getV6Network
func getV6Network(config *networkConfiguration, i *bridgeInterface) *net.IPNet { if config.AddressIPv6 != nil { return config.AddressIPv6 } if i.bridgeIPv6 != nil && i.bridgeIPv6.IP != nil && !i.bridgeIPv6.IP.IsLinkLocalUnicast() { return i.bridgeIPv6 } return nil }
go
func getV6Network(config *networkConfiguration, i *bridgeInterface) *net.IPNet { if config.AddressIPv6 != nil { return config.AddressIPv6 } if i.bridgeIPv6 != nil && i.bridgeIPv6.IP != nil && !i.bridgeIPv6.IP.IsLinkLocalUnicast() { return i.bridgeIPv6 } return nil }
[ "func", "getV6Network", "(", "config", "*", "networkConfiguration", ",", "i", "*", "bridgeInterface", ")", "*", "net", ".", "IPNet", "{", "if", "config", ".", "AddressIPv6", "!=", "nil", "{", "return", "config", ".", "AddressIPv6", "\n", "}", "\n", "if", ...
// Returns the non link-local IPv6 subnet for the containers attached to this bridge if found, nil otherwise
[ "Returns", "the", "non", "link", "-", "local", "IPv6", "subnet", "for", "the", "containers", "attached", "to", "this", "bridge", "if", "found", "nil", "otherwise" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/bridge/bridge.go#L509-L518
train
docker/libnetwork
drivers/bridge/bridge.go
CreateNetwork
func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error { if len(ipV4Data) == 0 || ipV4Data[0].Pool.String() == "0.0.0.0/0" { return types.BadRequestErrorf("ipv4 pool is empty") } // Sanity checks d.Lock() if _, ok := d....
go
func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error { if len(ipV4Data) == 0 || ipV4Data[0].Pool.String() == "0.0.0.0/0" { return types.BadRequestErrorf("ipv4 pool is empty") } // Sanity checks d.Lock() if _, ok := d....
[ "func", "(", "d", "*", "driver", ")", "CreateNetwork", "(", "id", "string", ",", "option", "map", "[", "string", "]", "interface", "{", "}", ",", "nInfo", "driverapi", ".", "NetworkInfo", ",", "ipV4Data", ",", "ipV6Data", "[", "]", "driverapi", ".", "I...
// Create a new network using bridge plugin
[ "Create", "a", "new", "network", "using", "bridge", "plugin" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/bridge/bridge.go#L548-L592
train
docker/libnetwork
service.go
assignIPToEndpoint
func (s *service) assignIPToEndpoint(ip, eID string) (bool, int) { return s.ipToEndpoint.Insert(ip, eID) }
go
func (s *service) assignIPToEndpoint(ip, eID string) (bool, int) { return s.ipToEndpoint.Insert(ip, eID) }
[ "func", "(", "s", "*", "service", ")", "assignIPToEndpoint", "(", "ip", ",", "eID", "string", ")", "(", "bool", ",", "int", ")", "{", "return", "s", ".", "ipToEndpoint", ".", "Insert", "(", "ip", ",", "eID", ")", "\n", "}" ]
// assignIPToEndpoint inserts the mapping between the IP and the endpoint identifier // returns true if the mapping was not present, false otherwise // returns also the number of endpoints associated to the IP
[ "assignIPToEndpoint", "inserts", "the", "mapping", "between", "the", "IP", "and", "the", "endpoint", "identifier", "returns", "true", "if", "the", "mapping", "was", "not", "present", "false", "otherwise", "returns", "also", "the", "number", "of", "endpoints", "a...
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/service.go#L67-L69
train
docker/libnetwork
service.go
removeIPToEndpoint
func (s *service) removeIPToEndpoint(ip, eID string) (bool, int) { return s.ipToEndpoint.Remove(ip, eID) }
go
func (s *service) removeIPToEndpoint(ip, eID string) (bool, int) { return s.ipToEndpoint.Remove(ip, eID) }
[ "func", "(", "s", "*", "service", ")", "removeIPToEndpoint", "(", "ip", ",", "eID", "string", ")", "(", "bool", ",", "int", ")", "{", "return", "s", ".", "ipToEndpoint", ".", "Remove", "(", "ip", ",", "eID", ")", "\n", "}" ]
// removeIPToEndpoint removes the mapping between the IP and the endpoint identifier // returns true if the mapping was deleted, false otherwise // returns also the number of endpoints associated to the IP
[ "removeIPToEndpoint", "removes", "the", "mapping", "between", "the", "IP", "and", "the", "endpoint", "identifier", "returns", "true", "if", "the", "mapping", "was", "deleted", "false", "otherwise", "returns", "also", "the", "number", "of", "endpoints", "associated...
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/service.go#L74-L76
train
docker/libnetwork
controller.go
New
func New(cfgOptions ...config.Option) (NetworkController, error) { c := &controller{ id: stringid.GenerateRandomID(), cfg: config.ParseConfigOptions(cfgOptions...), sandboxes: sandboxTable{}, svcRecords: make(map[string]svcInfo), serviceBindings: make(map[serviceKey]*...
go
func New(cfgOptions ...config.Option) (NetworkController, error) { c := &controller{ id: stringid.GenerateRandomID(), cfg: config.ParseConfigOptions(cfgOptions...), sandboxes: sandboxTable{}, svcRecords: make(map[string]svcInfo), serviceBindings: make(map[serviceKey]*...
[ "func", "New", "(", "cfgOptions", "...", "config", ".", "Option", ")", "(", "NetworkController", ",", "error", ")", "{", "c", ":=", "&", "controller", "{", "id", ":", "stringid", ".", "GenerateRandomID", "(", ")", ",", "cfg", ":", "config", ".", "Parse...
// New creates a new instance of network controller.
[ "New", "creates", "a", "new", "instance", "of", "network", "controller", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/controller.go#L189-L256
train
docker/libnetwork
controller.go
SetKeys
func (c *controller) SetKeys(keys []*types.EncryptionKey) error { subsysKeys := make(map[string]int) for _, key := range keys { if key.Subsystem != subsysGossip && key.Subsystem != subsysIPSec { return fmt.Errorf("key received for unrecognized subsystem") } subsysKeys[key.Subsystem]++ } for s, count := ...
go
func (c *controller) SetKeys(keys []*types.EncryptionKey) error { subsysKeys := make(map[string]int) for _, key := range keys { if key.Subsystem != subsysGossip && key.Subsystem != subsysIPSec { return fmt.Errorf("key received for unrecognized subsystem") } subsysKeys[key.Subsystem]++ } for s, count := ...
[ "func", "(", "c", "*", "controller", ")", "SetKeys", "(", "keys", "[", "]", "*", "types", ".", "EncryptionKey", ")", "error", "{", "subsysKeys", ":=", "make", "(", "map", "[", "string", "]", "int", ")", "\n", "for", "_", ",", "key", ":=", "range", ...
// libnetwork side of agent depends on the keys. On the first receipt of // keys setup the agent. For subsequent key set handle the key change
[ "libnetwork", "side", "of", "agent", "depends", "on", "the", "keys", ".", "On", "the", "first", "receipt", "of", "keys", "setup", "the", "agent", ".", "For", "subsequent", "key", "set", "handle", "the", "key", "change" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/controller.go#L285-L309
train
docker/libnetwork
controller.go
AgentInitWait
func (c *controller) AgentInitWait() { c.Lock() agentInitDone := c.agentInitDone c.Unlock() if agentInitDone != nil { <-agentInitDone } }
go
func (c *controller) AgentInitWait() { c.Lock() agentInitDone := c.agentInitDone c.Unlock() if agentInitDone != nil { <-agentInitDone } }
[ "func", "(", "c", "*", "controller", ")", "AgentInitWait", "(", ")", "{", "c", ".", "Lock", "(", ")", "\n", "agentInitDone", ":=", "c", ".", "agentInitDone", "\n", "c", ".", "Unlock", "(", ")", "\n\n", "if", "agentInitDone", "!=", "nil", "{", "<-", ...
// AgentInitWait waits for agent initialization to be completed in the controller.
[ "AgentInitWait", "waits", "for", "agent", "initialization", "to", "be", "completed", "in", "the", "controller", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/controller.go#L367-L375
train
docker/libnetwork
controller.go
AgentStopWait
func (c *controller) AgentStopWait() { c.Lock() agentStopDone := c.agentStopDone c.Unlock() if agentStopDone != nil { <-agentStopDone } }
go
func (c *controller) AgentStopWait() { c.Lock() agentStopDone := c.agentStopDone c.Unlock() if agentStopDone != nil { <-agentStopDone } }
[ "func", "(", "c", "*", "controller", ")", "AgentStopWait", "(", ")", "{", "c", ".", "Lock", "(", ")", "\n", "agentStopDone", ":=", "c", ".", "agentStopDone", "\n", "c", ".", "Unlock", "(", ")", "\n", "if", "agentStopDone", "!=", "nil", "{", "<-", "...
// AgentStopWait waits for the Agent stop to be completed in the controller
[ "AgentStopWait", "waits", "for", "the", "Agent", "stop", "to", "be", "completed", "in", "the", "controller" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/controller.go#L378-L385
train
docker/libnetwork
controller.go
agentOperationStart
func (c *controller) agentOperationStart() { c.Lock() if c.agentInitDone == nil { c.agentInitDone = make(chan struct{}) } if c.agentStopDone == nil { c.agentStopDone = make(chan struct{}) } c.Unlock() }
go
func (c *controller) agentOperationStart() { c.Lock() if c.agentInitDone == nil { c.agentInitDone = make(chan struct{}) } if c.agentStopDone == nil { c.agentStopDone = make(chan struct{}) } c.Unlock() }
[ "func", "(", "c", "*", "controller", ")", "agentOperationStart", "(", ")", "{", "c", ".", "Lock", "(", ")", "\n", "if", "c", ".", "agentInitDone", "==", "nil", "{", "c", ".", "agentInitDone", "=", "make", "(", "chan", "struct", "{", "}", ")", "\n",...
// agentOperationStart marks the start of an Agent Init or Agent Stop
[ "agentOperationStart", "marks", "the", "start", "of", "an", "Agent", "Init", "or", "Agent", "Stop" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/controller.go#L388-L397
train
docker/libnetwork
controller.go
agentInitComplete
func (c *controller) agentInitComplete() { c.Lock() if c.agentInitDone != nil { close(c.agentInitDone) c.agentInitDone = nil } c.Unlock() }
go
func (c *controller) agentInitComplete() { c.Lock() if c.agentInitDone != nil { close(c.agentInitDone) c.agentInitDone = nil } c.Unlock() }
[ "func", "(", "c", "*", "controller", ")", "agentInitComplete", "(", ")", "{", "c", ".", "Lock", "(", ")", "\n", "if", "c", ".", "agentInitDone", "!=", "nil", "{", "close", "(", "c", ".", "agentInitDone", ")", "\n", "c", ".", "agentInitDone", "=", "...
// agentInitComplete notifies the successful completion of the Agent initialization
[ "agentInitComplete", "notifies", "the", "successful", "completion", "of", "the", "Agent", "initialization" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/controller.go#L400-L407
train
docker/libnetwork
controller.go
agentStopComplete
func (c *controller) agentStopComplete() { c.Lock() if c.agentStopDone != nil { close(c.agentStopDone) c.agentStopDone = nil } c.Unlock() }
go
func (c *controller) agentStopComplete() { c.Lock() if c.agentStopDone != nil { close(c.agentStopDone) c.agentStopDone = nil } c.Unlock() }
[ "func", "(", "c", "*", "controller", ")", "agentStopComplete", "(", ")", "{", "c", ".", "Lock", "(", ")", "\n", "if", "c", ".", "agentStopDone", "!=", "nil", "{", "close", "(", "c", ".", "agentStopDone", ")", "\n", "c", ".", "agentStopDone", "=", "...
// agentStopComplete notifies the successful completion of the Agent stop
[ "agentStopComplete", "notifies", "the", "successful", "completion", "of", "the", "Agent", "stop" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/controller.go#L410-L417
train
docker/libnetwork
controller.go
SandboxDestroy
func (c *controller) SandboxDestroy(id string) error { var sb *sandbox c.Lock() for _, s := range c.sandboxes { if s.containerID == id { sb = s break } } c.Unlock() // It is not an error if sandbox is not available if sb == nil { return nil } return sb.Delete() }
go
func (c *controller) SandboxDestroy(id string) error { var sb *sandbox c.Lock() for _, s := range c.sandboxes { if s.containerID == id { sb = s break } } c.Unlock() // It is not an error if sandbox is not available if sb == nil { return nil } return sb.Delete() }
[ "func", "(", "c", "*", "controller", ")", "SandboxDestroy", "(", "id", "string", ")", "error", "{", "var", "sb", "*", "sandbox", "\n", "c", ".", "Lock", "(", ")", "\n", "for", "_", ",", "s", ":=", "range", "c", ".", "sandboxes", "{", "if", "s", ...
// SandboxDestroy destroys a sandbox given a container ID
[ "SandboxDestroy", "destroys", "a", "sandbox", "given", "a", "container", "ID" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/controller.go#L1231-L1248
train