Skip to content

Commit

Permalink
Make the table of fields to index more readable.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericpromislow committed Sep 3, 2024
1 parent b528439 commit 5ca4081
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions pkg/stores/sqlproxy/proxy_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,28 @@ var (
paramScheme = runtime.NewScheme()
paramCodec = runtime.NewParameterCodec(paramScheme)
typeSpecificIndexedFields = map[string][][]string{
"_v1_Namespace": {{`metadata`, `labels[field.cattle.io/projectId]`}},
"_v1_Node": {{`status`, `nodeInfo`, `kubeletVersion`}, {`status`, `nodeInfo`, `operatingSystem`}},
"_v1_Pod": {{`spec`, `containers`, `image`}, {`spec`, `nodeName`}},
"_v1_ConfigMap": {{`metadata`, `labels[harvesterhci.io/cloud-init-template]`}},

"cluster.x-k8s.io_v1beta1_Machine": {{`spec`, `clusterName`}},
"management.cattle.io_v3_Node": {{`status`, `nodeName`}},
"management.cattle.io_v3_NodePool": {{`spec`, `clusterName`}},
"management.cattle.io_v3_NodeTemplate": {{`spec`, `clusterName`}},
"provisioning.cattle.io_Cluster": {
{`metadata`, `labels[provider.cattle.io]`},
{`status`, `provider`},
{`status`, `allocatable`, `cpu`},
{`status`, `allocatable`, `memory`},
},
gvkKey("", "v1", "Namespace"): {
{"metadata", "labels[field.cattle.io/projectId]"}},
gvkKey("", "v1", "Node"): {
{"status", "nodeInfo", "kubeletVersion"},
{"status", "nodeInfo", "operatingSystem"}},
gvkKey("", "v1", "Pod"): {
{"spec", "containers", "image"}, {"spec", "nodeName"}},
gvkKey("", "v1", "ConfigMap"): {
{"metadata", "labels[harvesterhci.io/cloud-init-template]"}},
gvkKey("cluster.x-k8s.io", "v1beta1", "Machine"): {
{"spec", "clusterName"}},
gvkKey("management.cattle.io", "v3", "Node"): {
{"status", "nodeName"}},
gvkKey("management.cattle.io", "v3", "NodePool"): {
{"spec", "clusterName"}},
gvkKey("management.cattle.io", "v3", "NodeTemplate"): {
{"spec", "clusterName"}},
gvkKey("provisioning.cattle.io", "v1", "Cluster"): {
{"metadata", "labels[provider.cattle.io]"},
{"status", "provider"},
{"status", "allocatable", "cpu"},
{"status", "allocatable", "memory"}},
}
commonIndexFields = [][]string{
{`id`},
Expand Down Expand Up @@ -250,7 +257,11 @@ func getFieldForGVK(gvk schema.GroupVersionKind) [][]string {
}

func keyFromGVK(gvk schema.GroupVersionKind) string {
return gvk.Group + "_" + gvk.Version + "_" + gvk.Kind
return gvkKey(gvk.Group, gvk.Version, gvk.Kind)
}

func gvkKey(group, version, kind string) string {
return group + "_" + version + "_" + kind
}

// getFieldsFromSchema converts object field names from types.APISchema's format into lasso's
Expand Down

0 comments on commit 5ca4081

Please sign in to comment.