-
Notifications
You must be signed in to change notification settings - Fork 7
[AGENT-258] use util function from envutil #364
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
WalkthroughThe changes refactor environment variable secret detection by removing local regular expressions and helper functions from Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant EnvCmd (cmd/env.go)
participant EnvUtil (internal/envutil/envutil.go)
User->>EnvCmd: Load env variables
EnvCmd->>EnvUtil: LooksLikeSecret(key)
EnvUtil-->>EnvCmd: true/false
EnvCmd->>EnvUtil: DescriptionLookingLikeASecret(description)
EnvUtil-->>EnvCmd: true/false
EnvCmd-->>User: Mark env as secret/plain
Assessment against linked issues
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
✨ Finishing Touches
🪧 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: 2
🧹 Nitpick comments (2)
internal/envutil/envutil_test.go (2)
37-41: Add edge case testing for regex robustness.Consider adding test cases for edge cases to ensure the regex patterns handle various scenarios correctly:
{"some_random_var", false}, + {"", false}, // empty string + {"SECRET", true}, // single word + {"MY_SECRET_CONFIG", true}, // secret in middle + {"CONFIG_SECRET_TEMP", true}, // secret in middle + {"NOT_A_SECRET_VAR", false}, // contains "SECRET" but shouldn't match }
1-5: Consider adding test for regex compilation and nil safety.Add a basic test to ensure the regex patterns are properly compiled and accessible:
import ( "testing" ) +func TestRegexCompilation(t *testing.T) { + if LooksLikeSecret == nil { + t.Error("LooksLikeSecret regex is nil") + } + if IsAgentuityEnv == nil { + t.Error("IsAgentuityEnv regex is nil") + } +} + func TestLooksLikeSecret(t *testing.T) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
internal/envutil/envutil.go(3 hunks)internal/envutil/envutil_test.go(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- internal/envutil/envutil.go
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/envutil/envutil_test.go (1)
internal/envutil/envutil.go (2)
LooksLikeSecret(27-27)IsAgentuityEnv(28-28)
🔇 Additional comments (1)
internal/envutil/envutil_test.go (1)
44-73: LGTM! Well-structured test for Agentuity environment variable detection.The test cases comprehensively cover various positions of "AGENTUITY" in environment variable names and include both case variations. The table-driven test approach follows Go best practices.

Summary by CodeRabbit
Refactor
Style
Tests