Skip to content

Conversation

@aantn
Copy link
Collaborator

@aantn aantn commented Jan 30, 2026

Adds utility to detect whether user is running via:

  • CLI (command line)
  • Helm chart (Robusta)
  • Helm chart (Holmes standalone)

This enables showing deployment-specific guidance for environment
variable configuration and other setup instructions.

Key features:

  • DeploymentContext class with method and chart_type detection
  • get_env_var_guidance() helper for generating targeted help messages
  • Detection based on PLAYBOOKS_CONFIG_FILE_PATH, INSTALLATION_NAMESPACE,
    RELEASE_NAME, HOLMES_ENABLED, and HOLMES_STANDALONE env vars
  • Different guidance for CLI users vs Robusta Helm vs Holmes Helm

https://claude.ai/code/session_01DuWGiUa4DB1FBPG5mLmqhD

Adds utility to detect whether user is running via:
- CLI (command line)
- Helm chart (Robusta)
- Helm chart (Holmes standalone)

This enables showing deployment-specific guidance for environment
variable configuration and other setup instructions.

Key features:
- DeploymentContext class with method and chart_type detection
- get_env_var_guidance() helper for generating targeted help messages
- Detection based on PLAYBOOKS_CONFIG_FILE_PATH, INSTALLATION_NAMESPACE,
  RELEASE_NAME, HOLMES_ENABLED, and HOLMES_STANDALONE env vars
- Different guidance for CLI users vs Robusta Helm vs Holmes Helm

https://claude.ai/code/session_01DuWGiUa4DB1FBPG5mLmqhD
@github-actions
Copy link

github-actions bot commented Jan 30, 2026

Docker image ready for 1a5820c (built in 3m 48s)

⚠️ Warning: does not support ARM (ARM images are built on release only - not on every PR)

Use this tag to pull the image for testing.

📋 Copy commands

⚠️ Temporary images are deleted after 30 days. Copy to a permanent registry before using them:

gcloud auth configure-docker us-central1-docker.pkg.dev
docker pull us-central1-docker.pkg.dev/robusta-development/temporary-builds/robusta-runner:1a5820c
docker tag us-central1-docker.pkg.dev/robusta-development/temporary-builds/robusta-runner:1a5820c me-west1-docker.pkg.dev/robusta-development/development/robusta-runner-dev:1a5820c
docker push me-west1-docker.pkg.dev/robusta-development/development/robusta-runner-dev:1a5820c

Patch Helm values in one line:

helm upgrade --install robusta robusta/robusta \
  --reuse-values \
  --set runner.image=me-west1-docker.pkg.dev/robusta-development/development/robusta-runner-dev:1a5820c

@coderabbitai
Copy link

coderabbitai bot commented Jan 30, 2026

Walkthrough

A new deployment context detection module is introduced that identifies the deployment method (CLI vs Helm) and chart type (Robusta vs Holmes) from environment variables, along with utility functions to generate deployment-specific guidance for environment variable configuration.

Changes

Cohort / File(s) Summary
Deployment Context Detection
src/robusta/core/model/deployment_context.py
New module with DeploymentMethod and ChartType enums, DeploymentContext dataclass with helper properties (is_cli, is_helm, is_robusta_chart, is_holmes_chart), detect_deployment_context() function for inferring context from environment variables, and get_env_var_guidance() with multiple private helpers for generating deployment-specific guidance messages.
Deployment Context Tests
tests/test_deployment_context.py
Comprehensive test suite validating DeploymentContext properties, detect_deployment_context() behavior across CLI/Helm/Holmes scenarios with varying environment variables, and get_env_var_guidance() output for each deployment context including auto-detection and unknown chart handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.93% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add deployment context detection for targeted user guidance' directly and clearly summarizes the main change: introducing deployment context detection to provide targeted guidance.
Description check ✅ Passed The description is directly related to the changeset, providing clear details about detecting deployment contexts (CLI, Helm-Robusta, Helm-Holmes) and generating targeted user guidance messages.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/slack-detect-deployment-context-S6F6l

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@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: 1

🤖 Fix all issues with AI agents
In `@tests/test_deployment_context.py`:
- Line 6: Remove the unused import of pytest from the top of the file: delete
the line importing pytest (the lone "import pytest") in
tests/test_deployment_context.py since the file only uses built-in assert
statements and does not reference pytest anywhere else.
🧹 Nitpick comments (2)
src/robusta/core/model/deployment_context.py (1)

27-41: Consider using @dataclass decorator.

The class could benefit from the @dataclass decorator to reduce boilerplate and gain automatic __repr__, __eq__, and other dunder methods.

♻️ Proposed refactor using dataclass
+from dataclasses import dataclass
+
+
+@dataclass
 class DeploymentContext:
     """Detected deployment context information."""
-
-    def __init__(
-        self,
-        method: DeploymentMethod,
-        chart_type: ChartType,
-        release_name: Optional[str] = None,
-        namespace: Optional[str] = None,
-    ):
-        self.method = method
-        self.chart_type = chart_type
-        self.release_name = release_name
-        self.namespace = namespace
+    method: DeploymentMethod
+    chart_type: ChartType
+    release_name: Optional[str] = None
+    namespace: Optional[str] = None
tests/test_deployment_context.py (1)

88-102: Consider asserting chart_type in these tests.

These tests verify that method == DeploymentMethod.HELM but don't assert the chart_type. Based on the implementation logic, both cases should result in ChartType.ROBUSTA (since holmes_enabled is not set).

Adding these assertions would make the tests more comprehensive and catch potential regressions in chart type detection.

💚 Proposed enhancement
     def test_detects_helm_with_non_default_namespace(self):
         env = {
             "INSTALLATION_NAMESPACE": "custom-namespace",
         }
         with mock.patch.dict(os.environ, env, clear=True):
             context = detect_deployment_context()
             assert context.method == DeploymentMethod.HELM
+            assert context.chart_type == ChartType.ROBUSTA

     def test_detects_helm_with_non_default_release_name(self):
         env = {
             "RELEASE_NAME": "custom-release",
         }
         with mock.patch.dict(os.environ, env, clear=True):
             context = detect_deployment_context()
             assert context.method == DeploymentMethod.HELM
+            assert context.chart_type == ChartType.ROBUSTA

import os
from unittest import mock

import pytest
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused pytest import.

The pytest module is imported but not used in this file. The tests use plain assert statements which don't require an explicit import of pytest.

🧹 Proposed fix
-import pytest
-
 from robusta.core.model.deployment_context import (
📝 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
import pytest
from robusta.core.model.deployment_context import (
🧰 Tools
🪛 Flake8 (7.3.0)

[error] 6-6: 'pytest' imported but unused

(F401)

🤖 Prompt for AI Agents
In `@tests/test_deployment_context.py` at line 6, Remove the unused import of
pytest from the top of the file: delete the line importing pytest (the lone
"import pytest") in tests/test_deployment_context.py since the file only uses
built-in assert statements and does not reference pytest anywhere else.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants