mirror of
https://github.com/rancher/steve.git
synced 2025-09-03 00:15:27 +00:00
Added more fields - part 6. (#485)
* Added more fields - part 6. * Tweaks needed to get 'batch.cronjobs' working * Add a clarifying comment on pulling values out of an array. * Use the correct capitalization for the etcd-snapshot kind.
This commit is contained in:
@@ -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
|
||||
|
@@ -898,6 +898,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{})
|
||||
|
@@ -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)
|
||||
|
@@ -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"},
|
||||
|
Reference in New Issue
Block a user