refactor: deduplicate shared code across ocsf builders and driver crates#1526
Open
ericcurtin wants to merge 1 commit into
Open
refactor: deduplicate shared code across ocsf builders and driver crates#1526ericcurtin wants to merge 1 commit into
ericcurtin wants to merge 1 commit into
Conversation
Extract repeated patterns into shared helpers: - Add impl_builder_setters! macro to openshell-ocsf/builders that generates the identical severity(), status(), and message() setter methods present on all 7 OCSF event builders - Add SandboxContext::apply_common_fields() to consolidate the four-line build() finalization (set_status, set_message, set_device, set_container) repeated in every builder - Add driver_utils::sandbox_token_path() to centralize the XDG state path construction for sandbox JWT files used by both the Docker and Podman drivers - Add driver_utils::build_capabilities_response() to eliminate the identical GetCapabilitiesResponse struct literal repeated across the Docker, Podman, and Kubernetes compute drivers
Collaborator
|
/ok to test 9aae562 |
TaylorMutch
approved these changes
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Eliminate several categories of repeated code identified across the OCSF builder layer and compute driver crates. No behavioral changes — pure structural deduplication.
Related Issue
N/A
Changes
openshell-ocsf— OCSF builder deduplication (~90 lines removed)impl_builder_setters!macro inbuilders/mod.rsthat generates the identicalseverity(),status(), andmessage()setter methods present on all 7 OCSF event builders (two variants: with and withoutstatus)SandboxContext::apply_common_fields()to consolidate the four-line finalization pattern (set_status,set_message,set_device,set_container) repeated in every builder'sbuild()methodopenshell-core— two new shared driver utilitiesdriver_utils::sandbox_token_path(driver_subdir, namespace, sandbox_id)— centralizes the XDG state path construction for sandbox JWT token files previously duplicated between the Docker and Podman driversdriver_utils::build_capabilities_response(name, version, image, gpu)— centralizes theGetCapabilitiesResponsestruct literal repeated across the Docker, Podman, and Kubernetes compute driversopenshell-driver-docker,openshell-driver-podman,openshell-driver-kubernetescapabilities()methods now delegate to the shared helpers aboveSkipped (differences were too significant to abstract cleanly): gRPC
ComputeDriverServiceadapters (different error types and method signatures between k8s and podman), persistence store backends, test PKI helpers, provider boilerplate files.Testing
mise run pre-commitpassesChecklist