-
Notifications
You must be signed in to change notification settings - Fork 258
Add --slacktitle CLI option to be able to provide a custom title in the Slack message output #459
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
WalkthroughA new optional field, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI (main.py)
participant Config
participant Runner
User->>CLI (main.py): Run command with --slacktitle
CLI (main.py)->>Config: Pass slack_title to Config
Runner->>Config: Access slack_title
Runner->>Slack: Post message with slack_title (if set)
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
robusta_krr/core/models/config.py (1)
73-73: Add minimal validation & description forslack_titleThe field works as-is, but adding a description and trimming/ignoring blank strings prevents accidental empty Slack titles.
-slack_title: Optional[str] = pd.Field(None) +slack_title: Optional[str] = pd.Field( + default=None, + description="Custom title for the Slack message. Falls back to a default when None or empty.", +) + +@pd.validator("slack_title") +def _validate_slack_title(cls, v: Optional[str]) -> Optional[str]: + # Treat whitespace-only values as not provided + if v is not None and not v.strip(): + return None + return vrobusta_krr/core/runner.py (1)
160-165: Handle"*"namespace to generate clearer Slack titlesWhen
settings.namespaces == "*",' '.join(settings.namespaces)returns"*", which is technically fine but not very descriptive. A small refactor improves readability.-channel = settings.slack_output if settings.slack_output.startswith('#') else f"#{settings.slack_output}" -slack_title = settings.slack_title if settings.slack_title else f'Kubernetes Resource Report for {(" ".join(settings.namespaces))}' +channel = settings.slack_output if settings.slack_output.startswith('#') else f"#{settings.slack_output}" +namespaces_str = "all namespaces" if settings.namespaces == "*" else " ".join(settings.namespaces) +slack_title = settings.slack_title or f"Kubernetes Resource Report for {namespaces_str}"robusta_krr/main.py (1)
269-274: Minor UX polish for--slacktitleConsider:
- Adding a short alias (
-T) in line with other options.- Updating the help text to align with the actual default (
<namespaces>rather than<environment>).These tweaks keep the CLI consistent and self-explanatory.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
robusta_krr/core/models/config.py(1 hunks)robusta_krr/core/runner.py(1 hunks)robusta_krr/main.py(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
robusta_krr/core/runner.py (1)
robusta_krr/core/integrations/kubernetes/__init__.py (1)
namespaces(54-87)
🔇 Additional comments (1)
robusta_krr/main.py (1)
364-365: Wiring looks correctThe new CLI option is correctly forwarded into the
Config, ensuring end-to-end support.
arikalon1
left a comment
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.
nice work
Thanks for the PR @StFS
This PR adds the ability to provide a custom message in the slack output. This is useful for example if you want to include the environment name or something similar.