Add automatic PagerDuty environment variables to ocm-container#137
Merged
Add automatic PagerDuty environment variables to ocm-container#137
Conversation
This change automatically passes PagerDuty incident and alert information as environment variables when launching ocm-container via the login feature. Changes: - Add PAGERDUTY_INCIDENT environment variable containing the incident ID - Add ALERT_DETAILS environment variable with base64-encoded JSON of incident and alert data - Update login() function to serialize incident/alert data and pass via -e flags to ocm-container - Add unit tests for alertData serialization and base64 encoding - Update README with documentation on the new automatic environment variables This allows users to access full incident and alert details from within ocm-container without manual configuration, enabling better context awareness during on-call operations. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit fixes a critical bug where ocm-container's environment variable parser was rejecting the ALERT_DETAILS variable due to base64 padding characters (=). Changes: - Use base64.RawURLEncoding instead of StdEncoding to eliminate padding - Add incident notes to the alertData structure passed to ocm-container - Update login() function to accept and include notes parameter - Add comprehensive tests for all combinations of incident/alerts/notes - Update README to document notes inclusion and URL encoding The ocm-container env var parser splits on '=' and fails when there are more than 2 parts. Standard base64 padding uses '=' characters: "Length of env string split > 2 for env: ALERT_DETAILS=..." Using RawURLEncoding (RFC 4648) eliminates padding while maintaining full data integrity. The encoded data can still be decoded with standard base64 -d inside ocm-container. ALERT_DETAILS now contains: - Full incident object - All associated alerts - All incident notes Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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
This PR automatically passes PagerDuty incident and alert information as environment variables when launching ocm-container via the login feature (pressing
lon an incident).Changes
New environment variables automatically set in ocm-container:
PAGERDUTY_INCIDENT- Contains the PagerDuty incident IDALERT_DETAILS- Base64 URL-encoded JSON containing the full incident object, all associated alerts, and incident notesImplementation:
login()function inpkg/tui/commands.goto:-eflags to pass environment variables to ocm-containerpkg/tui/tui.goto pass incident, alert, and notes dataalertDatastruct to encapsulate the data being passedBug Fix:
base64.RawURLEncodinginstead ofbase64.StdEncoding=characters which broke ocm-container's parser (splits on=and expects max 2 parts)Testing:
pkg/tui/commands_test.goto verify:Documentation:
Benefits
Example Usage
Inside ocm-container after login:
Technical Details
The
ALERT_DETAILSJSON structure:{ "incident": { /* full PagerDuty incident object */ }, "alerts": [ /* array of incident alerts */ ], "notes": [ /* array of incident notes */ ] }Command structure generated:
The
-eflags are correctly positioned after the terminal separator (--) and theocm-containercommand, but before ocm-container's arguments.Test Plan
=padding characters in base64 output (verified in tests)🤖 Generated with Claude Code