kubernetes / apiserver

Library for writing a Kubernetes-style API server.
Apache License 2.0
654 stars 406 forks source link

no json naming on audit.Event object #64

Closed LiorAlafiArmo closed 3 years ago

LiorAlafiArmo commented 3 years ago

Hi, from k8s I've requested audit events and got an object

{ "kind": "Event", "apiVersion": "audit.k8s.io/v1", "level": "Metadata", "auditID": "1847e1e1-d66b-4661-b458-4dc553cd8539", "stage": "ResponseComplete", "requestURI": "/apis/storage.k8s.io/v1?timeout=32s", "verb": "get", "user": { "username": "system:serviceaccount:kube-system:generic-garbage-collector", "uid": "83093a4c-3f5f-433e-8fd4-4a2cc23eead8", "groups": [ "system:serviceaccounts", "system:serviceaccounts:kube-system", "system:authenticated" ] }, "sourceIPs": [ "192.168.49.2" ], "userAgent": "kube-controller-manager/v1.20.0 (linux/amd64) kubernetes/af46c47/system:serviceaccount:kube-system:generic-garbage-collector", "responseStatus": { "metadata": {}, "code": 200 }, "requestReceivedTimestamp": "2021-02-18T08:28:43.237861Z", "stageTimestamp": "2021-02-18T08:28:43.238551Z", "annotations": { "authentication.k8s.io/legacy-token": "system:serviceaccount:kube-system:generic-garbage-collector", "authorization.k8s.io/decision": "allow", "authorization.k8s.io/reason": "RBAC: allowed by ClusterRoleBinding \"system:discovery\" of ClusterRole \"system:discovery\" to Group \"system:authenticated\"" } }

yet when I marshal and unmarshal it i get the fields in PascalCase instead of camelCase I saw that audit.Event (/pkg/apis/audit/types.go) has no json names

this creates anomality between data received from k8s and data received from golang package.

{ "kind": "Event", "apiVersion": "audit.k8s.io/v1", "Level": "Metadata", "AuditID": "1847e1e1-d66b-4661-b458-4dc553cd8539", "Stage": "ResponseComplete", "RequestURI": "/apis/storage.k8s.io/v1?timeout=32s", "Verb": "get", "User": { "username": "system:serviceaccount:kube-system:generic-garbage-collector", "uid": "83093a4c-3f5f-433e-8fd4-4a2cc23eead8", "groups": [ "system:serviceaccounts", "system:serviceaccounts:kube-system", "system:authenticated" ] }, "ImpersonatedUser": null, "SourceIPs": [ "192.168.49.2" ], "UserAgent": "kube-controller-manager/v1.20.0 (linux/amd64) kubernetes/af46c47/system:serviceaccount:kube-system:generic-garbage-collector", "ObjectRef": null, "ResponseStatus": { "metadata": {}, "code": 200 }, "RequestObject": null, "ResponseObject": null, "RequestReceivedTimestamp": "2021-02-18T08:28:43.237861Z", "StageTimestamp": "2021-02-18T08:28:43.238551Z", "Annotations": { "authentication.k8s.io/legacy-token": "system:serviceaccount:kube-system:generic-garbage-collector", "authorization.k8s.io/decision": "allow", "authorization.k8s.io/reason": "RBAC: allowed by ClusterRoleBinding \"system:discovery\" of ClusterRole \"system:discovery\" to Group \"system:authenticated\"" } }

fejta-bot commented 3 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale

tech-geek29 commented 3 years ago

/assign

lavalamp commented 3 years ago

Please open an issue on the main repo and tag sig auth.

tech-geek29 commented 3 years ago

/unassign

njuptlzf commented 3 years ago

The internal version(staging/src/k8s.io/apiserver/pkg/apis/audit/types.go) is used internally by apiserver. Codec can use external version(such as staging/src/k8s.io/apiserver/pkg/apis/audit/v1/types.go)

fejta-bot commented 3 years ago

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten

k8s-triage-robot commented 3 years ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

k8s-ci-robot commented 3 years ago

@k8s-triage-robot: Closing this issue.

In response to [this](https://github.com/kubernetes/apiserver/issues/64#issuecomment-899473904): >The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. > >This bot triages issues and PRs according to the following rules: >- After 90d of inactivity, `lifecycle/stale` is applied >- After 30d of inactivity since `lifecycle/stale` was applied, `lifecycle/rotten` is applied >- After 30d of inactivity since `lifecycle/rotten` was applied, the issue is closed > >You can: >- Reopen this issue or PR with `/reopen` >- Mark this issue or PR as fresh with `/remove-lifecycle rotten` >- Offer to help out with [Issue Triage][1] > >Please send feedback to sig-contributor-experience at [kubernetes/community](https://github.com/kubernetes/community). > >/close > >[1]: https://www.kubernetes.dev/docs/guide/issue-triage/ Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.