-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
Logs improvements part2 #957
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThis pull request introduces enhancements to version checking, logging, and error handling across multiple files in the Atmos CLI. The changes focus on improving debug logging, error message clarity, and configuration initialization, particularly around version checks and log level processing. The modifications provide more granular feedback and more informative error messages without fundamentally altering the core functionality of the affected components. Changes
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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
Documentation and Community
|
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 (1)
cmd/cmd_utils.go (1)
498-512
: Fix typo in error message while maintaining good debug logging.The added debug logging enhances observability, but there's a grammatical error in the error message.
Fix the typo in the error message:
-u.LogWarning(atmosConfig, fmt.Sprintf("Unable not load cache: %s", err)) +u.LogWarning(atmosConfig, fmt.Sprintf("Unable to load cache: %s", err))
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
cmd/cmd_utils.go
(2 hunks)cmd/root.go
(1 hunks)cmd/version.go
(3 hunks)pkg/config/utils.go
(2 hunks)
🧰 Additional context used
📓 Learnings (1)
cmd/cmd_utils.go (1)
Learnt from: Listener430
PR: cloudposse/atmos#844
File: cmd/version.go:34-44
Timestamp: 2024-12-13T15:28:13.630Z
Learning: In `cmd/version.go`, when handling the `--check` flag in the `versionCmd`, avoid using `CheckForAtmosUpdateAndPrintMessage(cliConfig)` as it updates the cache timestamp, which may not be desired in this context.
⏰ Context from checks skipped due to timeout of 90000ms (20)
- GitHub Check: [mock-macos] tests/fixtures/scenarios/complete
- GitHub Check: [mock-macos] examples/demo-vendoring
- GitHub Check: [mock-macos] examples/demo-context
- GitHub Check: [mock-macos] examples/demo-component-versions
- GitHub Check: [mock-windows] tests/fixtures/scenarios/complete
- GitHub Check: [mock-windows] examples/demo-vendoring
- GitHub Check: [mock-windows] examples/demo-context
- GitHub Check: [mock-windows] examples/demo-component-versions
- GitHub Check: [mock-windows] examples/demo-atlantis
- GitHub Check: [mock-linux] tests/fixtures/scenarios/complete
- GitHub Check: [mock-linux] examples/demo-vendoring
- GitHub Check: Acceptance Tests (macos-latest, macos)
- GitHub Check: [mock-linux] examples/demo-context
- GitHub Check: Acceptance Tests (windows-latest, windows)
- GitHub Check: Acceptance Tests (ubuntu-latest, linux)
- GitHub Check: [lint] quick-start-advanced
- GitHub Check: [localstack] demo-localstack
- GitHub Check: Docker Lint
- GitHub Check: [k3s] demo-helmfile
- GitHub Check: Summary
🔇 Additional comments (7)
cmd/version.go (3)
26-40
: Well-structured initialization of log level configuration!The code properly validates the log level from command line flags before initializing the configuration, following good error handling practices.
54-75
: Consider the impact of cache updates during version checks.While the added debug logging improves observability, be cautious about using
CheckForAtmosUpdateAndPrintMessage
in this context as it updates the cache timestamp, which might not be desired here.Consider separating the version check logic from cache updates to maintain better control over when the cache is modified.
81-82
: Good addition of debug logging!The debug message clearly indicates that updates are being checked from the cache, improving observability.
cmd/root.go (1)
65-70
: Excellent improvement to error handling!The code now intelligently suppresses unnecessary warnings during help requests while maintaining proper error handling for other scenarios. This enhances the user experience.
cmd/cmd_utils.go (1)
535-536
: Good addition of status logging!The debug message clearly indicates when Atmos is up to date, improving observability.
pkg/config/utils.go (2)
364-364
: Excellent improvement to error messaging!The error message now clearly indicates both the invalid value and the valid options, making it easier for users to correct their input.
489-489
: Great consistency in error messaging!The error message for command line flags matches the style used for environment variables, maintaining a consistent user experience.
6c00f9d
to
59b899d
Compare
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 (2)
pkg/utils/github_utils.go (1)
34-35
: Consider using authenticated client for better rate limits.The change to use an unauthenticated client might lead to GitHub API rate limiting. Consider using the existing
newGitHubClient
function which handles authentication.-client := github.NewClient(nil) +client := newGitHubClient(context.Background())cmd/version.go (1)
56-65
: Simplify error handling logic.The error handling contains redundant checks and could be simplified.
- latestReleaseTag, err := u.GetLatestGitHubRepoRelease(atmosConfig, "cloudposse", "atmos") - if err == nil && latestReleaseTag != "" { - if err != nil { - u.LogWarning(atmosConfig, fmt.Sprintf("Failed to check for updates: %v", err)) - return - } - if latestReleaseTag == "" { - u.LogWarning(atmosConfig, "No release information available") - return - } + latestReleaseTag, err := u.GetLatestGitHubRepoRelease(atmosConfig, "cloudposse", "atmos") + if err != nil { + u.LogWarning(atmosConfig, fmt.Sprintf("Failed to check for updates: %v", err)) + return + } + if latestReleaseTag == "" { + u.LogWarning(atmosConfig, "No release information available") + return + }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
cmd/cmd_utils.go
(2 hunks)cmd/root.go
(1 hunks)cmd/version.go
(4 hunks)pkg/config/utils.go
(2 hunks)pkg/utils/github_utils.go
(2 hunks)pkg/utils/log_utils.go
(1 hunks)tests/test-cases/log-level-validation.yaml
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- cmd/root.go
- cmd/cmd_utils.go
- pkg/config/utils.go
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: [localstack] demo-localstack
- GitHub Check: Acceptance Tests (macos-latest, macos)
- GitHub Check: Acceptance Tests (windows-latest, windows)
- GitHub Check: Acceptance Tests (ubuntu-latest, linux)
- GitHub Check: Summary
🔇 Additional comments (5)
pkg/utils/log_utils.go (1)
82-82
: LGTM! Improved debug message clarity.Adding the "[DEBUG]" prefix makes it easier to identify debug level messages in logs.
tests/test-cases/log-level-validation.yaml (1)
34-34
: LGTM! Test case updated to match new error message format.The test case now properly validates the improved error message that includes the environment variable context.
cmd/version.go (3)
26-40
: LGTM! Proper initialization of logging configuration.The initialization of atmosConfig with log level from flags is well-structured and includes proper error handling.
69-71
: LGTM! Clear debug logging.The debug logging statements provide good visibility into the version comparison process.
82-83
: LGTM! Added debug logging for cache check.Good addition of debug logging before checking for updates from cache.
what
Fixed error message consistency for invalid log level validation
Updated test cases
Evidence:
wrong/invalid flag passed:
Env variable invalid:
why
Improved error messages
Better output clarity when theres an issue on the ATMOS_LOGS_LEVEL as env variable or when it's passed as a flag
references
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores