// AddNamedPolicySafe calls AddNamedPolicy in a safe way, returns error instead of causing panic.
347607
func (e *Enforcer) AddNamedPolicySafe(ptype string, params ...interface{}) (result bool, err error) {
	defer func() {
		if r := recover(); r != nil {
			err = fmt.Errorf("%v", r)
			result = false
		}
	}()

	result = e.AddNamedPolicy(ptype, params...)
	err = nil
	return
}
1058329
func AddCustomFunc(name string, f CustomFunc) error {
	name = strings.Title(name)
	if unFuncs[name] {
		return fmt.Errorf("invalid function name: %s", name)
	}

	funcs[name] = reflect.ValueOf(f)
	return nil
}
655613
func NewNamedPipeServer(ctx context.Context, name string) (StreamServer, error) {
	switch l := len(name); {
	case l == 0:
		return nil, errors.New("cannot have empty name")
	case l > maxWindowsNamedPipeLength:
		return nil, errors.Reason("name exceeds maximum length %d", maxWindowsNamedPipeLength).
			InternalReason("name(%s)", name).Err()
	}

	ctx = log.SetField(ctx, "name", name)
	return &listenerStreamServer{
		Context: ctx,
		gen: func() (net.Listener, string, error) {
			address := "net.pipe:" + name
			pipePath := streamclient.LocalNamedPipePath(name)
			log.Fields{
				"addr":     address,
				"pipePath": pipePath,
			}.Debugf(ctx, "Creating Windows server socket Listener.")

			l, err := winio.ListenPipe(pipePath, nil)
			if err != nil {
				return nil, "", errors.Annotate(err, "failed to listen on named pipe").Err()
			}
			return l, address, nil
		},
	}, nil
}
1342307
func (n Namespace) AddDynamicElement(name, description string) Namespace {
	nse := NamespaceElement{Name: name, Description: description, Value: "*"}
	return append(n, nse)
}
823403
func (b *FirewallModelBuilder) addDNSRules(c *fi.ModelBuilderContext, sgMap map[string]*openstacktasks.SecurityGroup) error {

	masterName := b.SecurityGroupName(kops.InstanceGroupRoleMaster)
	nodeName := b.SecurityGroupName(kops.InstanceGroupRoleNode)
	masterSG := sgMap[masterName]
	nodeSG := sgMap[nodeName]
	for _, protocol := range []string{IPProtocolTCP, IPProtocolUDP} {
		dnsRule := &openstacktasks.SecurityGroupRule{
			Lifecycle:    b.Lifecycle,
			Direction:    s(string(rules.DirIngress)),
			Protocol:     s(protocol),
			EtherType:    s(IPV4),
			PortRangeMin: i(53),
			PortRangeMax: i(53),
		}
		addDirectionalGroupRule(c, masterSG, nodeSG, dnsRule)
		addDirectionalGroupRule(c, nodeSG, masterSG, dnsRule)
		addDirectionalGroupRule(c, masterSG, masterSG, dnsRule)
	}
	return nil
}
985759
func AddGlobalFlags(fs *pflag.FlagSet, name string) {
	addKlogFlags(fs)
	logs.AddFlags(fs)

	fs.BoolP("help", "h", false, fmt.Sprintf("help for %s", name))
}
73887
func AddTrustVerificationFlags(fs *pflag.FlagSet, v *bool, trusted bool) {
	fs.BoolVar(v, "disable-content-trust", !trusted, "Skip image verification")
}
1258157
func (n *NIC) AddAddressWithOptions(protocol tcpip.NetworkProtocolNumber, addr tcpip.Address, peb PrimaryEndpointBehavior) *tcpip.Error {
	// Add the endpoint.
	n.mu.Lock()
	_, err := n.addAddressLocked(protocol, addr, peb, false)
	n.mu.Unlock()

	return err
}
880717
func (r *PCPRegistry) AddInstanceDomain(indom InstanceDomain) error {
	if r.HasInstanceDomain(indom.Name()) {
		return errors.New("InstanceDomain is already defined for the current registry")
	}

	r.indomlock.Lock()
	defer r.indomlock.Unlock()

	if r.mapped {
		return errors.New("Cannot add an indom when a mapping is active")
	}

	r.instanceDomains[indom.Name()] = indom.(*PCPInstanceDomain)
	r.instanceCount += indom.InstanceCount()

	if !r.version2 {
		for _, v := range indom.Instances() {
			if len(v) > MaxV1NameLength {
				r.version2 = true
			}
		}
	}

	if indom.(*PCPInstanceDomain).shortDescription != "" {
		r.stringcount++
	}

	if indom.(*PCPInstanceDomain).longDescription != "" {
		r.stringcount++
	}

	return nil
}
1044216
func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet) {
	pflag.CommandLine.StringSliceVar(&ca.BasePeerDirs, "base-peer-dirs", ca.BasePeerDirs,
		"Comma-separated list of apimachinery import paths which are considered, after tag-specified peers, for conversions. Only change these if you have very good reasons.")
	pflag.CommandLine.StringSliceVar(&ca.ExtraPeerDirs, "extra-peer-dirs", ca.ExtraPeerDirs,
		"Application specific comma-separated list of import paths which are considered, after tag-specified peers and base-peer-dirs, for conversions.")
	pflag.CommandLine.BoolVar(&ca.SkipUnsafe, "skip-unsafe", ca.SkipUnsafe,
		"If true, will not generate code using unsafe pointer conversions; resulting code may be slower.")
}
1354176
func (c *DNSCache) addNameToCleanup(entry *cacheEntry) {
	if entry.ExpirationTime.Before(c.lastCleanup) {
		// ExpirationTime can be before the lastCleanup don't add that value to
		// prevent leaks on the map.
		return
	}
	expiration := entry.ExpirationTime.Unix()
	expiredEntries, exists := c.cleanup[expiration]
	if !exists {
		expiredEntries = []string{}
	}
	c.cleanup[expiration] = append(expiredEntries, entry.Name)
}
794611
func OptionDomainname(name string) SandboxOption {
	return func(sb *sandbox) {
		sb.config.domainName = name
	}
}
1182397
func AddNamespaceEndpoint(namespaceId string, endpointId string) error {
	logrus.Debugf("hcn::HostComputeEndpoint::AddNamespaceEndpoint id=%s", endpointId)

	mapA := map[string]string{"EndpointId": endpointId}
	settingsJson, err := json.Marshal(mapA)
	if err != nil {
		return err
	}
	requestMessage := &ModifyNamespaceSettingRequest{
		ResourceType: NamespaceResourceTypeEndpoint,
		RequestType:  RequestTypeAdd,
		Settings:     settingsJson,
	}

	return ModifyNamespaceSettings(namespaceId, requestMessage)
}
22066
func (e *Enforcer) GetNamedPolicy(ptype string) [][]string {
	return e.model.GetPolicy("p", ptype)
}
822474
func (b *BigIP) AddBGPInstance(config *BGPInstance) error {
	return b.post(config, uriNet, uriRouting, uriBGP)
}
442205
func (s *ReactionsService) Add(name string) *ReactionsAddCall {
	var call ReactionsAddCall
	call.service = s
	call.name = name
	return &call
}
999663
func (s *Output) SetNameModifier(v string) *Output {
	s.NameModifier = &v
	return s
}