Skip to content

Support for split WEBHOOK_SERVER_DATA_DIR and WEBHOOK_SERVER_CONFIG_DIR#731

Closed
myakove wants to merge 1 commit intomainfrom
split-data-dir-and-config-dir
Closed

Support for split WEBHOOK_SERVER_DATA_DIR and WEBHOOK_SERVER_CONFIG_DIR#731
myakove wants to merge 1 commit intomainfrom
split-data-dir-and-config-dir

Conversation

@myakove
Copy link
Copy Markdown
Collaborator

@myakove myakove commented Apr 25, 2025

If user wants to have the config dir seperated from the data dir he can pass the above os env to set it.

If WEBHOOK_SERVER_CONFIG_DIR not passed, WEBHOOK_SERVER_DATA_DIR is used.

Summary by CodeRabbit

  • New Features
    • Added support for specifying a separate configuration directory via a new environment variable.
  • Documentation
    • Updated documentation to reflect changes in container image repository and clarify usage of new and existing environment variables.
  • Bug Fixes
    • Improved error handling during file operations to prevent crashes.
  • Refactor
    • Updated internal logic to use the new configuration directory for config and key files, and clarified log file path resolution.

If user wants to have the config dir seperated from the data dir he can
pass the above os env to set it.

If WEBHOOK_SERVER_CONFIG_DIR not passed, WEBHOOK_SERVER_DATA_DIR is
used.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 25, 2025

Walkthrough

This change introduces support for specifying a separate configuration directory for the GitHub webhook server using the WEBHOOK_SERVER_CONFIG_DIR environment variable, in addition to the existing WEBHOOK_SERVER_DATA_DIR. The codebase is updated to resolve configuration file and private key locations based on this new variable, defaulting to the data directory if not set. Associated documentation and Docker Compose examples are updated to reflect these changes. Minor internal logic adjustments are made to ensure correct file path resolution throughout the application.

Changes

Files/Paths Change Summary
README.md, docker-compose-example.yaml Updated documentation and example configuration to introduce and explain WEBHOOK_SERVER_CONFIG_DIR and clarify usage of WEBHOOK_SERVER_DATA_DIR. Changed container image references to ghcr.io/myk-org/github-webhook-server:latest.
webhook_server_container/libs/config.py Modified the Config class to support WEBHOOK_SERVER_CONFIG_DIR for config file resolution, defaulting to data dir if unset.
webhook_server_container/utils/github_repository_settings.py Changed private key file path resolution to use config_dir instead of data_dir.
webhook_server_container/utils/helpers.py Updated log file path construction to join the log file name with data_dir.
webhook_server_container/libs/github_api.py Added error handling for file write operations in _get_random_color to prevent exceptions from propagating.

Possibly related issues

Possibly related PRs

Suggested labels

size/S, verified, branch-main

Suggested reviewers

  • rnetser
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@myakove-bot
Copy link
Copy Markdown
Collaborator

Report bugs in Issues

The following are automatically added:

  • Add reviewers from OWNER file (in the root of the repository) under reviewers section.
  • Set PR size label.
  • New issue is created for the PR. (Closed when PR is merged/closed)
  • Run pre-commit if .pre-commit-config.yaml exists in the repo.

Available user actions:

  • To mark PR as WIP comment /wip to the PR, To remove it from the PR comment /wip cancel to the PR.
  • To block merging of PR comment /hold, To un-block merging of PR comment /hold cancel.
  • To mark PR as verified comment /verified to the PR, to un-verify comment /verified cancel to the PR.
    verified label removed on each new commit push.
  • To cherry pick a merged PR comment /cherry-pick <target branch to cherry-pick to> in the PR.
    • Multiple target branches can be cherry-picked, separated by spaces. (/cherry-pick branch1 branch2)
    • Cherry-pick will be started when PR is merged
  • To build and push container image command /build-and-push-container in the PR (tag will be the PR number).
    • You can add extra args to the Podman build command
      • Example: /build-and-push-container --build-arg OPENSHIFT_PYTHON_WRAPPER_COMMIT=<commit_hash>
  • To add a label by comment use /<label name>, to remove, use /<label name> cancel
  • To assign reviewers based on OWNERS file use /assign-reviewers
  • To check if PR can be merged use /check-can-merge
  • to assign reviewer to PR use /assign-reviewer @<reviewer>

PR will be approved when the following conditions are met:

  • /approve from one of the approvers.
  • Minimum number of required /lgtm (2) is met.
Approvers and Reviewers
  • Approvers:

    • myakove
    • rnetser
  • Reviewers:

    • myakove
    • rnetser
Supported /retest check runs
  • /retest tox: Retest tox
  • /retest build-container: Retest build-container
  • /retest python-module-install: Retest python-module-install
  • /retest pre-commit: Retest pre-commit
  • /retest all: Retest all
Supported labels
  • hold
  • verified
  • wip
  • lgtm
  • approve

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
README.md (1)

83-86: Line length exceeds recommended limit

The description for WEBHOOK_SERVER_CONFIG_DIR exceeds the recommended line length of 120 characters. Consider reformatting for better readability.

-  - `WEBHOOK_SERVER_CONFIG_DIR`: Path to the config directory where the `config.yaml` and `*-private-key.pem` (Github APP cert) file is located.
+  - `WEBHOOK_SERVER_CONFIG_DIR`: Path to the config directory where the `config.yaml` and 
+    `*-private-key.pem` (Github APP cert) files are located.

Also, I recommend changing "file is located" to "files are located" since there are multiple files mentioned.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~83-~83: Loose punctuation mark.
Context: ...here the . - WEBHOOK_SERVER_CONFIG_DIR: Path to the config directory where the ...

(UNLIKELY_OPENING_PUNCTUATION)

🪛 markdownlint-cli2 (0.17.2)

