Просмотр исходного кода

Remove references to legacy filters, Cloud Usage and Coverage

Signed-off-by: Sean Holcomb <seanholcomb@gmail.com>
Sean Holcomb 2 лет назад
Родитель
Сommit
c56893816d

+ 0 - 10
core/pkg/filter/legacy/allcut.go

@@ -1,10 +0,0 @@
-package legacy
-
-// AllCut is a filter that matches nothing. This is useful
-// for applications like authorization, where a user/group/role may be disallowed
-// from viewing data entirely.
-type AllCut[T any] struct{}
-
-func (ac AllCut[T]) String() string { return "(AllCut)" }
-
-func (ac AllCut[T]) Matches(T) bool { return false }

+ 0 - 9
core/pkg/filter/legacy/allpass.go

@@ -1,9 +0,0 @@
-package legacy
-
-// AllPass is a filter that matches everything and is the same as no filter. It is implemented here as a guard
-// against universal operations occurring in the absence of filters.
-type AllPass[T any] struct{}
-
-func (n AllPass[T]) String() string { return "(AllPass)" }
-
-func (n AllPass[T]) Matches(T) bool { return true }

+ 0 - 36
core/pkg/filter/legacy/and.go

@@ -1,36 +0,0 @@
-package legacy
-
-import (
-	"fmt"
-)
-
-// And is a set of filters that should be evaluated as a logical
-// AND.
-type And[T any] struct {
-	Filters []Filter[T]
-}
-
-func (a And[T]) String() string {
-	s := "(and"
-	for _, f := range a.Filters {
-		s += fmt.Sprintf(" %s", f)
-	}
-
-	s += ")"
-	return s
-}
-
-func (a And[T]) Matches(that T) bool {
-	filters := a.Filters
-	if len(filters) == 0 {
-		return true
-	}
-
-	for _, filter := range filters {
-		if !filter.Matches(that) {
-			return false
-		}
-	}
-
-	return true
-}

+ 0 - 155
core/pkg/filter/legacy/cloudcost/cloudcost.go

@@ -1,155 +0,0 @@
-package cloudcost
-
-import (
-	"reflect"
-	"strings"
-
-	filter "github.com/opencost/opencost/core/pkg/filter/legacy"
-	"github.com/opencost/opencost/core/pkg/log"
-	"github.com/opencost/opencost/core/pkg/opencost"
-	"github.com/opencost/opencost/core/pkg/util/mapper"
-)
-
-type CloudCostFilter struct {
-	AccountIDs       []string `json:"accountIDs,omitempty"`
-	Categories       []string `json:"categories,omitempty"`
-	InvoiceEntityIDs []string `json:"invoiceEntityIDs,omitempty"`
-	Labels           []string `json:"labels,omitempty"`
-	Providers        []string `json:"providers,omitempty"`
-	ProviderIDs      []string `json:"providerIDs,omitempty"`
-	Services         []string `json:"services,omitempty"`
-}
-
-func (g *CloudCostFilter) Equals(that CloudCostFilter) bool {
-	return reflect.DeepEqual(g.AccountIDs, that.AccountIDs) &&
-		reflect.DeepEqual(g.Categories, that.Categories) &&
-		reflect.DeepEqual(g.InvoiceEntityIDs, that.InvoiceEntityIDs) &&
-		reflect.DeepEqual(g.Labels, that.Labels) &&
-		reflect.DeepEqual(g.Providers, that.Providers) &&
-		reflect.DeepEqual(g.ProviderIDs, that.ProviderIDs) &&
-		reflect.DeepEqual(g.Services, that.Services)
-}
-func parseWildcardEnd(rawFilterValue string) (string, bool) {
-	return strings.TrimSuffix(rawFilterValue, "*"), strings.HasSuffix(rawFilterValue, "*")
-}
-
-func CloudCostFilterFromParams(pmr mapper.PrimitiveMapReader) filter.Filter[*opencost.CloudCost] {
-	ccFilter := convertFilterQueryParams(pmr)
-	return ParseCloudCostFilter(ccFilter)
-}
-
-func convertFilterQueryParams(pmr mapper.PrimitiveMapReader) CloudCostFilter {
-	return CloudCostFilter{
-		AccountIDs:       pmr.GetList("filterAccountIDs", ","),
-		Categories:       pmr.GetList("filterCategories", ","),
-		InvoiceEntityIDs: pmr.GetList("filterInvoiceEntityIDs", ","),
-		Labels:           pmr.GetList("filterLabels", ","),
-		Providers:        pmr.GetList("filterProviders", ","),
-		ProviderIDs:      pmr.GetList("filterProviderIDs", ","),
-		Services:         pmr.GetList("filterServices", ","),
-	}
-}
-func ParseCloudCostFilter(filters CloudCostFilter) filter.Filter[*opencost.CloudCost] {
-	result := filter.And[*opencost.CloudCost]{
-		Filters: []filter.Filter[*opencost.CloudCost]{},
-	}
-
-	if len(filters.InvoiceEntityIDs) > 0 {
-		result.Filters = append(result.Filters, filterV1SingleValueFromList(filters.InvoiceEntityIDs, opencost.CloudCostInvoiceEntityIDProp))
-	}
-
-	if len(filters.AccountIDs) > 0 {
-		result.Filters = append(result.Filters, filterV1SingleValueFromList(filters.AccountIDs, opencost.CloudCostAccountIDProp))
-	}
-
-	if len(filters.Providers) > 0 {
-		result.Filters = append(result.Filters, filterV1SingleValueFromList(filters.Providers, opencost.CloudCostProviderProp))
-	}
-
-	if len(filters.ProviderIDs) > 0 {
-		result.Filters = append(result.Filters, filterV1SingleValueFromList(filters.ProviderIDs, opencost.CloudCostProviderIDProp))
-	}
-
-	if len(filters.Services) > 0 {
-		result.Filters = append(result.Filters, filterV1SingleValueFromList(filters.Services, opencost.CloudCostServiceProp))
-	}
-
-	if len(filters.Categories) > 0 {
-		result.Filters = append(result.Filters, filterV1SingleValueFromList(filters.Categories, opencost.CloudCostCategoryProp))
-	}
-
-	if len(filters.Labels) > 0 {
-		result.Filters = append(result.Filters, filterV1DoubleValueFromList(filters.Labels, opencost.CloudCostLabelProp))
-	}
-
-	if len(result.Filters) == 0 {
-		return nil
-	}
-
-	return result
-}
-
-func filterV1SingleValueFromList(rawFilterValues []string, field string) filter.Filter[*opencost.CloudCost] {
-	result := filter.Or[*opencost.CloudCost]{
-		Filters: []filter.Filter[*opencost.CloudCost]{},
-	}
-
-	for _, filterValue := range rawFilterValues {
-		filterValue = strings.TrimSpace(filterValue)
-		filterValue, wildcard := parseWildcardEnd(filterValue)
-
-		subFilter := filter.StringProperty[*opencost.CloudCost]{
-			Field: field,
-			Op:    filter.StringEquals,
-			Value: filterValue,
-		}
-
-		if wildcard {
-			subFilter.Op = filter.StringStartsWith
-		}
-
-		result.Filters = append(result.Filters, subFilter)
-	}
-
-	return result
-}
-
-// filterV1DoubleValueFromList creates an OR of key:value equality filters for
-// colon-split filter values.
-//
-// The v1 query language (e.g. "filterLabels=app:foo,l2:bar") uses OR within
-// a field (e.g. label[app] = foo OR label[l2] = bar)
-func filterV1DoubleValueFromList(rawFilterValuesUnsplit []string, filterField string) filter.Filter[*opencost.CloudCost] {
-	result := filter.Or[*opencost.CloudCost]{
-		Filters: []filter.Filter[*opencost.CloudCost]{},
-	}
-
-	for _, unsplit := range rawFilterValuesUnsplit {
-		if unsplit != "" {
-			split := strings.Split(unsplit, ":")
-			if len(split) != 2 {
-				log.Warnf("illegal key/value filter (ignoring): %s", unsplit)
-				continue
-			}
-			labelName := strings.TrimSpace(split[0])
-			val := strings.TrimSpace(split[1])
-			val, wildcard := parseWildcardEnd(val)
-
-			subFilter := filter.StringMapProperty[*opencost.CloudCost]{
-				Field: filterField,
-				// All v1 filters are equality comparisons
-				Op:    filter.StringMapEquals,
-				Key:   labelName,
-				Value: val,
-			}
-
-			if wildcard {
-				subFilter.Op = filter.StringMapStartsWith
-			}
-
-			result.Filters = append(result.Filters, subFilter)
-		}
-	}
-
-	return result
-}

+ 0 - 134
core/pkg/filter/legacy/cloudcost/cloudcost_test.go

@@ -1,134 +0,0 @@
-package cloudcost
-
-import (
-	"testing"
-)
-
-type CloudCostFilterEqualsTestcase struct {
-	name     string
-	this     CloudCostFilter
-	that     CloudCostFilter
-	expected bool
-}
-
-func TestCloudCostFilter_Equals(t *testing.T) {
-	testCases := []CloudCostFilterEqualsTestcase{
-		{
-			name: "both filters nil",
-			this: CloudCostFilter{
-				AccountIDs:       nil,
-				Categories:       nil,
-				InvoiceEntityIDs: nil,
-				Labels:           nil,
-				Providers:        nil,
-				ProviderIDs:      nil,
-				Services:         nil,
-			},
-			that: CloudCostFilter{
-				AccountIDs:       nil,
-				Categories:       nil,
-				InvoiceEntityIDs: nil,
-				Labels:           nil,
-				Providers:        nil,
-				ProviderIDs:      nil,
-				Services:         nil,
-			},
-			expected: true,
-		},
-		{
-			name: "both filters not nil and matching",
-			this: CloudCostFilter{
-				AccountIDs:       []string{"account1", "account2", "account3"},
-				Categories:       []string{"category1", "category2"},
-				InvoiceEntityIDs: []string{"invoice1", "invoice2"},
-				Labels:           []string{"label1", "label2"},
-				Providers:        []string{"provider1", "provider2"},
-				ProviderIDs:      []string{"provider1", "provider2"},
-				Services:         []string{"s1"},
-			},
-			that: CloudCostFilter{
-				AccountIDs:       []string{"account1", "account2", "account3"},
-				Categories:       []string{"category1", "category2"},
-				InvoiceEntityIDs: []string{"invoice1", "invoice2"},
-				Labels:           []string{"label1", "label2"},
-				Providers:        []string{"provider1", "provider2"},
-				ProviderIDs:      []string{"provider1", "provider2"},
-				Services:         []string{"s1"},
-			},
-			expected: true,
-		},
-		{
-			name: "both filters diff count",
-			this: CloudCostFilter{
-				AccountIDs:       []string{"account1", "account2", "account3"},
-				Categories:       []string{"category1", "category2"},
-				InvoiceEntityIDs: []string{"invoice1", "invoice2"},
-				Labels:           []string{"label1", "label2"},
-				Providers:        []string{"provider1", "provider2"},
-				ProviderIDs:      []string{"provider1", "provider2"},
-				Services:         []string{"s1"},
-			},
-			that: CloudCostFilter{
-				AccountIDs:       []string{"account1", "account2"},
-				Categories:       []string{"category1", "category2"},
-				InvoiceEntityIDs: []string{"invoice1", "invoice2"},
-				Labels:           []string{"label1", "label2"},
-				Providers:        []string{"provider1", "provider2"},
-				ProviderIDs:      []string{"provider1", "provider2"},
-				Services:         []string{"s1"},
-			},
-			expected: false,
-		},
-		{
-			name: "slight mismatch",
-			this: CloudCostFilter{
-				AccountIDs:       []string{"account1", "account2", "account3"},
-				Categories:       []string{"category1", "category2"},
-				InvoiceEntityIDs: []string{"invoice1", "invoice2"},
-				Labels:           []string{"label1", "label2"},
-				Providers:        []string{"provider1", "provider2"},
-				ProviderIDs:      []string{"provider1", "provider2"},
-				Services:         []string{"s1"},
-			},
-			that: CloudCostFilter{
-				AccountIDs:       []string{"account10", "account2", "account3"},
-				Categories:       []string{"category1", "category2"},
-				InvoiceEntityIDs: []string{"invoice1", "invoice2"},
-				Labels:           []string{"label1", "label2"},
-				Providers:        []string{"provider1", "provider2"},
-				ProviderIDs:      []string{"provider1", "provider2"},
-				Services:         []string{"s1"},
-			},
-			expected: false,
-		},
-		{
-			name: "one nil, one not",
-			this: CloudCostFilter{
-				AccountIDs:       []string{"account1", "account2", "account3"},
-				Categories:       []string{"category1", "category2"},
-				InvoiceEntityIDs: []string{"invoice1", "invoice2"},
-				Labels:           []string{"label1", "label2"},
-				Providers:        []string{"provider1", "provider2"},
-				ProviderIDs:      []string{"provider1", "provider2"},
-				Services:         []string{"s1"},
-			},
-			that: CloudCostFilter{
-				AccountIDs:       nil,
-				Categories:       nil,
-				InvoiceEntityIDs: nil,
-				Labels:           nil,
-				Providers:        nil,
-				ProviderIDs:      nil,
-				Services:         nil,
-			},
-			expected: false,
-		},
-	}
-
-	for _, tc := range testCases {
-		got := tc.this.Equals(tc.that)
-		if got != tc.expected {
-			t.Fatalf("expected %t, got: %t for test case: %s", tc.expected, got, tc.name)
-		}
-	}
-}

+ 0 - 20
core/pkg/filter/legacy/filter.go

@@ -1,20 +0,0 @@
-package legacy
-
-// Filter represents anything that can be used to filter given generic type T.
-//
-// Implement this interface with caution. While it is generic, it
-// is intended to be introspectable so query handlers can perform various
-// optimizations. These optimizations include:
-// - Routing a query to the most optimal cache
-// - Querying backing data stores efficiently (e.g. translation to SQL)
-//
-// Custom implementations of this interface outside of this package should not
-// expect to receive these benefits. Passing a custom implementation to a
-// handler may in errors.
-type Filter[T any] interface {
-	String() string
-
-	// Matches is the canonical in-Go function for determining if T
-	// matches a filter.
-	Matches(T) bool
-}

+ 0 - 1073
core/pkg/filter/legacy/filter_test.go

@@ -1,1073 +0,0 @@
-package legacy_test
-
-import (
-	"testing"
-
-	filter "github.com/opencost/opencost/core/pkg/filter/legacy"
-	"github.com/opencost/opencost/core/pkg/opencost"
-)
-
-func Test_String_Matches(t *testing.T) {
-	cases := []struct {
-		name   string
-		a      *opencost.Allocation
-		filter filter.Filter[*opencost.Allocation]
-
-		expected bool
-	}{
-		{
-			name: "ClusterID Equals -> true",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Cluster: "cluster-one",
-				},
-			},
-			filter: filter.StringProperty[*opencost.Allocation]{
-				Field: opencost.AllocationClusterProp,
-				Op:    filter.StringEquals,
-				Value: "cluster-one",
-			},
-
-			expected: true,
-		},
-		{
-			name: "ClusterID StartsWith -> true",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Cluster: "cluster-one",
-				},
-			},
-			filter: filter.StringProperty[*opencost.Allocation]{
-				Field: opencost.AllocationClusterProp,
-				Op:    filter.StringStartsWith,
-				Value: "cluster",
-			},
-
-			expected: true,
-		},
-		{
-			name: "ClusterID StartsWith -> false",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Cluster: "k8s-one",
-				},
-			},
-			filter: filter.StringProperty[*opencost.Allocation]{
-				Field: opencost.AllocationClusterProp,
-				Op:    filter.StringStartsWith,
-				Value: "cluster",
-			},
-
-			expected: false,
-		},
-		{
-			name: "ClusterID empty StartsWith '' -> true",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Cluster: "",
-				},
-			},
-			filter: filter.StringProperty[*opencost.Allocation]{
-				Field: opencost.AllocationClusterProp,
-				Op:    filter.StringStartsWith,
-				Value: "",
-			},
-
-			expected: true,
-		},
-		{
-			name: "ClusterID nonempty StartsWith '' -> true",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Cluster: "abc",
-				},
-			},
-			filter: filter.StringProperty[*opencost.Allocation]{
-				Field: opencost.AllocationClusterProp,
-				Op:    filter.StringStartsWith,
-				Value: "",
-			},
-
-			expected: true,
-		},
-		{
-			name: "Node Equals -> true",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Node: "node123",
-				},
-			},
-			filter: filter.StringProperty[*opencost.Allocation]{
-				Field: opencost.AllocationNodeProp,
-				Op:    filter.StringEquals,
-				Value: "node123",
-			},
-
-			expected: true,
-		},
-		{
-			name: "Namespace Equals Unallocated -> true",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Namespace: "",
-				},
-			},
-			filter: filter.StringProperty[*opencost.Allocation]{
-				Field: opencost.AllocationNamespaceProp,
-				Op:    filter.StringEquals,
-				Value: opencost.UnallocatedSuffix,
-			},
-
-			expected: true,
-		},
-		{
-			name: "ControllerKind Equals -> true",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					ControllerKind: "deployment", // We generally store controller kinds as all lowercase
-				},
-			},
-			filter: filter.StringProperty[*opencost.Allocation]{
-				Field: opencost.AllocationControllerKindProp,
-				Op:    filter.StringEquals,
-				Value: "deployment",
-			},
-
-			expected: true,
-		},
-		{
-			name: "ControllerName Equals -> true",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Controller: "kc-cost-analyzer",
-				},
-			},
-			filter: filter.StringProperty[*opencost.Allocation]{
-				Field: opencost.AllocationControllerProp,
-				Op:    filter.StringEquals,
-				Value: "kc-cost-analyzer",
-			},
-
-			expected: true,
-		},
-		{
-			name: "Pod (with UID) Equals -> true",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Pod: "pod-123 UID-ABC",
-				},
-			},
-			filter: filter.StringProperty[*opencost.Allocation]{
-				Field: opencost.AllocationPodProp,
-				Op:    filter.StringEquals,
-				Value: "pod-123 UID-ABC",
-			},
-
-			expected: true,
-		},
-		{
-			name: "Container Equals -> true",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Container: "cost-model",
-				},
-			},
-			filter: filter.StringProperty[*opencost.Allocation]{
-				Field: opencost.AllocationContainerProp,
-				Op:    filter.StringEquals,
-				Value: "cost-model",
-			},
-
-			expected: true,
-		},
-		{
-			name: `namespace unallocated -> true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Namespace: "",
-				},
-			},
-			filter: filter.StringProperty[*opencost.Allocation]{
-				Field: opencost.AllocationNamespaceProp,
-				Op:    filter.StringEquals,
-				Value: opencost.UnallocatedSuffix,
-			},
-
-			expected: true,
-		},
-	}
-
-	for _, c := range cases {
-		result := c.filter.Matches(c.a)
-
-		if result != c.expected {
-			t.Errorf("%s: expected %t, got %t", c.name, c.expected, result)
-		}
-	}
-}
-
-func Test_StringSlice_Matches(t *testing.T) {
-	cases := []struct {
-		name   string
-		a      *opencost.Allocation
-		filter filter.Filter[*opencost.Allocation]
-
-		expected bool
-	}{
-		{
-			name: `services contains -> true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Services: []string{"serv1", "serv2"},
-				},
-			},
-			filter: filter.StringSliceProperty[*opencost.Allocation]{
-				Field: opencost.AllocationServiceProp,
-				Op:    filter.StringSliceContains,
-				Value: "serv2",
-			},
-
-			expected: true,
-		},
-		{
-			name: `services contains -> false`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Services: []string{"serv1", "serv2"},
-				},
-			},
-			filter: filter.StringSliceProperty[*opencost.Allocation]{
-				Field: opencost.AllocationServiceProp,
-				Op:    filter.StringSliceContains,
-				Value: "serv3",
-			},
-
-			expected: false,
-		},
-		{
-			name: `services contains unallocated -> false`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Services: []string{"serv1", "serv2"},
-				},
-			},
-			filter: filter.StringSliceProperty[*opencost.Allocation]{
-				Field: opencost.AllocationServiceProp,
-				Op:    filter.StringSliceContains,
-				Value: opencost.UnallocatedSuffix,
-			},
-
-			expected: false,
-		},
-		{
-			name: `services contains unallocated -> true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Services: []string{},
-				},
-			},
-			filter: filter.StringSliceProperty[*opencost.Allocation]{
-				Field: opencost.AllocationServiceProp,
-				Op:    filter.StringSliceContains,
-				Value: opencost.UnallocatedSuffix,
-			},
-
-			expected: true,
-		},
-	}
-
-	for _, c := range cases {
-		result := c.filter.Matches(c.a)
-
-		if result != c.expected {
-			t.Errorf("%s: expected %t, got %t", c.name, c.expected, result)
-		}
-	}
-}
-
-func Test_StringMap_Matches(t *testing.T) {
-	cases := []struct {
-		name   string
-		a      *opencost.Allocation
-		filter filter.Filter[*opencost.Allocation]
-
-		expected bool
-	}{
-		{
-			name: `label[app]="foo" -> true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Labels: map[string]string{
-						"app": "foo",
-					},
-				},
-			},
-			filter: filter.StringMapProperty[*opencost.Allocation]{
-				Field: opencost.AllocationLabelProp,
-				Op:    filter.StringMapEquals,
-				Key:   "app",
-				Value: "foo",
-			},
-
-			expected: true,
-		},
-		{
-			name: `label[app]="foo" -> different value -> false`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Labels: map[string]string{
-						"app": "bar",
-					},
-				},
-			},
-			filter: filter.StringMapProperty[*opencost.Allocation]{
-				Field: opencost.AllocationLabelProp,
-				Op:    filter.StringMapEquals,
-				Key:   "app",
-				Value: "foo",
-			},
-
-			expected: false,
-		},
-		{
-			name: `label[app]="foo" -> label missing -> false`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Labels: map[string]string{
-						"someotherlabel": "someothervalue",
-					},
-				},
-			},
-			filter: filter.StringMapProperty[*opencost.Allocation]{
-				Field: opencost.AllocationLabelProp,
-				Op:    filter.StringMapEquals,
-				Key:   "app",
-				Value: "foo",
-			},
-
-			expected: false,
-		},
-		{
-			name: `label[app]=Unallocated -> label missing -> true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Labels: map[string]string{
-						"someotherlabel": "someothervalue",
-					},
-				},
-			},
-			filter: filter.StringMapProperty[*opencost.Allocation]{
-				Field: opencost.AllocationLabelProp,
-				Op:    filter.StringMapEquals,
-				Key:   "app",
-				Value: opencost.UnallocatedSuffix,
-			},
-
-			expected: true,
-		},
-		{
-			name: `label[app]=Unallocated -> label present -> false`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Labels: map[string]string{
-						"app": "test",
-					},
-				},
-			},
-			filter: filter.StringMapProperty[*opencost.Allocation]{
-				Field: opencost.AllocationLabelProp,
-				Op:    filter.StringMapEquals,
-				Key:   "app",
-				Value: opencost.UnallocatedSuffix,
-			},
-
-			expected: false,
-		},
-		{
-			name: `annotation[prom_modified_name]="testing123" -> true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Annotations: map[string]string{
-						"prom_modified_name": "testing123",
-					},
-				},
-			},
-			filter: filter.StringMapProperty[*opencost.Allocation]{
-				Field: opencost.AllocationAnnotationProp,
-				Op:    filter.StringMapEquals,
-				Key:   "prom_modified_name",
-				Value: "testing123",
-			},
-
-			expected: true,
-		},
-		{
-			name: `annotation[app]="foo" -> different value -> false`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Annotations: map[string]string{
-						"app": "bar",
-					},
-				},
-			},
-			filter: filter.StringMapProperty[*opencost.Allocation]{
-				Field: opencost.AllocationAnnotationProp,
-				Op:    filter.StringMapEquals,
-				Key:   "app",
-				Value: "foo",
-			},
-
-			expected: false,
-		},
-		{
-			name: `annotation[app]="foo" -> annotation missing -> false`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Annotations: map[string]string{
-						"someotherannotation": "someothervalue",
-					},
-				},
-			},
-			filter: filter.StringMapProperty[*opencost.Allocation]{
-				Field: opencost.AllocationAnnotationProp,
-				Op:    filter.StringMapEquals,
-				Key:   "app",
-				Value: "foo",
-			},
-
-			expected: false,
-		},
-	}
-
-	for _, c := range cases {
-		result := c.filter.Matches(c.a)
-
-		if result != c.expected {
-			t.Errorf("%s: expected %t, got %t", c.name, c.expected, result)
-		}
-	}
-}
-
-func Test_Not_Matches(t *testing.T) {
-	cases := []struct {
-		name   string
-		a      *opencost.Allocation
-		filter filter.Filter[*opencost.Allocation]
-
-		expected bool
-	}{
-		{
-			name: "Namespace NotEquals -> false",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Namespace: "kube-system",
-				},
-			},
-			filter: filter.Not[*opencost.Allocation]{
-				Filter: filter.StringProperty[*opencost.Allocation]{
-					Field: opencost.AllocationNamespaceProp,
-					Op:    filter.StringEquals,
-					Value: "kube-system",
-				},
-			},
-
-			expected: false,
-		},
-		{
-			name: "Namespace NotEquals Unallocated -> true",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Namespace: "kube-system",
-				},
-			},
-			filter: filter.Not[*opencost.Allocation]{
-				Filter: filter.StringProperty[*opencost.Allocation]{
-					Field: opencost.AllocationNamespaceProp,
-					Op:    filter.StringEquals,
-					Value: opencost.UnallocatedSuffix,
-				},
-			},
-			expected: true,
-		},
-		{
-			name: "Namespace NotEquals Unallocated -> false",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Namespace: "",
-				},
-			},
-			filter: filter.Not[*opencost.Allocation]{
-				Filter: filter.StringProperty[*opencost.Allocation]{
-					Field: opencost.AllocationNamespaceProp,
-					Op:    filter.StringEquals,
-					Value: opencost.UnallocatedSuffix,
-				},
-			},
-
-			expected: false,
-		},
-
-		{
-			name: `label[app]!=Unallocated -> label missing -> false`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Labels: map[string]string{
-						"someotherlabel": "someothervalue",
-					},
-				},
-			},
-			filter: filter.Not[*opencost.Allocation]{
-				Filter: filter.StringMapProperty[*opencost.Allocation]{
-					Field: opencost.AllocationLabelProp,
-					Op:    filter.StringMapEquals,
-					Key:   "app",
-					Value: opencost.UnallocatedSuffix,
-				},
-			},
-			expected: false,
-		},
-		{
-			name: `label[app]!=Unallocated -> label present -> true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Labels: map[string]string{
-						"app": "test",
-					},
-				},
-			},
-			filter: filter.Not[*opencost.Allocation]{
-				Filter: filter.StringMapProperty[*opencost.Allocation]{
-					Field: opencost.AllocationLabelProp,
-					Op:    filter.StringMapEquals,
-					Key:   "app",
-					Value: opencost.UnallocatedSuffix,
-				},
-			},
-			expected: true,
-		},
-		{
-			name: `label[app]!="foo" -> label missing -> true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Labels: map[string]string{
-						"someotherlabel": "someothervalue",
-					},
-				},
-			},
-			filter: filter.Not[*opencost.Allocation]{
-				Filter: filter.StringMapProperty[*opencost.Allocation]{
-					Field: opencost.AllocationLabelProp,
-					Op:    filter.StringMapEquals,
-					Key:   "app",
-					Value: "foo",
-				},
-			},
-
-			expected: true,
-		},
-		{
-			name: `annotation[prom_modified_name]="testing123" -> true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Annotations: map[string]string{
-						"prom_modified_name": "testing123",
-					},
-				},
-			},
-			filter: filter.StringMapProperty[*opencost.Allocation]{
-				Field: opencost.AllocationAnnotationProp,
-				Op:    filter.StringMapEquals,
-				Key:   "prom_modified_name",
-				Value: "testing123",
-			},
-
-			expected: true,
-		},
-		{
-			name: `annotation[app]="foo" -> different value -> false`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Annotations: map[string]string{
-						"app": "bar",
-					},
-				},
-			},
-			filter: filter.StringMapProperty[*opencost.Allocation]{
-				Field: opencost.AllocationAnnotationProp,
-				Op:    filter.StringMapEquals,
-				Key:   "app",
-				Value: "foo",
-			},
-
-			expected: false,
-		},
-		{
-			name: `annotation[app]="foo" -> annotation missing -> false`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Annotations: map[string]string{
-						"someotherannotation": "someothervalue",
-					},
-				},
-			},
-			filter: filter.StringMapProperty[*opencost.Allocation]{
-				Field: opencost.AllocationAnnotationProp,
-				Op:    filter.StringMapEquals,
-				Key:   "app",
-				Value: "foo",
-			},
-
-			expected: false,
-		},
-		{
-			name: `annotation[app]!="foo" -> annotation missing -> true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Annotations: map[string]string{
-						"someotherannotation": "someothervalue",
-					},
-				},
-			},
-			filter: filter.Not[*opencost.Allocation]{
-				Filter: filter.StringMapProperty[*opencost.Allocation]{
-					Field: opencost.AllocationAnnotationProp,
-					Op:    filter.StringMapEquals,
-					Key:   "app",
-					Value: "foo",
-				},
-			},
-
-			expected: true,
-		},
-		{
-			name: `namespace unallocated -> true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Namespace: "",
-				},
-			},
-			filter: filter.StringProperty[*opencost.Allocation]{
-				Field: opencost.AllocationNamespaceProp,
-				Op:    filter.StringEquals,
-				Value: opencost.UnallocatedSuffix,
-			},
-
-			expected: true,
-		},
-		{
-			name: `services contains -> true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Services: []string{"serv1", "serv2"},
-				},
-			},
-			filter: filter.StringSliceProperty[*opencost.Allocation]{
-				Field: opencost.AllocationServiceProp,
-				Op:    filter.StringSliceContains,
-				Value: "serv2",
-			},
-
-			expected: true,
-		},
-		{
-			name: `services contains -> false`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Services: []string{"serv1", "serv2"},
-				},
-			},
-			filter: filter.StringSliceProperty[*opencost.Allocation]{
-				Field: opencost.AllocationServiceProp,
-				Op:    filter.StringSliceContains,
-				Value: "serv3",
-			},
-
-			expected: false,
-		},
-		{
-			name: `services notcontains -> true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Services: []string{"serv1", "serv2"},
-				},
-			},
-			filter: filter.Not[*opencost.Allocation]{
-				Filter: filter.StringSliceProperty[*opencost.Allocation]{
-					Field: opencost.AllocationServiceProp,
-					Op:    filter.StringSliceContains,
-					Value: "serv3",
-				},
-			},
-			expected: true,
-		},
-		{
-			name: `services notcontains -> false`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Services: []string{"serv1", "serv2"},
-				},
-			},
-			filter: filter.Not[*opencost.Allocation]{
-				Filter: filter.StringSliceProperty[*opencost.Allocation]{
-					Field: opencost.AllocationServiceProp,
-					Op:    filter.StringSliceContains,
-					Value: "serv2",
-				},
-			},
-
-			expected: false,
-		},
-		{
-			name: `services notcontains unallocated -> true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Services: []string{"serv1", "serv2"},
-				},
-			},
-			filter: filter.Not[*opencost.Allocation]{
-				Filter: filter.StringSliceProperty[*opencost.Allocation]{
-					Field: opencost.AllocationServiceProp,
-					Op:    filter.StringSliceContains,
-					Value: opencost.UnallocatedSuffix,
-				},
-			},
-
-			expected: true,
-		},
-		{
-			name: `services notcontains unallocated -> false`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Services: []string{},
-				},
-			},
-			filter: filter.Not[*opencost.Allocation]{
-				Filter: filter.StringSliceProperty[*opencost.Allocation]{
-					Field: opencost.AllocationServiceProp,
-					Op:    filter.StringSliceContains,
-					Value: opencost.UnallocatedSuffix,
-				},
-			},
-
-			expected: false,
-		},
-		{
-			name: `services containsprefix -> true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Services: []string{"serv1", "serv2"},
-				},
-			},
-			filter: filter.StringSliceProperty[*opencost.Allocation]{
-				Field: opencost.AllocationServiceProp,
-				Op:    filter.StringSliceContainsPrefix,
-				Value: "serv",
-			},
-
-			expected: true,
-		},
-		{
-			name: `services containsprefix -> false`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Services: []string{"foo", "bar"},
-				},
-			},
-			filter: filter.StringSliceProperty[*opencost.Allocation]{
-				Field: opencost.AllocationServiceProp,
-				Op:    filter.StringSliceContainsPrefix,
-				Value: "serv",
-			},
-
-			expected: false,
-		},
-		{
-			name: `services contains unallocated -> false`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Services: []string{"serv1", "serv2"},
-				},
-			},
-			filter: filter.StringSliceProperty[*opencost.Allocation]{
-				Field: opencost.AllocationServiceProp,
-				Op:    filter.StringSliceContains,
-				Value: opencost.UnallocatedSuffix,
-			},
-
-			expected: false,
-		},
-		{
-			name: `services contains unallocated -> true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Services: []string{},
-				},
-			},
-			filter: filter.StringSliceProperty[*opencost.Allocation]{
-				Field: opencost.AllocationServiceProp,
-				Op:    filter.StringSliceContains,
-				Value: opencost.UnallocatedSuffix,
-			},
-
-			expected: true,
-		},
-	}
-
-	for _, c := range cases {
-		result := c.filter.Matches(c.a)
-
-		if result != c.expected {
-			t.Errorf("%s: expected %t, got %t", c.name, c.expected, result)
-		}
-	}
-}
-
-func Test_None_Matches(t *testing.T) {
-	cases := []struct {
-		name string
-		a    *opencost.Allocation
-	}{
-		{
-			name: "nil",
-			a:    nil,
-		},
-		{
-			name: "nil properties",
-			a: &opencost.Allocation{
-				Properties: nil,
-			},
-		},
-		{
-			name: "empty properties",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{},
-			},
-		},
-		{
-			name: "ClusterID",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Cluster: "cluster-one",
-				},
-			},
-		},
-		{
-			name: "Node",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Node: "node123",
-				},
-			},
-		},
-		{
-			name: "Namespace",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Namespace: "kube-system",
-				},
-			},
-		},
-		{
-			name: "ControllerKind",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					ControllerKind: "deployment", // We generally store controller kinds as all lowercase
-				},
-			},
-		},
-		{
-			name: "ControllerName",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Controller: "kc-cost-analyzer",
-				},
-			},
-		},
-		{
-			name: "Pod",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Pod: "pod-123 UID-ABC",
-				},
-			},
-		},
-		{
-			name: "Container",
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Container: "cost-model",
-				},
-			},
-		},
-		{
-			name: `label`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Labels: map[string]string{
-						"app": "foo",
-					},
-				},
-			},
-		},
-		{
-			name: `annotation`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Annotations: map[string]string{
-						"prom_modified_name": "testing123",
-					},
-				},
-			},
-		},
-		{
-			name: `services`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Services: []string{"serv1", "serv2"},
-				},
-			},
-		},
-	}
-
-	for _, c := range cases {
-		result := filter.AllCut[*opencost.Allocation]{}.Matches(c.a)
-
-		if result {
-			t.Errorf("%s: should have been rejected", c.name)
-		}
-	}
-}
-
-func Test_And_Matches(t *testing.T) {
-	cases := []struct {
-		name   string
-		a      *opencost.Allocation
-		filter filter.Filter[*opencost.Allocation]
-
-		expected bool
-	}{
-		{
-			name: `label[app]="foo" and namespace="kubecost" -> both true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Namespace: "kubecost",
-					Labels: map[string]string{
-						"app": "foo",
-					},
-				},
-			},
-			filter: filter.And[*opencost.Allocation]{[]filter.Filter[*opencost.Allocation]{
-				filter.StringMapProperty[*opencost.Allocation]{
-					Field: opencost.AllocationLabelProp,
-					Op:    filter.StringMapEquals,
-					Key:   "app",
-					Value: "foo",
-				},
-				filter.StringProperty[*opencost.Allocation]{
-					Field: opencost.AllocationNamespaceProp,
-					Op:    filter.StringEquals,
-					Value: "kubecost",
-				},
-			}},
-			expected: true,
-		},
-		{
-			name: `label[app]="foo" and namespace="kubecost" -> first true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Namespace: "kube-system",
-					Labels: map[string]string{
-						"app": "foo",
-					},
-				},
-			},
-			filter: filter.And[*opencost.Allocation]{[]filter.Filter[*opencost.Allocation]{
-				filter.StringMapProperty[*opencost.Allocation]{
-					Field: opencost.AllocationLabelProp,
-					Op:    filter.StringMapEquals,
-					Key:   "app",
-					Value: "foo",
-				},
-				filter.StringProperty[*opencost.Allocation]{
-					Field: opencost.AllocationNamespaceProp,
-					Op:    filter.StringEquals,
-					Value: "kubecost",
-				},
-			}},
-			expected: false,
-		},
-		{
-			name: `label[app]="foo" and namespace="kubecost" -> second true`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Namespace: "kubecost",
-					Labels: map[string]string{
-						"app": "bar",
-					},
-				},
-			},
-			filter: filter.And[*opencost.Allocation]{[]filter.Filter[*opencost.Allocation]{
-				filter.StringMapProperty[*opencost.Allocation]{
-					Field: opencost.AllocationLabelProp,
-					Op:    filter.StringMapEquals,
-					Key:   "app",
-					Value: "foo",
-				},
-				filter.StringProperty[*opencost.Allocation]{
-					Field: opencost.AllocationNamespaceProp,
-					Op:    filter.StringEquals,
-					Value: "kubecost",
-				},
-			}},
-			expected: false,
-		},
-		{
-			name: `label[app]="foo" and namespace="kubecost" -> both false`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Namespace: "kube-system",
-					Labels: map[string]string{
-						"app": "bar",
-					},
-				},
-			},
-			filter: filter.And[*opencost.Allocation]{[]filter.Filter[*opencost.Allocation]{
-				filter.StringMapProperty[*opencost.Allocation]{
-					Field: opencost.AllocationLabelProp,
-					Op:    filter.StringMapEquals,
-					Key:   "app",
-					Value: "foo",
-				},
-				filter.StringProperty[*opencost.Allocation]{
-					Field: opencost.AllocationNamespaceProp,
-					Op:    filter.StringEquals,
-					Value: "kubecost",
-				},
-			}},
-			expected: false,
-		},
-		{
-			name: `(and none) matches nothing`,
-			a: &opencost.Allocation{
-				Properties: &opencost.AllocationProperties{
-					Namespace: "kube-system",
-					Labels: map[string]string{
-						"app": "bar",
-					},
-				},
-			},
-			filter: filter.And[*opencost.Allocation]{[]filter.Filter[*opencost.Allocation]{
-				filter.AllCut[*opencost.Allocation]{},
-			}},
-			expected: false,
-		},
-	}
-
-	for _, c := range cases {
-		result := c.filter.Matches(c.a)
-
-		if result != c.expected {
-			t.Errorf("%s: expected %t, got %t", c.name, c.expected, result)
-		}
-	}
-}

+ 0 - 17
core/pkg/filter/legacy/not.go

@@ -1,17 +0,0 @@
-package legacy
-
-import "fmt"
-
-// Not negates any filter contained within it
-type Not[T any] struct {
-	Filter Filter[T]
-}
-
-func (n Not[T]) String() string {
-	return fmt.Sprintf("(not %s)", n.Filter.String())
-}
-
-// Matches inverts the result of the child filter
-func (n Not[T]) Matches(that T) bool {
-	return !n.Filter.Matches(that)
-}

+ 0 - 36
core/pkg/filter/legacy/or.go

@@ -1,36 +0,0 @@
-package legacy
-
-import (
-	"fmt"
-)
-
-// Or is a set of filters that should be evaluated as a logical
-// OR.
-type Or[T any] struct {
-	Filters []Filter[T]
-}
-
-func (o Or[T]) String() string {
-	s := "(or"
-	for _, f := range o.Filters {
-		s += fmt.Sprintf(" %s", f)
-	}
-
-	s += ")"
-	return s
-}
-
-func (o Or[T]) Matches(that T) bool {
-	filters := o.Filters
-	if len(filters) == 0 {
-		return true
-	}
-
-	for _, filter := range filters {
-		if filter.Matches(that) {
-			return true
-		}
-	}
-
-	return false
-}

+ 0 - 83
core/pkg/filter/legacy/stringmapproperty.go

@@ -1,83 +0,0 @@
-package legacy
-
-import (
-	"fmt"
-	"strings"
-
-	"github.com/opencost/opencost/core/pkg/log"
-)
-
-const unallocatedSuffix = "__unallocated__"
-
-type StringMapPropertied interface {
-	StringMapProperty(string) (map[string]string, error)
-}
-
-// StringMapOperation is an enum that represents operations that can be performed
-// when filtering (equality, inequality, etc.)
-type StringMapOperation string
-
-const (
-	// StringMapHasKey passes if the map has the provided key
-	StringMapHasKey StringMapOperation = "stringmapcontains"
-
-	StringMapStartsWith = "stringmapstartswith"
-
-	// StringMapEquals when the given key and value match
-	StringMapEquals = "stringmapequals"
-)
-
-// StringMapProperty is the lowest-level type of filter. It represents
-// a filter operation (equality, inequality, etc.) on a property that contains a string map
-type StringMapProperty[T StringMapPropertied] struct {
-	Field string
-	Op    StringMapOperation
-	Key   string
-	Value string
-}
-
-func (smp StringMapProperty[T]) String() string {
-	return fmt.Sprintf(`(%s %s[%s] "%s")`, smp.Op, smp.Field, smp.Key, smp.Value)
-}
-
-func (smp StringMapProperty[T]) Matches(that T) bool {
-
-	thatMap, err := that.StringMapProperty(smp.Field)
-	if err != nil {
-		log.Errorf("Filter: StringMapProperty: could not retrieve field %s: %s", smp.Field, err.Error())
-		return false
-	}
-
-	valueToCompare, keyIsPresent := thatMap[smp.Key]
-
-	switch smp.Op {
-	case StringMapHasKey:
-		return keyIsPresent
-	case StringMapEquals:
-		// namespace:"__unallocated__" should match a.Properties.Namespace = ""
-		// label[app]:"__unallocated__" should match _, ok := Labels[app]; !ok
-		if !keyIsPresent || valueToCompare == "" {
-			return smp.Value == unallocatedSuffix
-		}
-
-		if valueToCompare == smp.Value {
-			return true
-		}
-
-	case StringMapStartsWith:
-		if !keyIsPresent {
-			return false
-		}
-
-		// We don't need special __unallocated__ logic here because a query
-		// asking for "__unallocated__" won't have a wildcard and unallocated
-		// properties are the empty string.
-
-		return strings.HasPrefix(valueToCompare, smp.Value)
-	default:
-		log.Errorf("Filter: StringMapProperty: Unhandled filter op. This is a filter implementation error and requires immediate patching. Op: %s", smp.Op)
-		return false
-	}
-
-	return false
-}

+ 0 - 83
core/pkg/filter/legacy/stringproperty.go

@@ -1,83 +0,0 @@
-package legacy
-
-import (
-	"fmt"
-	"strings"
-
-	"github.com/opencost/opencost/core/pkg/log"
-)
-
-// StringPropertied is used to validate the name of a property field and return its value
-type StringPropertied interface {
-	// StringProperty acts as a validator and getter for a structs string properties
-	StringProperty(string) (string, error)
-}
-
-// StringOperation is an enum that represents operations that can be performed
-// when filtering (equality, inequality, etc.)
-type StringOperation string
-
-// If you add a FilterOp, MAKE SURE TO UPDATE ALL FILTER IMPLEMENTATIONS! Go
-// does not enforce exhaustive pattern matching on "enum" types.
-const (
-	// StringEquals is the equality operator
-	// "kube-system" FilterEquals "kube-system" = true
-	// "kube-syste" FilterEquals "kube-system" = false
-	StringEquals StringOperation = "stringequals"
-
-	// StringStartsWith matches strings with the given prefix.
-	// "kube-system" StartsWith "kube" = true
-	//
-	// When comparing with a field represented by an array/slice, this is like
-	// applying FilterContains to every element of the slice.
-	StringStartsWith = "stringstartswith"
-)
-
-// StringProperty is the lowest-level type of filter. It represents
-// a filter operation (equality, inequality, etc.) on a field with a string value (namespace,
-// node, pod, etc.).
-type StringProperty[T StringPropertied] struct {
-	Field string
-	Op    StringOperation
-
-	// Value is for _all_ filters. A filter of 'namespace:"kubecost"' has
-	// Value="kubecost"
-	Value string
-}
-
-func (sp StringProperty[T]) String() string {
-	return fmt.Sprintf(`(%s %s "%s")`, sp.Op, sp.Field, sp.Value)
-}
-
-func (sp StringProperty[T]) Matches(that T) bool {
-
-	thatString, err := that.StringProperty(sp.Field)
-	if err != nil {
-		log.Errorf("Filter: StringProperty: could not retrieve field %s: %s", sp.Field, err.Error())
-		return false
-	}
-
-	switch sp.Op {
-	case StringEquals:
-		// namespace:"__unallocated__" should match a.Properties.Namespace = ""
-		if thatString == "" {
-			return sp.Value == unallocatedSuffix
-		}
-
-		if thatString == sp.Value {
-			return true
-		}
-	case StringStartsWith:
-
-		// We don't need special __unallocated__ logic here because a query
-		// asking for "__unallocated__" won't have a wildcard and unallocated
-		// properties are the empty string.
-
-		return strings.HasPrefix(thatString, sp.Value)
-	default:
-		log.Errorf("Filter: StringProperty: Unhandled filter op. This is a filter implementation error and requires immediate patching. Op: %s", sp.Op)
-		return false
-	}
-
-	return false
-}

+ 0 - 80
core/pkg/filter/legacy/stringsliceproperty.go

@@ -1,80 +0,0 @@
-package legacy
-
-import (
-	"fmt"
-	"strings"
-
-	"github.com/opencost/opencost/core/pkg/log"
-)
-
-type StringSlicePropertied interface {
-	StringSliceProperty(string) ([]string, error)
-}
-
-// StringSliceOperation is an enum that represents operations that can be performed
-// when filtering (equality, inequality, etc.)
-type StringSliceOperation string
-
-const (
-	// StringSliceContains is an array/slice membership operator
-	// ["a", "b", "c"] FilterContains "a" = true
-	StringSliceContains StringSliceOperation = "stringslicecontains"
-
-	// StringSliceContainsPrefix is like FilterContains, but using StartsWith instead
-	// of Equals.
-	// ["kube-system", "abc123"] ContainsPrefix ["kube"] = true
-	StringSliceContainsPrefix = "stringslicecontainsprefix"
-)
-
-// StringSliceProperty is the lowest-level type of filter. It represents
-// a filter operation (equality, inequality, etc.) on a property that contains a string slice
-type StringSliceProperty[T StringSlicePropertied] struct {
-	Field string
-	Op    StringSliceOperation
-
-	Value string
-}
-
-func (ssp StringSliceProperty[T]) String() string {
-	return fmt.Sprintf(`(%s %s "%s")`, ssp.Op, ssp.Field, ssp.Value)
-}
-
-func (ssp StringSliceProperty[T]) Matches(that T) bool {
-
-	thatSlice, err := that.StringSliceProperty(ssp.Field)
-	if err != nil {
-		log.Errorf("Filter: StringSliceProperty: could not retrieve field %s: %s", ssp.Field, err.Error())
-		return false
-	}
-
-	switch ssp.Op {
-
-	case StringSliceContains:
-		if len(thatSlice) == 0 {
-			return ssp.Value == unallocatedSuffix
-		}
-
-		for _, s := range thatSlice {
-			if s == ssp.Value {
-				return true
-			}
-		}
-	case StringSliceContainsPrefix:
-		// We don't need special __unallocated__ logic here because a query
-		// asking for "__unallocated__" won't have a wildcard and unallocated
-		// properties are the empty string.
-
-		for _, s := range thatSlice {
-			if strings.HasPrefix(s, ssp.Value) {
-				return true
-			}
-		}
-
-		return false
-	default:
-		log.Errorf("Filter: StringSliceProperty: Unhandled filter op. This is a filter implementation error and requires immediate patching. Op: %s", ssp.Op)
-		return false
-	}
-
-	return false
-}

+ 0 - 40
core/pkg/filter/legacy/window.go

@@ -1,40 +0,0 @@
-package legacy
-
-//
-//import (
-//	"fmt"
-//	"github.com/opencost/opencost/pkg/kubecost"
-//	"github.com/opencost/opencost/pkg/log"
-//)
-//
-//type Windowed interface {
-//	GetWindow() opencost.Window
-//}
-//
-//// WindowOperation are operations that can be performed on types that have windows
-//type WindowOperation string
-//
-//const (
-//	WindowContains WindowOperation = "windowcontains"
-//)
-//
-//// WindowCondition is a filter can be used on any type that has a window and implements GetWindow()
-//type WindowCondition[T Windowed] struct {
-//	Window opencost.Window
-//	Op     WindowOperation
-//}
-//
-//func (wc WindowCondition[T]) String() string {
-//	return fmt.Sprintf(`(%s "%s")`, wc.Op, wc.Window.String())
-//}
-//
-//func (wc WindowCondition[T]) Matches(that T) bool {
-//	thatWindow := that.GetWindow()
-//	switch wc.Op {
-//	case WindowContains:
-//		return wc.Window.ContainsWindow(thatWindow)
-//	default:
-//		log.Errorf("Filter: Window: Unhandled filter operation. This is a filter implementation error and requires immediate patching. Op: %s", wc.Op)
-//		return false
-//	}
-//}

+ 0 - 112
core/pkg/filter/legacy/window_test.go

@@ -1,112 +0,0 @@
-package legacy_test
-
-// import (
-// 	"github.com/opencost/opencost/pkg/kubecost"
-// 	"testing"
-// 	"time"
-// )
-
-// type windowedImpl struct {
-// 	opencost.Window
-// }
-
-// func (w *windowedImpl) GetWindow() opencost.Window {
-// 	return w.Window
-// }
-
-// func newWindowedImpl(start, end *time.Time) *windowedImpl {
-// 	return &windowedImpl{opencost.NewWindow(start, end)}
-// }
-
-// func Test_WindowContains_Matches(t *testing.T) {
-// 	noon := time.Date(2022, 9, 29, 12, 0, 0, 0, time.UTC)
-// 	one := noon.Add(time.Hour)
-// 	two := one.Add(time.Hour)
-// 	three := two.Add(time.Hour)
-// 	cases := map[string]struct {
-// 		windowed *windowedImpl
-// 		filter   Filter[*windowedImpl]
-// 		expected bool
-// 	}{
-// 		"fully contains": {
-// 			windowed: newWindowedImpl(&one, &two),
-// 			filter: WindowCondition[*windowedImpl]{
-// 				Window: opencost.NewWindow(&noon, &three),
-// 				Op:     WindowContains,
-// 			},
-
-// 			expected: true,
-// 		},
-// 		"window matches": {
-// 			windowed: newWindowedImpl(&one, &two),
-// 			filter: WindowCondition[*windowedImpl]{
-// 				Window: opencost.NewWindow(&one, &two),
-// 				Op:     WindowContains,
-// 			},
-
-// 			expected: true,
-// 		},
-// 		"contains start": {
-// 			windowed: newWindowedImpl(&one, &three),
-// 			filter: WindowCondition[*windowedImpl]{
-// 				Window: opencost.NewWindow(&noon, &two),
-// 				Op:     WindowContains,
-// 			},
-
-// 			expected: false,
-// 		},
-// 		"contains end": {
-// 			windowed: newWindowedImpl(&noon, &two),
-// 			filter: WindowCondition[*windowedImpl]{
-// 				Window: opencost.NewWindow(&one, &three),
-// 				Op:     WindowContains,
-// 			},
-
-// 			expected: false,
-// 		},
-// 		"window start = filter end": {
-// 			windowed: newWindowedImpl(&one, &two),
-// 			filter: WindowCondition[*windowedImpl]{
-// 				Window: opencost.NewWindow(&noon, &one),
-// 				Op:     WindowContains,
-// 			},
-
-// 			expected: false,
-// 		},
-// 		"window end = filter start": {
-// 			windowed: newWindowedImpl(&noon, &one),
-// 			filter: WindowCondition[*windowedImpl]{
-// 				Window: opencost.NewWindow(&one, &two),
-// 				Op:     WindowContains,
-// 			},
-
-// 			expected: false,
-// 		},
-// 		"window before": {
-// 			windowed: newWindowedImpl(&noon, &one),
-// 			filter: WindowCondition[*windowedImpl]{
-// 				Window: opencost.NewWindow(&two, &three),
-// 				Op:     WindowContains,
-// 			},
-
-// 			expected: false,
-// 		},
-// 		"window after": {
-// 			windowed: newWindowedImpl(&two, &three),
-// 			filter: WindowCondition[*windowedImpl]{
-// 				Window: opencost.NewWindow(&noon, &one),
-// 				Op:     WindowContains,
-// 			},
-
-// 			expected: false,
-// 		},
-// 	}
-
-// 	for name, c := range cases {
-// 		result := c.filter.Matches(c.windowed)
-
-// 		if result != c.expected {
-// 			t.Errorf("%s: expected %t, got %t", name, c.expected, result)
-// 		}
-// 	}
-// }

+ 0 - 2
core/pkg/opencost/bingen.go

@@ -22,8 +22,6 @@ package opencost
 
 // Default Version Set (uses -version flag passed) includes shared resources
 // @bingen:generate:Window
-// @bingen:generate:Coverage
-// @bingen:generate:CoverageSet
 
 // Asset Version Set: Includes Asset pipeline specific resources
 // @bingen:set[name=Assets,version=21]

+ 1 - 22
core/pkg/opencost/cloudcost.go

@@ -7,7 +7,6 @@ import (
 
 	"github.com/opencost/opencost/core/pkg/filter"
 	"github.com/opencost/opencost/core/pkg/filter/ast"
-	legacyfilter "github.com/opencost/opencost/core/pkg/filter/legacy"
 	"github.com/opencost/opencost/core/pkg/log"
 	"github.com/opencost/opencost/core/pkg/util/timeutil"
 )
@@ -279,27 +278,7 @@ func (ccs *CloudCostSet) Equal(that *CloudCostSet) bool {
 	return true
 }
 
-func (ccs *CloudCostSet) Filter(filters legacyfilter.Filter[*CloudCost]) *CloudCostSet {
-	if ccs == nil {
-		return nil
-	}
-
-	if filters == nil {
-		return ccs.Clone()
-	}
-
-	result := ccs.cloneSet()
-
-	for _, cc := range ccs.CloudCosts {
-		if filters.Matches(cc) {
-			result.Insert(cc.Clone())
-		}
-	}
-
-	return result
-}
-
-func (ccs *CloudCostSet) Filter21(filters filter.Filter) (*CloudCostSet, error) {
+func (ccs *CloudCostSet) Filter(filters filter.Filter) (*CloudCostSet, error) {
 	if ccs == nil {
 		return nil, nil
 	}

+ 0 - 13
core/pkg/opencost/cloudusage.go

@@ -1,13 +0,0 @@
-package opencost
-
-// CloudUsage is temporarily aliased as the Cloud Asset type until further infrastructure and pages can be built to support its usage
-type CloudUsage = Cloud
-
-// CloudUsageSet is temporarily aliased as the AssetSet until further infrastructure and pages can be built to support its usage
-type CloudUsageSet = AssetSet
-
-// CloudUsageSetRange is temporarily aliased as the AssetSetRange until further infrastructure and pages can be built to support its usage
-type CloudUsageSetRange = AssetSetRange
-
-// CloudUsageAggregationOptions is temporarily aliased as the AssetAggregationOptions until further infrastructure and pages can be built to support its usage
-type CloudUsageAggregationOptions = AssetAggregationOptions

+ 0 - 131
core/pkg/opencost/coverage.go

@@ -1,131 +0,0 @@
-package opencost
-
-import (
-	"time"
-
-	filter "github.com/opencost/opencost/core/pkg/filter/legacy"
-	"github.com/opencost/opencost/core/pkg/log"
-)
-
-// Coverage This is a placeholder struct which can be replaced by a more specific implementation later
-type Coverage struct {
-	Window   Window    `json:"window"`
-	Type     string    `json:"type"`
-	Count    int       `json:"count"`
-	Updated  time.Time `json:"updated"`
-	Errors   []string  `json:"errors"`
-	Warnings []string  `json:"warnings"`
-}
-
-func (c *Coverage) GetWindow() Window {
-	return c.Window
-}
-
-func (c *Coverage) Key() string {
-	return c.Type
-}
-
-func (c *Coverage) IsEmpty() bool {
-	if c == nil {
-		log.Warnf("calling IsEmpty() on a nil Coverage")
-		return true
-	}
-	return c.Type == "" && c.Count == 0 && len(c.Errors) == 0 && len(c.Warnings) == 0 && c.Updated == time.Time{}
-}
-
-func (c *Coverage) Clone() *Coverage {
-	if c == nil {
-		log.Warnf("calling Clone() on a nil Coverage")
-		return nil
-	}
-	var errors []string
-	if len(c.Errors) > 0 {
-		errors = make([]string, len(c.Errors))
-		copy(errors, c.Errors)
-	}
-	var warnings []string
-	if len(c.Warnings) > 0 {
-		warnings = make([]string, len(c.Warnings))
-		copy(warnings, c.Warnings)
-	}
-	return &Coverage{
-		Window:   c.Window.Clone(),
-		Type:     c.Type,
-		Count:    c.Count,
-		Updated:  c.Updated,
-		Errors:   errors,
-		Warnings: warnings,
-	}
-}
-
-// Coverage This is a placeholder struct which can be replaced by a more specific implementation later
-type CoverageSet struct {
-	Window Window               `json:"window"`
-	Items  map[string]*Coverage `json:"items"`
-}
-
-func NewCoverageSet(start, end time.Time) *CoverageSet {
-	return &CoverageSet{
-		Window: NewWindow(&start, &end),
-		Items:  map[string]*Coverage{},
-	}
-}
-
-func (cs *CoverageSet) GetWindow() Window {
-	return cs.Window
-}
-
-func (cs *CoverageSet) IsEmpty() bool {
-	if cs == nil {
-		log.Warnf("calling IsEmpty() on a nil CoverageSet")
-		return true
-	}
-	for _, item := range cs.Items {
-		if !item.IsEmpty() {
-			return false
-		}
-	}
-	return true
-}
-
-func (cs *CoverageSet) Clone() *CoverageSet {
-	var items map[string]*Coverage
-	if cs.Items != nil {
-		items = make(map[string]*Coverage, len(cs.Items))
-		for k, item := range cs.Items {
-			items[k] = item.Clone()
-		}
-
-	}
-	return &CoverageSet{
-		Window: cs.Window.Clone(),
-		Items:  items,
-	}
-}
-
-func (cs *CoverageSet) Insert(coverage *Coverage) {
-	if cs.Items == nil {
-		cs.Items = map[string]*Coverage{}
-	}
-	cs.Items[coverage.Key()] = coverage
-}
-
-func (cs *CoverageSet) Filter(filters filter.Filter[*Coverage]) *CoverageSet {
-	if cs == nil {
-		return nil
-	}
-
-	if filters == nil {
-		return cs.Clone()
-	}
-
-	result := NewCoverageSet(*cs.Window.start, *cs.Window.end)
-
-	for _, c := range cs.Items {
-		if filters.Matches(c) {
-			result.Insert(c.Clone())
-		}
-	}
-
-	return result
-}

+ 4 - 438
core/pkg/opencost/opencost_codecs.go

@@ -13,12 +13,11 @@ package opencost
 
 import (
 	"fmt"
+	util "github.com/opencost/opencost/core/pkg/util"
 	"reflect"
 	"strings"
 	"sync"
 	"time"
-
-	util "github.com/opencost/opencost/core/pkg/util"
 )
 
 const (
@@ -34,9 +33,6 @@ const (
 )
 
 const (
-	// DefaultCodecVersion is used for any resources listed in the Default version set
-	DefaultCodecVersion uint8 = 17
-
 	// AssetsCodecVersion is used for any resources listed in the Assets version set
 	AssetsCodecVersion uint8 = 21
 
@@ -45,6 +41,9 @@ const (
 
 	// CloudCostCodecVersion is used for any resources listed in the CloudCost version set
 	CloudCostCodecVersion uint8 = 2
+
+	// DefaultCodecVersion is used for any resources listed in the Default version set
+	DefaultCodecVersion uint8 = 17
 )
 
 //--------------------------------------------------------------------------
@@ -70,8 +69,6 @@ var typeMap map[string]reflect.Type = map[string]reflect.Type{
 	"CloudCostSetRange":     reflect.TypeOf((*CloudCostSetRange)(nil)).Elem(),
 	"ClusterManagement":     reflect.TypeOf((*ClusterManagement)(nil)).Elem(),
 	"CostMetric":            reflect.TypeOf((*CostMetric)(nil)).Elem(),
-	"Coverage":              reflect.TypeOf((*Coverage)(nil)).Elem(),
-	"CoverageSet":           reflect.TypeOf((*CoverageSet)(nil)).Elem(),
 	"Disk":                  reflect.TypeOf((*Disk)(nil)).Elem(),
 	"LbAllocation":          reflect.TypeOf((*LbAllocation)(nil)).Elem(),
 	"LoadBalancer":          reflect.TypeOf((*LoadBalancer)(nil)).Elem(),
@@ -4521,437 +4518,6 @@ func (target *CostMetric) UnmarshalBinaryWithContext(ctx *DecodingContext) (err
 	return nil
 }
 
-//--------------------------------------------------------------------------
-//  Coverage
-//--------------------------------------------------------------------------
-
-// MarshalBinary serializes the internal properties of this Coverage instance
-// into a byte array
-func (target *Coverage) MarshalBinary() (data []byte, err error) {
-	ctx := &EncodingContext{
-		Buffer: util.NewBuffer(),
-		Table:  nil,
-	}
-
-	e := target.MarshalBinaryWithContext(ctx)
-	if e != nil {
-		return nil, e
-	}
-
-	encBytes := ctx.Buffer.Bytes()
-	return encBytes, nil
-}
-
-// MarshalBinaryWithContext serializes the internal properties of this Coverage instance
-// into a byte array leveraging a predefined context.
-func (target *Coverage) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
-	// panics are recovered and propagated as errors
-	defer func() {
-		if r := recover(); r != nil {
-			if e, ok := r.(error); ok {
-				err = e
-			} else if s, ok := r.(string); ok {
-				err = fmt.Errorf("Unexpected panic: %s", s)
-			} else {
-				err = fmt.Errorf("Unexpected panic: %+v", r)
-			}
-		}
-	}()
-
-	buff := ctx.Buffer
-	buff.WriteUInt8(DefaultCodecVersion) // version
-
-	// --- [begin][write][struct](Window) ---
-	buff.WriteInt(0) // [compatibility, unused]
-	errA := target.Window.MarshalBinaryWithContext(ctx)
-	if errA != nil {
-		return errA
-	}
-	// --- [end][write][struct](Window) ---
-
-	if ctx.IsStringTable() {
-		a := ctx.Table.AddOrGet(target.Type)
-		buff.WriteInt(a) // write table index
-	} else {
-		buff.WriteString(target.Type) // write string
-	}
-	buff.WriteInt(target.Count) // write int
-	// --- [begin][write][reference](time.Time) ---
-	b, errB := target.Updated.MarshalBinary()
-	if errB != nil {
-		return errB
-	}
-	buff.WriteInt(len(b))
-	buff.WriteBytes(b)
-	// --- [end][write][reference](time.Time) ---
-
-	if target.Errors == nil {
-		buff.WriteUInt8(uint8(0)) // write nil byte
-	} else {
-		buff.WriteUInt8(uint8(1)) // write non-nil byte
-
-		// --- [begin][write][slice]([]string) ---
-		buff.WriteInt(len(target.Errors)) // array length
-		for i := 0; i < len(target.Errors); i++ {
-			if ctx.IsStringTable() {
-				c := ctx.Table.AddOrGet(target.Errors[i])
-				buff.WriteInt(c) // write table index
-			} else {
-				buff.WriteString(target.Errors[i]) // write string
-			}
-		}
-		// --- [end][write][slice]([]string) ---
-
-	}
-	if target.Warnings == nil {
-		buff.WriteUInt8(uint8(0)) // write nil byte
-	} else {
-		buff.WriteUInt8(uint8(1)) // write non-nil byte
-
-		// --- [begin][write][slice]([]string) ---
-		buff.WriteInt(len(target.Warnings)) // array length
-		for j := 0; j < len(target.Warnings); j++ {
-			if ctx.IsStringTable() {
-				d := ctx.Table.AddOrGet(target.Warnings[j])
-				buff.WriteInt(d) // write table index
-			} else {
-				buff.WriteString(target.Warnings[j]) // write string
-			}
-		}
-		// --- [end][write][slice]([]string) ---
-
-	}
-	return nil
-}
-
-// UnmarshalBinary uses the data passed byte array to set all the internal properties of
-// the Coverage type
-func (target *Coverage) UnmarshalBinary(data []byte) error {
-	var table []string
-	buff := util.NewBufferFromBytes(data)
-
-	// string table header validation
-	if isBinaryTag(data, BinaryTagStringTable) {
-		buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
-		tl := buff.ReadInt()                      // table length
-		if tl > 0 {
-			table = make([]string, tl, tl)
-			for i := 0; i < tl; i++ {
-				table[i] = buff.ReadString()
-			}
-		}
-	}
-
-	ctx := &DecodingContext{
-		Buffer: buff,
-		Table:  table,
-	}
-
-	err := target.UnmarshalBinaryWithContext(ctx)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
-// UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
-// the Coverage type
-func (target *Coverage) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
-	// panics are recovered and propagated as errors
-	defer func() {
-		if r := recover(); r != nil {
-			if e, ok := r.(error); ok {
-				err = e
-			} else if s, ok := r.(string); ok {
-				err = fmt.Errorf("Unexpected panic: %s", s)
-			} else {
-				err = fmt.Errorf("Unexpected panic: %+v", r)
-			}
-		}
-	}()
-
-	buff := ctx.Buffer
-	version := buff.ReadUInt8()
-
-	if version > DefaultCodecVersion {
-		return fmt.Errorf("Invalid Version Unmarshaling Coverage. Expected %d or less, got %d", DefaultCodecVersion, version)
-	}
-
-	// --- [begin][read][struct](Window) ---
-	a := &Window{}
-	buff.ReadInt() // [compatibility, unused]
-	errA := a.UnmarshalBinaryWithContext(ctx)
-	if errA != nil {
-		return errA
-	}
-	target.Window = *a
-	// --- [end][read][struct](Window) ---
-
-	var c string
-	if ctx.IsStringTable() {
-		d := buff.ReadInt() // read string index
-		c = ctx.Table[d]
-	} else {
-		c = buff.ReadString() // read string
-	}
-	b := c
-	target.Type = b
-
-	e := buff.ReadInt() // read int
-	target.Count = e
-
-	// --- [begin][read][reference](time.Time) ---
-	f := &time.Time{}
-	g := buff.ReadInt()    // byte array length
-	h := buff.ReadBytes(g) // byte array
-	errB := f.UnmarshalBinary(h)
-	if errB != nil {
-		return errB
-	}
-	target.Updated = *f
-	// --- [end][read][reference](time.Time) ---
-
-	if buff.ReadUInt8() == uint8(0) {
-		target.Errors = nil
-	} else {
-		// --- [begin][read][slice]([]string) ---
-		l := buff.ReadInt() // array len
-		k := make([]string, l)
-		for i := 0; i < l; i++ {
-			var m string
-			var o string
-			if ctx.IsStringTable() {
-				p := buff.ReadInt() // read string index
-				o = ctx.Table[p]
-			} else {
-				o = buff.ReadString() // read string
-			}
-			n := o
-			m = n
-
-			k[i] = m
-		}
-		target.Errors = k
-		// --- [end][read][slice]([]string) ---
-
-	}
-	if buff.ReadUInt8() == uint8(0) {
-		target.Warnings = nil
-	} else {
-		// --- [begin][read][slice]([]string) ---
-		r := buff.ReadInt() // array len
-		q := make([]string, r)
-		for j := 0; j < r; j++ {
-			var s string
-			var u string
-			if ctx.IsStringTable() {
-				w := buff.ReadInt() // read string index
-				u = ctx.Table[w]
-			} else {
-				u = buff.ReadString() // read string
-			}
-			t := u
-			s = t
-
-			q[j] = s
-		}
-		target.Warnings = q
-		// --- [end][read][slice]([]string) ---
-
-	}
-	return nil
-}
-
-//--------------------------------------------------------------------------
-//  CoverageSet
-//--------------------------------------------------------------------------
-
-// MarshalBinary serializes the internal properties of this CoverageSet instance
-// into a byte array
-func (target *CoverageSet) MarshalBinary() (data []byte, err error) {
-	ctx := &EncodingContext{
-		Buffer: util.NewBuffer(),
-		Table:  nil,
-	}
-
-	e := target.MarshalBinaryWithContext(ctx)
-	if e != nil {
-		return nil, e
-	}
-
-	encBytes := ctx.Buffer.Bytes()
-	return encBytes, nil
-}
-
-// MarshalBinaryWithContext serializes the internal properties of this CoverageSet instance
-// into a byte array leveraging a predefined context.
-func (target *CoverageSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
-	// panics are recovered and propagated as errors
-	defer func() {
-		if r := recover(); r != nil {
-			if e, ok := r.(error); ok {
-				err = e
-			} else if s, ok := r.(string); ok {
-				err = fmt.Errorf("Unexpected panic: %s", s)
-			} else {
-				err = fmt.Errorf("Unexpected panic: %+v", r)
-			}
-		}
-	}()
-
-	buff := ctx.Buffer
-	buff.WriteUInt8(DefaultCodecVersion) // version
-
-	// --- [begin][write][struct](Window) ---
-	buff.WriteInt(0) // [compatibility, unused]
-	errA := target.Window.MarshalBinaryWithContext(ctx)
-	if errA != nil {
-		return errA
-	}
-	// --- [end][write][struct](Window) ---
-
-	if target.Items == nil {
-		buff.WriteUInt8(uint8(0)) // write nil byte
-	} else {
-		buff.WriteUInt8(uint8(1)) // write non-nil byte
-
-		// --- [begin][write][map](map[string]*Coverage) ---
-		buff.WriteInt(len(target.Items)) // map length
-		for v, z := range target.Items {
-			if ctx.IsStringTable() {
-				a := ctx.Table.AddOrGet(v)
-				buff.WriteInt(a) // write table index
-			} else {
-				buff.WriteString(v) // write string
-			}
-			if z == nil {
-				buff.WriteUInt8(uint8(0)) // write nil byte
-			} else {
-				buff.WriteUInt8(uint8(1)) // write non-nil byte
-
-				// --- [begin][write][struct](Coverage) ---
-				buff.WriteInt(0) // [compatibility, unused]
-				errB := z.MarshalBinaryWithContext(ctx)
-				if errB != nil {
-					return errB
-				}
-				// --- [end][write][struct](Coverage) ---
-
-			}
-		}
-		// --- [end][write][map](map[string]*Coverage) ---
-
-	}
-	return nil
-}
-
-// UnmarshalBinary uses the data passed byte array to set all the internal properties of
-// the CoverageSet type
-func (target *CoverageSet) UnmarshalBinary(data []byte) error {
-	var table []string
-	buff := util.NewBufferFromBytes(data)
-
-	// string table header validation
-	if isBinaryTag(data, BinaryTagStringTable) {
-		buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
-		tl := buff.ReadInt()                      // table length
-		if tl > 0 {
-			table = make([]string, tl, tl)
-			for i := 0; i < tl; i++ {
-				table[i] = buff.ReadString()
-			}
-		}
-	}
-
-	ctx := &DecodingContext{
-		Buffer: buff,
-		Table:  table,
-	}
-
-	err := target.UnmarshalBinaryWithContext(ctx)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
-// UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
-// the CoverageSet type
-func (target *CoverageSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
-	// panics are recovered and propagated as errors
-	defer func() {
-		if r := recover(); r != nil {
-			if e, ok := r.(error); ok {
-				err = e
-			} else if s, ok := r.(string); ok {
-				err = fmt.Errorf("Unexpected panic: %s", s)
-			} else {
-				err = fmt.Errorf("Unexpected panic: %+v", r)
-			}
-		}
-	}()
-
-	buff := ctx.Buffer
-	version := buff.ReadUInt8()
-
-	if version > DefaultCodecVersion {
-		return fmt.Errorf("Invalid Version Unmarshaling CoverageSet. Expected %d or less, got %d", DefaultCodecVersion, version)
-	}
-
-	// --- [begin][read][struct](Window) ---
-	a := &Window{}
-	buff.ReadInt() // [compatibility, unused]
-	errA := a.UnmarshalBinaryWithContext(ctx)
-	if errA != nil {
-		return errA
-	}
-	target.Window = *a
-	// --- [end][read][struct](Window) ---
-
-	if buff.ReadUInt8() == uint8(0) {
-		target.Items = nil
-	} else {
-		// --- [begin][read][map](map[string]*Coverage) ---
-		c := buff.ReadInt() // map len
-		b := make(map[string]*Coverage, c)
-		for i := 0; i < c; i++ {
-			var v string
-			var e string
-			if ctx.IsStringTable() {
-				f := buff.ReadInt() // read string index
-				e = ctx.Table[f]
-			} else {
-				e = buff.ReadString() // read string
-			}
-			d := e
-			v = d
-
-			var z *Coverage
-			if buff.ReadUInt8() == uint8(0) {
-				z = nil
-			} else {
-				// --- [begin][read][struct](Coverage) ---
-				g := &Coverage{}
-				buff.ReadInt() // [compatibility, unused]
-				errB := g.UnmarshalBinaryWithContext(ctx)
-				if errB != nil {
-					return errB
-				}
-				z = g
-				// --- [end][read][struct](Coverage) ---
-
-			}
-			b[v] = z
-		}
-		target.Items = b
-		// --- [end][read][map](map[string]*Coverage) ---
-
-	}
-	return nil
-}
-
 //--------------------------------------------------------------------------
 //  Disk
 //--------------------------------------------------------------------------

+ 28 - 77
core/pkg/opencost/query.go

@@ -4,7 +4,7 @@ import (
 	"strings"
 	"time"
 
-	filter21 "github.com/opencost/opencost/core/pkg/filter"
+	"github.com/opencost/opencost/core/pkg/filter"
 )
 
 // Querier is an aggregate interface which has the ability to query each Kubecost store type
@@ -12,7 +12,6 @@ type Querier interface {
 	AllocationQuerier
 	SummaryAllocationQuerier
 	AssetQuerier
-	CloudUsageQuerier
 }
 
 // AllocationQuerier interface defining api for requesting Allocation data
@@ -30,32 +29,26 @@ type AssetQuerier interface {
 	QueryAsset(start, end time.Time, opts *AssetQueryOptions) (*AssetSetRange, error)
 }
 
-// CloudUsageQuerier interface defining api for requesting CloudUsage data
-type CloudUsageQuerier interface {
-	QueryCloudUsage(start, end time.Time, opts *CloudUsageQueryOptions) (*CloudUsageSetRange, error)
-}
-
 // AllocationQueryOptions defines optional parameters for querying an Allocation Store
 type AllocationQueryOptions struct {
-	Accumulate              AccumulateOption
-	AggregateBy             []string
-	Compute                 bool
-	DisableAggregatedStores bool
-	Filter                  filter21.Filter
-	IdleByNode              bool
-	IncludeExternal         bool
-	IncludeIdle             bool
-	LabelConfig             *LabelConfig
-	MergeUnallocated        bool
-	Reconcile               bool
-	ReconcileNetwork        bool
-	ShareFuncs              []AllocationMatchFunc
-	SharedHourlyCosts       map[string]float64
-	ShareIdle               string
-	ShareSplit              string
-	ShareTenancyCosts       bool
-	SplitIdle               bool
-	Step                    time.Duration
+	Accumulate        AccumulateOption
+	AggregateBy       []string
+	Compute           bool
+	Filter            filter.Filter
+	IdleByNode        bool
+	IncludeExternal   bool
+	IncludeIdle       bool
+	LabelConfig       *LabelConfig
+	MergeUnallocated  bool
+	Reconcile         bool
+	ReconcileNetwork  bool
+	ShareFuncs        []AllocationMatchFunc
+	SharedHourlyCosts map[string]float64
+	ShareIdle         string
+	ShareSplit        string
+	ShareTenancyCosts bool
+	SplitIdle         bool
+	Step              time.Duration
 }
 
 type AccumulateOption string
@@ -94,36 +87,15 @@ func ParseAccumulate(acc string) AccumulateOption {
 
 // AssetQueryOptions defines optional parameters for querying an Asset Store
 type AssetQueryOptions struct {
-	Accumulate              bool
-	AggregateBy             []string
-	Compute                 bool
-	DisableAdjustments      bool
-	DisableAggregatedStores bool
-	Filter                  filter21.Filter
-	IncludeCloud            bool
-	SharedHourlyCosts       map[string]float64
-	Step                    time.Duration
-	LabelConfig             *LabelConfig
-}
-
-// CloudUsageQueryOptions define optional parameters for querying a Store
-type CloudUsageQueryOptions struct {
-	Accumulate   bool
-	AggregateBy  []string
-	Compute      bool
-	Filter       filter21.Filter
-	FilterValues CloudUsageFilter
-	LabelConfig  *LabelConfig
-}
-
-type CloudUsageFilter struct {
-	Categories  []string            `json:"categories"`
-	Providers   []string            `json:"providers"`
-	ProviderIDs []string            `json:"providerIDs"`
-	Accounts    []string            `json:"accounts"`
-	Projects    []string            `json:"projects"`
-	Services    []string            `json:"services"`
-	Labels      map[string][]string `json:"labels"`
+	Accumulate         bool
+	AggregateBy        []string
+	Compute            bool
+	DisableAdjustments bool
+	Filter             filter.Filter
+	IncludeCloud       bool
+	SharedHourlyCosts  map[string]float64
+	Step               time.Duration
+	LabelConfig        *LabelConfig
 }
 
 // QueryAllocationAsync provide a functions for retrieving results from any AllocationQuerier Asynchronously
@@ -188,24 +160,3 @@ func QueryAssetAsync(assetQuerier AssetQuerier, start, end time.Time, opts *Asse
 
 	return asrCh, errCh
 }
-
-// QueryCloudUsageAsync provide a functions for retrieving results from any CloudUsageQuerier Asynchronously
-func QueryCloudUsageAsync(cloudUsageQuerier CloudUsageQuerier, start, end time.Time, opts *CloudUsageQueryOptions) (chan *CloudUsageSetRange, chan error) {
-	cusrCh := make(chan *CloudUsageSetRange)
-	errCh := make(chan error)
-
-	go func(cusrCh chan *CloudUsageSetRange, errCh chan error) {
-		defer close(cusrCh)
-		defer close(errCh)
-
-		cusr, err := cloudUsageQuerier.QueryCloudUsage(start, end, opts)
-		if err != nil {
-			errCh <- err
-			return
-		}
-
-		cusrCh <- cusr
-	}(cusrCh, errCh)
-
-	return cusrCh, errCh
-}