Export pod inspect functions for external consumption#2308
Conversation
Export the following unexported functions in pkg/cli/admin/inspect/pod.go so they can be imported by external Go packages without vendoring the full oc binary (which pulls in CVE-affected transitive dependencies): - gatherPodData → GatherPodData - gatherContainerInfo → GatherContainerInfo - gatherContainerAllLogs → GatherContainerAllLogs - gatherContainerLogs → GatherContainerLogs - gatherContainerRotatedLogFiles → GatherContainerRotatedLogFiles - filterContainerLogsErrors → FilterContainerLogsErrors - rotatedLogFilename → RotatedLogFilename All internal callers in pod.go and namespace.go are updated to use the new exported names. Godoc comments are added to each exported function per project conventions. No behavioral changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: kaovilai The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
WalkthroughSeveral unexported helper methods and functions in pkg/cli/admin/inspect/pod.go for gathering pod and container data/logs are renamed to exported equivalents, and the caller in namespace.go is updated to use the new exported method name. ChangesExport Inspect Pod/Container Helpers
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 15✅ Passed checks (15 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
/retest |
|
Exporting those functions means that we should provide backwards compatibility guarantees for anyone using them. We wouldn't not want to expose those functions, since they can likely change. However, I understand the inconvenience here. If you only depend on these functions, why don't you directly copy to your repository and fully drop the dependency from oc?. That would be easier. |
|
/retest |
We don't require backwards compatibility guarantees. If we do we'd use older go.mod |
|
/retest |
We want future compatibility updates to flow in without recopying in the future. If things break for older version then we pin for release branch for older releases. |
I was referring to the backwards compatibility guarantees of oc. |
|
@kaovilai: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
I understand the compatibility concern, but I don’t think this PR materially changes These functions already exist and are already part of the inspect implementation. The PR does not introduce new behavior, new flags, new output, or a new CLI contract; it only allows downstream Go consumers to call the same implementation instead of copying it. If these helpers need to change in the future, downstreams can pin to an older Copying the code would solve the immediate compile problem, but it creates a worse long-term maintenance model: downstream copies drift from upstream, miss fixes, and need manual re-syncing. Exporting the helpers keeps the implementation centralized and lets future inspect fixes flow naturally. If the exported names are the issue, I’m happy to add wording to the GoDoc making the intended support level clear. But as-is, this PR has essentially no downside for current |
|
There is a difference between locking behavior and locking package API, but I guess the additional burden is not big. |
Export the following unexported functions in pkg/cli/admin/inspect/pod.go so they can be imported by external Go packages without vendoring the full oc binary (which pulls in CVE-affected transitive dependencies):
All internal callers in pod.go and namespace.go are updated to use the new exported names. Godoc comments are added to each exported function per project conventions. No behavioral changes.
Summary by CodeRabbit