id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c22400 | }
defaultScopes[LocalScope].Client.Address = defaultPrefix + "/local-kv.db"
return defaultScopes
} | |
c22401 | strings.TrimSpace(cfg.Client.Address) == "" {
return false
}
return true
} | |
c22402 | strings.Join(keychain, "/")
return str + "/"
} | |
c22403 | <= len(rootChain) || !reflect.DeepEqual(chain[0:len(rootChain)], rootChain) {
return nil, types.BadRequestErrorf("invalid Key : %s", key)
}
return chain[len(rootChain):], nil
} | |
c22404 |
// Add the custom prefix to the root chain
if len(parts) == 2 {
rootChain = append([]string{parts[1]}, defaultRootChain...)
}
}
store, err := libkv.NewStore(store.Backend(kv), addrs, config)
if err != nil {
return nil, err
}
ds := &datastore{scope: scope, store: store, active: true, watchCh: make(cha... | |
c22405 | || c.Client.Address == "" {
return nil, fmt.Errorf("unexpected scope %s without configuration passed", scope)
}
cfg = c
}
var cached bool
if scope == LocalScope {
cached = true
}
return newClient(scope, cfg.Client.Provider, cfg.Client.Address, cfg.Client.Config, cached)
} | |
c22406 | }
ds, err := NewDataStore(dsc.Scope, scopeCfg)
if err != nil {
return nil, fmt.Errorf("failed to construct datastore client from datastore configuration %v: %v", dsc, err)
}
return ds, err
} | |
c22407 | = nil
}
_, pair, err = ds.store.AtomicPut(Key(kvObject.Key()...), kvObjValue, previous, nil)
if err != nil {
if err == store.ErrKeyExists {
return ErrKeyModified
}
return err
}
kvObject.SetIndex(pair.LastIndex)
add_cache:
if ds.cache != nil {
// If persistent store is skipped, sequencing needs to
... | |
c22408 |
return err
}
add_cache:
if ds.cache != nil {
// If persistent store is skipped, sequencing needs to
// happen in cache.
return ds.cache.add(kvObject, kvObject.Skip())
}
return nil
} | |
c22409 |
if err != nil {
return err
}
if err := o.SetValue(kvPair.Value); err != nil {
return err
}
// Make sure the object has a correct view of the DB index in
// case we need to modify it and update the DB.
o.SetIndex(kvPair.LastIndex)
return nil
} | |
c22410 | in cache.
ds.cache.del(kvObject, kvObject.Skip())
}
if kvObject.Skip() {
return nil
}
return ds.store.Delete(Key(kvObject.Key()...))
} | |
c22411 | return err
}
del_cache:
// cleanup the cache only if AtomicDelete went through successfully
if ds.cache != nil {
// If persistent store is skipped, sequencing needs to
// happen in cache.
return ds.cache.del(kvObject, kvObject.Skip())
}
return nil
} | |
c22412 | in cache.
ds.cache.del(kvObject, kvObject.Skip())
}
if kvObject.Skip() {
return nil
}
return ds.store.DeleteTree(Key(kvObject.KeyPrefix()...))
} | |
c22413 |
logrus.Errorf("error registering driver for %s due to %v", name, err)
}
}
// Unit test code is unaware of a true PluginStore. So we fall back to v1 plugins.
handleFunc := plugins.Handle
if pg := dc.GetPluginGetter(); pg != nil {
handleFunc = pg.Handle
activePlugins := pg.GetAllManagedPluginsByCap(drivera... | |
c22414 |
default:
return nil, fmt.Errorf("invalid capability: expecting 'local' or 'global', got %s", capResp.Scope)
}
switch capResp.ConnectivityScope {
case "global":
c.ConnectivityScope = datastore.GlobalScope
case "local":
c.ConnectivityScope = datastore.LocalScope
case "":
c.ConnectivityScope = c.DataScope
... | |
c22415 |
Options: options,
}
err := d.call("ProgramExternalConnectivity", data, &api.ProgramExternalConnectivityResponse{})
if err != nil && plugins.IsNotFound(err) {
// It is not mandatory yet to support this method
return nil
}
return err
} | |
c22416 | if err != nil && plugins.IsNotFound(err) {
// It is not mandatory yet to support this method
return nil
}
return err
} | |
c22417 | {
return nil, err
}
}
if inIf.MacAddress != "" {
if outIf.MacAddress, err = net.ParseMAC(inIf.MacAddress); err != nil {
return nil, err
}
}
}
return outIf, nil
} | |
c22418 | for _, conn := range proxy.connTrackTable {
conn.Close()
}
} | |
c22419 | keys = append(keys, key.Key)
tags = append(tags, key.LamportTime)
}
}
keys[0], keys[1] = keys[1], keys[0]
tags[0], tags[1] = tags[1], tags[0]
return keys, tags
} | |
c22420 | keys := []*types.EncryptionKey{}
for _, key := range c.keys {
if key.Subsystem == subsys {
keys = append(keys, key)
}
}
return keys[1].Key, keys[1].LamportTime, nil
} | |
c22421 | != nil {
return nil
}
// first check if the mask lengths are the same
i, _ := snet.Mask.Size()
j, _ := ip.Mask.Size()
if i != j {
continue
}
if snet.Contains(ip.IP) {
return s
}
}
return nil
} | |
c22422 | != nil {
return nil
}
// first check if the mask lengths are the same
i, _ := snet.Mask.Size()
j, _ := ip.Mask.Size()
if i != j {
continue
}
if snet.Contains(ip.IP) {
return s
}
}
return nil
} | |
c22423 | fs.output == nil {
return os.Stderr
}
return fs.output
} | |
c22424 | fs.actual[name] != nil
} | |
c22425 | }
if fs.actual == nil {
fs.actual = make(map[string]*Flag)
}
fs.actual[name] = flag
return nil
} | |
c22426 | if isZeroValue(val) {
format := " -%s"
fmt.Fprintf(writer, format, strings.Join(names, ", -"))
} else {
format := " -%s=%s"
fmt.Fprintf(writer, format, strings.Join(names, ", -"), val)
}
for _, line := range strings.Split(flag.Usage, "\n") {
fmt.Fprintln(writer, "\t", line)
}
}
})
... | |
c22427 | {
if name[0] != '#' {
count++
break
}
}
}
return count
} | |
c22428 | defaultUsage(fs)
} else {
fs.Usage()
}
} | |
c22429 | + os.Args[0] + " " + fs.Name() + " --help'"
}
}
fmt.Fprintf(fs.Out(), "%s: %s.\n", os.Args[0], str)
} | |
c22430 | string
}
if nVal, ok := v.Value.(namedValue); ok {
return nVal.Name()
}
return v.key
} | |
c22431 | {
case ContinueOnError:
return err
case ExitOnError:
os.Exit(2)
case PanicOnError:
panic(err)
}
}
newF := *f
newF.Value = mergeVal{f.Value, k, fset}
if dest.formal == nil {
dest.formal = make(map[string]*Flag)
}
dest.formal[k] = &newF
}
}
return nil
} | |
c22432 |
}
if num, err := strconv.Atoi(parts[1]); err != nil {
return fmt.Errorf("invalid number for ndots option: %v", parts[1])
} else if num >= 0 {
// if the user sets ndots, use the user setting
sb.ndotsSet = true
break dnsOpt
} else {
return fmt.Errorf("invalid number for ... | |
c22433 | *NetworkCli {
return &NetworkCli{
out: out,
err: err,
call: call,
}
} | |
c22434 |
method := reflect.ValueOf(cli).MethodByName(methodName)
if !method.IsValid() {
return nil, false
}
return method.Interface().(func(string, ...string) error), true
} | |
c22435 | cli.getMethod(args[:2]...)
if exists {
return method(chain+" "+args[0], args[2:]...)
}
}
if len(args) > 0 {
method, exists := cli.getMethod(args[0])
if !exists {
return fmt.Errorf("%s: '%s' is not a %s command. See '%s --help'", chain, args[0], chain, chain)
}
return method(chain, args[1:]...)
}
... | |
c22436 | " " + signature
}
if flags.FlagCountUndeprecated() > 0 {
options = " [OPTIONS]"
}
fmt.Fprintf(cli.out, "\nUsage: %s %s%s%s\n\n%s\n\n", chain, name, options, signature, description)
flags.SetOutput(cli.out)
}
return flags
} | |
c22437 | fmt.Fprintf(w, "%s\t%s\n", r.IP, r.Hosts)
return int64(n), err
} | |
c22438 | pathMutex.Unlock()
delete(pathMap, path)
} | |
c22439 | }
parts := strings.SplitN(fqdn, ".", 2)
if len(parts) == 2 {
mainRec.Hosts = fmt.Sprintf("%s %s", fqdn, parts[0])
} else {
mainRec.Hosts = fqdn
}
if _, err := mainRec.WriteTo(content); err != nil {
return err
}
}
// Write defaultContent slice to buffer
for _, r := range defaultContent {
if _,... | |
c22440 | err
}
var re = regexp.MustCompile(fmt.Sprintf("(\\S*)(\\t%s)(\\s|\\.)", regexp.QuoteMeta(hostname)))
return ioutil.WriteFile(path, re.ReplaceAll(old, []byte(IP+"$2"+"$3")), 0644)
} | |
c22441 |
if err := n.joinSandbox(s, true, true); err != nil {
return fmt.Errorf("restore network sandbox failed: %v", err)
}
Ifaces := make(map[string][]osl.IfaceOption)
vethIfaceOption := make([]osl.IfaceOption, 1)
vethIfaceOption = append(vethIfaceOption, n.sbox.InterfaceOptions().Master(s.brName))
Ifaces["ve... | |
c22442 | if d.peerOpCancel != nil {
d.peerOpCancel()
}
if d.exitCh != nil {
waitCh := make(chan struct{})
d.exitCh <- waitCh
<-waitCh
}
} | |
c22443 | DataScope: datastore.LocalScope,
ConnectivityScope: datastore.LocalScope,
}
return dc.RegisterDriver(networkType, &driver{}, c)
} | |
c22444 |
// Attempt to find an existing bridge named with the specified name.
i.Link, err = nlh.LinkByName(config.BridgeName)
if err != nil {
logrus.Debugf("Did not find any interface with name %s: %v", config.BridgeName, err)
} else if _, ok := i.Link.(*netlink.Bridge); !ok {
return nil, fmt.Errorf("existing interfac... | |
c22445 | != nil {
return nil, nil, fmt.Errorf("Failed to retrieve V6 addresses: %v", err)
}
if len(v4addr) == 0 {
return nil, v6addr, nil
}
return v4addr, v6addr, nil
} | |
c22446 |
// Register local handlers
s.RegisterHandler(s, diagPaths2Func)
} | |
c22447 | continue
}
s.mux.Handle(path, httpHandlerCustom{ctx, fun})
s.registeredHanders[path] = true
}
} | |
c22448 |
srv := &http.Server{Addr: fmt.Sprintf("%s:%d", ip, port), Handler: s}
s.srv = srv
s.enable = 1
go func(n *Server) {
// Ignore ErrServerClosed that is returned on the Shutdown call
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
logrus.Errorf("ListenAndServe error: %s", err)
at... | |
c22449 |
s.enable = 0
logrus.Info("Disabling the diagnostic server")
} | |
c22450 |
defer s.Unlock()
return s.enable == 1
} | |
c22451 | v := range r.Form {
logrus.Debugf("Form[%q] = %q\n", k, v)
}
} | |
c22452 | "pretty"
}
return unsafe, &JSONOutput{enable: json, prettyPrint: pretty}
} | |
c22453 | response, err = json.Marshal(r)
if err != nil {
response, _ = json.Marshal(FailCommand(err))
}
}
} else {
response = []byte(r.String())
}
return fmt.Fprint(w, string(response))
} | |
c22454 | if err := a.call("GetDefaultAddressSpaces", nil, res); err != nil {
return "", "", err
}
return res.LocalDefaultAddressSpace, res.GlobalDefaultAddressSpace, nil
} | |
c22455 | Pool: pool, SubPool: subPool, Options: options, V6: v6}
res := &api.RequestPoolResponse{}
if err := a.call("RequestPool", req, res); err != nil {
return "", nil, nil, err
}
retPool, err := types.ParseCIDR(res.Pool)
return res.PoolID, retPool, res.Data, err
} | |
c22456 | &api.ReleasePoolResponse{}
return a.call("ReleasePool", req, res)
} | |
c22457 | := a.call("RequestAddress", req, res); err != nil {
return nil, nil, err
}
if res.Address != "" {
retAddress, err = types.ParseCIDR(res.Address)
} else {
return nil, nil, ipamapi.ErrNoIPReturned
}
return retAddress, res.Data, err
} | |
c22458 | Address: relAddress}
res := &api.ReleaseAddressResponse{}
return a.call("ReleaseAddress", req, res)
} | |
c22459 |
Details: &ErrorCmd{Error: err.Error()},
}
} | |
c22460 |
return &HTTPResult{
Message: message,
Details: &UsageCmd{Usage: usage},
}
} | |
c22461 | datastore.LocalScope,
ConnectivityScope: datastore.LocalScope,
}
return dc.RegisterDriver(networkType, d, c)
} | |
c22462 | gw must belong to AddressIPv6 subnet
if c.EnableIPv6 && c.DefaultGatewayIPv6 != nil {
if c.AddressIPv6 == nil || !c.AddressIPv6.Contains(c.DefaultGatewayIPv6) {
return &ErrInvalidGateway{}
}
}
return nil
} | |
c22463 | if (c.AddressIPv4 != nil && o.AddressIPv4 != nil) &&
(c.AddressIPv4.Contains(o.AddressIPv4.IP) || o.AddressIPv4.Contains(c.AddressIPv4.IP)) {
return errors.New("networks have overlapping IPv4")
}
// They must be in different v6 subnets
if (c.AddressIPv6 != nil && o.AddressIPv6 != nil) &&
(c.AddressIPv6.Conta... | |
c22464 |
return config.AddressIPv6
}
if i.bridgeIPv6 != nil && i.bridgeIPv6.IP != nil && !i.bridgeIPv6.IP.IsLinkLocalUnicast() {
return i.bridgeIPv6
}
return nil
} | |
c22465 | network conflicts
if err = d.checkConflict(config); err != nil {
nerr, ok := err.(defaultBridgeNetworkConflict)
if !ok {
return err
}
// Got a conflict with a stale default network, clean that up and continue
logrus.Warn(nerr)
d.deleteNetwork(nerr.ID)
}
// there is no conflict, now create the networ... | |
c22466 |
return s.ipToEndpoint.Insert(ip, eID)
} | |
c22467 |
return s.ipToEndpoint.Remove(ip, eID)
} | |
c22468 | {
return nil, err
}
c.drvRegistry = drvRegistry
if c.cfg != nil && c.cfg.Cluster.Watcher != nil {
if err := c.initDiscovery(c.cfg.Cluster.Watcher); err != nil {
// Failing to initialize discovery is a bad situation to be in.
// But it cannot fail creating the Controller
logrus.Errorf("Failed to Initi... | |
c22469 | subsystem")
}
subsysKeys[key.Subsystem]++
}
for s, count := range subsysKeys {
if count != keyringSize {
return fmt.Errorf("incorrect number of keys for subsystem %v", s)
}
}
agent := c.getAgent()
if agent == nil {
c.Lock()
c.keys = keys
c.Unlock()
return nil
}
return c.handleKeyChange(keys... | |
c22470 | := c.agentInitDone
c.Unlock()
if agentInitDone != nil {
<-agentInitDone
}
} | |
c22471 |
if agentStopDone != nil {
<-agentStopDone
}
} | |
c22472 | c.agentStopDone == nil {
c.agentStopDone = make(chan struct{})
}
c.Unlock()
} | |
c22473 | close(c.agentInitDone)
c.agentInitDone = nil
}
c.Unlock()
} | |
c22474 | close(c.agentStopDone)
c.agentStopDone = nil
}
c.Unlock()
} | |
c22475 | if s.containerID == id {
sb = s
break
}
}
c.Unlock()
// It is not an error if sandbox is not available
if sb == nil {
return nil
}
return sb.Delete()
} | |
c22476 | containerID {
*out = sb
return true
}
return false
}
} | |
c22477 | key {
*out = sb
return true
}
return false
}
} | |
c22478 | {
c.DiagnosticServer.EnableDiagnostic("127.0.0.1", port)
}
c.Unlock()
} | |
c22479 | {
c.DiagnosticServer.DisableDiagnostic()
}
c.Unlock()
} | |
c22480 | return c.DiagnosticServer.IsDiagnosticEnabled()
} | |
c22481 | err := removeNetworkChain(n.id[:12]); err != nil {
logrus.Warnf("could not remove network chain: %v", err)
}
}
// Close the netlink socket, this will also release the watchMiss goroutine that is using it
if n.nlSocket != nil {
n.nlSocket.Close()
n.nlSocket = nil
}
n.sbox.Destroy()
n.sbox = n... | |
c22482 | else {
if err := n.setupSubnetSandbox(s, brName, vxlanName); err != nil {
return err
}
}
s.vxlanName = vxlanName
s.brName = brName
return nil
} | |
c22483 | = d
n.endpoints = endpointTable{}
d.networks[nid] = n
}
return n
} | |
c22484 | // a valid example is 'eth0.10' for a parent iface 'eth0' with a vlan id '10'
err := createVlanLink(config.Parent)
if err != nil {
return err
}
// if driver created the networks slave link, record it for future deletion
config.CreatedSlaveLink = true
}
}
n := &network{
id: config.ID,
... | |
c22485 | n.config.Parent, err)
}
}
}
}
for _, ep := range n.endpoints {
if link, err := ns.NlHandle().LinkByName(ep.srcName); err == nil {
if err := ns.NlHandle().LinkDel(link); err != nil {
logrus.WithError(err).Warnf("Failed to delete interface (%s)'s link on endpoint (%s) delete", ep.srcName, ep.id)
... | |
c22486 | parent link
if _, ok := option[netlabel.Internal]; ok {
config.Internal = true
// empty --parent= and --internal are handled the same.
config.Parent = ""
}
return config, nil
} | |
c22487 | = options.GenerateFromModel(opt, config); err == nil {
config = opaqueConfig.(*configuration)
}
default:
err = types.BadRequestErrorf("unrecognized network configuration format: %v", opt)
}
return config, err
} | |
c22488 | case driverModeOpt:
// parse driver option '-o ipvlan_mode'
config.IpvlanMode = value
}
}
return nil
} | |
c22489 | := range ipamV6Data {
s := &ipv6Subnet{
SubnetIP: ipd.Pool.String(),
GwIP: ipd.Gateway.String(),
}
config.Ipv6Subnets = append(config.Ipv6Subnets, s)
}
}
return nil
} | |
c22490 | nodes: mapset.NewSet(), stopChan: make(chan struct{})}
} | |
c22491 | am := make(map[string]string, len(i.AuxAddresses))
for k, v := range i.AuxAddresses {
am[k] = v.String()
}
m["AuxAddresses"] = am
}
return json.Marshal(m)
} | |
c22492 | if v, ok := m["AuxAddresses"]; ok {
b, _ := json.Marshal(v)
var am map[string]string
if err = json.Unmarshal(b, &am); err != nil {
return err
}
i.AuxAddresses = make(map[string]*net.IPNet, len(am))
for k, v := range am {
if i.AuxAddresses[k], err = types.ParseCIDR(v); err != nil {
return err
}... | |
c22493 |
}
}
if !i.Pool.Contains(i.Gateway.IP) {
return types.BadRequestErrorf("invalid gateway address (%s) does not belong to the pool (%s)", i.Gateway, i.Pool)
}
for k, sip := range i.AuxAddresses {
if !i.Pool.Contains(sip.IP) {
return types.BadRequestErrorf("invalid secondary address %s (%s) does not belong to... | |
c22494 | := ep.Delete(false); err != nil {
return fmt.Errorf("container %s: deleting endpoint on GW Network failed: %v", sb.containerID, err)
}
return nil
} | |
c22495 | // TODO v6 needs to be handled.
if len(ep.Gateway()) > 0 {
return false
}
for _, r := range ep.StaticRoutes() {
if r.Destination != nil && r.Destination.String() == "0.0.0.0/0" {
return false
}
}
needGW = true
}
return needGW
} | |
c22496 | _, ok := err.(types.NotFoundError); ok {
n, err = c.createGWNetwork()
}
return n, err
} | |
c22497 |
continue
}
if len(ep.Gateway()) != 0 {
return ep
}
}
return nil
} | |
c22498 | _, nsNetwork, err := net.ParseCIDR(ns)
if err != nil {
return err
}
if NetworkOverlaps(toCheck, nsNetwork) {
return ErrNetworkOverlapsWithNameservers
}
}
}
return nil
} | |
c22499 | netX.Contains(netY.IP) || netY.Contains(netX.IP)
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.