-
Notifications
You must be signed in to change notification settings - Fork 92
Header generation refactoring #2436
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
Conversation
Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber <[email protected]>
…and there's no more duplication possible Signed-off-by: Amber <[email protected]>
…k methods Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber <[email protected]>
…mended that needs to be Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber <[email protected]>
📅 Suggested merge-by date: 3/5/2025 |
Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2436 +/- ##
==========================================
- Coverage 91.51% 91.45% -0.06%
==========================================
Files 641 642 +1
Lines 18425 18430 +5
Branches 4002 3990 -12
==========================================
- Hits 16861 16855 -6
- Misses 1562 1573 +11
Partials 2 2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Amber Torrise <[email protected]>
Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber <[email protected]>
momentarily moving this to draft status for a few hours to make a significant change based on sonar cloud's good suggestion |
Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber <[email protected]>
Signed-off-by: Amber Torrise <[email protected]>
|
private static headerMap = new Map<string, <T>(options: T, context?: ZosFilesContext) => IHeaderContent | IHeaderContent[]>(); | ||
static initializeHeaderMap() { | ||
this.headerMap.set("binary", (options) => (options as any).binary === true ? ZosmfHeaders.X_IBM_BINARY : undefined); | ||
this.headerMap.set("record", (options) => (options as any).binary !== true ? ZosmfHeaders.X_IBM_RECORD : undefined); |
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.
The system tests are failing because many data sets are being uploaded with a record header. This line seems to be setting the record header if the data set is not being transferred in binary mode. I believe that instead it should only be setting the record header if the record option is true.
closing this PR and opening a new PR without the enhancement that only provides a fix for the RTO header |
This refactoring effort centralizes and standardizes header generation across the Files SDK and CLI, consolidating all header logic into a single utility class—
ZosFilesHeaders
—and replacing duplicate header creation code across multiple methods.The new implementation leverages a unified
headerMap
to manage header generation functions, ensuring that headers like responseTimeout, etag, and others are applied consistently in all ZosFiles REST calls.Header Generation now:
options
dataLength
parameter to add a Content-Length header when needed.ZosFilesContext
enum that guides which Content-Type headers are applied for certain methods. These enum values include:USS_MULTIPLE
ZFS
&LIST
UPLOAD
Content-Type: application/octet-stream
for binary data.DOWNLOAD
Content-Type
header.Because of this centralization, organization, and newly-provided, clear header expectations, any future header changes or additions require modifications in only one location. Creating headers can now be done with a single function call without much thought required in future development of the methods within ZosFiles SDK.