code: func CalculateUsageStats(options quota.UsageStatsOptions,
  	listFunc ListFuncByNamespace,
  	scopeFunc MatchesScopeFunc,
  	usageFunc UsageFunc) (quota.UsageStats, error) {
  	// default each tracked resource to zero
  	result := quota.UsageStats{Used: corev1.ResourceList{}}
  	for _, resourceName := range options.Resources {
  		result.Used[resourceName] = resource.Quantity{Format: resource.DecimalSI}
  	}
  	items, err := listFunc(options.Namespace)
  	if err != nil {
  		return result, fmt.Errorf("failed to list content: %v", err)
  	}
  	for _, item := range items {
  		// need to verify that the item matches the set of scopes
  		matchesScopes := true
  		for _, scope := range options.Scopes {
  			innerMatch, err := scopeFunc(corev1.ScopedResourceSelectorRequirement{ScopeName: scope}, item)
  			if err != nil {
  				return result, nil
  			}
  			if !innerMatch {
  				matchesScopes = false
  			}
  		}
  		if options.ScopeSelector != nil {
  			for _, selector := range options.ScopeSelector.MatchExpressions {
  				innerMatch, err := scopeFunc(selector, item)
  				if err != nil {
  					return result, nil
  				}
  				matchesScopes = matchesScopes && innerMatch
  			}
  		}
  		// only count usage if there was a match
  		if matchesScopes {
  			usage, err := usageFunc(item)
  			if err != nil {
  				return result, err
  			}
  			result.Used = quota.Add(result.Used, usage)
  		}
  	}
  	return result, nil
  }
docs: // CalculateUsageStats is a utility function that knows how to calculate aggregate usage.