Documentation
¶
Index ¶
- Constants
- Variables
- func AllHTTPParamKeys() []string
- func AllocationFilterFromParamsV1(params AllocationFilterV1, labelConfig *kubecost.LabelConfig, ...) filter.Filter
- func AssetFilterFromParamsV1(qp mapper.PrimitiveMapReader, clusterMap clusters.ClusterMap) filter.Filter
- func DefaultFieldByName[T ~string](field T) *ast.Field
- func GetList(primaryKey, secondaryKey string, qp mapper.PrimitiveMapReader) []string
- func TestingOnlySortNode(n ast.FilterNode) ast.FilterNode
- func ValidAssetFilterParams() []string
- type AllocationFilterV1
Constants ¶
const ( ParamFilterClusters = "filterClusters" ParamFilterNodes = "filterNodes" ParamFilterNamespaces = "filterNamespaces" ParamFilterControllerKinds = "filterControllerKinds" ParamFilterControllers = "filterControllers" ParamFilterPods = "filterPods" ParamFilterContainers = "filterContainers" ParamFilterDepartments = "filterDepartments" ParamFilterEnvironments = "filterEnvironments" ParamFilterOwners = "filterOwners" ParamFilterProducts = "filterProducts" ParamFilterTeams = "filterTeams" ParamFilterAnnotations = "filterAnnotations" ParamFilterLabels = "filterLabels" ParamFilterServices = "filterServices" ParamFilterAccounts = "filterAccounts" ParamFilterCategories = "filterCategories" ParamFilterNames = "filterNames" ParamFilterProjects = "filterProjects" ParamFilterProviders = "filterProviders" ParamFilterProviderIDs = "filterProviderIDs" ParamFilterProviderIDsV2 = "filterProviderIds" ParamFilterRegions = "filterRegions" ParamFilterTypes = "filterTypes" )
Variables ¶
var AllocationPropToV1FilterParamKey = map[string]string{ kubecost.AllocationClusterProp: ParamFilterClusters, kubecost.AllocationNodeProp: ParamFilterNodes, kubecost.AllocationNamespaceProp: ParamFilterNamespaces, kubecost.AllocationControllerProp: ParamFilterControllers, kubecost.AllocationControllerKindProp: ParamFilterControllerKinds, kubecost.AllocationPodProp: ParamFilterPods, kubecost.AllocationLabelProp: ParamFilterLabels, kubecost.AllocationServiceProp: ParamFilterServices, kubecost.AllocationDepartmentProp: ParamFilterDepartments, kubecost.AllocationEnvironmentProp: ParamFilterEnvironments, kubecost.AllocationOwnerProp: ParamFilterOwners, kubecost.AllocationProductProp: ParamFilterProducts, kubecost.AllocationTeamProp: ParamFilterTeams, }
AllocationPropToV1FilterParamKey maps allocation string property representations to v1 filter param keys for legacy filter config support (e.g. reports). Example mapping: "cluster" -> "filterClusters"
var AssetPropToV1FilterParamKey = map[kubecost.AssetProperty]string{ kubecost.AssetNameProp: ParamFilterNames, kubecost.AssetTypeProp: ParamFilterTypes, kubecost.AssetAccountProp: ParamFilterAccounts, kubecost.AssetCategoryProp: ParamFilterCategories, kubecost.AssetClusterProp: ParamFilterClusters, kubecost.AssetProjectProp: ParamFilterProjects, kubecost.AssetProviderProp: ParamFilterProviders, kubecost.AssetProviderIDProp: ParamFilterProviderIDs, kubecost.AssetServiceProp: ParamFilterServices, }
Map to store Kubecost Asset property to Asset Filter types. AssetPropToV1FilterParamKey maps asset string property representations to v1 filter param keys for legacy filter config support (e.g. reports). Example mapping: "category" -> "filterCategories"
Functions ¶
func AllHTTPParamKeys ¶
func AllHTTPParamKeys() []string
AllHTTPParamKeys returns all HTTP GET parameters used for v1 filters. It is intended to help validate HTTP queries in handlers to help avoid e.g. spelling errors.
func AllocationFilterFromParamsV1 ¶
func AllocationFilterFromParamsV1( params AllocationFilterV1, labelConfig *kubecost.LabelConfig, clusterMap clusters.ClusterMap, ) filter.Filter
AllocationFilterFromParamsV1 takes a set of HTTP query parameters and converts them to an AllocationFilter, which is a structured in-Go representation of a set of filters.
The HTTP query parameters are the "v1" filters attached to the Allocation API: "filterNamespaces=", "filterNodes=", etc.
It takes an optional LabelConfig, which if provided enables "label-mapped" filters like "filterDepartments".
It takes an optional ClusterMap, which if provided enables cluster name filtering. This turns all `filterClusters=foo` arguments into the equivalent of `clusterID = "foo" OR clusterName = "foo"`.
func AssetFilterFromParamsV1 ¶
func AssetFilterFromParamsV1( qp mapper.PrimitiveMapReader, clusterMap clusters.ClusterMap, ) filter.Filter
func DefaultFieldByName ¶
DefaultFieldByName looks up a specific T field instance by name and returns the default ast.Field value for that type.
func GetList ¶
func GetList(primaryKey, secondaryKey string, qp mapper.PrimitiveMapReader) []string
GetList provides a list of values from the first key if they exist, otherwise, it returns the values from the second key.
func TestingOnlySortNode ¶
func TestingOnlySortNode(n ast.FilterNode) ast.FilterNode
TestingOnlySortNode sorts the provided node deterministically, intended only for use in unit tests to ensure that filter parsing steps produce logically- equivalent filters. This is useful only for cases where filters are constructed nondeterministically, like via a map iteration.
func ValidAssetFilterParams ¶
func ValidAssetFilterParams() []string
ValidAssetFilterParams returns a list of all possible filter parameters
Types ¶
type AllocationFilterV1 ¶
type AllocationFilterV1 struct { Annotations []string `json:"annotations,omitempty"` Containers []string `json:"containers,omitempty"` Controllers []string `json:"controllers,omitempty"` ControllerKinds []string `json:"controllerKinds,omitempty"` Clusters []string `json:"clusters,omitempty"` Departments []string `json:"departments,omitempty"` Environments []string `json:"environments,omitempty"` Labels []string `json:"labels,omitempty"` Namespaces []string `json:"namespaces,omitempty"` Nodes []string `json:"nodes,omitempty"` Owners []string `json:"owners,omitempty"` Pods []string `json:"pods,omitempty"` Products []string `json:"products,omitempty"` Services []string `json:"services,omitempty"` Teams []string `json:"teams,omitempty"` }
func ConvertFilterQueryParams ¶
func ConvertFilterQueryParams(qp mapper.PrimitiveMapReader, labelConfig *kubecost.LabelConfig) AllocationFilterV1
func (AllocationFilterV1) Equals ¶
func (f AllocationFilterV1) Equals(that AllocationFilterV1) bool