-
Notifications
You must be signed in to change notification settings - Fork 474
cmd/tetra: add explain command for standalone CRD documentation #4362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for tetragon ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
9d341ec to
b228245
Compare
df12a48 to
a67900a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a suggestion to improve the implementation.
|
Can you squash the commits into a single one? |
2c0a8ad to
d13186a
Compare
b49b93d to
7e19e98
Compare
cmd/tetra/explain/explain.go
Outdated
| } | ||
|
|
||
| // Handle array notation like field[] or field[0] | ||
| if strings.Contains(part, "[") && strings.Contains(part, "]") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question about this one: what are we supporting by doing so (considering we are leaving out the string between "[" and "]")?
Should we expand this a little bit to support eg:
./tetra explain tracingpolicy[spec][uprobes]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is a limitation and needs to be expanded. It requires a separate function to handle it. I will implement this in the next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented!
./tetra explain tracingpolicy[spec][uprobes]
KIND: TracingPolicy
VERSION: v1alpha1
FIELD: uprobes <[]object>
DESCRIPTION:
A list of uprobe specs.
FIELDS:
addrs <[]integer>
List of the traced addresses
args <[]object>
A list of function arguments to include in the trace output.
btfPath <string>
path for a BTF file for the traced binary
data <[]object>
A list of data to include in the trace output.
message <string>
A short message of 256 characters max that will be included
in the event output to inform users what is going on.
offsets <[]integer>
List of the traced offsets
path <string> -required-
Name of the traced binary
refCtrOffsets <[]integer>
List of the traced ref_ctr_offsets
return <boolean>
Indicates whether to collect return value of the traced function.
returnArg <object>
A return argument to include in the trace output.
selectors <[]object>
Selectors to apply before producing trace output
symbols <[]string>
List of the traced symbols
tags <[]string>
Tags to categorize the event, will be include in the event output.
Maximum of 16 Tags are supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
|
This is quite ready; left some comments :) |
711f048 to
878f1fa
Compare
878f1fa to
fe349d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wdyt if we drop supportedResources in favor of using client.AllCRDs?
I got a patch that should work fine. At that point we basically have no custom code in explain.go :)
explain.patch
We also use aliases (ie: short names) from the crds.
Example:
$ ./tetra explain --list
NAME SHORTNAMES
TracingPolicy tgtp
TracingPolicyNamespaced tgtpn
PodInfo tgpi
And
$ ./tetra explain tracingpolicies
Error: unsupported resource: tracingpolicies (supported resources: PodInfo, TracingPolicy, TracingPolicyNamespaced, tgpi, tgtp, tgtpn)
And:
$ ./tetra explain tracingpolicy
KIND: TracingPolicy
VERSION: v1alpha1
DESCRIPTION:
FIELDS:
apiVersion <string>
APIVersion defines the versioned schema of this representation of an object.
kind <string>
Kind is a string value representing the REST resource this object represents.
metadata <object> -required-
spec <object> -required-
Tracing policy specification.
|
Got it — using |
Users need kubectl and cluster access to explore Tetragon CRD schemas. Add tetra explain command to provide kubectl-like functionality locally: - Explore TracingPolicy, TracingPolicyNamespaced, PodInfo schemas - Field navigation with dot notation (e.g., tracingpolicy.spec.kprobes) - JSON/YAML output formats and recursive field listing - Works without Kubernetes cluster dependency Fixes cilium#2073 Signed-off-by: Aritra Dey <[email protected]>
fe349d0 to
2ab78e4
Compare
|
Thanks! And sorry for the scattered review :) I am going through it piece by piece! |
FedeDP
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you very much!
Fixes #2073
Description
See commit.
Changelog