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
portmapper/mapper.go
ReMapAll
func (pm *PortMapper) ReMapAll() { pm.lock.Lock() defer pm.lock.Unlock() logrus.Debugln("Re-applying all port mappings.") for _, data := range pm.currentMappings { containerIP, containerPort := getIPAndPort(data.container) hostIP, hostPort := getIPAndPort(data.host) if err := pm.AppendForwardingTableEntry(dat...
go
func (pm *PortMapper) ReMapAll() { pm.lock.Lock() defer pm.lock.Unlock() logrus.Debugln("Re-applying all port mappings.") for _, data := range pm.currentMappings { containerIP, containerPort := getIPAndPort(data.container) hostIP, hostPort := getIPAndPort(data.host) if err := pm.AppendForwardingTableEntry(dat...
[ "func", "(", "pm", "*", "PortMapper", ")", "ReMapAll", "(", ")", "{", "pm", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "pm", ".", "lock", ".", "Unlock", "(", ")", "\n", "logrus", ".", "Debugln", "(", "\"", "\"", ")", "\n", "for", "_", ...
//ReMapAll will re-apply all port mappings
[ "ReMapAll", "will", "re", "-", "apply", "all", "port", "mappings" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/portmapper/mapper.go#L222-L233
train
docker/libnetwork
datastore/mock_store.go
Get
func (s *MockStore) Get(key string) (*store.KVPair, error) { mData := s.db[key] if mData == nil { return nil, nil } return &store.KVPair{Value: mData.Data, LastIndex: mData.Index}, nil }
go
func (s *MockStore) Get(key string) (*store.KVPair, error) { mData := s.db[key] if mData == nil { return nil, nil } return &store.KVPair{Value: mData.Data, LastIndex: mData.Index}, nil }
[ "func", "(", "s", "*", "MockStore", ")", "Get", "(", "key", "string", ")", "(", "*", "store", ".", "KVPair", ",", "error", ")", "{", "mData", ":=", "s", ".", "db", "[", "key", "]", "\n", "if", "mData", "==", "nil", "{", "return", "nil", ",", ...
// Get the value at "key", returns the last modified index // to use in conjunction to CAS calls
[ "Get", "the", "value", "at", "key", "returns", "the", "last", "modified", "index", "to", "use", "in", "conjunction", "to", "CAS", "calls" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/mock_store.go#L34-L41
train
docker/libnetwork
datastore/mock_store.go
Put
func (s *MockStore) Put(key string, value []byte, options *store.WriteOptions) error { mData := s.db[key] if mData == nil { mData = &MockData{value, 0} } mData.Index = mData.Index + 1 s.db[key] = mData return nil }
go
func (s *MockStore) Put(key string, value []byte, options *store.WriteOptions) error { mData := s.db[key] if mData == nil { mData = &MockData{value, 0} } mData.Index = mData.Index + 1 s.db[key] = mData return nil }
[ "func", "(", "s", "*", "MockStore", ")", "Put", "(", "key", "string", ",", "value", "[", "]", "byte", ",", "options", "*", "store", ".", "WriteOptions", ")", "error", "{", "mData", ":=", "s", ".", "db", "[", "key", "]", "\n", "if", "mData", "==",...
// Put a value at "key"
[ "Put", "a", "value", "at", "key" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/mock_store.go#L44-L52
train
docker/libnetwork
datastore/mock_store.go
Delete
func (s *MockStore) Delete(key string) error { delete(s.db, key) return nil }
go
func (s *MockStore) Delete(key string) error { delete(s.db, key) return nil }
[ "func", "(", "s", "*", "MockStore", ")", "Delete", "(", "key", "string", ")", "error", "{", "delete", "(", "s", ".", "db", ",", "key", ")", "\n", "return", "nil", "\n", "}" ]
// Delete a value at "key"
[ "Delete", "a", "value", "at", "key" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/mock_store.go#L55-L58
train
docker/libnetwork
datastore/mock_store.go
Exists
func (s *MockStore) Exists(key string) (bool, error) { _, ok := s.db[key] return ok, nil }
go
func (s *MockStore) Exists(key string) (bool, error) { _, ok := s.db[key] return ok, nil }
[ "func", "(", "s", "*", "MockStore", ")", "Exists", "(", "key", "string", ")", "(", "bool", ",", "error", ")", "{", "_", ",", "ok", ":=", "s", ".", "db", "[", "key", "]", "\n", "return", "ok", ",", "nil", "\n", "}" ]
// Exists checks that the key exists inside the store
[ "Exists", "checks", "that", "the", "key", "exists", "inside", "the", "store" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/mock_store.go#L61-L64
train
docker/libnetwork
datastore/mock_store.go
List
func (s *MockStore) List(prefix string) ([]*store.KVPair, error) { return nil, ErrNotImplemented }
go
func (s *MockStore) List(prefix string) ([]*store.KVPair, error) { return nil, ErrNotImplemented }
[ "func", "(", "s", "*", "MockStore", ")", "List", "(", "prefix", "string", ")", "(", "[", "]", "*", "store", ".", "KVPair", ",", "error", ")", "{", "return", "nil", ",", "ErrNotImplemented", "\n", "}" ]
// List gets a range of values at "directory"
[ "List", "gets", "a", "range", "of", "values", "at", "directory" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/mock_store.go#L67-L69
train
docker/libnetwork
datastore/mock_store.go
DeleteTree
func (s *MockStore) DeleteTree(prefix string) error { delete(s.db, prefix) return nil }
go
func (s *MockStore) DeleteTree(prefix string) error { delete(s.db, prefix) return nil }
[ "func", "(", "s", "*", "MockStore", ")", "DeleteTree", "(", "prefix", "string", ")", "error", "{", "delete", "(", "s", ".", "db", ",", "prefix", ")", "\n", "return", "nil", "\n", "}" ]
// DeleteTree deletes a range of values at "directory"
[ "DeleteTree", "deletes", "a", "range", "of", "values", "at", "directory" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/mock_store.go#L72-L75
train
docker/libnetwork
datastore/mock_store.go
Watch
func (s *MockStore) Watch(key string, stopCh <-chan struct{}) (<-chan *store.KVPair, error) { return nil, ErrNotImplemented }
go
func (s *MockStore) Watch(key string, stopCh <-chan struct{}) (<-chan *store.KVPair, error) { return nil, ErrNotImplemented }
[ "func", "(", "s", "*", "MockStore", ")", "Watch", "(", "key", "string", ",", "stopCh", "<-", "chan", "struct", "{", "}", ")", "(", "<-", "chan", "*", "store", ".", "KVPair", ",", "error", ")", "{", "return", "nil", ",", "ErrNotImplemented", "\n", "...
// Watch a single key for modifications
[ "Watch", "a", "single", "key", "for", "modifications" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/mock_store.go#L78-L80
train
docker/libnetwork
datastore/mock_store.go
WatchTree
func (s *MockStore) WatchTree(prefix string, stopCh <-chan struct{}) (<-chan []*store.KVPair, error) { return nil, ErrNotImplemented }
go
func (s *MockStore) WatchTree(prefix string, stopCh <-chan struct{}) (<-chan []*store.KVPair, error) { return nil, ErrNotImplemented }
[ "func", "(", "s", "*", "MockStore", ")", "WatchTree", "(", "prefix", "string", ",", "stopCh", "<-", "chan", "struct", "{", "}", ")", "(", "<-", "chan", "[", "]", "*", "store", ".", "KVPair", ",", "error", ")", "{", "return", "nil", ",", "ErrNotImpl...
// WatchTree triggers a watch on a range of values at "directory"
[ "WatchTree", "triggers", "a", "watch", "on", "a", "range", "of", "values", "at", "directory" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/mock_store.go#L83-L85
train
docker/libnetwork
datastore/mock_store.go
AtomicPut
func (s *MockStore) AtomicPut(key string, newValue []byte, previous *store.KVPair, options *store.WriteOptions) (bool, *store.KVPair, error) { mData := s.db[key] if previous == nil { if mData != nil { return false, nil, types.BadRequestErrorf("atomic put failed because key exists") } // Else OK. } else { i...
go
func (s *MockStore) AtomicPut(key string, newValue []byte, previous *store.KVPair, options *store.WriteOptions) (bool, *store.KVPair, error) { mData := s.db[key] if previous == nil { if mData != nil { return false, nil, types.BadRequestErrorf("atomic put failed because key exists") } // Else OK. } else { i...
[ "func", "(", "s", "*", "MockStore", ")", "AtomicPut", "(", "key", "string", ",", "newValue", "[", "]", "byte", ",", "previous", "*", "store", ".", "KVPair", ",", "options", "*", "store", ".", "WriteOptions", ")", "(", "bool", ",", "*", "store", ".", ...
// AtomicPut put a value at "key" if the key has not been // modified in the meantime, throws an error if this is the case
[ "AtomicPut", "put", "a", "value", "at", "key", "if", "the", "key", "has", "not", "been", "modified", "in", "the", "meantime", "throws", "an", "error", "if", "this", "is", "the", "case" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/mock_store.go#L94-L114
train
docker/libnetwork
datastore/mock_store.go
AtomicDelete
func (s *MockStore) AtomicDelete(key string, previous *store.KVPair) (bool, error) { mData := s.db[key] if mData != nil && mData.Index != previous.LastIndex { return false, types.BadRequestErrorf("atomic delete failed due to mismatched Index") } return true, s.Delete(key) }
go
func (s *MockStore) AtomicDelete(key string, previous *store.KVPair) (bool, error) { mData := s.db[key] if mData != nil && mData.Index != previous.LastIndex { return false, types.BadRequestErrorf("atomic delete failed due to mismatched Index") } return true, s.Delete(key) }
[ "func", "(", "s", "*", "MockStore", ")", "AtomicDelete", "(", "key", "string", ",", "previous", "*", "store", ".", "KVPair", ")", "(", "bool", ",", "error", ")", "{", "mData", ":=", "s", ".", "db", "[", "key", "]", "\n", "if", "mData", "!=", "nil...
// AtomicDelete deletes a value at "key" if the key has not // been modified in the meantime, throws an error if this is the case
[ "AtomicDelete", "deletes", "a", "value", "at", "key", "if", "the", "key", "has", "not", "been", "modified", "in", "the", "meantime", "throws", "an", "error", "if", "this", "is", "the", "case" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/datastore/mock_store.go#L118-L124
train
docker/libnetwork
resolver.go
NewResolver
func NewResolver(address string, proxyDNS bool, resolverKey string, backend DNSBackend) Resolver { return &resolver{ backend: backend, proxyDNS: proxyDNS, listenAddress: address, resolverKey: resolverKey, err: fmt.Errorf("setup not done yet"), startCh: make(chan struct{}, 1), ...
go
func NewResolver(address string, proxyDNS bool, resolverKey string, backend DNSBackend) Resolver { return &resolver{ backend: backend, proxyDNS: proxyDNS, listenAddress: address, resolverKey: resolverKey, err: fmt.Errorf("setup not done yet"), startCh: make(chan struct{}, 1), ...
[ "func", "NewResolver", "(", "address", "string", ",", "proxyDNS", "bool", ",", "resolverKey", "string", ",", "backend", "DNSBackend", ")", "Resolver", "{", "return", "&", "resolver", "{", "backend", ":", "backend", ",", "proxyDNS", ":", "proxyDNS", ",", "lis...
// NewResolver creates a new instance of the Resolver
[ "NewResolver", "creates", "a", "new", "instance", "of", "the", "Resolver" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/resolver.go#L102-L111
train
docker/libnetwork
ipam/utils.go
generateAddress
func generateAddress(ordinal uint64, network *net.IPNet) net.IP { var address [16]byte // Get network portion of IP if getAddressVersion(network.IP) == v4 { copy(address[:], network.IP.To4()) } else { copy(address[:], network.IP) } end := len(network.Mask) addIntToIP(address[:end], ordinal) return net.IP...
go
func generateAddress(ordinal uint64, network *net.IPNet) net.IP { var address [16]byte // Get network portion of IP if getAddressVersion(network.IP) == v4 { copy(address[:], network.IP.To4()) } else { copy(address[:], network.IP) } end := len(network.Mask) addIntToIP(address[:end], ordinal) return net.IP...
[ "func", "generateAddress", "(", "ordinal", "uint64", ",", "network", "*", "net", ".", "IPNet", ")", "net", ".", "IP", "{", "var", "address", "[", "16", "]", "byte", "\n\n", "// Get network portion of IP", "if", "getAddressVersion", "(", "network", ".", "IP",...
// It generates the ip address in the passed subnet specified by // the passed host address ordinal
[ "It", "generates", "the", "ip", "address", "in", "the", "passed", "subnet", "specified", "by", "the", "passed", "host", "address", "ordinal" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipam/utils.go#L41-L55
train
docker/libnetwork
ipam/utils.go
addIntToIP
func addIntToIP(array []byte, ordinal uint64) { for i := len(array) - 1; i >= 0; i-- { array[i] |= (byte)(ordinal & 0xff) ordinal >>= 8 } }
go
func addIntToIP(array []byte, ordinal uint64) { for i := len(array) - 1; i >= 0; i-- { array[i] |= (byte)(ordinal & 0xff) ordinal >>= 8 } }
[ "func", "addIntToIP", "(", "array", "[", "]", "byte", ",", "ordinal", "uint64", ")", "{", "for", "i", ":=", "len", "(", "array", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", "{", "array", "[", "i", "]", "|=", "(", "byte", ")", "(", "...
// Adds the ordinal IP to the current array // 192.168.0.0 + 53 => 192.168.0.53
[ "Adds", "the", "ordinal", "IP", "to", "the", "current", "array", "192", ".", "168", ".", "0", ".", "0", "+", "53", "=", ">", "192", ".", "168", ".", "0", ".", "53" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipam/utils.go#L66-L71
train
docker/libnetwork
ipam/utils.go
ipToUint64
func ipToUint64(ip []byte) (value uint64) { cip := types.GetMinimalIP(ip) for i := 0; i < len(cip); i++ { j := len(cip) - 1 - i value += uint64(cip[i]) << uint(j*8) } return value }
go
func ipToUint64(ip []byte) (value uint64) { cip := types.GetMinimalIP(ip) for i := 0; i < len(cip); i++ { j := len(cip) - 1 - i value += uint64(cip[i]) << uint(j*8) } return value }
[ "func", "ipToUint64", "(", "ip", "[", "]", "byte", ")", "(", "value", "uint64", ")", "{", "cip", ":=", "types", ".", "GetMinimalIP", "(", "ip", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "cip", ")", ";", "i", "++", "{", "j",...
// Convert an ordinal to the respective IP address
[ "Convert", "an", "ordinal", "to", "the", "respective", "IP", "address" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipam/utils.go#L74-L81
train
docker/libnetwork
netlabel/labels.go
Key
func Key(label string) (key string) { if kv := strings.SplitN(label, "=", 2); len(kv) > 0 { key = kv[0] } return }
go
func Key(label string) (key string) { if kv := strings.SplitN(label, "=", 2); len(kv) > 0 { key = kv[0] } return }
[ "func", "Key", "(", "label", "string", ")", "(", "key", "string", ")", "{", "if", "kv", ":=", "strings", ".", "SplitN", "(", "label", ",", "\"", "\"", ",", "2", ")", ";", "len", "(", "kv", ")", ">", "0", "{", "key", "=", "kv", "[", "0", "]"...
// Key extracts the key portion of the label
[ "Key", "extracts", "the", "key", "portion", "of", "the", "label" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/netlabel/labels.go#L105-L110
train
docker/libnetwork
netlabel/labels.go
Value
func Value(label string) (value string) { if kv := strings.SplitN(label, "=", 2); len(kv) > 1 { value = kv[1] } return }
go
func Value(label string) (value string) { if kv := strings.SplitN(label, "=", 2); len(kv) > 1 { value = kv[1] } return }
[ "func", "Value", "(", "label", "string", ")", "(", "value", "string", ")", "{", "if", "kv", ":=", "strings", ".", "SplitN", "(", "label", ",", "\"", "\"", ",", "2", ")", ";", "len", "(", "kv", ")", ">", "1", "{", "value", "=", "kv", "[", "1",...
// Value extracts the value portion of the label
[ "Value", "extracts", "the", "value", "portion", "of", "the", "label" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/netlabel/labels.go#L113-L118
train
docker/libnetwork
ipams/windowsipam/windowsipam.go
GetInit
func GetInit(ipamName string) func(ic ipamapi.Callback, l, g interface{}) error { return func(ic ipamapi.Callback, l, g interface{}) error { return ic.RegisterIpamDriver(ipamName, &allocator{}) } }
go
func GetInit(ipamName string) func(ic ipamapi.Callback, l, g interface{}) error { return func(ic ipamapi.Callback, l, g interface{}) error { return ic.RegisterIpamDriver(ipamName, &allocator{}) } }
[ "func", "GetInit", "(", "ipamName", "string", ")", "func", "(", "ic", "ipamapi", ".", "Callback", ",", "l", ",", "g", "interface", "{", "}", ")", "error", "{", "return", "func", "(", "ic", "ipamapi", ".", "Callback", ",", "l", ",", "g", "interface", ...
// GetInit registers the built-in ipam service with libnetwork
[ "GetInit", "registers", "the", "built", "-", "in", "ipam", "service", "with", "libnetwork" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipams/windowsipam/windowsipam.go#L28-L32
train
docker/libnetwork
ipams/windowsipam/windowsipam.go
RequestPool
func (a *allocator) RequestPool(addressSpace, pool, subPool string, options map[string]string, v6 bool) (string, *net.IPNet, map[string]string, error) { logrus.Debugf("RequestPool(%s, %s, %s, %v, %t)", addressSpace, pool, subPool, options, v6) if subPool != "" || v6 { return "", nil, nil, types.InternalErrorf("This...
go
func (a *allocator) RequestPool(addressSpace, pool, subPool string, options map[string]string, v6 bool) (string, *net.IPNet, map[string]string, error) { logrus.Debugf("RequestPool(%s, %s, %s, %v, %t)", addressSpace, pool, subPool, options, v6) if subPool != "" || v6 { return "", nil, nil, types.InternalErrorf("This...
[ "func", "(", "a", "*", "allocator", ")", "RequestPool", "(", "addressSpace", ",", "pool", ",", "subPool", "string", ",", "options", "map", "[", "string", "]", "string", ",", "v6", "bool", ")", "(", "string", ",", "*", "net", ".", "IPNet", ",", "map",...
// RequestPool returns an address pool along with its unique id. This is a null ipam driver. It allocates the // subnet user asked and does not validate anything. Doesn't support subpool allocation
[ "RequestPool", "returns", "an", "address", "pool", "along", "with", "its", "unique", "id", ".", "This", "is", "a", "null", "ipam", "driver", ".", "It", "allocates", "the", "subnet", "user", "asked", "and", "does", "not", "validate", "anything", ".", "Doesn...
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipams/windowsipam/windowsipam.go#L40-L59
train
docker/libnetwork
ipams/windowsipam/windowsipam.go
ReleasePool
func (a *allocator) ReleasePool(poolID string) error { logrus.Debugf("ReleasePool(%s)", poolID) return nil }
go
func (a *allocator) ReleasePool(poolID string) error { logrus.Debugf("ReleasePool(%s)", poolID) return nil }
[ "func", "(", "a", "*", "allocator", ")", "ReleasePool", "(", "poolID", "string", ")", "error", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "poolID", ")", "\n", "return", "nil", "\n", "}" ]
// ReleasePool releases the address pool - always succeeds
[ "ReleasePool", "releases", "the", "address", "pool", "-", "always", "succeeds" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipams/windowsipam/windowsipam.go#L62-L65
train
docker/libnetwork
ipams/windowsipam/windowsipam.go
ReleaseAddress
func (a *allocator) ReleaseAddress(poolID string, address net.IP) error { logrus.Debugf("ReleaseAddress(%s, %v)", poolID, address) return nil }
go
func (a *allocator) ReleaseAddress(poolID string, address net.IP) error { logrus.Debugf("ReleaseAddress(%s, %v)", poolID, address) return nil }
[ "func", "(", "a", "*", "allocator", ")", "ReleaseAddress", "(", "poolID", "string", ",", "address", "net", ".", "IP", ")", "error", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "poolID", ",", "address", ")", "\n", "return", "nil", "\n", "}" ]
// ReleaseAddress releases the address - always succeeds
[ "ReleaseAddress", "releases", "the", "address", "-", "always", "succeeds" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipams/windowsipam/windowsipam.go#L85-L88
train
docker/libnetwork
ipams/remote/api/api.go
ToCapability
func (capRes GetCapabilityResponse) ToCapability() *ipamapi.Capability { return &ipamapi.Capability{ RequiresMACAddress: capRes.RequiresMACAddress, RequiresRequestReplay: capRes.RequiresRequestReplay, } }
go
func (capRes GetCapabilityResponse) ToCapability() *ipamapi.Capability { return &ipamapi.Capability{ RequiresMACAddress: capRes.RequiresMACAddress, RequiresRequestReplay: capRes.RequiresRequestReplay, } }
[ "func", "(", "capRes", "GetCapabilityResponse", ")", "ToCapability", "(", ")", "*", "ipamapi", ".", "Capability", "{", "return", "&", "ipamapi", ".", "Capability", "{", "RequiresMACAddress", ":", "capRes", ".", "RequiresMACAddress", ",", "RequiresRequestReplay", "...
// ToCapability converts the capability response into the internal ipam driver capability structure
[ "ToCapability", "converts", "the", "capability", "response", "into", "the", "internal", "ipam", "driver", "capability", "structure" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipams/remote/api/api.go#L30-L35
train
docker/libnetwork
driverapi/driverapi.go
IsValidType
func IsValidType(objType ObjectType) bool { switch objType { case EndpointObject: fallthrough case NetworkObject: fallthrough case OpaqueObject: return true } return false }
go
func IsValidType(objType ObjectType) bool { switch objType { case EndpointObject: fallthrough case NetworkObject: fallthrough case OpaqueObject: return true } return false }
[ "func", "IsValidType", "(", "objType", "ObjectType", ")", "bool", "{", "switch", "objType", "{", "case", "EndpointObject", ":", "fallthrough", "\n", "case", "NetworkObject", ":", "fallthrough", "\n", "case", "OpaqueObject", ":", "return", "true", "\n", "}", "\...
// IsValidType validates the passed in type against the valid object types
[ "IsValidType", "validates", "the", "passed", "in", "type", "against", "the", "valid", "object", "types" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/driverapi/driverapi.go#L203-L213
train
docker/libnetwork
network.go
Validate
func (c *IpamConf) Validate() error { if c.Gateway != "" && nil == net.ParseIP(c.Gateway) { return types.BadRequestErrorf("invalid gateway address %s in Ipam configuration", c.Gateway) } return nil }
go
func (c *IpamConf) Validate() error { if c.Gateway != "" && nil == net.ParseIP(c.Gateway) { return types.BadRequestErrorf("invalid gateway address %s in Ipam configuration", c.Gateway) } return nil }
[ "func", "(", "c", "*", "IpamConf", ")", "Validate", "(", ")", "error", "{", "if", "c", ".", "Gateway", "!=", "\"", "\"", "&&", "nil", "==", "net", ".", "ParseIP", "(", "c", ".", "Gateway", ")", "{", "return", "types", ".", "BadRequestErrorf", "(", ...
// Validate checks whether the configuration is valid
[ "Validate", "checks", "whether", "the", "configuration", "is", "valid" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/network.go#L146-L151
train
docker/libnetwork
network.go
MarshalJSON
func (i *IpamInfo) MarshalJSON() ([]byte, error) { m := map[string]interface{}{ "PoolID": i.PoolID, } v, err := json.Marshal(&i.IPAMData) if err != nil { return nil, err } m["IPAMData"] = string(v) if i.Meta != nil { m["Meta"] = i.Meta } return json.Marshal(m) }
go
func (i *IpamInfo) MarshalJSON() ([]byte, error) { m := map[string]interface{}{ "PoolID": i.PoolID, } v, err := json.Marshal(&i.IPAMData) if err != nil { return nil, err } m["IPAMData"] = string(v) if i.Meta != nil { m["Meta"] = i.Meta } return json.Marshal(m) }
[ "func", "(", "i", "*", "IpamInfo", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "m", ":=", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "i", ".", "PoolID", ",", "}", "\n", "v", ",", ...
// MarshalJSON encodes IpamInfo into json message
[ "MarshalJSON", "encodes", "IpamInfo", "into", "json", "message" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/network.go#L161-L175
train
docker/libnetwork
network.go
UnmarshalJSON
func (i *IpamInfo) UnmarshalJSON(data []byte) error { var ( m map[string]interface{} err error ) if err = json.Unmarshal(data, &m); err != nil { return err } i.PoolID = m["PoolID"].(string) if v, ok := m["Meta"]; ok { b, _ := json.Marshal(v) if err = json.Unmarshal(b, &i.Meta); err != nil { return ...
go
func (i *IpamInfo) UnmarshalJSON(data []byte) error { var ( m map[string]interface{} err error ) if err = json.Unmarshal(data, &m); err != nil { return err } i.PoolID = m["PoolID"].(string) if v, ok := m["Meta"]; ok { b, _ := json.Marshal(v) if err = json.Unmarshal(b, &i.Meta); err != nil { return ...
[ "func", "(", "i", "*", "IpamInfo", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "(", "m", "map", "[", "string", "]", "interface", "{", "}", "\n", "err", "error", "\n", ")", "\n", "if", "err", "=", "json", ".", ...
// UnmarshalJSON decodes json message into PoolData
[ "UnmarshalJSON", "decodes", "json", "message", "into", "PoolData" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/network.go#L178-L199
train
docker/libnetwork
network.go
CopyTo
func (c *IpamConf) CopyTo(dstC *IpamConf) error { dstC.PreferredPool = c.PreferredPool dstC.SubPool = c.SubPool dstC.Gateway = c.Gateway if c.AuxAddresses != nil { dstC.AuxAddresses = make(map[string]string, len(c.AuxAddresses)) for k, v := range c.AuxAddresses { dstC.AuxAddresses[k] = v } } return nil }
go
func (c *IpamConf) CopyTo(dstC *IpamConf) error { dstC.PreferredPool = c.PreferredPool dstC.SubPool = c.SubPool dstC.Gateway = c.Gateway if c.AuxAddresses != nil { dstC.AuxAddresses = make(map[string]string, len(c.AuxAddresses)) for k, v := range c.AuxAddresses { dstC.AuxAddresses[k] = v } } return nil }
[ "func", "(", "c", "*", "IpamConf", ")", "CopyTo", "(", "dstC", "*", "IpamConf", ")", "error", "{", "dstC", ".", "PreferredPool", "=", "c", ".", "PreferredPool", "\n", "dstC", ".", "SubPool", "=", "c", ".", "SubPool", "\n", "dstC", ".", "Gateway", "="...
// CopyTo deep copies to the destination IpamConfig
[ "CopyTo", "deep", "copies", "to", "the", "destination", "IpamConfig" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/network.go#L335-L346
train
docker/libnetwork
network.go
CopyTo
func (i *IpamInfo) CopyTo(dstI *IpamInfo) error { dstI.PoolID = i.PoolID if i.Meta != nil { dstI.Meta = make(map[string]string) for k, v := range i.Meta { dstI.Meta[k] = v } } dstI.AddressSpace = i.AddressSpace dstI.Pool = types.GetIPNetCopy(i.Pool) dstI.Gateway = types.GetIPNetCopy(i.Gateway) if i.Au...
go
func (i *IpamInfo) CopyTo(dstI *IpamInfo) error { dstI.PoolID = i.PoolID if i.Meta != nil { dstI.Meta = make(map[string]string) for k, v := range i.Meta { dstI.Meta[k] = v } } dstI.AddressSpace = i.AddressSpace dstI.Pool = types.GetIPNetCopy(i.Pool) dstI.Gateway = types.GetIPNetCopy(i.Gateway) if i.Au...
[ "func", "(", "i", "*", "IpamInfo", ")", "CopyTo", "(", "dstI", "*", "IpamInfo", ")", "error", "{", "dstI", ".", "PoolID", "=", "i", ".", "PoolID", "\n", "if", "i", ".", "Meta", "!=", "nil", "{", "dstI", ".", "Meta", "=", "make", "(", "map", "["...
// CopyTo deep copies to the destination IpamInfo
[ "CopyTo", "deep", "copies", "to", "the", "destination", "IpamInfo" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/network.go#L349-L370
train
docker/libnetwork
network.go
applyConfigurationTo
func (n *network) applyConfigurationTo(to *network) error { to.enableIPv6 = n.enableIPv6 if len(n.labels) > 0 { to.labels = make(map[string]string, len(n.labels)) for k, v := range n.labels { if _, ok := to.labels[k]; !ok { to.labels[k] = v } } } if len(n.ipamType) != 0 { to.ipamType = n.ipamType ...
go
func (n *network) applyConfigurationTo(to *network) error { to.enableIPv6 = n.enableIPv6 if len(n.labels) > 0 { to.labels = make(map[string]string, len(n.labels)) for k, v := range n.labels { if _, ok := to.labels[k]; !ok { to.labels[k] = v } } } if len(n.ipamType) != 0 { to.ipamType = n.ipamType ...
[ "func", "(", "n", "*", "network", ")", "applyConfigurationTo", "(", "to", "*", "network", ")", "error", "{", "to", ".", "enableIPv6", "=", "n", ".", "enableIPv6", "\n", "if", "len", "(", "n", ".", "labels", ")", ">", "0", "{", "to", ".", "labels", ...
// Applies network specific configurations
[ "Applies", "network", "specific", "configurations" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/network.go#L420-L456
train
docker/libnetwork
network.go
NetworkOptionGeneric
func NetworkOptionGeneric(generic map[string]interface{}) NetworkOption { return func(n *network) { if n.generic == nil { n.generic = make(map[string]interface{}) } if val, ok := generic[netlabel.EnableIPv6]; ok { n.enableIPv6 = val.(bool) } if val, ok := generic[netlabel.Internal]; ok { n.internal ...
go
func NetworkOptionGeneric(generic map[string]interface{}) NetworkOption { return func(n *network) { if n.generic == nil { n.generic = make(map[string]interface{}) } if val, ok := generic[netlabel.EnableIPv6]; ok { n.enableIPv6 = val.(bool) } if val, ok := generic[netlabel.Internal]; ok { n.internal ...
[ "func", "NetworkOptionGeneric", "(", "generic", "map", "[", "string", "]", "interface", "{", "}", ")", "NetworkOption", "{", "return", "func", "(", "n", "*", "network", ")", "{", "if", "n", ".", "generic", "==", "nil", "{", "n", ".", "generic", "=", ...
// NetworkOptionGeneric function returns an option setter for a Generic option defined // in a Dictionary of Key-Value pair
[ "NetworkOptionGeneric", "function", "returns", "an", "option", "setter", "for", "a", "Generic", "option", "defined", "in", "a", "Dictionary", "of", "Key", "-", "Value", "pair" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/network.go#L733-L748
train
docker/libnetwork
network.go
NetworkOptionEnableIPv6
func NetworkOptionEnableIPv6(enableIPv6 bool) NetworkOption { return func(n *network) { if n.generic == nil { n.generic = make(map[string]interface{}) } n.enableIPv6 = enableIPv6 n.generic[netlabel.EnableIPv6] = enableIPv6 } }
go
func NetworkOptionEnableIPv6(enableIPv6 bool) NetworkOption { return func(n *network) { if n.generic == nil { n.generic = make(map[string]interface{}) } n.enableIPv6 = enableIPv6 n.generic[netlabel.EnableIPv6] = enableIPv6 } }
[ "func", "NetworkOptionEnableIPv6", "(", "enableIPv6", "bool", ")", "NetworkOption", "{", "return", "func", "(", "n", "*", "network", ")", "{", "if", "n", ".", "generic", "==", "nil", "{", "n", ".", "generic", "=", "make", "(", "map", "[", "string", "]"...
// NetworkOptionEnableIPv6 returns an option setter to explicitly configure IPv6
[ "NetworkOptionEnableIPv6", "returns", "an", "option", "setter", "to", "explicitly", "configure", "IPv6" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/network.go#L766-L774
train
docker/libnetwork
network.go
NetworkOptionInternalNetwork
func NetworkOptionInternalNetwork() NetworkOption { return func(n *network) { if n.generic == nil { n.generic = make(map[string]interface{}) } n.internal = true n.generic[netlabel.Internal] = true } }
go
func NetworkOptionInternalNetwork() NetworkOption { return func(n *network) { if n.generic == nil { n.generic = make(map[string]interface{}) } n.internal = true n.generic[netlabel.Internal] = true } }
[ "func", "NetworkOptionInternalNetwork", "(", ")", "NetworkOption", "{", "return", "func", "(", "n", "*", "network", ")", "{", "if", "n", ".", "generic", "==", "nil", "{", "n", ".", "generic", "=", "make", "(", "map", "[", "string", "]", "interface", "{...
// NetworkOptionInternalNetwork returns an option setter to config the network // to be internal which disables default gateway service
[ "NetworkOptionInternalNetwork", "returns", "an", "option", "setter", "to", "config", "the", "network", "to", "be", "internal", "which", "disables", "default", "gateway", "service" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/network.go#L778-L786
train
docker/libnetwork
network.go
NetworkOptionIpam
func NetworkOptionIpam(ipamDriver string, addrSpace string, ipV4 []*IpamConf, ipV6 []*IpamConf, opts map[string]string) NetworkOption { return func(n *network) { if ipamDriver != "" { n.ipamType = ipamDriver if ipamDriver == ipamapi.DefaultIPAM { n.ipamType = defaultIpamForNetworkType(n.Type()) } } ...
go
func NetworkOptionIpam(ipamDriver string, addrSpace string, ipV4 []*IpamConf, ipV6 []*IpamConf, opts map[string]string) NetworkOption { return func(n *network) { if ipamDriver != "" { n.ipamType = ipamDriver if ipamDriver == ipamapi.DefaultIPAM { n.ipamType = defaultIpamForNetworkType(n.Type()) } } ...
[ "func", "NetworkOptionIpam", "(", "ipamDriver", "string", ",", "addrSpace", "string", ",", "ipV4", "[", "]", "*", "IpamConf", ",", "ipV6", "[", "]", "*", "IpamConf", ",", "opts", "map", "[", "string", "]", "string", ")", "NetworkOption", "{", "return", "...
// NetworkOptionIpam function returns an option setter for the ipam configuration for this network
[ "NetworkOptionIpam", "function", "returns", "an", "option", "setter", "for", "the", "ipam", "configuration", "for", "this", "network" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/network.go#L804-L817
train
docker/libnetwork
network.go
NetworkOptionLBEndpoint
func NetworkOptionLBEndpoint(ip net.IP) NetworkOption { return func(n *network) { n.loadBalancerIP = ip } }
go
func NetworkOptionLBEndpoint(ip net.IP) NetworkOption { return func(n *network) { n.loadBalancerIP = ip } }
[ "func", "NetworkOptionLBEndpoint", "(", "ip", "net", ".", "IP", ")", "NetworkOption", "{", "return", "func", "(", "n", "*", "network", ")", "{", "n", ".", "loadBalancerIP", "=", "ip", "\n", "}", "\n", "}" ]
// NetworkOptionLBEndpoint function returns an option setter for the configuration of the load balancer endpoint for this network
[ "NetworkOptionLBEndpoint", "function", "returns", "an", "option", "setter", "for", "the", "configuration", "of", "the", "load", "balancer", "endpoint", "for", "this", "network" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/network.go#L820-L824
train
docker/libnetwork
network.go
NetworkOptionDriverOpts
func NetworkOptionDriverOpts(opts map[string]string) NetworkOption { return func(n *network) { if n.generic == nil { n.generic = make(map[string]interface{}) } if opts == nil { opts = make(map[string]string) } // Store the options n.generic[netlabel.GenericData] = opts } }
go
func NetworkOptionDriverOpts(opts map[string]string) NetworkOption { return func(n *network) { if n.generic == nil { n.generic = make(map[string]interface{}) } if opts == nil { opts = make(map[string]string) } // Store the options n.generic[netlabel.GenericData] = opts } }
[ "func", "NetworkOptionDriverOpts", "(", "opts", "map", "[", "string", "]", "string", ")", "NetworkOption", "{", "return", "func", "(", "n", "*", "network", ")", "{", "if", "n", ".", "generic", "==", "nil", "{", "n", ".", "generic", "=", "make", "(", ...
// NetworkOptionDriverOpts function returns an option setter for any driver parameter described by a map
[ "NetworkOptionDriverOpts", "function", "returns", "an", "option", "setter", "for", "any", "driver", "parameter", "described", "by", "a", "map" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/network.go#L827-L838
train
docker/libnetwork
network.go
NetworkOptionLabels
func NetworkOptionLabels(labels map[string]string) NetworkOption { return func(n *network) { n.labels = labels } }
go
func NetworkOptionLabels(labels map[string]string) NetworkOption { return func(n *network) { n.labels = labels } }
[ "func", "NetworkOptionLabels", "(", "labels", "map", "[", "string", "]", "string", ")", "NetworkOption", "{", "return", "func", "(", "n", "*", "network", ")", "{", "n", ".", "labels", "=", "labels", "\n", "}", "\n", "}" ]
// NetworkOptionLabels function returns an option setter for labels specific to a network
[ "NetworkOptionLabels", "function", "returns", "an", "option", "setter", "for", "labels", "specific", "to", "a", "network" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/network.go#L841-L845
train
docker/libnetwork
network.go
getConfigNetwork
func (c *controller) getConfigNetwork(name string) (*network, error) { var n Network s := func(current Network) bool { if current.Info().ConfigOnly() && current.Name() == name { n = current return true } return false } c.WalkNetworks(s) if n == nil { return nil, types.NotFoundErrorf("configuration...
go
func (c *controller) getConfigNetwork(name string) (*network, error) { var n Network s := func(current Network) bool { if current.Info().ConfigOnly() && current.Name() == name { n = current return true } return false } c.WalkNetworks(s) if n == nil { return nil, types.NotFoundErrorf("configuration...
[ "func", "(", "c", "*", "controller", ")", "getConfigNetwork", "(", "name", "string", ")", "(", "*", "network", ",", "error", ")", "{", "var", "n", "Network", "\n\n", "s", ":=", "func", "(", "current", "Network", ")", "bool", "{", "if", "current", "."...
// config-only network is looked up by name
[ "config", "-", "only", "network", "is", "looked", "up", "by", "name" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/network.go#L2105-L2123
train
docker/libnetwork
iptables/iptables.go
NewChain
func NewChain(name string, table Table, hairpinMode bool) (*ChainInfo, error) { c := &ChainInfo{ Name: name, Table: table, HairpinMode: hairpinMode, } if string(c.Table) == "" { c.Table = Filter } // Add chain if it doesn't exist if _, err := Raw("-t", string(c.Table), "-n", "-L", c.Name); e...
go
func NewChain(name string, table Table, hairpinMode bool) (*ChainInfo, error) { c := &ChainInfo{ Name: name, Table: table, HairpinMode: hairpinMode, } if string(c.Table) == "" { c.Table = Filter } // Add chain if it doesn't exist if _, err := Raw("-t", string(c.Table), "-n", "-L", c.Name); e...
[ "func", "NewChain", "(", "name", "string", ",", "table", "Table", ",", "hairpinMode", "bool", ")", "(", "*", "ChainInfo", ",", "error", ")", "{", "c", ":=", "&", "ChainInfo", "{", "Name", ":", "name", ",", "Table", ":", "table", ",", "HairpinMode", "...
// NewChain adds a new chain to ip table.
[ "NewChain", "adds", "a", "new", "chain", "to", "ip", "table", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/iptables/iptables.go#L120-L139
train
docker/libnetwork
iptables/iptables.go
RemoveExistingChain
func RemoveExistingChain(name string, table Table) error { c := &ChainInfo{ Name: name, Table: table, } if string(c.Table) == "" { c.Table = Filter } return c.Remove() }
go
func RemoveExistingChain(name string, table Table) error { c := &ChainInfo{ Name: name, Table: table, } if string(c.Table) == "" { c.Table = Filter } return c.Remove() }
[ "func", "RemoveExistingChain", "(", "name", "string", ",", "table", "Table", ")", "error", "{", "c", ":=", "&", "ChainInfo", "{", "Name", ":", "name", ",", "Table", ":", "table", ",", "}", "\n", "if", "string", "(", "c", ".", "Table", ")", "==", "\...
// RemoveExistingChain removes existing chain from the table.
[ "RemoveExistingChain", "removes", "existing", "chain", "from", "the", "table", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/iptables/iptables.go#L227-L236
train
docker/libnetwork
iptables/iptables.go
Forward
func (c *ChainInfo) Forward(action Action, ip net.IP, port int, proto, destAddr string, destPort int, bridgeName string) error { daddr := ip.String() if ip.IsUnspecified() { // iptables interprets "0.0.0.0" as "0.0.0.0/32", whereas we // want "0.0.0.0/0". "0/0" is correctly interpreted as "any // value" by both...
go
func (c *ChainInfo) Forward(action Action, ip net.IP, port int, proto, destAddr string, destPort int, bridgeName string) error { daddr := ip.String() if ip.IsUnspecified() { // iptables interprets "0.0.0.0" as "0.0.0.0/32", whereas we // want "0.0.0.0/0". "0/0" is correctly interpreted as "any // value" by both...
[ "func", "(", "c", "*", "ChainInfo", ")", "Forward", "(", "action", "Action", ",", "ip", "net", ".", "IP", ",", "port", "int", ",", "proto", ",", "destAddr", "string", ",", "destPort", "int", ",", "bridgeName", "string", ")", "error", "{", "daddr", ":...
// Forward adds forwarding rule to 'filter' table and corresponding nat rule to 'nat' table.
[ "Forward", "adds", "forwarding", "rule", "to", "filter", "table", "and", "corresponding", "nat", "rule", "to", "nat", "table", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/iptables/iptables.go#L239-L305
train
docker/libnetwork
iptables/iptables.go
Link
func (c *ChainInfo) Link(action Action, ip1, ip2 net.IP, port int, proto string, bridgeName string) error { // forward args := []string{ "-i", bridgeName, "-o", bridgeName, "-p", proto, "-s", ip1.String(), "-d", ip2.String(), "--dport", strconv.Itoa(port), "-j", "ACCEPT", } if err := ProgramRule(Filter,...
go
func (c *ChainInfo) Link(action Action, ip1, ip2 net.IP, port int, proto string, bridgeName string) error { // forward args := []string{ "-i", bridgeName, "-o", bridgeName, "-p", proto, "-s", ip1.String(), "-d", ip2.String(), "--dport", strconv.Itoa(port), "-j", "ACCEPT", } if err := ProgramRule(Filter,...
[ "func", "(", "c", "*", "ChainInfo", ")", "Link", "(", "action", "Action", ",", "ip1", ",", "ip2", "net", ".", "IP", ",", "port", "int", ",", "proto", "string", ",", "bridgeName", "string", ")", "error", "{", "// forward", "args", ":=", "[", "]", "s...
// Link adds reciprocal ACCEPT rule for two supplied IP addresses. // Traffic is allowed from ip1 to ip2 and vice-versa
[ "Link", "adds", "reciprocal", "ACCEPT", "rule", "for", "two", "supplied", "IP", "addresses", ".", "Traffic", "is", "allowed", "from", "ip1", "to", "ip2", "and", "vice", "-", "versa" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/iptables/iptables.go#L309-L326
train
docker/libnetwork
iptables/iptables.go
ProgramRule
func ProgramRule(table Table, chain string, action Action, args []string) error { if Exists(table, chain, args...) != (action == Delete) { return nil } return RawCombinedOutput(append([]string{"-t", string(table), string(action), chain}, args...)...) }
go
func ProgramRule(table Table, chain string, action Action, args []string) error { if Exists(table, chain, args...) != (action == Delete) { return nil } return RawCombinedOutput(append([]string{"-t", string(table), string(action), chain}, args...)...) }
[ "func", "ProgramRule", "(", "table", "Table", ",", "chain", "string", ",", "action", "Action", ",", "args", "[", "]", "string", ")", "error", "{", "if", "Exists", "(", "table", ",", "chain", ",", "args", "...", ")", "!=", "(", "action", "==", "Delete...
// ProgramRule adds the rule specified by args only if the // rule is not already present in the chain. Reciprocally, // it removes the rule only if present.
[ "ProgramRule", "adds", "the", "rule", "specified", "by", "args", "only", "if", "the", "rule", "is", "not", "already", "present", "in", "the", "chain", ".", "Reciprocally", "it", "removes", "the", "rule", "only", "if", "present", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/iptables/iptables.go#L331-L336
train
docker/libnetwork
iptables/iptables.go
Remove
func (c *ChainInfo) Remove() error { // Ignore errors - This could mean the chains were never set up if c.Table == Nat { c.Prerouting(Delete, "-m", "addrtype", "--dst-type", "LOCAL", "-j", c.Name) c.Output(Delete, "-m", "addrtype", "--dst-type", "LOCAL", "!", "--dst", "127.0.0.0/8", "-j", c.Name) c.Output(Delet...
go
func (c *ChainInfo) Remove() error { // Ignore errors - This could mean the chains were never set up if c.Table == Nat { c.Prerouting(Delete, "-m", "addrtype", "--dst-type", "LOCAL", "-j", c.Name) c.Output(Delete, "-m", "addrtype", "--dst-type", "LOCAL", "!", "--dst", "127.0.0.0/8", "-j", c.Name) c.Output(Delet...
[ "func", "(", "c", "*", "ChainInfo", ")", "Remove", "(", ")", "error", "{", "// Ignore errors - This could mean the chains were never set up", "if", "c", ".", "Table", "==", "Nat", "{", "c", ".", "Prerouting", "(", "Delete", ",", "\"", "\"", ",", "\"", "\"", ...
// Remove removes the chain.
[ "Remove", "removes", "the", "chain", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/iptables/iptables.go#L367-L380
train
docker/libnetwork
iptables/iptables.go
Exists
func Exists(table Table, chain string, rule ...string) bool { return exists(false, table, chain, rule...) }
go
func Exists(table Table, chain string, rule ...string) bool { return exists(false, table, chain, rule...) }
[ "func", "Exists", "(", "table", "Table", ",", "chain", "string", ",", "rule", "...", "string", ")", "bool", "{", "return", "exists", "(", "false", ",", "table", ",", "chain", ",", "rule", "...", ")", "\n", "}" ]
// Exists checks if a rule exists
[ "Exists", "checks", "if", "a", "rule", "exists" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/iptables/iptables.go#L383-L385
train
docker/libnetwork
iptables/iptables.go
ExistsNative
func ExistsNative(table Table, chain string, rule ...string) bool { return exists(true, table, chain, rule...) }
go
func ExistsNative(table Table, chain string, rule ...string) bool { return exists(true, table, chain, rule...) }
[ "func", "ExistsNative", "(", "table", "Table", ",", "chain", "string", ",", "rule", "...", "string", ")", "bool", "{", "return", "exists", "(", "true", ",", "table", ",", "chain", ",", "rule", "...", ")", "\n", "}" ]
// ExistsNative behaves as Exists with the difference it // will always invoke `iptables` binary.
[ "ExistsNative", "behaves", "as", "Exists", "with", "the", "difference", "it", "will", "always", "invoke", "iptables", "binary", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/iptables/iptables.go#L389-L391
train
docker/libnetwork
iptables/iptables.go
Raw
func Raw(args ...string) ([]byte, error) { if firewalldRunning { startTime := time.Now() output, err := Passthrough(Iptables, args...) if err == nil || !strings.Contains(err.Error(), "was not provided by any .service files") { return filterOutput(startTime, output, args...), err } } return raw(args...) }
go
func Raw(args ...string) ([]byte, error) { if firewalldRunning { startTime := time.Now() output, err := Passthrough(Iptables, args...) if err == nil || !strings.Contains(err.Error(), "was not provided by any .service files") { return filterOutput(startTime, output, args...), err } } return raw(args...) }
[ "func", "Raw", "(", "args", "...", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "firewalldRunning", "{", "startTime", ":=", "time", ".", "Now", "(", ")", "\n", "output", ",", "err", ":=", "Passthrough", "(", "Iptables", ",", ...
// Raw calls 'iptables' system command, passing supplied arguments.
[ "Raw", "calls", "iptables", "system", "command", "passing", "supplied", "arguments", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/iptables/iptables.go#L447-L456
train
docker/libnetwork
iptables/iptables.go
RawCombinedOutput
func RawCombinedOutput(args ...string) error { if output, err := Raw(args...); err != nil || len(output) != 0 { return fmt.Errorf("%s (%v)", string(output), err) } return nil }
go
func RawCombinedOutput(args ...string) error { if output, err := Raw(args...); err != nil || len(output) != 0 { return fmt.Errorf("%s (%v)", string(output), err) } return nil }
[ "func", "RawCombinedOutput", "(", "args", "...", "string", ")", "error", "{", "if", "output", ",", "err", ":=", "Raw", "(", "args", "...", ")", ";", "err", "!=", "nil", "||", "len", "(", "output", ")", "!=", "0", "{", "return", "fmt", ".", "Errorf"...
// RawCombinedOutput internally calls the Raw function and returns a non nil // error if Raw returned a non nil error or a non empty output
[ "RawCombinedOutput", "internally", "calls", "the", "Raw", "function", "and", "returns", "a", "non", "nil", "error", "if", "Raw", "returned", "a", "non", "nil", "error", "or", "a", "non", "empty", "output" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/iptables/iptables.go#L482-L487
train
docker/libnetwork
iptables/iptables.go
RawCombinedOutputNative
func RawCombinedOutputNative(args ...string) error { if output, err := raw(args...); err != nil || len(output) != 0 { return fmt.Errorf("%s (%v)", string(output), err) } return nil }
go
func RawCombinedOutputNative(args ...string) error { if output, err := raw(args...); err != nil || len(output) != 0 { return fmt.Errorf("%s (%v)", string(output), err) } return nil }
[ "func", "RawCombinedOutputNative", "(", "args", "...", "string", ")", "error", "{", "if", "output", ",", "err", ":=", "raw", "(", "args", "...", ")", ";", "err", "!=", "nil", "||", "len", "(", "output", ")", "!=", "0", "{", "return", "fmt", ".", "E...
// RawCombinedOutputNative behave as RawCombinedOutput with the difference it // will always invoke `iptables` binary
[ "RawCombinedOutputNative", "behave", "as", "RawCombinedOutput", "with", "the", "difference", "it", "will", "always", "invoke", "iptables", "binary" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/iptables/iptables.go#L491-L496
train
docker/libnetwork
iptables/iptables.go
ExistChain
func ExistChain(chain string, table Table) bool { if _, err := Raw("-t", string(table), "-nL", chain); err == nil { return true } return false }
go
func ExistChain(chain string, table Table) bool { if _, err := Raw("-t", string(table), "-nL", chain); err == nil { return true } return false }
[ "func", "ExistChain", "(", "chain", "string", ",", "table", "Table", ")", "bool", "{", "if", "_", ",", "err", ":=", "Raw", "(", "\"", "\"", ",", "string", "(", "table", ")", ",", "\"", "\"", ",", "chain", ")", ";", "err", "==", "nil", "{", "ret...
// ExistChain checks if a chain exists
[ "ExistChain", "checks", "if", "a", "chain", "exists" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/iptables/iptables.go#L499-L504
train
docker/libnetwork
iptables/iptables.go
GetVersion
func GetVersion() (major, minor, micro int, err error) { out, err := exec.Command(iptablesPath, "--version").CombinedOutput() if err == nil { major, minor, micro = parseVersionNumbers(string(out)) } return }
go
func GetVersion() (major, minor, micro int, err error) { out, err := exec.Command(iptablesPath, "--version").CombinedOutput() if err == nil { major, minor, micro = parseVersionNumbers(string(out)) } return }
[ "func", "GetVersion", "(", ")", "(", "major", ",", "minor", ",", "micro", "int", ",", "err", "error", ")", "{", "out", ",", "err", ":=", "exec", ".", "Command", "(", "iptablesPath", ",", "\"", "\"", ")", ".", "CombinedOutput", "(", ")", "\n", "if",...
// GetVersion reads the iptables version numbers during initialization
[ "GetVersion", "reads", "the", "iptables", "version", "numbers", "during", "initialization" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/iptables/iptables.go#L507-L513
train
docker/libnetwork
iptables/iptables.go
AddReturnRule
func AddReturnRule(chain string) error { var ( table = Filter args = []string{"-j", "RETURN"} ) if Exists(table, chain, args...) { return nil } err := RawCombinedOutput(append([]string{"-A", chain}, args...)...) if err != nil { return fmt.Errorf("unable to add return rule in %s chain: %s", chain, err.E...
go
func AddReturnRule(chain string) error { var ( table = Filter args = []string{"-j", "RETURN"} ) if Exists(table, chain, args...) { return nil } err := RawCombinedOutput(append([]string{"-A", chain}, args...)...) if err != nil { return fmt.Errorf("unable to add return rule in %s chain: %s", chain, err.E...
[ "func", "AddReturnRule", "(", "chain", "string", ")", "error", "{", "var", "(", "table", "=", "Filter", "\n", "args", "=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", "}", "\n", ")", "\n\n", "if", "Exists", "(", "table", ",", "chain", "...
// AddReturnRule adds a return rule for the chain in the filter table
[ "AddReturnRule", "adds", "a", "return", "rule", "for", "the", "chain", "in", "the", "filter", "table" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/iptables/iptables.go#L537-L553
train
docker/libnetwork
iptables/iptables.go
EnsureJumpRule
func EnsureJumpRule(fromChain, toChain string) error { var ( table = Filter args = []string{"-j", toChain} ) if Exists(table, fromChain, args...) { err := RawCombinedOutput(append([]string{"-D", fromChain}, args...)...) if err != nil { return fmt.Errorf("unable to remove jump to %s rule in %s chain: %s"...
go
func EnsureJumpRule(fromChain, toChain string) error { var ( table = Filter args = []string{"-j", toChain} ) if Exists(table, fromChain, args...) { err := RawCombinedOutput(append([]string{"-D", fromChain}, args...)...) if err != nil { return fmt.Errorf("unable to remove jump to %s rule in %s chain: %s"...
[ "func", "EnsureJumpRule", "(", "fromChain", ",", "toChain", "string", ")", "error", "{", "var", "(", "table", "=", "Filter", "\n", "args", "=", "[", "]", "string", "{", "\"", "\"", ",", "toChain", "}", "\n", ")", "\n\n", "if", "Exists", "(", "table",...
// EnsureJumpRule ensures the jump rule is on top
[ "EnsureJumpRule", "ensures", "the", "jump", "rule", "is", "on", "top" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/iptables/iptables.go#L556-L575
train
docker/libnetwork
client/network.go
CmdNetwork
func (cli *NetworkCli) CmdNetwork(chain string, args ...string) error { cmd := cli.Subcmd(chain, "network", "COMMAND [OPTIONS] [arg...]", networkUsage(chain), false) cmd.Require(flag.Min, 1) err := cmd.ParseFlags(args, true) if err == nil { cmd.Usage() return fmt.Errorf("invalid command : %v", args) } return ...
go
func (cli *NetworkCli) CmdNetwork(chain string, args ...string) error { cmd := cli.Subcmd(chain, "network", "COMMAND [OPTIONS] [arg...]", networkUsage(chain), false) cmd.Require(flag.Min, 1) err := cmd.ParseFlags(args, true) if err == nil { cmd.Usage() return fmt.Errorf("invalid command : %v", args) } return ...
[ "func", "(", "cli", "*", "NetworkCli", ")", "CmdNetwork", "(", "chain", "string", ",", "args", "...", "string", ")", "error", "{", "cmd", ":=", "cli", ".", "Subcmd", "(", "chain", ",", "\"", "\"", ",", "\"", "\"", ",", "networkUsage", "(", "chain", ...
// CmdNetwork handles the root Network UI
[ "CmdNetwork", "handles", "the", "root", "Network", "UI" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/network.go#L31-L40
train
docker/libnetwork
client/network.go
CmdNetworkCreate
func (cli *NetworkCli) CmdNetworkCreate(chain string, args ...string) error { cmd := cli.Subcmd(chain, "create", "NETWORK-NAME", "Creates a new network with a name specified by the user", false) flDriver := cmd.String([]string{"d", "-driver"}, "", "Driver to manage the Network") flID := cmd.String([]string{"-id"}, "...
go
func (cli *NetworkCli) CmdNetworkCreate(chain string, args ...string) error { cmd := cli.Subcmd(chain, "create", "NETWORK-NAME", "Creates a new network with a name specified by the user", false) flDriver := cmd.String([]string{"d", "-driver"}, "", "Driver to manage the Network") flID := cmd.String([]string{"-id"}, "...
[ "func", "(", "cli", "*", "NetworkCli", ")", "CmdNetworkCreate", "(", "chain", "string", ",", "args", "...", "string", ")", "error", "{", "cmd", ":=", "cli", ".", "Subcmd", "(", "chain", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "false...
// CmdNetworkCreate handles Network Create UI
[ "CmdNetworkCreate", "handles", "Network", "Create", "UI" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/network.go#L43-L100
train
docker/libnetwork
client/network.go
CmdNetworkRm
func (cli *NetworkCli) CmdNetworkRm(chain string, args ...string) error { cmd := cli.Subcmd(chain, "rm", "NETWORK", "Deletes a network", false) cmd.Require(flag.Exact, 1) err := cmd.ParseFlags(args, true) if err != nil { return err } id, err := lookupNetworkID(cli, cmd.Arg(0)) if err != nil { return err } ...
go
func (cli *NetworkCli) CmdNetworkRm(chain string, args ...string) error { cmd := cli.Subcmd(chain, "rm", "NETWORK", "Deletes a network", false) cmd.Require(flag.Exact, 1) err := cmd.ParseFlags(args, true) if err != nil { return err } id, err := lookupNetworkID(cli, cmd.Arg(0)) if err != nil { return err } ...
[ "func", "(", "cli", "*", "NetworkCli", ")", "CmdNetworkRm", "(", "chain", "string", ",", "args", "...", "string", ")", "error", "{", "cmd", ":=", "cli", ".", "Subcmd", "(", "chain", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "false", ...
// CmdNetworkRm handles Network Delete UI
[ "CmdNetworkRm", "handles", "Network", "Delete", "UI" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/network.go#L103-L119
train
docker/libnetwork
client/network.go
CmdNetworkLs
func (cli *NetworkCli) CmdNetworkLs(chain string, args ...string) error { cmd := cli.Subcmd(chain, "ls", "", "Lists all the networks created by the user", false) quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only display numeric IDs") noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Do not truncat...
go
func (cli *NetworkCli) CmdNetworkLs(chain string, args ...string) error { cmd := cli.Subcmd(chain, "ls", "", "Lists all the networks created by the user", false) quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only display numeric IDs") noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Do not truncat...
[ "func", "(", "cli", "*", "NetworkCli", ")", "CmdNetworkLs", "(", "chain", "string", ",", "args", "...", "string", ")", "error", "{", "cmd", ":=", "cli", ".", "Subcmd", "(", "chain", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "false", ...
// CmdNetworkLs handles Network List UI
[ "CmdNetworkLs", "handles", "Network", "List", "UI" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/network.go#L122-L172
train
docker/libnetwork
client/network.go
CmdNetworkInfo
func (cli *NetworkCli) CmdNetworkInfo(chain string, args ...string) error { cmd := cli.Subcmd(chain, "info", "NETWORK", "Displays detailed information on a network", false) cmd.Require(flag.Exact, 1) err := cmd.ParseFlags(args, true) if err != nil { return err } id, err := lookupNetworkID(cli, cmd.Arg(0)) if ...
go
func (cli *NetworkCli) CmdNetworkInfo(chain string, args ...string) error { cmd := cli.Subcmd(chain, "info", "NETWORK", "Displays detailed information on a network", false) cmd.Require(flag.Exact, 1) err := cmd.ParseFlags(args, true) if err != nil { return err } id, err := lookupNetworkID(cli, cmd.Arg(0)) if ...
[ "func", "(", "cli", "*", "NetworkCli", ")", "CmdNetworkInfo", "(", "chain", "string", ",", "args", "...", "string", ")", "error", "{", "cmd", ":=", "cli", ".", "Subcmd", "(", "chain", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "false",...
// CmdNetworkInfo handles Network Info UI
[ "CmdNetworkInfo", "handles", "Network", "Info", "UI" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/network.go#L175-L207
train
docker/libnetwork
client/network.go
lookupNetworkID
func lookupNetworkID(cli *NetworkCli, nameID string) (string, error) { obj, statusCode, err := readBody(cli.call("GET", "/networks?name="+nameID, nil, nil)) if err != nil { return "", err } if statusCode != http.StatusOK { return "", fmt.Errorf("name query failed for %s due to : statuscode(%d) %v", nameID, sta...
go
func lookupNetworkID(cli *NetworkCli, nameID string) (string, error) { obj, statusCode, err := readBody(cli.call("GET", "/networks?name="+nameID, nil, nil)) if err != nil { return "", err } if statusCode != http.StatusOK { return "", fmt.Errorf("name query failed for %s due to : statuscode(%d) %v", nameID, sta...
[ "func", "lookupNetworkID", "(", "cli", "*", "NetworkCli", ",", "nameID", "string", ")", "(", "string", ",", "error", ")", "{", "obj", ",", "statusCode", ",", "err", ":=", "readBody", "(", "cli", ".", "call", "(", "\"", "\"", ",", "\"", "\"", "+", "...
// Helper function to predict if a string is a name or id or partial-id // This provides a best-effort mechanism to identify an id with the help of GET Filter APIs // Being a UI, its most likely that name will be used by the user, which is used to lookup // the corresponding ID. If ID is not found, this function will a...
[ "Helper", "function", "to", "predict", "if", "a", "string", "is", "a", "name", "or", "id", "or", "partial", "-", "id", "This", "provides", "a", "best", "-", "effort", "mechanism", "to", "identify", "an", "id", "with", "the", "help", "of", "GET", "Filte...
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/client/network.go#L215-L256
train
docker/libnetwork
drivers/ipvlan/ipvlan.go
Init
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error { c := driverapi.Capability{ DataScope: datastore.LocalScope, ConnectivityScope: datastore.GlobalScope, } d := &driver{ networks: networkTable{}, } d.initStore(config) return dc.RegisterDriver(ipvlanType, d, c) }
go
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error { c := driverapi.Capability{ DataScope: datastore.LocalScope, ConnectivityScope: datastore.GlobalScope, } d := &driver{ networks: networkTable{}, } d.initStore(config) return dc.RegisterDriver(ipvlanType, d, c) }
[ "func", "Init", "(", "dc", "driverapi", ".", "DriverCallback", ",", "config", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "c", ":=", "driverapi", ".", "Capability", "{", "DataScope", ":", "datastore", ".", "LocalScope", ",", "Con...
// Init initializes and registers the libnetwork ipvlan driver
[ "Init", "initializes", "and", "registers", "the", "libnetwork", "ipvlan", "driver" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/ipvlan/ipvlan.go#L59-L70
train
docker/libnetwork
networkdb/networkdb.go
DefaultConfig
func DefaultConfig() *Config { hostname, _ := os.Hostname() return &Config{ NodeID: stringid.TruncateID(stringid.GenerateRandomID()), Hostname: hostname, BindAddr: "0.0.0.0", PacketBufferSize: 1400, StatsPrintPeriod: 5 * time.Minute, HealthPrintPeriod: 1 * time.Minute, rea...
go
func DefaultConfig() *Config { hostname, _ := os.Hostname() return &Config{ NodeID: stringid.TruncateID(stringid.GenerateRandomID()), Hostname: hostname, BindAddr: "0.0.0.0", PacketBufferSize: 1400, StatsPrintPeriod: 5 * time.Minute, HealthPrintPeriod: 1 * time.Minute, rea...
[ "func", "DefaultConfig", "(", ")", "*", "Config", "{", "hostname", ",", "_", ":=", "os", ".", "Hostname", "(", ")", "\n", "return", "&", "Config", "{", "NodeID", ":", "stringid", ".", "TruncateID", "(", "stringid", ".", "GenerateRandomID", "(", ")", ")...
// DefaultConfig returns a NetworkDB config with default values
[ "DefaultConfig", "returns", "a", "NetworkDB", "config", "with", "default", "values" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/networkdb.go#L225-L236
train
docker/libnetwork
networkdb/networkdb.go
New
func New(c *Config) (*NetworkDB, error) { // The garbage collection logic for entries leverage the presence of the network. // For this reason the expiration time of the network is put slightly higher than the entry expiration so that // there is at least 5 extra cycle to make sure that all the entries are properly ...
go
func New(c *Config) (*NetworkDB, error) { // The garbage collection logic for entries leverage the presence of the network. // For this reason the expiration time of the network is put slightly higher than the entry expiration so that // there is at least 5 extra cycle to make sure that all the entries are properly ...
[ "func", "New", "(", "c", "*", "Config", ")", "(", "*", "NetworkDB", ",", "error", ")", "{", "// The garbage collection logic for entries leverage the presence of the network.", "// For this reason the expiration time of the network is put slightly higher than the entry expiration so th...
// New creates a new instance of NetworkDB using the Config passed by // the caller.
[ "New", "creates", "a", "new", "instance", "of", "NetworkDB", "using", "the", "Config", "passed", "by", "the", "caller", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/networkdb.go#L240-L267
train
docker/libnetwork
networkdb/networkdb.go
Close
func (nDB *NetworkDB) Close() { if err := nDB.clusterLeave(); err != nil { logrus.Errorf("%v(%v) Could not close DB: %v", nDB.config.Hostname, nDB.config.NodeID, err) } //Avoid (*Broadcaster).run goroutine leak nDB.broadcaster.Close() }
go
func (nDB *NetworkDB) Close() { if err := nDB.clusterLeave(); err != nil { logrus.Errorf("%v(%v) Could not close DB: %v", nDB.config.Hostname, nDB.config.NodeID, err) } //Avoid (*Broadcaster).run goroutine leak nDB.broadcaster.Close() }
[ "func", "(", "nDB", "*", "NetworkDB", ")", "Close", "(", ")", "{", "if", "err", ":=", "nDB", ".", "clusterLeave", "(", ")", ";", "err", "!=", "nil", "{", "logrus", ".", "Errorf", "(", "\"", "\"", ",", "nDB", ".", "config", ".", "Hostname", ",", ...
// Close destroys this NetworkDB instance by leave the cluster, // stopping timers, canceling goroutines etc.
[ "Close", "destroys", "this", "NetworkDB", "instance", "by", "leave", "the", "cluster", "stopping", "timers", "canceling", "goroutines", "etc", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/networkdb.go#L281-L288
train
docker/libnetwork
networkdb/networkdb.go
ClusterPeers
func (nDB *NetworkDB) ClusterPeers() []PeerInfo { nDB.RLock() defer nDB.RUnlock() peers := make([]PeerInfo, 0, len(nDB.nodes)) for _, node := range nDB.nodes { peers = append(peers, PeerInfo{ Name: node.Name, IP: node.Node.Addr.String(), }) } return peers }
go
func (nDB *NetworkDB) ClusterPeers() []PeerInfo { nDB.RLock() defer nDB.RUnlock() peers := make([]PeerInfo, 0, len(nDB.nodes)) for _, node := range nDB.nodes { peers = append(peers, PeerInfo{ Name: node.Name, IP: node.Node.Addr.String(), }) } return peers }
[ "func", "(", "nDB", "*", "NetworkDB", ")", "ClusterPeers", "(", ")", "[", "]", "PeerInfo", "{", "nDB", ".", "RLock", "(", ")", "\n", "defer", "nDB", ".", "RUnlock", "(", ")", "\n", "peers", ":=", "make", "(", "[", "]", "PeerInfo", ",", "0", ",", ...
// ClusterPeers returns all the gossip cluster peers.
[ "ClusterPeers", "returns", "all", "the", "gossip", "cluster", "peers", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/networkdb.go#L291-L302
train
docker/libnetwork
networkdb/networkdb.go
Peers
func (nDB *NetworkDB) Peers(nid string) []PeerInfo { nDB.RLock() defer nDB.RUnlock() peers := make([]PeerInfo, 0, len(nDB.networkNodes[nid])) for _, nodeName := range nDB.networkNodes[nid] { if node, ok := nDB.nodes[nodeName]; ok { peers = append(peers, PeerInfo{ Name: node.Name, IP: node.Addr.String...
go
func (nDB *NetworkDB) Peers(nid string) []PeerInfo { nDB.RLock() defer nDB.RUnlock() peers := make([]PeerInfo, 0, len(nDB.networkNodes[nid])) for _, nodeName := range nDB.networkNodes[nid] { if node, ok := nDB.nodes[nodeName]; ok { peers = append(peers, PeerInfo{ Name: node.Name, IP: node.Addr.String...
[ "func", "(", "nDB", "*", "NetworkDB", ")", "Peers", "(", "nid", "string", ")", "[", "]", "PeerInfo", "{", "nDB", ".", "RLock", "(", ")", "\n", "defer", "nDB", ".", "RUnlock", "(", ")", "\n", "peers", ":=", "make", "(", "[", "]", "PeerInfo", ",", ...
// Peers returns the gossip peers for a given network.
[ "Peers", "returns", "the", "gossip", "peers", "for", "a", "given", "network", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/networkdb.go#L305-L322
train
docker/libnetwork
networkdb/networkdb.go
GetTableByNetwork
func (nDB *NetworkDB) GetTableByNetwork(tname, nid string) map[string]*TableElem { entries := make(map[string]*TableElem) nDB.indexes[byTable].WalkPrefix(fmt.Sprintf("/%s/%s", tname, nid), func(k string, v interface{}) bool { entry := v.(*entry) if entry.deleting { return false } key := k[strings.LastIndex...
go
func (nDB *NetworkDB) GetTableByNetwork(tname, nid string) map[string]*TableElem { entries := make(map[string]*TableElem) nDB.indexes[byTable].WalkPrefix(fmt.Sprintf("/%s/%s", tname, nid), func(k string, v interface{}) bool { entry := v.(*entry) if entry.deleting { return false } key := k[strings.LastIndex...
[ "func", "(", "nDB", "*", "NetworkDB", ")", "GetTableByNetwork", "(", "tname", ",", "nid", "string", ")", "map", "[", "string", "]", "*", "TableElem", "{", "entries", ":=", "make", "(", "map", "[", "string", "]", "*", "TableElem", ")", "\n", "nDB", "....
// GetTableByNetwork walks the networkdb by the give table and network id and // returns a map of keys and values
[ "GetTableByNetwork", "walks", "the", "networkdb", "by", "the", "give", "table", "and", "network", "id", "and", "returns", "a", "map", "of", "keys", "and", "values" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/networkdb.go#L413-L425
train
docker/libnetwork
networkdb/networkdb.go
WalkTable
func (nDB *NetworkDB) WalkTable(tname string, fn func(string, string, []byte, bool) bool) error { nDB.RLock() values := make(map[string]interface{}) nDB.indexes[byTable].WalkPrefix(fmt.Sprintf("/%s", tname), func(path string, v interface{}) bool { values[path] = v return false }) nDB.RUnlock() for k, v := ra...
go
func (nDB *NetworkDB) WalkTable(tname string, fn func(string, string, []byte, bool) bool) error { nDB.RLock() values := make(map[string]interface{}) nDB.indexes[byTable].WalkPrefix(fmt.Sprintf("/%s", tname), func(path string, v interface{}) bool { values[path] = v return false }) nDB.RUnlock() for k, v := ra...
[ "func", "(", "nDB", "*", "NetworkDB", ")", "WalkTable", "(", "tname", "string", ",", "fn", "func", "(", "string", ",", "string", ",", "[", "]", "byte", ",", "bool", ")", "bool", ")", "error", "{", "nDB", ".", "RLock", "(", ")", "\n", "values", ":...
// WalkTable walks a single table in NetworkDB and invokes the passed // function for each entry in the table passing the network, key, // value. The walk stops if the passed function returns a true.
[ "WalkTable", "walks", "a", "single", "table", "in", "NetworkDB", "and", "invokes", "the", "passed", "function", "for", "each", "entry", "in", "the", "table", "passing", "the", "network", "key", "value", ".", "The", "walk", "stops", "if", "the", "passed", "...
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/networkdb.go#L569-L588
train
docker/libnetwork
networkdb/networkdb.go
JoinNetwork
func (nDB *NetworkDB) JoinNetwork(nid string) error { ltime := nDB.networkClock.Increment() nDB.Lock() nodeNetworks, ok := nDB.networks[nDB.config.NodeID] if !ok { nodeNetworks = make(map[string]*network) nDB.networks[nDB.config.NodeID] = nodeNetworks } n, ok := nodeNetworks[nid] var entries int if ok { ...
go
func (nDB *NetworkDB) JoinNetwork(nid string) error { ltime := nDB.networkClock.Increment() nDB.Lock() nodeNetworks, ok := nDB.networks[nDB.config.NodeID] if !ok { nodeNetworks = make(map[string]*network) nDB.networks[nDB.config.NodeID] = nodeNetworks } n, ok := nodeNetworks[nid] var entries int if ok { ...
[ "func", "(", "nDB", "*", "NetworkDB", ")", "JoinNetwork", "(", "nid", "string", ")", "error", "{", "ltime", ":=", "nDB", ".", "networkClock", ".", "Increment", "(", ")", "\n\n", "nDB", ".", "Lock", "(", ")", "\n", "nodeNetworks", ",", "ok", ":=", "nD...
// JoinNetwork joins this node to a given network and propagates this // event across the cluster. This triggers this node joining the // sub-cluster of this network and participates in the network-scoped // gossip and bulk sync for this network.
[ "JoinNetwork", "joins", "this", "node", "to", "a", "given", "network", "and", "propagates", "this", "event", "across", "the", "cluster", ".", "This", "triggers", "this", "node", "joining", "the", "sub", "-", "cluster", "of", "this", "network", "and", "partic...
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/networkdb.go#L594-L641
train
docker/libnetwork
networkdb/networkdb.go
LeaveNetwork
func (nDB *NetworkDB) LeaveNetwork(nid string) error { ltime := nDB.networkClock.Increment() if err := nDB.sendNetworkEvent(nid, NetworkEventTypeLeave, ltime); err != nil { return fmt.Errorf("failed to send leave network event for %s: %v", nid, err) } nDB.Lock() defer nDB.Unlock() // Remove myself from the li...
go
func (nDB *NetworkDB) LeaveNetwork(nid string) error { ltime := nDB.networkClock.Increment() if err := nDB.sendNetworkEvent(nid, NetworkEventTypeLeave, ltime); err != nil { return fmt.Errorf("failed to send leave network event for %s: %v", nid, err) } nDB.Lock() defer nDB.Unlock() // Remove myself from the li...
[ "func", "(", "nDB", "*", "NetworkDB", ")", "LeaveNetwork", "(", "nid", "string", ")", "error", "{", "ltime", ":=", "nDB", ".", "networkClock", ".", "Increment", "(", ")", "\n", "if", "err", ":=", "nDB", ".", "sendNetworkEvent", "(", "nid", ",", "Networ...
// LeaveNetwork leaves this node from a given network and propagates // this event across the cluster. This triggers this node leaving the // sub-cluster of this network and as a result will no longer // participate in the network-scoped gossip and bulk sync for this // network. Also remove all the table entries for th...
[ "LeaveNetwork", "leaves", "this", "node", "from", "a", "given", "network", "and", "propagates", "this", "event", "across", "the", "cluster", ".", "This", "triggers", "this", "node", "leaving", "the", "sub", "-", "cluster", "of", "this", "network", "and", "as...
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/networkdb.go#L649-L679
train
docker/libnetwork
networkdb/networkdb.go
addNetworkNode
func (nDB *NetworkDB) addNetworkNode(nid string, nodeName string) { nodes := nDB.networkNodes[nid] for _, node := range nodes { if node == nodeName { return } } nDB.networkNodes[nid] = append(nDB.networkNodes[nid], nodeName) }
go
func (nDB *NetworkDB) addNetworkNode(nid string, nodeName string) { nodes := nDB.networkNodes[nid] for _, node := range nodes { if node == nodeName { return } } nDB.networkNodes[nid] = append(nDB.networkNodes[nid], nodeName) }
[ "func", "(", "nDB", "*", "NetworkDB", ")", "addNetworkNode", "(", "nid", "string", ",", "nodeName", "string", ")", "{", "nodes", ":=", "nDB", ".", "networkNodes", "[", "nid", "]", "\n", "for", "_", ",", "node", ":=", "range", "nodes", "{", "if", "nod...
// addNetworkNode adds the node to the list of nodes which participate // in the passed network only if it is not already present. Caller // should hold the NetworkDB lock while calling this
[ "addNetworkNode", "adds", "the", "node", "to", "the", "list", "of", "nodes", "which", "participate", "in", "the", "passed", "network", "only", "if", "it", "is", "not", "already", "present", ".", "Caller", "should", "hold", "the", "NetworkDB", "lock", "while"...
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/networkdb.go#L684-L693
train
docker/libnetwork
networkdb/networkdb.go
deleteNetworkNode
func (nDB *NetworkDB) deleteNetworkNode(nid string, nodeName string) { nodes, ok := nDB.networkNodes[nid] if !ok || len(nodes) == 0 { return } newNodes := make([]string, 0, len(nodes)-1) for _, name := range nodes { if name == nodeName { continue } newNodes = append(newNodes, name) } nDB.networkNodes[...
go
func (nDB *NetworkDB) deleteNetworkNode(nid string, nodeName string) { nodes, ok := nDB.networkNodes[nid] if !ok || len(nodes) == 0 { return } newNodes := make([]string, 0, len(nodes)-1) for _, name := range nodes { if name == nodeName { continue } newNodes = append(newNodes, name) } nDB.networkNodes[...
[ "func", "(", "nDB", "*", "NetworkDB", ")", "deleteNetworkNode", "(", "nid", "string", ",", "nodeName", "string", ")", "{", "nodes", ",", "ok", ":=", "nDB", ".", "networkNodes", "[", "nid", "]", "\n", "if", "!", "ok", "||", "len", "(", "nodes", ")", ...
// Deletes the node from the list of nodes which participate in the // passed network. Caller should hold the NetworkDB lock while calling // this
[ "Deletes", "the", "node", "from", "the", "list", "of", "nodes", "which", "participate", "in", "the", "passed", "network", ".", "Caller", "should", "hold", "the", "NetworkDB", "lock", "while", "calling", "this" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/networkdb.go#L698-L711
train
docker/libnetwork
networkdb/networkdb.go
findCommonNetworks
func (nDB *NetworkDB) findCommonNetworks(nodeName string) []string { nDB.RLock() defer nDB.RUnlock() var networks []string for nid := range nDB.networks[nDB.config.NodeID] { if n, ok := nDB.networks[nodeName][nid]; ok { if !n.leaving { networks = append(networks, nid) } } } return networks }
go
func (nDB *NetworkDB) findCommonNetworks(nodeName string) []string { nDB.RLock() defer nDB.RUnlock() var networks []string for nid := range nDB.networks[nDB.config.NodeID] { if n, ok := nDB.networks[nodeName][nid]; ok { if !n.leaving { networks = append(networks, nid) } } } return networks }
[ "func", "(", "nDB", "*", "NetworkDB", ")", "findCommonNetworks", "(", "nodeName", "string", ")", "[", "]", "string", "{", "nDB", ".", "RLock", "(", ")", "\n", "defer", "nDB", ".", "RUnlock", "(", ")", "\n\n", "var", "networks", "[", "]", "string", "\...
// findCommonnetworks find the networks that both this node and the // passed node have joined.
[ "findCommonnetworks", "find", "the", "networks", "that", "both", "this", "node", "and", "the", "passed", "node", "have", "joined", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/networkdb.go#L715-L729
train
docker/libnetwork
networkdb/cluster.go
SetKey
func (nDB *NetworkDB) SetKey(key []byte) { logrus.Debugf("Adding key %.5s", hex.EncodeToString(key)) nDB.Lock() defer nDB.Unlock() for _, dbKey := range nDB.config.Keys { if bytes.Equal(key, dbKey) { return } } nDB.config.Keys = append(nDB.config.Keys, key) if nDB.keyring != nil { nDB.keyring.AddKey(key...
go
func (nDB *NetworkDB) SetKey(key []byte) { logrus.Debugf("Adding key %.5s", hex.EncodeToString(key)) nDB.Lock() defer nDB.Unlock() for _, dbKey := range nDB.config.Keys { if bytes.Equal(key, dbKey) { return } } nDB.config.Keys = append(nDB.config.Keys, key) if nDB.keyring != nil { nDB.keyring.AddKey(key...
[ "func", "(", "nDB", "*", "NetworkDB", ")", "SetKey", "(", "key", "[", "]", "byte", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "hex", ".", "EncodeToString", "(", "key", ")", ")", "\n", "nDB", ".", "Lock", "(", ")", "\n", "defer", "...
// SetKey adds a new key to the key ring
[ "SetKey", "adds", "a", "new", "key", "to", "the", "key", "ring" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/cluster.go#L57-L70
train
docker/libnetwork
networkdb/cluster.go
SetPrimaryKey
func (nDB *NetworkDB) SetPrimaryKey(key []byte) { logrus.Debugf("Primary Key %.5s", hex.EncodeToString(key)) nDB.RLock() defer nDB.RUnlock() for _, dbKey := range nDB.config.Keys { if bytes.Equal(key, dbKey) { if nDB.keyring != nil { nDB.keyring.UseKey(dbKey) } break } } }
go
func (nDB *NetworkDB) SetPrimaryKey(key []byte) { logrus.Debugf("Primary Key %.5s", hex.EncodeToString(key)) nDB.RLock() defer nDB.RUnlock() for _, dbKey := range nDB.config.Keys { if bytes.Equal(key, dbKey) { if nDB.keyring != nil { nDB.keyring.UseKey(dbKey) } break } } }
[ "func", "(", "nDB", "*", "NetworkDB", ")", "SetPrimaryKey", "(", "key", "[", "]", "byte", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "hex", ".", "EncodeToString", "(", "key", ")", ")", "\n", "nDB", ".", "RLock", "(", ")", "\n", "def...
// SetPrimaryKey sets the given key as the primary key. This should have // been added apriori through SetKey
[ "SetPrimaryKey", "sets", "the", "given", "key", "as", "the", "primary", "key", ".", "This", "should", "have", "been", "added", "apriori", "through", "SetKey" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/cluster.go#L74-L86
train
docker/libnetwork
networkdb/cluster.go
RemoveKey
func (nDB *NetworkDB) RemoveKey(key []byte) { logrus.Debugf("Remove Key %.5s", hex.EncodeToString(key)) nDB.Lock() defer nDB.Unlock() for i, dbKey := range nDB.config.Keys { if bytes.Equal(key, dbKey) { nDB.config.Keys = append(nDB.config.Keys[:i], nDB.config.Keys[i+1:]...) if nDB.keyring != nil { nDB.k...
go
func (nDB *NetworkDB) RemoveKey(key []byte) { logrus.Debugf("Remove Key %.5s", hex.EncodeToString(key)) nDB.Lock() defer nDB.Unlock() for i, dbKey := range nDB.config.Keys { if bytes.Equal(key, dbKey) { nDB.config.Keys = append(nDB.config.Keys[:i], nDB.config.Keys[i+1:]...) if nDB.keyring != nil { nDB.k...
[ "func", "(", "nDB", "*", "NetworkDB", ")", "RemoveKey", "(", "key", "[", "]", "byte", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "hex", ".", "EncodeToString", "(", "key", ")", ")", "\n", "nDB", ".", "Lock", "(", ")", "\n", "defer", ...
// RemoveKey removes a key from the key ring. The key being removed // can't be the primary key
[ "RemoveKey", "removes", "a", "key", "from", "the", "key", "ring", ".", "The", "key", "being", "removed", "can", "t", "be", "the", "primary", "key" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/cluster.go#L90-L103
train
docker/libnetwork
networkdb/cluster.go
mRandomNodes
func (nDB *NetworkDB) mRandomNodes(m int, nodes []string) []string { n := len(nodes) mNodes := make([]string, 0, m) OUTER: // Probe up to 3*n times, with large n this is not necessary // since k << n, but with small n we want search to be // exhaustive for i := 0; i < 3*n && len(mNodes) < m; i++ { // Get random...
go
func (nDB *NetworkDB) mRandomNodes(m int, nodes []string) []string { n := len(nodes) mNodes := make([]string, 0, m) OUTER: // Probe up to 3*n times, with large n this is not necessary // since k << n, but with small n we want search to be // exhaustive for i := 0; i < 3*n && len(mNodes) < m; i++ { // Get random...
[ "func", "(", "nDB", "*", "NetworkDB", ")", "mRandomNodes", "(", "m", "int", ",", "nodes", "[", "]", "string", ")", "[", "]", "string", "{", "n", ":=", "len", "(", "nodes", ")", "\n", "mNodes", ":=", "make", "(", "[", "]", "string", ",", "0", ",...
// mRandomNodes is used to select up to m random nodes. It is possible // that less than m nodes are returned.
[ "mRandomNodes", "is", "used", "to", "select", "up", "to", "m", "random", "nodes", ".", "It", "is", "possible", "that", "less", "than", "m", "nodes", "are", "returned", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/cluster.go#L733-L761
train
docker/libnetwork
drvregistry/drvregistry.go
New
func New(lDs, gDs interface{}, dfn DriverNotifyFunc, ifn IPAMNotifyFunc, pg plugingetter.PluginGetter) (*DrvRegistry, error) { r := &DrvRegistry{ drivers: make(driverTable), ipamDrivers: make(ipamTable), dfn: dfn, ifn: ifn, pluginGetter: pg, } return r, nil }
go
func New(lDs, gDs interface{}, dfn DriverNotifyFunc, ifn IPAMNotifyFunc, pg plugingetter.PluginGetter) (*DrvRegistry, error) { r := &DrvRegistry{ drivers: make(driverTable), ipamDrivers: make(ipamTable), dfn: dfn, ifn: ifn, pluginGetter: pg, } return r, nil }
[ "func", "New", "(", "lDs", ",", "gDs", "interface", "{", "}", ",", "dfn", "DriverNotifyFunc", ",", "ifn", "IPAMNotifyFunc", ",", "pg", "plugingetter", ".", "PluginGetter", ")", "(", "*", "DrvRegistry", ",", "error", ")", "{", "r", ":=", "&", "DrvRegistry...
// New returns a new driver registry handle.
[ "New", "returns", "a", "new", "driver", "registry", "handle", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L58-L68
train
docker/libnetwork
drvregistry/drvregistry.go
AddDriver
func (r *DrvRegistry) AddDriver(ntype string, fn InitFunc, config map[string]interface{}) error { return fn(r, config) }
go
func (r *DrvRegistry) AddDriver(ntype string, fn InitFunc, config map[string]interface{}) error { return fn(r, config) }
[ "func", "(", "r", "*", "DrvRegistry", ")", "AddDriver", "(", "ntype", "string", ",", "fn", "InitFunc", ",", "config", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "return", "fn", "(", "r", ",", "config", ")", "\n", "}" ]
// AddDriver adds a network driver to the registry.
[ "AddDriver", "adds", "a", "network", "driver", "to", "the", "registry", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L71-L73
train
docker/libnetwork
drvregistry/drvregistry.go
WalkIPAMs
func (r *DrvRegistry) WalkIPAMs(ifn IPAMWalkFunc) { type ipamVal struct { name string data *ipamData } r.Lock() ivl := make([]ipamVal, 0, len(r.ipamDrivers)) for k, v := range r.ipamDrivers { ivl = append(ivl, ipamVal{name: k, data: v}) } r.Unlock() for _, iv := range ivl { if ifn(iv.name, iv.data.dri...
go
func (r *DrvRegistry) WalkIPAMs(ifn IPAMWalkFunc) { type ipamVal struct { name string data *ipamData } r.Lock() ivl := make([]ipamVal, 0, len(r.ipamDrivers)) for k, v := range r.ipamDrivers { ivl = append(ivl, ipamVal{name: k, data: v}) } r.Unlock() for _, iv := range ivl { if ifn(iv.name, iv.data.dri...
[ "func", "(", "r", "*", "DrvRegistry", ")", "WalkIPAMs", "(", "ifn", "IPAMWalkFunc", ")", "{", "type", "ipamVal", "struct", "{", "name", "string", "\n", "data", "*", "ipamData", "\n", "}", "\n\n", "r", ".", "Lock", "(", ")", "\n", "ivl", ":=", "make",...
// WalkIPAMs walks the IPAM drivers registered in the registry and invokes the passed walk function and each one of them.
[ "WalkIPAMs", "walks", "the", "IPAM", "drivers", "registered", "in", "the", "registry", "and", "invokes", "the", "passed", "walk", "function", "and", "each", "one", "of", "them", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L76-L94
train
docker/libnetwork
drvregistry/drvregistry.go
WalkDrivers
func (r *DrvRegistry) WalkDrivers(dfn DriverWalkFunc) { type driverVal struct { name string data *driverData } r.Lock() dvl := make([]driverVal, 0, len(r.drivers)) for k, v := range r.drivers { dvl = append(dvl, driverVal{name: k, data: v}) } r.Unlock() for _, dv := range dvl { if dfn(dv.name, dv.data...
go
func (r *DrvRegistry) WalkDrivers(dfn DriverWalkFunc) { type driverVal struct { name string data *driverData } r.Lock() dvl := make([]driverVal, 0, len(r.drivers)) for k, v := range r.drivers { dvl = append(dvl, driverVal{name: k, data: v}) } r.Unlock() for _, dv := range dvl { if dfn(dv.name, dv.data...
[ "func", "(", "r", "*", "DrvRegistry", ")", "WalkDrivers", "(", "dfn", "DriverWalkFunc", ")", "{", "type", "driverVal", "struct", "{", "name", "string", "\n", "data", "*", "driverData", "\n", "}", "\n\n", "r", ".", "Lock", "(", ")", "\n", "dvl", ":=", ...
// WalkDrivers walks the network drivers registered in the registry and invokes the passed walk function and each one of them.
[ "WalkDrivers", "walks", "the", "network", "drivers", "registered", "in", "the", "registry", "and", "invokes", "the", "passed", "walk", "function", "and", "each", "one", "of", "them", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L97-L115
train
docker/libnetwork
drvregistry/drvregistry.go
Driver
func (r *DrvRegistry) Driver(name string) (driverapi.Driver, *driverapi.Capability) { r.Lock() defer r.Unlock() d, ok := r.drivers[name] if !ok { return nil, nil } return d.driver, &d.capability }
go
func (r *DrvRegistry) Driver(name string) (driverapi.Driver, *driverapi.Capability) { r.Lock() defer r.Unlock() d, ok := r.drivers[name] if !ok { return nil, nil } return d.driver, &d.capability }
[ "func", "(", "r", "*", "DrvRegistry", ")", "Driver", "(", "name", "string", ")", "(", "driverapi", ".", "Driver", ",", "*", "driverapi", ".", "Capability", ")", "{", "r", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Unlock", "(", ")", "\n\n", ...
// Driver returns the actual network driver instance and its capability which registered with the passed name.
[ "Driver", "returns", "the", "actual", "network", "driver", "instance", "and", "its", "capability", "which", "registered", "with", "the", "passed", "name", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L118-L128
train
docker/libnetwork
drvregistry/drvregistry.go
IPAM
func (r *DrvRegistry) IPAM(name string) (ipamapi.Ipam, *ipamapi.Capability) { r.Lock() defer r.Unlock() i, ok := r.ipamDrivers[name] if !ok { return nil, nil } return i.driver, i.capability }
go
func (r *DrvRegistry) IPAM(name string) (ipamapi.Ipam, *ipamapi.Capability) { r.Lock() defer r.Unlock() i, ok := r.ipamDrivers[name] if !ok { return nil, nil } return i.driver, i.capability }
[ "func", "(", "r", "*", "DrvRegistry", ")", "IPAM", "(", "name", "string", ")", "(", "ipamapi", ".", "Ipam", ",", "*", "ipamapi", ".", "Capability", ")", "{", "r", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Unlock", "(", ")", "\n\n", "i", ...
// IPAM returns the actual IPAM driver instance and its capability which registered with the passed name.
[ "IPAM", "returns", "the", "actual", "IPAM", "driver", "instance", "and", "its", "capability", "which", "registered", "with", "the", "passed", "name", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L131-L141
train
docker/libnetwork
drvregistry/drvregistry.go
IPAMDefaultAddressSpaces
func (r *DrvRegistry) IPAMDefaultAddressSpaces(name string) (string, string, error) { r.Lock() defer r.Unlock() i, ok := r.ipamDrivers[name] if !ok { return "", "", fmt.Errorf("ipam %s not found", name) } return i.defaultLocalAddressSpace, i.defaultGlobalAddressSpace, nil }
go
func (r *DrvRegistry) IPAMDefaultAddressSpaces(name string) (string, string, error) { r.Lock() defer r.Unlock() i, ok := r.ipamDrivers[name] if !ok { return "", "", fmt.Errorf("ipam %s not found", name) } return i.defaultLocalAddressSpace, i.defaultGlobalAddressSpace, nil }
[ "func", "(", "r", "*", "DrvRegistry", ")", "IPAMDefaultAddressSpaces", "(", "name", "string", ")", "(", "string", ",", "string", ",", "error", ")", "{", "r", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Unlock", "(", ")", "\n\n", "i", ",", "ok"...
// IPAMDefaultAddressSpaces returns the default address space strings for the passed IPAM driver name.
[ "IPAMDefaultAddressSpaces", "returns", "the", "default", "address", "space", "strings", "for", "the", "passed", "IPAM", "driver", "name", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L144-L154
train
docker/libnetwork
drvregistry/drvregistry.go
RegisterDriver
func (r *DrvRegistry) RegisterDriver(ntype string, driver driverapi.Driver, capability driverapi.Capability) error { if strings.TrimSpace(ntype) == "" { return errors.New("network type string cannot be empty") } r.Lock() dd, ok := r.drivers[ntype] r.Unlock() if ok && dd.driver.IsBuiltIn() { return driverapi...
go
func (r *DrvRegistry) RegisterDriver(ntype string, driver driverapi.Driver, capability driverapi.Capability) error { if strings.TrimSpace(ntype) == "" { return errors.New("network type string cannot be empty") } r.Lock() dd, ok := r.drivers[ntype] r.Unlock() if ok && dd.driver.IsBuiltIn() { return driverapi...
[ "func", "(", "r", "*", "DrvRegistry", ")", "RegisterDriver", "(", "ntype", "string", ",", "driver", "driverapi", ".", "Driver", ",", "capability", "driverapi", ".", "Capability", ")", "error", "{", "if", "strings", ".", "TrimSpace", "(", "ntype", ")", "=="...
// RegisterDriver registers the network driver when it gets discovered.
[ "RegisterDriver", "registers", "the", "network", "driver", "when", "it", "gets", "discovered", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L162-L188
train
docker/libnetwork
drvregistry/drvregistry.go
RegisterIpamDriver
func (r *DrvRegistry) RegisterIpamDriver(name string, driver ipamapi.Ipam) error { return r.registerIpamDriver(name, driver, &ipamapi.Capability{}) }
go
func (r *DrvRegistry) RegisterIpamDriver(name string, driver ipamapi.Ipam) error { return r.registerIpamDriver(name, driver, &ipamapi.Capability{}) }
[ "func", "(", "r", "*", "DrvRegistry", ")", "RegisterIpamDriver", "(", "name", "string", ",", "driver", "ipamapi", ".", "Ipam", ")", "error", "{", "return", "r", ".", "registerIpamDriver", "(", "name", ",", "driver", ",", "&", "ipamapi", ".", "Capability", ...
// RegisterIpamDriver registers the IPAM driver discovered with default capabilities.
[ "RegisterIpamDriver", "registers", "the", "IPAM", "driver", "discovered", "with", "default", "capabilities", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L221-L223
train
docker/libnetwork
drvregistry/drvregistry.go
RegisterIpamDriverWithCapabilities
func (r *DrvRegistry) RegisterIpamDriverWithCapabilities(name string, driver ipamapi.Ipam, caps *ipamapi.Capability) error { return r.registerIpamDriver(name, driver, caps) }
go
func (r *DrvRegistry) RegisterIpamDriverWithCapabilities(name string, driver ipamapi.Ipam, caps *ipamapi.Capability) error { return r.registerIpamDriver(name, driver, caps) }
[ "func", "(", "r", "*", "DrvRegistry", ")", "RegisterIpamDriverWithCapabilities", "(", "name", "string", ",", "driver", "ipamapi", ".", "Ipam", ",", "caps", "*", "ipamapi", ".", "Capability", ")", "error", "{", "return", "r", ".", "registerIpamDriver", "(", "...
// RegisterIpamDriverWithCapabilities registers the IPAM driver discovered with specified capabilities.
[ "RegisterIpamDriverWithCapabilities", "registers", "the", "IPAM", "driver", "discovered", "with", "specified", "capabilities", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L226-L228
train
docker/libnetwork
drivers/bridge/netlink_deprecated_linux.go
getIfSocket
func getIfSocket() (fd int, err error) { for _, socket := range []int{ syscall.AF_INET, syscall.AF_PACKET, syscall.AF_INET6, } { if fd, err = syscall.Socket(socket, syscall.SOCK_DGRAM, 0); err == nil { break } } if err == nil { return fd, nil } return -1, err }
go
func getIfSocket() (fd int, err error) { for _, socket := range []int{ syscall.AF_INET, syscall.AF_PACKET, syscall.AF_INET6, } { if fd, err = syscall.Socket(socket, syscall.SOCK_DGRAM, 0); err == nil { break } } if err == nil { return fd, nil } return -1, err }
[ "func", "getIfSocket", "(", ")", "(", "fd", "int", ",", "err", "error", ")", "{", "for", "_", ",", "socket", ":=", "range", "[", "]", "int", "{", "syscall", ".", "AF_INET", ",", "syscall", ".", "AF_PACKET", ",", "syscall", ".", "AF_INET6", ",", "}"...
// THIS CODE DOES NOT COMMUNICATE WITH KERNEL VIA RTNETLINK INTERFACE // IT IS HERE FOR BACKWARDS COMPATIBILITY WITH OLDER LINUX KERNELS // WHICH SHIP WITH OLDER NOT ENTIRELY FUNCTIONAL VERSION OF NETLINK
[ "THIS", "CODE", "DOES", "NOT", "COMMUNICATE", "WITH", "KERNEL", "VIA", "RTNETLINK", "INTERFACE", "IT", "IS", "HERE", "FOR", "BACKWARDS", "COMPATIBILITY", "WITH", "OLDER", "LINUX", "KERNELS", "WHICH", "SHIP", "WITH", "OLDER", "NOT", "ENTIRELY", "FUNCTIONAL", "VER...
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/bridge/netlink_deprecated_linux.go#L35-L49
train
docker/libnetwork
drivers/bridge/netlink_deprecated_linux.go
ioctlAddToBridge
func ioctlAddToBridge(iface, master *net.Interface) error { return ifIoctBridge(iface, master, ioctlBrAddIf) }
go
func ioctlAddToBridge(iface, master *net.Interface) error { return ifIoctBridge(iface, master, ioctlBrAddIf) }
[ "func", "ioctlAddToBridge", "(", "iface", ",", "master", "*", "net", ".", "Interface", ")", "error", "{", "return", "ifIoctBridge", "(", "iface", ",", "master", ",", "ioctlBrAddIf", ")", "\n", "}" ]
// Add a slave to a bridge device. This is more backward-compatible than // netlink.NetworkSetMaster and works on RHEL 6.
[ "Add", "a", "slave", "to", "a", "bridge", "device", ".", "This", "is", "more", "backward", "-", "compatible", "than", "netlink", ".", "NetworkSetMaster", "and", "works", "on", "RHEL", "6", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/bridge/netlink_deprecated_linux.go#L75-L77
train
docker/libnetwork
sandbox.go
OptionHostname
func OptionHostname(name string) SandboxOption { return func(sb *sandbox) { sb.config.hostName = name } }
go
func OptionHostname(name string) SandboxOption { return func(sb *sandbox) { sb.config.hostName = name } }
[ "func", "OptionHostname", "(", "name", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "hostName", "=", "name", "\n", "}", "\n", "}" ]
// OptionHostname function returns an option setter for hostname option to // be passed to NewSandbox method.
[ "OptionHostname", "function", "returns", "an", "option", "setter", "for", "hostname", "option", "to", "be", "passed", "to", "NewSandbox", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1038-L1042
train
docker/libnetwork
sandbox.go
OptionDomainname
func OptionDomainname(name string) SandboxOption { return func(sb *sandbox) { sb.config.domainName = name } }
go
func OptionDomainname(name string) SandboxOption { return func(sb *sandbox) { sb.config.domainName = name } }
[ "func", "OptionDomainname", "(", "name", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "domainName", "=", "name", "\n", "}", "\n", "}" ]
// OptionDomainname function returns an option setter for domainname option to // be passed to NewSandbox method.
[ "OptionDomainname", "function", "returns", "an", "option", "setter", "for", "domainname", "option", "to", "be", "passed", "to", "NewSandbox", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1046-L1050
train
docker/libnetwork
sandbox.go
OptionHostsPath
func OptionHostsPath(path string) SandboxOption { return func(sb *sandbox) { sb.config.hostsPath = path } }
go
func OptionHostsPath(path string) SandboxOption { return func(sb *sandbox) { sb.config.hostsPath = path } }
[ "func", "OptionHostsPath", "(", "path", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "hostsPath", "=", "path", "\n", "}", "\n", "}" ]
// OptionHostsPath function returns an option setter for hostspath option to // be passed to NewSandbox method.
[ "OptionHostsPath", "function", "returns", "an", "option", "setter", "for", "hostspath", "option", "to", "be", "passed", "to", "NewSandbox", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1054-L1058
train
docker/libnetwork
sandbox.go
OptionOriginHostsPath
func OptionOriginHostsPath(path string) SandboxOption { return func(sb *sandbox) { sb.config.originHostsPath = path } }
go
func OptionOriginHostsPath(path string) SandboxOption { return func(sb *sandbox) { sb.config.originHostsPath = path } }
[ "func", "OptionOriginHostsPath", "(", "path", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "originHostsPath", "=", "path", "\n", "}", "\n", "}" ]
// OptionOriginHostsPath function returns an option setter for origin hosts file path // to be passed to NewSandbox method.
[ "OptionOriginHostsPath", "function", "returns", "an", "option", "setter", "for", "origin", "hosts", "file", "path", "to", "be", "passed", "to", "NewSandbox", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1062-L1066
train
docker/libnetwork
sandbox.go
OptionParentUpdate
func OptionParentUpdate(cid string, name, ip string) SandboxOption { return func(sb *sandbox) { sb.config.parentUpdates = append(sb.config.parentUpdates, parentUpdate{cid: cid, name: name, ip: ip}) } }
go
func OptionParentUpdate(cid string, name, ip string) SandboxOption { return func(sb *sandbox) { sb.config.parentUpdates = append(sb.config.parentUpdates, parentUpdate{cid: cid, name: name, ip: ip}) } }
[ "func", "OptionParentUpdate", "(", "cid", "string", ",", "name", ",", "ip", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "parentUpdates", "=", "append", "(", "sb", ".", "config", ...
// OptionParentUpdate function returns an option setter for parent container // which needs to update the IP address for the linked container.
[ "OptionParentUpdate", "function", "returns", "an", "option", "setter", "for", "parent", "container", "which", "needs", "to", "update", "the", "IP", "address", "for", "the", "linked", "container", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1078-L1082
train
docker/libnetwork
sandbox.go
OptionResolvConfPath
func OptionResolvConfPath(path string) SandboxOption { return func(sb *sandbox) { sb.config.resolvConfPath = path } }
go
func OptionResolvConfPath(path string) SandboxOption { return func(sb *sandbox) { sb.config.resolvConfPath = path } }
[ "func", "OptionResolvConfPath", "(", "path", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "resolvConfPath", "=", "path", "\n", "}", "\n", "}" ]
// OptionResolvConfPath function returns an option setter for resolvconfpath option to // be passed to net container methods.
[ "OptionResolvConfPath", "function", "returns", "an", "option", "setter", "for", "resolvconfpath", "option", "to", "be", "passed", "to", "net", "container", "methods", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1086-L1090
train
docker/libnetwork
sandbox.go
OptionOriginResolvConfPath
func OptionOriginResolvConfPath(path string) SandboxOption { return func(sb *sandbox) { sb.config.originResolvConfPath = path } }
go
func OptionOriginResolvConfPath(path string) SandboxOption { return func(sb *sandbox) { sb.config.originResolvConfPath = path } }
[ "func", "OptionOriginResolvConfPath", "(", "path", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "originResolvConfPath", "=", "path", "\n", "}", "\n", "}" ]
// OptionOriginResolvConfPath function returns an option setter to set the path to the // origin resolv.conf file to be passed to net container methods.
[ "OptionOriginResolvConfPath", "function", "returns", "an", "option", "setter", "to", "set", "the", "path", "to", "the", "origin", "resolv", ".", "conf", "file", "to", "be", "passed", "to", "net", "container", "methods", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1094-L1098
train
docker/libnetwork
sandbox.go
OptionDNS
func OptionDNS(dns string) SandboxOption { return func(sb *sandbox) { sb.config.dnsList = append(sb.config.dnsList, dns) } }
go
func OptionDNS(dns string) SandboxOption { return func(sb *sandbox) { sb.config.dnsList = append(sb.config.dnsList, dns) } }
[ "func", "OptionDNS", "(", "dns", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "dnsList", "=", "append", "(", "sb", ".", "config", ".", "dnsList", ",", "dns", ")", "\n", "}", "...
// OptionDNS function returns an option setter for dns entry option to // be passed to container Create method.
[ "OptionDNS", "function", "returns", "an", "option", "setter", "for", "dns", "entry", "option", "to", "be", "passed", "to", "container", "Create", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1102-L1106
train
docker/libnetwork
sandbox.go
OptionDNSSearch
func OptionDNSSearch(search string) SandboxOption { return func(sb *sandbox) { sb.config.dnsSearchList = append(sb.config.dnsSearchList, search) } }
go
func OptionDNSSearch(search string) SandboxOption { return func(sb *sandbox) { sb.config.dnsSearchList = append(sb.config.dnsSearchList, search) } }
[ "func", "OptionDNSSearch", "(", "search", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "dnsSearchList", "=", "append", "(", "sb", ".", "config", ".", "dnsSearchList", ",", "search", ...
// OptionDNSSearch function returns an option setter for dns search entry option to // be passed to container Create method.
[ "OptionDNSSearch", "function", "returns", "an", "option", "setter", "for", "dns", "search", "entry", "option", "to", "be", "passed", "to", "container", "Create", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1110-L1114
train
docker/libnetwork
sandbox.go
OptionDNSOptions
func OptionDNSOptions(options string) SandboxOption { return func(sb *sandbox) { sb.config.dnsOptionsList = append(sb.config.dnsOptionsList, options) } }
go
func OptionDNSOptions(options string) SandboxOption { return func(sb *sandbox) { sb.config.dnsOptionsList = append(sb.config.dnsOptionsList, options) } }
[ "func", "OptionDNSOptions", "(", "options", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "dnsOptionsList", "=", "append", "(", "sb", ".", "config", ".", "dnsOptionsList", ",", "option...
// OptionDNSOptions function returns an option setter for dns options entry option to // be passed to container Create method.
[ "OptionDNSOptions", "function", "returns", "an", "option", "setter", "for", "dns", "options", "entry", "option", "to", "be", "passed", "to", "container", "Create", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1118-L1122
train
docker/libnetwork
sandbox.go
OptionGeneric
func OptionGeneric(generic map[string]interface{}) SandboxOption { return func(sb *sandbox) { if sb.config.generic == nil { sb.config.generic = make(map[string]interface{}, len(generic)) } for k, v := range generic { sb.config.generic[k] = v } } }
go
func OptionGeneric(generic map[string]interface{}) SandboxOption { return func(sb *sandbox) { if sb.config.generic == nil { sb.config.generic = make(map[string]interface{}, len(generic)) } for k, v := range generic { sb.config.generic[k] = v } } }
[ "func", "OptionGeneric", "(", "generic", "map", "[", "string", "]", "interface", "{", "}", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "if", "sb", ".", "config", ".", "generic", "==", "nil", "{", "sb", ".", "conf...
// OptionGeneric function returns an option setter for Generic configuration // that is not managed by libNetwork but can be used by the Drivers during the call to // net container creation method. Container Labels are a good example.
[ "OptionGeneric", "function", "returns", "an", "option", "setter", "for", "Generic", "configuration", "that", "is", "not", "managed", "by", "libNetwork", "but", "can", "be", "used", "by", "the", "Drivers", "during", "the", "call", "to", "net", "container", "cre...
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1143-L1152
train
docker/libnetwork
sandbox.go
OptionExposedPorts
func OptionExposedPorts(exposedPorts []types.TransportPort) SandboxOption { return func(sb *sandbox) { if sb.config.generic == nil { sb.config.generic = make(map[string]interface{}) } // Defensive copy eps := make([]types.TransportPort, len(exposedPorts)) copy(eps, exposedPorts) // Store endpoint label ...
go
func OptionExposedPorts(exposedPorts []types.TransportPort) SandboxOption { return func(sb *sandbox) { if sb.config.generic == nil { sb.config.generic = make(map[string]interface{}) } // Defensive copy eps := make([]types.TransportPort, len(exposedPorts)) copy(eps, exposedPorts) // Store endpoint label ...
[ "func", "OptionExposedPorts", "(", "exposedPorts", "[", "]", "types", ".", "TransportPort", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "if", "sb", ".", "config", ".", "generic", "==", "nil", "{", "sb", ".", "config"...
// OptionExposedPorts function returns an option setter for the container exposed // ports option to be passed to container Create method.
[ "OptionExposedPorts", "function", "returns", "an", "option", "setter", "for", "the", "container", "exposed", "ports", "option", "to", "be", "passed", "to", "container", "Create", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1156-L1168
train
docker/libnetwork
sandbox.go
OptionPortMapping
func OptionPortMapping(portBindings []types.PortBinding) SandboxOption { return func(sb *sandbox) { if sb.config.generic == nil { sb.config.generic = make(map[string]interface{}) } // Store a copy of the bindings as generic data to pass to the driver pbs := make([]types.PortBinding, len(portBindings)) cop...
go
func OptionPortMapping(portBindings []types.PortBinding) SandboxOption { return func(sb *sandbox) { if sb.config.generic == nil { sb.config.generic = make(map[string]interface{}) } // Store a copy of the bindings as generic data to pass to the driver pbs := make([]types.PortBinding, len(portBindings)) cop...
[ "func", "OptionPortMapping", "(", "portBindings", "[", "]", "types", ".", "PortBinding", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "if", "sb", ".", "config", ".", "generic", "==", "nil", "{", "sb", ".", "config", ...
// OptionPortMapping function returns an option setter for the mapping // ports option to be passed to container Create method.
[ "OptionPortMapping", "function", "returns", "an", "option", "setter", "for", "the", "mapping", "ports", "option", "to", "be", "passed", "to", "container", "Create", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1172-L1182
train