// NewSimpleAllocationPlugin creates a new SimpleAllocationPlugin.
548869
func NewSimpleAllocationPlugin(suffix string) (*SimpleAllocationPlugin, error) {
	if len(suffix) == 0 {
		suffix = defaultDNSSuffix
	}

	klog.V(4).Infof("Route plugin initialized with suffix=%s", suffix)

	// Check that the DNS suffix is valid.
	if len(kvalidation.IsDNS1123Subdomain(suffix)) != 0 {
		return nil, fmt.Errorf("invalid DNS suffix: %s", suffix)
	}

	return &SimpleAllocationPlugin{DNSSuffix: suffix}, nil
}
939637
func NewSimpleElection(electionId, id string, callback func(leader string), c client.Interface) (*leaderelection.LeaderElector, error) {
	return NewElection(electionId, id, api.NamespaceDefault, 10*time.Second, callback, c)
}
658209
func (p *SimpleAllocationPlugin) Allocate(route *routeapi.Route) (*routeapi.RouterShard, error) {
	klog.V(4).Infof("Allocating global shard *.%s to Route: %s", p.DNSSuffix, route.Name)

	return &routeapi.RouterShard{ShardName: "global", DNSSuffix: p.DNSSuffix}, nil
}
474648
func NewRelocationBatchResult(Entries []*RelocationBatchResultData) *RelocationBatchResult {
	s := new(RelocationBatchResult)
	s.Entries = Entries
	return s
}
20681
func Convert_v1_RangeAllocation_To_core_RangeAllocation(in *v1.RangeAllocation, out *core.RangeAllocation, s conversion.Scope) error {
	return autoConvert_v1_RangeAllocation_To_core_RangeAllocation(in, out, s)
}
649728
func NewAllocateReplicaAllocationCommand(index string, shardId int, node string) *AllocateReplicaAllocationCommand {
	return &AllocateReplicaAllocationCommand{
		index:   index,
		shardId: shardId,
		node:    node,
	}
}
376388
func (factory *RouteAllocationControllerFactory) Create(plugin route.AllocationPlugin) *RouteAllocationController {
	return &RouteAllocationController{Plugin: plugin}
}
899886
func configLocation() string {
	// First, check for the "GOPASS_CONFIG" environment variable
	if cf := os.Getenv("GOPASS_CONFIG"); cf != "" {
		return cf
	}

	// Second, check for the "XDG_CONFIG_HOME" environment variable
	// (which is part of the XDG Base Directory Specification for Linux and
	// other Unix-like operating sytstems)
	if xch := os.Getenv("XDG_CONFIG_HOME"); xch != "" {
		return filepath.Join(xch, "gopass", "config.yml")
	}

	return filepath.Join(Homedir(), ".config", "gopass", "config.yml")
}
688993
func networkAllocAddress(nwCfg *mastercfg.CfgNetworkState, epgCfg *mastercfg.EndpointGroupState,
	reqAddr string, isIPv6 bool) (string, error) {
	var ipAddress string
	var ipAddrValue uint
	var found bool
	var err error
	var hostID string

	// alloc address
	if reqAddr == "" {
		if isIPv6 {
			// Get the next available IPv6 address
			hostID, err = netutils.GetNextIPv6HostID(nwCfg.IPv6LastHost, nwCfg.IPv6Subnet, nwCfg.IPv6SubnetLen, nwCfg.IPv6AllocMap)
			if err != nil {
				log.Errorf("create eps: error allocating ip. Error: %s", err)
				return "", err
			}
			ipAddress, err = netutils.GetSubnetIPv6(nwCfg.IPv6Subnet, nwCfg.IPv6SubnetLen, hostID)
			if err != nil {
				log.Errorf("create eps: error acquiring subnet ip. Error: %s", err)
				return "", err
			}
			nwCfg.IPv6LastHost = hostID
			netutils.ReserveIPv6HostID(hostID, &nwCfg.IPv6AllocMap)
		} else {
			if epgCfg != nil && len(epgCfg.IPPool) > 0 { // allocate from epg network
				log.Infof("allocating ip address from epg pool %s", epgCfg.IPPool)
				ipAddrValue, found = netutils.NextClear(epgCfg.EPGIPAllocMap, 0, nwCfg.SubnetLen)
				if !found {
					log.Errorf("auto allocation failed - address exhaustion in pool %s",
						epgCfg.IPPool)
					err = core.Errorf("auto allocation failed - address exhaustion in pool %s",
						epgCfg.IPPool)
					return "", err
				}
				ipAddress, err = netutils.GetSubnetIP(nwCfg.SubnetIP, nwCfg.SubnetLen, 32, ipAddrValue)
				if err != nil {
					log.Errorf("create eps: error acquiring subnet ip. Error: %s", err)
					return "", err
				}
				epgCfg.EPGIPAllocMap.Set(ipAddrValue)
			} else {
				ipAddrValue, found = netutils.NextClear(nwCfg.IPAllocMap, 0, nwCfg.SubnetLen)
				if !found {
					log.Errorf("auto allocation failed - address exhaustion in subnet %s/%d",
						nwCfg.SubnetIP, nwCfg.SubnetLen)
					err = core.Errorf("auto allocation failed - address exhaustion in subnet %s/%d",
						nwCfg.SubnetIP, nwCfg.SubnetLen)
					return "", err
				}
				ipAddress, err = netutils.GetSubnetIP(nwCfg.SubnetIP, nwCfg.SubnetLen, 32, ipAddrValue)
				if err != nil {
					log.Errorf("create eps: error acquiring subnet ip. Error: %s", err)
					return "", err
				}
				nwCfg.IPAllocMap.Set(ipAddrValue)
			}
		}

		// Docker, Mesos issue a Alloc Address first, followed by a CreateEndpoint
		// Kubernetes issues a create endpoint directly
		// since networkAllocAddress is called from both AllocAddressHandler and CreateEndpointHandler,
		// we need to make sure that the EpCount is incremented only when we are allocating
		// a new IP. In case of Docker, Mesos CreateEndPoint will already request a IP that
		// allocateAddress had allocated in the earlier call.
		nwCfg.EpAddrCount++

	} else if reqAddr != "" && nwCfg.SubnetIP != "" {
		if isIPv6 {
			hostID, err = netutils.GetIPv6HostID(nwCfg.IPv6Subnet, nwCfg.IPv6SubnetLen, reqAddr)
			if err != nil {
				log.Errorf("create eps: error getting host id from hostIP %s Subnet %s/%d. Error: %s",
					reqAddr, nwCfg.IPv6Subnet, nwCfg.IPv6SubnetLen, err)
				return "", err
			}
			netutils.ReserveIPv6HostID(hostID, &nwCfg.IPv6AllocMap)
		} else {

			if epgCfg != nil && len(epgCfg.IPPool) > 0 { // allocate from epg network
				ipAddrValue, err = netutils.GetIPNumber(nwCfg.SubnetIP, nwCfg.SubnetLen, 32, reqAddr)
				if err != nil {
					log.Errorf("create eps: error getting host id from hostIP %s pool %s. Error: %s",
						reqAddr, epgCfg.IPPool, err)
					return "", err
				}
				epgCfg.EPGIPAllocMap.Set(ipAddrValue)
			} else {
				ipAddrValue, err = netutils.GetIPNumber(nwCfg.SubnetIP, nwCfg.SubnetLen, 32, reqAddr)
				if err != nil {
					log.Errorf("create eps: error getting host id from hostIP %s Subnet %s/%d. Error: %s",
						reqAddr, nwCfg.SubnetIP, nwCfg.SubnetLen, err)
					return "", err
				}
				nwCfg.IPAllocMap.Set(ipAddrValue)
			}
		}

		ipAddress = reqAddr
	}

	if epgCfg != nil && len(epgCfg.IPPool) > 0 {
		err = epgCfg.Write()
		if err != nil {
			log.Errorf("error writing epg config. Error: %s", err)
			return "", err
		}
	}

	err = nwCfg.Write()
	if err != nil {
		log.Errorf("error writing nw config. Error: %s", err)
		return "", err
	}

	return ipAddress, nil
}
1335831
func (c *Client) LoadPlugin(p []string) *LoadPluginResult {
	r := new(LoadPluginResult)
	resp, err := c.pluginUploadRequest(p)
	if err != nil {
		r.Err = serror.New(err)
		return r
	}

	switch resp.Meta.Type {
	case rbody.PluginsLoadedType:
		pl := resp.Body.(*rbody.PluginsLoaded)
		r.LoadedPlugins = convertLoadedPlugins(pl.LoadedPlugins)
	case rbody.ErrorType:
		f := resp.Body.(*rbody.Error).Fields
		fields := make(map[string]interface{})
		for k, v := range f {
			fields[k] = v
		}
		r.Err = serror.New(resp.Body.(*rbody.Error), fields)
	default:
		r.Err = serror.New(ErrAPIResponseMetaType)
	}
	return r
}
271356
func LoadPlugin(name string) (Plugin, bool, error) {
	pluginDir := GetPluginDir(name)

	if exists, err := pathutil.IsDirExists(pluginDir); err != nil {
		return Plugin{}, false, fmt.Errorf("Failed to check dir (%s), err: %s", pluginDir, err)
	} else if !exists {
		return Plugin{}, false, nil
	}

	pluginYMLPath := GetPluginDefinitionPath(name)
	plugin, err := ParsePluginFromYML(pluginYMLPath)
	if err != nil {
		return Plugin{}, true, err
	}

	return plugin, true, nil
}
222657
func NewSimplePageMapper(errUrl string, loginUrl string, logoutUrl string) *SimplePageMapper {
	return &SimplePageMapper{
		errorPage: errUrl,
		loginOk:   loginUrl,
		logoutOk:  logoutUrl,
	}
}
132379
func NewBlockSplitterSimpleExact(
	maxSize int64, maxPtrsPerBlock int, blockChangeEmbedMaxSize uint64) (
	*BlockSplitterSimple, error) {
	maxDirEntriesPerBlock, err := getMaxDirEntriesPerBlock()
	if err != nil {
		return nil, err
	}
	return &BlockSplitterSimple{
		maxSize:                 maxSize,
		maxPtrsPerBlock:         maxPtrsPerBlock,
		blockChangeEmbedMaxSize: blockChangeEmbedMaxSize,
		maxDirEntriesPerBlock:   maxDirEntriesPerBlock,
	}, nil
}
212982
func newSimpleRateLimiter(mbPerSec float64) *SimpleRateLimiter {
	ans := &SimpleRateLimiter{}
	ans.SetMbPerSec(mbPerSec)
	return ans
}
647085
func (bot TgBot) SimpleSendLocation(msg Message, latitude float64, longitude float64) (res Message, err error) {
	ressm := bot.SendLocation(msg.Chat.ID, latitude, longitude, nil, nil)
	return splitResultInMessageError(ressm)
}
1232623
func (p *Predict) VaultPlugins(pluginTypes ...consts.PluginType) complete.Predictor {
	filterFunc := func() []string {
		return p.plugins(pluginTypes...)
	}
	return p.filterFunc(filterFunc)
}
558976
func (a *StartTrackingHeapObjectsArgs) SetTrackAllocations(trackAllocations bool) *StartTrackingHeapObjectsArgs {
	a.TrackAllocations = &trackAllocations
	return a
}