// ScopesForInternalAddrTypes returns the set of key scopes that are able to
// produce the target address type as internal addresses.
764954
func (m *Manager) ScopesForInternalAddrTypes(addrType AddressType) []KeyScope {
	m.mtx.RLock()
	defer m.mtx.RUnlock()

	scopes, _ := m.internalAddrSchemas[addrType]
	return scopes
}
517033
func SelectInternalAddresses(addresses []Address, machineLocal bool) []Address {
	indexes := bestAddressIndexes(len(addresses), func(i int) Address {
		return addresses[i]
	}, internalAddressMatcher(machineLocal))
	if len(indexes) == 0 {
		return nil
	}

	out := make([]Address, 0, len(indexes))
	for _, index := range indexes {
		out = append(out, addresses[index])
	}
	return out
}
1290978
func (cm AsStandard) MValidationExternalType(resource, validationExternal string) *metadata.MValidationExternalType {
	mvet := metadata.MValidationExternalType{}
	mi := metadata.MIValidationExternalType
	for _, cd := range cm.Elements[mi.Name] {
		if cd.Attr["Resource"] != resource {
			continue
		}
		if cd.Attr["ValidationExternal"] != validationExternal {
			continue
		}
		metadata.FieldTransfer(cd.Attr).To(&mvet)
		for _, entry := range cd.Entries() {
			tmp := metadata.ValidationExternalType{}
			entry.SetFields(&tmp)
			mvet.ValidationExternalType = append(mvet.ValidationExternalType, tmp)
		}
	}
	return &mvet
}
1154694
func ExactScopeMatch(addr Address, addrScopes ...Scope) bool {
	for _, scope := range addrScopes {
		if addr.Scope == scope {
			return true
		}
	}
	return false
}
1156556
func ScopeForViewingRolesInResourceType(resourceType string) string {
	switch resourceType {
	case ResourceTypeSpace:
		return ViewRoleAssignmentsInSpaceScope
	case IdentityResourceTypeOrganization:
		return ViewOrganizationMembersScope
	case IdentityResourceTypeTeam:
		return ViewTeamMembersScope
	case IdentityResourceTypeGroup:
		return ViewSecurityGroupMembersScope
	}
	// a default which we can choose to change later
	return ViewRoleAssignmentsInSpaceScope
}
45096
func (s *S3Settings) SetExternalTableDefinition(v string) *S3Settings {
	s.ExternalTableDefinition = &v
	return s
}
405094
func (env *environ) StorageProviderTypes() ([]storage.ProviderType, error) {
	var types []storage.ProviderType
	if env.storageSupported() {
		types = append(types, lxdStorageProviderType)
	}
	return types, nil
}
773940
func (ic *IngressIPController) ensureExternalIP(service *v1.Service, key, ingressIP string) error {
	// Assume it is safe to modify the service without worrying about changing the local cache

	ipExists := false
	for _, ip := range service.Spec.ExternalIPs {
		if ip == ingressIP {
			ipExists = true
			klog.V(6).Infof("Service %v already has ip %v as an external ip", key, ingressIP)
			break
		}
	}
	if !ipExists {
		service.Spec.ExternalIPs = append(service.Spec.ExternalIPs, ingressIP)
		klog.V(5).Infof("Adding ip %v to service %v as an external ip", ingressIP, key)
		return ic.persistServiceSpec(service)
	}
	return nil
}
1006130
func (s *ModifyEndpointInput) SetExternalTableDefinition(v string) *ModifyEndpointInput {
	s.ExternalTableDefinition = &v
	return s
}
761228
func (r ChainedProviderRegistry) StorageProviderTypes() ([]ProviderType, error) {
	var result []ProviderType
	for _, r := range r {
		types, err := r.StorageProviderTypes()
		if err != nil {
			return nil, errors.Trace(err)
		}
		result = append(result, types...)
	}
	return result, nil
}
231754
func (c *ResourceController) Scopes(ctx *app.ScopesResourceContext) error {
	// Load the identity from the context
	currentIdentity, err := c.app.UserService().LoadContextIdentityIfNotBanned(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}

	// Check if the resource exists
	err = c.app.ResourceRepository().CheckExists(ctx, ctx.ResourceID)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}

	// Load the scopes
	pc, err := c.app.PrivilegeCacheService().CachedPrivileges(ctx, currentIdentity.ID, ctx.ResourceID)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}

	scopes := []*app.ResourceScopes{}

	for _, scope := range pc.ScopesAsArray() {
		scopes = append(scopes, &app.ResourceScopes{
			ID:   scope,
			Type: "user_resource_scope",
		})
	}

	res := &app.ResourceScopesData{
		Data: scopes,
	}

	return ctx.OK(res)
}
1207765
func AddressedTypes(providerAddrs []addrs.ProviderConfig) []string {
	if len(providerAddrs) == 0 {
		return nil
	}
	m := map[string]struct{}{}
	for _, addr := range providerAddrs {
		m[addr.Type] = struct{}{}
	}

	names := make([]string, 0, len(m))
	for typeName := range m {
		names = append(names, typeName)
	}

	sort.Strings(names) // Stable result for tests
	return names
}
350975
func (s *CreateEndpointInput) SetExternalTableDefinition(v string) *CreateEndpointInput {
	s.ExternalTableDefinition = &v
	return s
}
557035
func (env *environ) StorageProviderTypes() ([]storage.ProviderType, error) {
	return []storage.ProviderType{EBS_ProviderType}, nil
}
1329879
func getSecurityScopes(ss raml.DefinitionChoice) ([]string, error) {
	scopes := []string{}

	// check if there is scopes
	v, ok := ss.Parameters["scopes"]
	if !ok {
		return scopes, nil
	}

	// cast it to []string, return error if failed
	scopesArr, ok := v.([]interface{})
	if !ok {
		return scopes, fmt.Errorf("scopes must be array")
	}

	// build []string
	for _, s := range scopesArr {
		scopes = append(scopes, s.(string))
	}
	return scopes, nil
}
998498
func Scope(name string, desc ...string) {
	switch current := dslengine.CurrentDefinition().(type) {
	case *design.SecurityDefinition:
		if len(desc) >= 1 {
			dslengine.ReportError("too many arguments")
			return
		}
		current.Scopes = append(current.Scopes, name)
	case *design.SecuritySchemeDefinition:
		if len(desc) > 1 {
			dslengine.ReportError("too many arguments")
			return
		}
		if current.Scopes == nil {
			current.Scopes = make(map[string]string)
		}
		d := "no description"
		if len(desc) == 1 {
			d = desc[0]
		}
		current.Scopes[name] = d
	default:
		dslengine.IncompatibleDSL()
	}
}
514505
func DefaultScopes(dataDir string) map[string]*ScopeCfg {
	if dataDir != "" {
		defaultScopes[LocalScope].Client.Address = dataDir + "/network/files/local-kv.db"
		return defaultScopes
	}

	defaultScopes[LocalScope].Client.Address = defaultPrefix + "/local-kv.db"
	return defaultScopes
}