diff --git a/README.md b/README.md index ee40d0c7..f54bb18d 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,9 @@ displayed by `kubectl get $TYPE`. For example `secrets` have `"metadata.fields[0 corresponding to `"name"`, `"type"`, `"data"`, and `"age"`. For CRDs, these come from [Additional printer columns](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#additional-printer-columns) +When matching on array-type fields, the array's values are stored in the database as a single field separated by or-bars (`|`s).= +So searching for those fields needs to do a partial match when a field contains more than one value. + #### `projectsornamespaces` Resources can also be filtered by the Rancher projects their namespaces belong diff --git a/pkg/sqlcache/informer/listoption_indexer.go b/pkg/sqlcache/informer/listoption_indexer.go index 70653363..2fb755fa 100644 --- a/pkg/sqlcache/informer/listoption_indexer.go +++ b/pkg/sqlcache/informer/listoption_indexer.go @@ -802,6 +802,7 @@ func getField(a any, field string) (any, error) { } obj = fmt.Sprintf("%v", t[key]) } else if i == len(subFields)-1 { + // If the last layer is an array, return array.map(a => a[subfield]) result := make([]string, len(t)) for index, v := range t { itemVal, ok := v.(map[string]interface{}) diff --git a/pkg/sqlcache/store/store.go b/pkg/sqlcache/store/store.go index ab220a43..4ec00fec 100644 --- a/pkg/sqlcache/store/store.go +++ b/pkg/sqlcache/store/store.go @@ -76,7 +76,7 @@ func NewStore(ctx context.Context, example any, keyFunc cache.KeyFunc, c db.Clie dbName := db.Sanitize(s.name) - // once multiple informerfactories are needed, this can accept the case where table already exists error is received + // once multiple informer-factories are needed, this can accept the case where table already exists error is received err := s.WithTransaction(ctx, true, func(tx transaction.Client) error { createTableQuery := fmt.Sprintf(createTableFmt, dbName) _, err := tx.Exec(createTableQuery) diff --git a/pkg/stores/sqlproxy/proxy_store.go b/pkg/stores/sqlproxy/proxy_store.go index 8c7c00bc..aacaac2e 100644 --- a/pkg/stores/sqlproxy/proxy_store.go +++ b/pkg/stores/sqlproxy/proxy_store.go @@ -84,18 +84,26 @@ var ( gvkKey("", "v1", "Pod"): { {"spec", "containers", "image"}, {"spec", "nodeName"}}, + gvkKey("", "v1", "ReplicationController"): { + {"spec", "template", "spec", "containers", "image"}}, gvkKey("", "v1", "Service"): { {"spec", "clusterIP"}, {"spec", "type"}, }, gvkKey("apps", "v1", "DaemonSet"): { {"metadata", "annotations", "field.cattle.io/publicEndpoints"}, + {"spec", "template", "spec", "containers", "image"}, }, gvkKey("apps", "v1", "Deployment"): { {"metadata", "annotations", "field.cattle.io/publicEndpoints"}, + {"spec", "template", "spec", "containers", "image"}, + }, + gvkKey("apps", "v1", "ReplicaSet"): { + {"spec", "template", "spec", "containers", "image"}, }, gvkKey("apps", "v1", "StatefulSet"): { {"metadata", "annotations", "field.cattle.io/publicEndpoints"}, + {"spec", "template", "spec", "containers", "image"}, }, gvkKey("autoscaling", "v2", "HorizontalPodAutoscaler"): { {"spec", "scaleTargetRef", "name"}, @@ -105,9 +113,11 @@ var ( }, gvkKey("batch", "v1", "CronJob"): { {"metadata", "annotations", "field.cattle.io/publicEndpoints"}, + {"spec", "jobTemplate", "spec", "template", "spec", "containers", "image"}, }, gvkKey("batch", "v1", "Job"): { {"metadata", "annotations", "field.cattle.io/publicEndpoints"}, + {"spec", "template", "spec", "containers", "image"}, }, gvkKey("catalog.cattle.io", "v1", "App"): { {"spec", "chart", "metadata", "name"}, @@ -124,6 +134,8 @@ var ( }, gvkKey("cluster.x-k8s.io", "v1beta1", "Machine"): { {"spec", "clusterName"}}, + gvkKey("cluster.x-k8s.io", "v1beta1", "MachineDeployment"): { + {"spec", "clusterName"}}, gvkKey("management.cattle.io", "v3", "Cluster"): { {"metadata", "labels", "provider.cattle.io"}, {"spec", "internal"}, @@ -137,6 +149,8 @@ var ( {"spec", "clusterName"}}, gvkKey("management.cattle.io", "v3", "NodeTemplate"): { {"spec", "clusterName"}}, + gvkKey("management.cattle.io", "v3", "Project"): { + {"spec", "clusterName"}}, gvkKey("networking.k8s.io", "v1", "Ingress"): { {"spec", "rules", "host"}, {"spec", "ingressClassName"}, @@ -146,6 +160,10 @@ var ( {"status", "clusterName"}, {"status", "provider"}, }, + gvkKey("rke.cattle.io", "v1", "ETCDSnapshot"): { + {"snapshotFile", "createdAt"}, + {"spec", "clusterName"}, + }, gvkKey("storage.k8s.io", "v1", "StorageClass"): { {"provisioner"}, {"metadata", "annotations", "storageclass.kubernetes.io/is-default-class"},