83-83: Line length
Expected: 120; Actual: 142

(MD013, line-length)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7ee036 and aaec83c.

📒 Files selected for processing (6)
  • README.md (3 hunks)
  • docker-compose-example.yaml (1 hunks)
  • webhook_server_container/libs/config.py (1 hunks)
  • webhook_server_container/libs/github_api.py (1 hunks)
  • webhook_server_container/utils/github_repository_settings.py (1 hunks)
  • webhook_server_container/utils/helpers.py (2 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[uncategorized] ~82-~82: Loose punctuation mark.
Context: ...o be stored. - WEBHOOK_SERVER_DATA_DIR: Path to the data directory where the . ...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~83-~83: Loose punctuation mark.
Context: ...here the . - WEBHOOK_SERVER_CONFIG_DIR: Path to the config directory where the ...

(UNLIKELY_OPENING_PUNCTUATION)

🪛 markdownlint-cli2 (0.17.2)
README.md

83-83: Line length
Expected: 120; Actual: 142

(MD013, line-length)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: tox
  • GitHub Check: python-module-install
  • GitHub Check: pre-commit
  • GitHub Check: build-container
🔇 Additional comments (6)
webhook_server_container/utils/github_repository_settings.py (1)

393-393: Using config_dir for the private key location aligns with the PR objectives.

This change correctly uses the new config_dir property to locate the private key file, which is appropriately considered configuration rather than runtime data. This change supports the goal of separating configuration from data storage.

webhook_server_container/libs/github_api.py (1)

262-266: Good enhancement to error handling for file operations.

The added try-except block improves robustness by gracefully handling file write errors instead of allowing exceptions to propagate. This ensures the application continues functioning even if it can't write to the color file.

webhook_server_container/utils/helpers.py (1)

4-4: Correctly updated log file path resolution.

Adding the os import and constructing proper file paths for logs ensures they are correctly stored in the data directory. This change properly maintains the separation between configuration and data files.

Also applies to: 25-26

README.md (1)

45-45: Repository URL update is consistent

The change from the old repository URL to ghcr.io/myk-org/github-webhook-server:latest is consistently applied in both locations.

Also applies to: 196-196

webhook_server_container/libs/config.py (2)

13-14: Proper implementation of config directory separation

Good implementation of the new WEBHOOK_SERVER_CONFIG_DIR environment variable that defaults to the data directory when not set. This matches the behavior described in the documentation and provides a clean way to separate configuration files from data files.


1-72:

Details

✅ Verification successful

Verify other code dependencies

Make sure other parts of the codebase that might rely on the location of the config file have been updated to use config_dir instead of data_dir where appropriate.


🏁 Script executed:

#!/bin/bash
# Find any references to config.yaml that might need updating
echo "Finding references to config file path:"
rg "config\.yaml|config_path" --type py

# Check if there are any references to private key files that need to be updated
echo "Finding references to private key files:"
rg "private-key\.pem" --type py

Length of output: 1759


No outstanding config path dependencies
All references to config.yaml and webhook-server.private-key.pem already use config_dir. No other parts of the codebase rely on the old data_dir for config paths.

  • webhook_server_container/utils/github_repository_settings.py correctly uses config_.config_dir for the private key.
  • Tests patch Config.config_path and aren’t affected.

Comment on lines +13 to +14
- WEBHOOK_SERVER_CONFIG_DIR: /path/to/config/dir # Default to WEBHOOK_SERVER_DATA_DIR if not set
- WEBHOOK_SERVER_DATA_DIR: /path/to/data/dir
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix environment variable syntax in Docker Compose file.

Docker Compose environment variables should use = for assignment, not :.

Apply this correction:

-      - WEBHOOK_SERVER_CONFIG_DIR: /path/to/config/dir # Default to WEBHOOK_SERVER_DATA_DIR if not set
-      - WEBHOOK_SERVER_DATA_DIR: /path/to/data/dir
+      - WEBHOOK_SERVER_CONFIG_DIR=/path/to/config/dir # Default to WEBHOOK_SERVER_DATA_DIR if not set
+      - WEBHOOK_SERVER_DATA_DIR=/path/to/data/dir
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- WEBHOOK_SERVER_CONFIG_DIR: /path/to/config/dir # Default to WEBHOOK_SERVER_DATA_DIR if not set
- WEBHOOK_SERVER_DATA_DIR: /path/to/data/dir
- WEBHOOK_SERVER_CONFIG_DIR=/path/to/config/dir # Default to WEBHOOK_SERVER_DATA_DIR if not set
- WEBHOOK_SERVER_DATA_DIR=/path/to/data/dir

Comment thread README.md

- `WEBHOOK_SERVER_LOG_FILE`: Path to the log file where the server logs are to be stored.
- `WEBHOOK_SERVER_DATA_DIR`: Path to the data directory where the `config.yaml` file is located.
- `WEBHOOK_SERVER_DATA_DIR`: Path to the data directory where the .
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix incomplete description of WEBHOOK_SERVER_DATA_DIR

The description for WEBHOOK_SERVER_DATA_DIR ends abruptly with "where the ." - it should specify what the data directory contains or its purpose.

-  - `WEBHOOK_SERVER_DATA_DIR`: Path to the data directory where the .
+  - `WEBHOOK_SERVER_DATA_DIR`: Path to the data directory where the server stores its data.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- `WEBHOOK_SERVER_DATA_DIR`: Path to the data directory where the .
- `WEBHOOK_SERVER_DATA_DIR`: Path to the data directory where the server stores its data.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~82-~82: Loose punctuation mark.
Context: ...o be stored. - WEBHOOK_SERVER_DATA_DIR: Path to the data directory where the . ...

(UNLIKELY_OPENING_PUNCTUATION)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants