Conversation
Signed-off-by: sahil.kamble@ayanworks.com <sahil.kamble@ayanworks.com>
Signed-off-by: sahil.kamble@ayanworks.com <sahil.kamble@ayanworks.com>
WalkthroughTwo shell scripts in the agent-provisioning module were changed to improve token extraction from container logs: primary extraction now uses case-insensitive sed matching, and a fallback awk-based extraction runs if the primary result is empty. Changes
Sequence Diagram(s)sequenceDiagram
participant Container as Container logs
participant Script as Start script
participant Sed as sed (case-insensitive)
participant Awk as awk fallback
participant Output as Token output
Container->>Script: provide logs
Script->>Sed: run printf | sed -En (case-insensitive KEY:)
Sed-->>Script: token (may be empty)
alt token non-empty
Script->>Output: print token
else token empty
Script->>Awk: scan logs for API[ _]?KEY pattern, extract last field
Awk-->>Script: token (fallback)
Script->>Output: print token
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/agent-provisioning/AFJ/scripts/start_agent.sh (1)
246-247: Consider using[[for conditional expressions in bash.In bash scripts,
[[is preferred over[for conditional tests as it's safer and supports additional operators. The SonarCloud analysis flagged this pattern.Apply this diff:
- [ -z "$token" ] && \ - token=$(printf "%s" "$container_logs" | awk '/[Aa][Pp][Ii][ -]*[Kk][Ee][Yy]/ {print $NF; exit}') + [[ -z "$token" ]] && \ + token=$(printf "%s" "$container_logs" | awk '/[Aa][Pp][Ii][ -]*[Kk][Ee][Yy]/ {print $NF; exit}')Note: This refactor is specific to
start_agent.sh(which uses#!/bin/bash). The corresponding filedocker_start_agent.shuses#!/bin/sh(POSIX shell) where[is the standard and[[is not available.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/agent-provisioning/AFJ/scripts/docker_start_agent.sh(1 hunks)apps/agent-provisioning/AFJ/scripts/start_agent.sh(1 hunks)
🧰 Additional context used
🪛 GitHub Check: SonarCloud Code Analysis
apps/agent-provisioning/AFJ/scripts/start_agent.sh
[failure] 246-246: Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.
Signed-off-by: sahil.kamble@ayanworks.com <sahil.kamble@ayanworks.com>
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/agent-provisioning/AFJ/scripts/start_agent.sh (1)
246-246: Minor: Consider using[[for safer conditional testing.SonarCloud suggests using
[[instead of[for conditional tests, which is a bash best practice. While the current code works correctly,[[provides better robustness and clarity:- if [ -z "$token" ]; then + if [[ -z "$token" ]]; then
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/agent-provisioning/AFJ/scripts/docker_start_agent.sh(1 hunks)apps/agent-provisioning/AFJ/scripts/start_agent.sh(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/agent-provisioning/AFJ/scripts/docker_start_agent.sh
🧰 Additional context used
🪛 GitHub Check: SonarCloud Code Analysis
apps/agent-provisioning/AFJ/scripts/start_agent.sh
[failure] 246-246: Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.
🔇 Additional comments (2)
apps/agent-provisioning/AFJ/scripts/start_agent.sh (2)
242-243: Fixed: sed regex now uses correct unescaped parentheses for extended mode.The critical issue from the previous review has been successfully resolved. The capture group now correctly uses
([^ ]*)instead of the previously incorrect\([^ ]*\)when running with the-E(extended regex) flag.
245-249: Fallback extraction strategy is sound.The awk-based fallback appropriately handles cases where BSD/macOS sed may fail. The approach of searching for case-insensitive "API KEY" or "API-KEY" patterns and extracting the last field is reasonable for multi-architecture compatibility.



What ?
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.