_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q22300 | It | train | func It(text string, body interface{}, timeout ...float64) bool {
globalSuite.PushItNode(text, body, types.FlagTypeNone, codelocation.New(1), parseTimeout(timeout...))
return true
} | go | {
"resource": ""
} |
q22301 | FIt | train | func FIt(text string, body interface{}, timeout ...float64) bool {
globalSuite.PushItNode(text, body, types.FlagTypeFocused, codelocation.New(1), parseTimeout(timeout...))
return true
} | go | {
"resource": ""
} |
q22302 | PIt | train | func PIt(text string, _ ...interface{}) bool {
globalSuite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0)
return true
} | go | {
"resource": ""
} |
q22303 | PSpecify | train | func PSpecify(text string, is ...interface{}) bool {
globalSuite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0)
return true
} | go | {
"resource": ""
} |
q22304 | FMeasure | train | func FMeasure(text string, body interface{}, samples int) bool {
globalSuite.PushMeasureNode(text, body, types.FlagTypeFocused, codelocation.New(1), samples)
return true
} | go | {
"resource": ""
} |
q22305 | PMeasure | train | func PMeasure(text string, _ ...interface{}) bool {
globalSuite.PushMeasureNode(text, func(b Benchmarker) {}, types.FlagTypePending, codelocation.New(1), 0)
return true
} | go | {
"resource": ""
} |
q22306 | BeforeEach | train | func BeforeEach(body interface{}, timeout ...float64) bool {
globalSuite.PushBeforeEachNode(body, codelocation.New(1), parseTimeout(timeout...))
return true
} | go | {
"resource": ""
} |
q22307 | AfterEach | train | func AfterEach(body interface{}, timeout ...float64) bool {
globalSuite.PushAfterEachNode(body, codelocation.New(1), parseTimeout(timeout...))
return true
} | go | {
"resource": ""
} |
q22308 | initStore | train | func (d *driver) initStore(option map[string]interface{}) error {
if data, ok := option[netlabel.LocalKVClient]; ok {
var err error
dsc, ok := data.(discoverapi.DatastoreConfigData)
if !ok {
return types.InternalErrorf("incorrect data in datastore configuration: %v", data)
}
d.store, err = datastore.NewDa... | go | {
"resource": ""
} |
q22309 | populateNetworks | train | func (d *driver) populateNetworks() error {
kvol, err := d.store.List(datastore.Key(macvlanPrefix), &configuration{})
if err != nil && err != datastore.ErrKeyNotFound {
return fmt.Errorf("failed to get macvlan network configurations from store: %v", err)
}
// If empty it simply means no macvlan networks have been... | go | {
"resource": ""
} |
q22310 | CreateEndpoint | train | func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
epOptions map[string]interface{}) error {
defer osl.InitOSContext()()
if err := validateID(nid, eid); err != nil {
return err
}
n, err := d.getNetwork(nid)
if err != nil {
return fmt.Errorf("network id %q not found", nid)
}
if... | go | {
"resource": ""
} |
q22311 | DeleteEndpoint | train | func (d *driver) DeleteEndpoint(nid, eid string) error {
defer osl.InitOSContext()()
if err := validateID(nid, eid); err != nil {
return err
}
n := d.network(nid)
if n == nil {
return fmt.Errorf("network id %q not found", nid)
}
ep := n.endpoint(eid)
if ep == nil {
return fmt.Errorf("endpoint id %q not fo... | go | {
"resource": ""
} |
q22312 | ApplyOSTweaks | train | func ApplyOSTweaks(osConfig map[string]*OSValue) {
for k, v := range osConfig {
// read the existing property from disk
oldv, err := readSystemProperty(k)
if err != nil {
logrus.WithError(err).Errorf("error reading the kernel parameter %s", k)
continue
}
if propertyIsValid(oldv, v.Value, v.CheckFn) {
... | go | {
"resource": ""
} |
q22313 | GetID | train | func (i *Idm) GetID(serial bool) (uint64, error) {
if i.handle == nil {
return 0, errors.New("ID set is not initialized")
}
ordinal, err := i.handle.SetAny(serial)
return i.start + ordinal, err
} | go | {
"resource": ""
} |
q22314 | GetSpecificID | train | func (i *Idm) GetSpecificID(id uint64) error {
if i.handle == nil {
return errors.New("ID set is not initialized")
}
if id < i.start || id > i.end {
return errors.New("Requested id does not belong to the set")
}
return i.handle.Set(id - i.start)
} | go | {
"resource": ""
} |
q22315 | Release | train | func (i *Idm) Release(id uint64) {
i.handle.Unset(id - i.start)
} | go | {
"resource": ""
} |
q22316 | Equal | train | func (t *TransportPort) Equal(o *TransportPort) bool {
if t == o {
return true
}
if o == nil {
return false
}
if t.Proto != o.Proto || t.Port != o.Port {
return false
}
return true
} | go | {
"resource": ""
} |
q22317 | GetCopy | train | func (t *TransportPort) GetCopy() TransportPort {
return TransportPort{Proto: t.Proto, Port: t.Port}
} | go | {
"resource": ""
} |
q22318 | String | train | func (t *TransportPort) String() string {
return fmt.Sprintf("%s/%d", t.Proto.String(), t.Port)
} | go | {
"resource": ""
} |
q22319 | FromString | train | func (t *TransportPort) FromString(s string) error {
ps := strings.Split(s, "/")
if len(ps) == 2 {
t.Proto = ParseProtocol(ps[0])
if p, err := strconv.ParseUint(ps[1], 10, 16); err == nil {
t.Port = uint16(p)
return nil
}
}
return BadRequestErrorf("invalid format for transport port: %s", s)
} | go | {
"resource": ""
} |
q22320 | HostAddr | train | func (p PortBinding) HostAddr() (net.Addr, error) {
switch p.Proto {
case UDP:
return &net.UDPAddr{IP: p.HostIP, Port: int(p.HostPort)}, nil
case TCP:
return &net.TCPAddr{IP: p.HostIP, Port: int(p.HostPort)}, nil
case SCTP:
return &sctp.SCTPAddr{IP: []net.IP{p.HostIP}, Port: int(p.HostPort)}, nil
default:
... | go | {
"resource": ""
} |
q22321 | GetCopy | train | func (p *PortBinding) GetCopy() PortBinding {
return PortBinding{
Proto: p.Proto,
IP: GetIPCopy(p.IP),
Port: p.Port,
HostIP: GetIPCopy(p.HostIP),
HostPort: p.HostPort,
HostPortEnd: p.HostPortEnd,
}
} | go | {
"resource": ""
} |
q22322 | String | train | func (p *PortBinding) String() string {
ret := fmt.Sprintf("%s/", p.Proto)
if p.IP != nil {
ret += p.IP.String()
}
ret = fmt.Sprintf("%s:%d/", ret, p.Port)
if p.HostIP != nil {
ret += p.HostIP.String()
}
ret = fmt.Sprintf("%s:%d", ret, p.HostPort)
return ret
} | go | {
"resource": ""
} |
q22323 | Equal | train | func (p *PortBinding) Equal(o *PortBinding) bool {
if p == o {
return true
}
if o == nil {
return false
}
if p.Proto != o.Proto || p.Port != o.Port ||
p.HostPort != o.HostPort || p.HostPortEnd != o.HostPortEnd {
return false
}
if p.IP != nil {
if !p.IP.Equal(o.IP) {
return false
}
} else {
i... | go | {
"resource": ""
} |
q22324 | ParseProtocol | train | func ParseProtocol(s string) Protocol {
switch strings.ToLower(s) {
case "icmp":
return ICMP
case "udp":
return UDP
case "tcp":
return TCP
case "sctp":
return SCTP
default:
return 0
}
} | go | {
"resource": ""
} |
q22325 | GetMacCopy | train | func GetMacCopy(from net.HardwareAddr) net.HardwareAddr {
if from == nil {
return nil
}
to := make(net.HardwareAddr, len(from))
copy(to, from)
return to
} | go | {
"resource": ""
} |
q22326 | GetIPCopy | train | func GetIPCopy(from net.IP) net.IP {
if from == nil {
return nil
}
to := make(net.IP, len(from))
copy(to, from)
return to
} | go | {
"resource": ""
} |
q22327 | GetIPNetCopy | train | func GetIPNetCopy(from *net.IPNet) *net.IPNet {
if from == nil {
return nil
}
bm := make(net.IPMask, len(from.Mask))
copy(bm, from.Mask)
return &net.IPNet{IP: GetIPCopy(from.IP), Mask: bm}
} | go | {
"resource": ""
} |
q22328 | GetIPNetCanonical | train | func GetIPNetCanonical(nw *net.IPNet) *net.IPNet {
if nw == nil {
return nil
}
c := GetIPNetCopy(nw)
c.IP = c.IP.Mask(nw.Mask)
return c
} | go | {
"resource": ""
} |
q22329 | CompareIPNet | train | func CompareIPNet(a, b *net.IPNet) bool {
if a == b {
return true
}
if a == nil || b == nil {
return false
}
return a.IP.Equal(b.IP) && bytes.Equal(a.Mask, b.Mask)
} | go | {
"resource": ""
} |
q22330 | GetMinimalIP | train | func GetMinimalIP(ip net.IP) net.IP {
if ip != nil && ip.To4() != nil {
return ip.To4()
}
return ip
} | go | {
"resource": ""
} |
q22331 | GetMinimalIPNet | train | func GetMinimalIPNet(nw *net.IPNet) *net.IPNet {
if nw == nil {
return nil
}
if len(nw.IP) == 16 && nw.IP.To4() != nil {
m := nw.Mask
if len(m) == 16 {
m = m[12:16]
}
return &net.IPNet{IP: nw.IP.To4(), Mask: m}
}
return nw
} | go | {
"resource": ""
} |
q22332 | compareIPMask | train | func compareIPMask(ip net.IP, mask net.IPMask) (is int, ms int, err error) {
// Find the effective starting of address and mask
if len(ip) == net.IPv6len && ip.To4() != nil {
is = 12
}
if len(ip[is:]) == net.IPv4len && len(mask) == net.IPv6len && bytes.Equal(mask[:12], v4inV6MaskPrefix) {
ms = 12
}
// Check i... | go | {
"resource": ""
} |
q22333 | GetHostPartIP | train | func GetHostPartIP(ip net.IP, mask net.IPMask) (net.IP, error) {
// Find the effective starting of address and mask
is, ms, err := compareIPMask(ip, mask)
if err != nil {
return nil, fmt.Errorf("cannot compute host portion ip address because %s", err)
}
// Compute host portion
out := GetIPCopy(ip)
for i := 0;... | go | {
"resource": ""
} |
q22334 | GetCopy | train | func (r *StaticRoute) GetCopy() *StaticRoute {
d := GetIPNetCopy(r.Destination)
nh := GetIPCopy(r.NextHop)
return &StaticRoute{Destination: d,
RouteType: r.RouteType,
NextHop: nh,
}
} | go | {
"resource": ""
} |
q22335 | NotFoundErrorf | train | func NotFoundErrorf(format string, params ...interface{}) error {
return notFound(fmt.Sprintf(format, params...))
} | go | {
"resource": ""
} |
q22336 | ForbiddenErrorf | train | func ForbiddenErrorf(format string, params ...interface{}) error {
return forbidden(fmt.Sprintf(format, params...))
} | go | {
"resource": ""
} |
q22337 | NoServiceErrorf | train | func NoServiceErrorf(format string, params ...interface{}) error {
return noService(fmt.Sprintf(format, params...))
} | go | {
"resource": ""
} |
q22338 | NotImplementedErrorf | train | func NotImplementedErrorf(format string, params ...interface{}) error {
return notImpl(fmt.Sprintf(format, params...))
} | go | {
"resource": ""
} |
q22339 | TimeoutErrorf | train | func TimeoutErrorf(format string, params ...interface{}) error {
return timeout(fmt.Sprintf(format, params...))
} | go | {
"resource": ""
} |
q22340 | InternalErrorf | train | func InternalErrorf(format string, params ...interface{}) error {
return internal(fmt.Sprintf(format, params...))
} | go | {
"resource": ""
} |
q22341 | InternalMaskableErrorf | train | func InternalMaskableErrorf(format string, params ...interface{}) error {
return maskInternal(fmt.Sprintf(format, params...))
} | go | {
"resource": ""
} |
q22342 | RetryErrorf | train | func RetryErrorf(format string, params ...interface{}) error {
return retry(fmt.Sprintf(format, params...))
} | go | {
"resource": ""
} |
q22343 | getNetworks | train | func (d *driver) getNetworks() []*network {
d.Lock()
defer d.Unlock()
ls := make([]*network, 0, len(d.networks))
for _, nw := range d.networks {
ls = append(ls, nw)
}
return ls
} | go | {
"resource": ""
} |
q22344 | LoadDefaultScopes | train | func (c *Config) LoadDefaultScopes(dataDir string) {
for k, v := range datastore.DefaultScopes(dataDir) {
if _, ok := c.Scopes[k]; !ok {
c.Scopes[k] = v
}
}
} | go | {
"resource": ""
} |
q22345 | ParseConfigOptions | train | func ParseConfigOptions(cfgOptions ...Option) *Config {
cfg := &Config{
Daemon: DaemonCfg{
DriverCfg: make(map[string]interface{}),
},
Scopes: make(map[string]*datastore.ScopeCfg),
}
cfg.ProcessOptions(cfgOptions...)
cfg.LoadDefaultScopes(cfg.Daemon.DataDir)
return cfg
} | go | {
"resource": ""
} |
q22346 | OptionDefaultNetwork | train | func OptionDefaultNetwork(dn string) Option {
return func(c *Config) {
logrus.Debugf("Option DefaultNetwork: %s", dn)
c.Daemon.DefaultNetwork = strings.TrimSpace(dn)
}
} | go | {
"resource": ""
} |
q22347 | OptionDefaultDriver | train | func OptionDefaultDriver(dd string) Option {
return func(c *Config) {
logrus.Debugf("Option DefaultDriver: %s", dd)
c.Daemon.DefaultDriver = strings.TrimSpace(dd)
}
} | go | {
"resource": ""
} |
q22348 | OptionDefaultAddressPoolConfig | train | func OptionDefaultAddressPoolConfig(addressPool []*ipamutils.NetworkToSplit) Option {
return func(c *Config) {
c.Daemon.DefaultAddressPool = addressPool
}
} | go | {
"resource": ""
} |
q22349 | OptionDriverConfig | train | func OptionDriverConfig(networkType string, config map[string]interface{}) Option {
return func(c *Config) {
c.Daemon.DriverCfg[networkType] = config
}
} | go | {
"resource": ""
} |
q22350 | OptionLabels | train | func OptionLabels(labels []string) Option {
return func(c *Config) {
for _, label := range labels {
if strings.HasPrefix(label, netlabel.Prefix) {
c.Daemon.Labels = append(c.Daemon.Labels, label)
}
}
}
} | go | {
"resource": ""
} |
q22351 | OptionKVProvider | train | func OptionKVProvider(provider string) Option {
return func(c *Config) {
logrus.Debugf("Option OptionKVProvider: %s", provider)
if _, ok := c.Scopes[datastore.GlobalScope]; !ok {
c.Scopes[datastore.GlobalScope] = &datastore.ScopeCfg{}
}
c.Scopes[datastore.GlobalScope].Client.Provider = strings.TrimSpace(pro... | go | {
"resource": ""
} |
q22352 | OptionKVProviderURL | train | func OptionKVProviderURL(url string) Option {
return func(c *Config) {
logrus.Debugf("Option OptionKVProviderURL: %s", url)
if _, ok := c.Scopes[datastore.GlobalScope]; !ok {
c.Scopes[datastore.GlobalScope] = &datastore.ScopeCfg{}
}
c.Scopes[datastore.GlobalScope].Client.Address = strings.TrimSpace(url)
}
... | go | {
"resource": ""
} |
q22353 | OptionKVOpts | train | func OptionKVOpts(opts map[string]string) Option {
return func(c *Config) {
if opts["kv.cacertfile"] != "" && opts["kv.certfile"] != "" && opts["kv.keyfile"] != "" {
logrus.Info("Option Initializing KV with TLS")
tlsConfig, err := tlsconfig.Client(tlsconfig.Options{
CAFile: opts["kv.cacertfile"],
Cer... | go | {
"resource": ""
} |
q22354 | OptionDiscoveryWatcher | train | func OptionDiscoveryWatcher(watcher discovery.Watcher) Option {
return func(c *Config) {
c.Cluster.Watcher = watcher
}
} | go | {
"resource": ""
} |
q22355 | OptionDiscoveryAddress | train | func OptionDiscoveryAddress(address string) Option {
return func(c *Config) {
c.Cluster.Address = address
}
} | go | {
"resource": ""
} |
q22356 | OptionDataDir | train | func OptionDataDir(dataDir string) Option {
return func(c *Config) {
c.Daemon.DataDir = dataDir
}
} | go | {
"resource": ""
} |
q22357 | OptionExecRoot | train | func OptionExecRoot(execRoot string) Option {
return func(c *Config) {
c.Daemon.ExecRoot = execRoot
osl.SetBasePath(execRoot)
}
} | go | {
"resource": ""
} |
q22358 | OptionPluginGetter | train | func OptionPluginGetter(pg plugingetter.PluginGetter) Option {
return func(c *Config) {
c.PluginGetter = pg
}
} | go | {
"resource": ""
} |
q22359 | OptionExperimental | train | func OptionExperimental(exp bool) Option {
return func(c *Config) {
logrus.Debugf("Option Experimental: %v", exp)
c.Daemon.Experimental = exp
}
} | go | {
"resource": ""
} |
q22360 | OptionNetworkControlPlaneMTU | train | func OptionNetworkControlPlaneMTU(exp int) Option {
return func(c *Config) {
logrus.Debugf("Network Control Plane MTU: %d", exp)
if exp < warningThNetworkControlPlaneMTU {
logrus.Warnf("Received a MTU of %d, this value is very low, the network control plane can misbehave,"+
" defaulting to minimum value (%d... | go | {
"resource": ""
} |
q22361 | ProcessOptions | train | func (c *Config) ProcessOptions(options ...Option) {
for _, opt := range options {
if opt != nil {
opt(c)
}
}
} | go | {
"resource": ""
} |
q22362 | OptionLocalKVProviderConfig | train | func OptionLocalKVProviderConfig(config *store.Config) Option {
return func(c *Config) {
logrus.Debugf("Option OptionLocalKVProviderConfig: %v", config)
if _, ok := c.Scopes[datastore.LocalScope]; !ok {
c.Scopes[datastore.LocalScope] = &datastore.ScopeCfg{}
}
c.Scopes[datastore.LocalScope].Client.Config = c... | go | {
"resource": ""
} |
q22363 | FirewalldInit | train | func FirewalldInit() error {
var err error
if connection, err = newConnection(); err != nil {
return fmt.Errorf("Failed to connect to D-Bus system bus: %v", err)
}
firewalldRunning = checkRunning()
if !firewalldRunning {
connection.sysconn.Close()
connection = nil
}
if connection != nil {
go signalHandl... | go | {
"resource": ""
} |
q22364 | initConnection | train | func (c *Conn) initConnection() error {
var err error
c.sysconn, err = dbus.SystemBus()
if err != nil {
return err
}
// This never fails, even if the service is not running atm.
c.sysobj = c.sysconn.Object(dbusInterface, dbus.ObjectPath(dbusPath))
rule := fmt.Sprintf("type='signal',path='%s',interface='%s',... | go | {
"resource": ""
} |
q22365 | OnReloaded | train | func OnReloaded(callback func()) {
for _, pf := range onReloaded {
if pf == &callback {
return
}
}
onReloaded = append(onReloaded, &callback)
} | go | {
"resource": ""
} |
q22366 | checkRunning | train | func checkRunning() bool {
var zone string
var err error
if connection != nil {
err = connection.sysobj.Call(dbusInterface+".getDefaultZone", 0).Store(&zone)
return err == nil
}
return false
} | go | {
"resource": ""
} |
q22367 | contains | train | func (n *network) contains(ip net.IP) bool {
for _, s := range n.subnets {
if s.subnetIP.Contains(ip) {
return true
}
}
return false
} | go | {
"resource": ""
} |
q22368 | getMatchingSubnet | train | func (n *network) getMatchingSubnet(ip *net.IPNet) *subnet {
if ip == nil {
return nil
}
for _, s := range n.subnets {
// first check if the mask lengths are the same
i, _ := s.subnetIP.Mask.Size()
j, _ := ip.Mask.Size()
if i != j {
continue
}
if s.subnetIP.IP.Equal(ip.IP) {
return s
}
}
retu... | go | {
"resource": ""
} |
q22369 | String | train | func (r *AddressRange) String() string {
return fmt.Sprintf("Sub: %s, range [%d, %d]", r.Sub, r.Start, r.End)
} | go | {
"resource": ""
} |
q22370 | MarshalJSON | train | func (r *AddressRange) MarshalJSON() ([]byte, error) {
m := map[string]interface{}{
"Sub": r.Sub.String(),
"Start": r.Start,
"End": r.End,
}
return json.Marshal(m)
} | go | {
"resource": ""
} |
q22371 | UnmarshalJSON | train | func (r *AddressRange) UnmarshalJSON(data []byte) error {
m := map[string]interface{}{}
err := json.Unmarshal(data, &m)
if err != nil {
return err
}
if r.Sub, err = types.ParseCIDR(m["Sub"].(string)); err != nil {
return err
}
r.Start = uint64(m["Start"].(float64))
r.End = uint64(m["End"].(float64))
return... | go | {
"resource": ""
} |
q22372 | String | train | func (s *SubnetKey) String() string {
k := fmt.Sprintf("%s/%s", s.AddressSpace, s.Subnet)
if s.ChildSubnet != "" {
k = fmt.Sprintf("%s/%s", k, s.ChildSubnet)
}
return k
} | go | {
"resource": ""
} |
q22373 | FromString | train | func (s *SubnetKey) FromString(str string) error {
if str == "" || !strings.Contains(str, "/") {
return types.BadRequestErrorf("invalid string form for subnetkey: %s", str)
}
p := strings.Split(str, "/")
if len(p) != 3 && len(p) != 5 {
return types.BadRequestErrorf("invalid string form for subnetkey: %s", str)... | go | {
"resource": ""
} |
q22374 | String | train | func (p *PoolData) String() string {
return fmt.Sprintf("ParentKey: %s, Pool: %s, Range: %s, RefCount: %d",
p.ParentKey.String(), p.Pool.String(), p.Range, p.RefCount)
} | go | {
"resource": ""
} |
q22375 | MarshalJSON | train | func (p *PoolData) MarshalJSON() ([]byte, error) {
m := map[string]interface{}{
"ParentKey": p.ParentKey,
"RefCount": p.RefCount,
}
if p.Pool != nil {
m["Pool"] = p.Pool.String()
}
if p.Range != nil {
m["Range"] = p.Range
}
return json.Marshal(m)
} | go | {
"resource": ""
} |
q22376 | UnmarshalJSON | train | func (p *PoolData) UnmarshalJSON(data []byte) error {
var (
err error
t struct {
ParentKey SubnetKey
Pool string
Range *AddressRange `json:",omitempty"`
RefCount int
}
)
if err = json.Unmarshal(data, &t); err != nil {
return err
}
p.ParentKey = t.ParentKey
p.Range = t.Range
p.Re... | go | {
"resource": ""
} |
q22377 | MarshalJSON | train | func (aSpace *addrSpace) MarshalJSON() ([]byte, error) {
aSpace.Lock()
defer aSpace.Unlock()
m := map[string]interface{}{
"Scope": string(aSpace.scope),
}
if aSpace.subnets != nil {
s := map[string]*PoolData{}
for k, v := range aSpace.subnets {
s[k.String()] = v
}
m["Subnets"] = s
}
return json.M... | go | {
"resource": ""
} |
q22378 | UnmarshalJSON | train | func (aSpace *addrSpace) UnmarshalJSON(data []byte) error {
aSpace.Lock()
defer aSpace.Unlock()
m := map[string]interface{}{}
err := json.Unmarshal(data, &m)
if err != nil {
return err
}
aSpace.scope = datastore.LocalScope
s := m["Scope"].(string)
if s == string(datastore.GlobalScope) {
aSpace.scope = da... | go | {
"resource": ""
} |
q22379 | CopyTo | train | func (p *PoolData) CopyTo(dstP *PoolData) error {
dstP.ParentKey = p.ParentKey
dstP.Pool = types.GetIPNetCopy(p.Pool)
if p.Range != nil {
dstP.Range = &AddressRange{}
dstP.Range.Sub = types.GetIPNetCopy(p.Range.Sub)
dstP.Range.Start = p.Range.Start
dstP.Range.End = p.Range.End
}
dstP.RefCount = p.RefCoun... | go | {
"resource": ""
} |
q22380 | updatePoolDBOnAdd | train | func (aSpace *addrSpace) updatePoolDBOnAdd(k SubnetKey, nw *net.IPNet, ipr *AddressRange, pdf bool) (func() error, error) {
aSpace.Lock()
defer aSpace.Unlock()
// Check if already allocated
if _, ok := aSpace.subnets[k]; ok {
if pdf {
return nil, types.InternalMaskableErrorf("predefined pool %s is already res... | go | {
"resource": ""
} |
q22381 | contains | train | func (aSpace *addrSpace) contains(space string, nw *net.IPNet) bool {
for k, v := range aSpace.subnets {
if space == k.AddressSpace && k.ChildSubnet == "" {
if nw.Contains(v.Pool.IP) || v.Pool.Contains(nw.IP) {
return true
}
}
}
return false
} | go | {
"resource": ""
} |
q22382 | NewStubProxy | train | func NewStubProxy(frontendAddr, backendAddr net.Addr) (Proxy, error) {
return &StubProxy{
frontendAddr: frontendAddr,
backendAddr: backendAddr,
}, nil
} | go | {
"resource": ""
} |
q22383 | CheckRouteOverlaps | train | func CheckRouteOverlaps(toCheck *net.IPNet) error {
if networkGetRoutesFct == nil {
networkGetRoutesFct = ns.NlHandle().RouteList
}
networks, err := networkGetRoutesFct(nil, netlink.FAMILY_V4)
if err != nil {
return err
}
for _, network := range networks {
if network.Dst != nil && NetworkOverlaps(toCheck, n... | go | {
"resource": ""
} |
q22384 | GenerateIfaceName | train | func GenerateIfaceName(nlh *netlink.Handle, prefix string, len int) (string, error) {
linkByName := netlink.LinkByName
if nlh != nil {
linkByName = nlh.LinkByName
}
for i := 0; i < 3; i++ {
name, err := GenerateRandomName(prefix, len)
if err != nil {
continue
}
_, err = linkByName(name)
if err != nil... | go | {
"resource": ""
} |
q22385 | GC | train | func GC() {
gpmLock.Lock()
if len(garbagePathMap) == 0 {
// No need for GC if map is empty
gpmLock.Unlock()
return
}
gpmLock.Unlock()
// if content exists in the garbage paths
// we can trigger GC to run, providing a
// channel to be notified on completion
waitGC := make(chan struct{})
gpmChan <- waitGC... | go | {
"resource": ""
} |
q22386 | GetSandboxForExternalKey | train | func GetSandboxForExternalKey(basePath string, key string) (Sandbox, error) {
if err := createNamespaceFile(key); err != nil {
return nil, err
}
if err := mountNetworkNamespace(basePath, key); err != nil {
return nil, err
}
n := &networkNamespace{path: key, nextIfIndex: make(map[string]int)}
sboxNs, err := ... | go | {
"resource": ""
} |
q22387 | InitOSContext | train | func InitOSContext() func() {
runtime.LockOSThread()
if err := ns.SetNamespace(); err != nil {
logrus.Error(err)
}
return runtime.UnlockOSThread
} | go | {
"resource": ""
} |
q22388 | ApplyOSTweaks | train | func (n *networkNamespace) ApplyOSTweaks(types []SandboxType) {
for _, t := range types {
switch t {
case SandboxTypeLoadBalancer:
kernel.ApplyOSTweaks(loadBalancerConfig)
}
}
} | go | {
"resource": ""
} |
q22389 | Watch | train | func (nDB *NetworkDB) Watch(tname, nid, key string) (*events.Channel, func()) {
var matcher events.Matcher
if tname != "" || nid != "" || key != "" {
matcher = events.MatcherFunc(func(ev events.Event) bool {
var evt event
switch ev := ev.(type) {
case CreateEvent:
evt = event(ev)
case UpdateEvent:
... | go | {
"resource": ""
} |
q22390 | Run | train | func (proxy *TCPProxy) Run() {
quit := make(chan bool)
defer close(quit)
for {
client, err := proxy.listener.Accept()
if err != nil {
log.Printf("Stopping proxy on tcp/%v for tcp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err)
return
}
go proxy.clientLoop(client.(*net.TCPConn), quit)
}
} | go | {
"resource": ""
} |
q22391 | SetValue | train | func (h *Handle) SetValue(value []byte) error {
return json.Unmarshal(value, h)
} | go | {
"resource": ""
} |
q22392 | New | train | func (h *Handle) New() datastore.KVObject {
h.Lock()
defer h.Unlock()
return &Handle{
app: h.app,
store: h.store,
}
} | go | {
"resource": ""
} |
q22393 | CopyTo | train | func (h *Handle) CopyTo(o datastore.KVObject) error {
h.Lock()
defer h.Unlock()
dstH := o.(*Handle)
if h == dstH {
return nil
}
dstH.Lock()
dstH.bits = h.bits
dstH.unselected = h.unselected
dstH.head = h.head.getCopy()
dstH.app = h.app
dstH.id = h.id
dstH.dbIndex = h.dbIndex
dstH.dbExists = h.dbExists
... | go | {
"resource": ""
} |
q22394 | createIPVlan | train | func createIPVlan(containerIfName, parent, ipvlanMode string) (string, error) {
// Set the ipvlan mode. Default is bridge mode
mode, err := setIPVlanMode(ipvlanMode)
if err != nil {
return "", fmt.Errorf("Unsupported %s ipvlan mode: %v", ipvlanMode, err)
}
// verify the Docker host interface acting as the macvla... | go | {
"resource": ""
} |
q22395 | setIPVlanMode | train | func setIPVlanMode(mode string) (netlink.IPVlanMode, error) {
switch mode {
case modeL2:
return netlink.IPVLAN_MODE_L2, nil
case modeL3:
return netlink.IPVLAN_MODE_L3, nil
default:
return 0, fmt.Errorf("Unknown ipvlan mode: %s", mode)
}
} | go | {
"resource": ""
} |
q22396 | parentExists | train | func parentExists(ifaceStr string) bool {
_, err := ns.NlHandle().LinkByName(ifaceStr)
if err != nil {
return false
}
return true
} | go | {
"resource": ""
} |
q22397 | createVlanLink | train | func createVlanLink(parentName string) error {
if strings.Contains(parentName, ".") {
parent, vidInt, err := parseVlan(parentName)
if err != nil {
return err
}
// VLAN identifier or VID is a 12-bit field specifying the VLAN to which the frame belongs
if vidInt > 4094 || vidInt < 1 {
return fmt.Errorf("... | go | {
"resource": ""
} |
q22398 | createDummyLink | train | func createDummyLink(dummyName, truncNetID string) error {
// create a parent interface since one was not specified
parent := &netlink.Dummy{
LinkAttrs: netlink.LinkAttrs{
Name: dummyName,
},
}
if err := ns.NlHandle().LinkAdd(parent); err != nil {
return err
}
parentDummyLink, err := ns.NlHandle().LinkBy... | go | {
"resource": ""
} |
q22399 | delDummyLink | train | func delDummyLink(linkName string) error {
// delete the vlan subinterface
dummyLink, err := ns.NlHandle().LinkByName(linkName)
if err != nil {
return fmt.Errorf("failed to find link %s on the Docker host : %v", linkName, err)
}
// verify a parent interface is being deleted
if dummyLink.Attrs().ParentIndex != 0... | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.