Skip to content
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

Improve error stack trace. Add --stack flag to atmos describe affected command. Improve atmos.Component template function #714

Merged
merged 10 commits into from
Oct 12, 2024

Conversation

aknysh
Copy link
Member

@aknysh aknysh commented Oct 12, 2024

what

  • Improve error stack trace
  • Add --stack flag to atmos describe affected command
  • Improve atmos.Component template function

why

  • On any error in the CLI, print Go stack trace only when Atmos log level is Trace - improve user experience

  • The --stack flag in the atmos describe affected command allows filtering the results by the specific stack only:

atmos describe affected --stack plat-ue2-prod
Affected components and stacks:

[
  {
    "component": "vpc",
    "component_type": "terraform",
    "component_path": "examples/quick-start-advanced/components/terraform/vpc",
    "stack": "plat-ue2-prod",
    "stack_slug": "plat-ue2-prod-vpc",
    "affected": "stack.vars"
  }
]
  • In the atmos.Component template function, don't execute terraform output on disabled and abstract components. The disabled components (when enabled: false) don't produce any terraform outputs. The abstract components are not meant to be provisioned (they are just blueprints for other components with default values), and they don't have any outputs.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a --stack flag to the atmos describe affected command for filtering results by stack.
    • Enhanced error handling across various commands to include configuration context in error logs.
  • Documentation

    • Updated documentation for the atmos describe affected command to reflect the new --stack flag.
    • Revised "Atlantis Integration" documentation to highlight support for Terraform Pull Request Automation.
  • Dependency Updates

    • Upgraded several dependencies, including Atmos version from 1.88.0 to 1.89.0 and Terraform version from 1.9.5 to 1.9.7.

@aknysh aknysh requested review from osterman and mcalhoun October 12, 2024 15:54
@aknysh aknysh self-assigned this Oct 12, 2024
@aknysh aknysh requested review from a team as code owners October 12, 2024 15:54
@aknysh aknysh requested review from kevcube and jamengual October 12, 2024 15:54
Copy link
Contributor

coderabbitai bot commented Oct 12, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request primarily focus on updating error handling across various commands and functions in the codebase. The modifications involve passing an instance of schema.CliConfiguration{} to the LogErrorAndExit function instead of just the error, enhancing the context for error logging. Additionally, several new import statements for the schema package have been added, and a new command-line flag --stack has been introduced in the documentation for the atmos describe affected command. Dependency versions have also been updated in go.mod.

Changes

File Change Summary
cmd/atlantis_generate_repo_config.go Updated error handling in Run function to include schema.CliConfiguration{} in LogErrorAndExit.
cmd/aws_eks_update_kubeconfig.go Added import for schema and updated error handling in Run function.
cmd/cmd_utils.go Modified error handling in multiple functions to include cliConfig in LogErrorAndExit.
cmd/completion.go Updated error handling in Run function to include schema.CliConfiguration{}.
cmd/describe_affected.go Added import for schema, updated error handling in Run, and added a new persistent flag stack.
cmd/describe_component.go Updated error handling in Run function to include schema.CliConfiguration{}.
cmd/describe_config.go Updated error handling in Run function to include schema.CliConfiguration{}.
cmd/describe_dependents.go Added import for schema, updated error handling in Run function.
cmd/describe_stacks.go Added import for schema, updated error handling in Run function.
cmd/describe_workflows.go Updated error handling in Run function to include schema.CliConfiguration{}.
cmd/docs.go Updated error handling in Run function to include schema.CliConfiguration{}.
cmd/helmfile.go Updated error handling in Run function to include schema.CliConfiguration{}.
cmd/helmfile_generate_varfile.go Added import for schema, updated error handling in Run function.
cmd/pro_lock.go Updated error handling in Run function to include schema.CliConfiguration{}.
cmd/pro_unlock.go Added import for schema, updated error handling in Run function.
cmd/root.go Updated error handling in Run and Execute functions to include schema.CliConfiguration{}.
cmd/terraform.go Updated error handling in Run function to include schema.CliConfiguration{}.
cmd/terraform_generate_backend.go Added import for schema, updated error handling in Run function.
cmd/terraform_generate_backends.go Added import for schema, updated error handling in Run function.
cmd/terraform_generate_varfile.go Added import for schema, updated error handling in Run function.
cmd/terraform_generate_varfiles.go Added import for schema, updated error handling in Run function.
cmd/validate_component.go Updated error handling in Run function to include schema.CliConfiguration{}.
cmd/validate_stacks.go Added import for schema, updated error handling in Run function.
cmd/vendor_diff.go Added import for schema, updated error handling in Run function.
cmd/vendor_pull.go Updated error handling in Run function to include schema.CliConfiguration{}.
cmd/version.go Updated error handling in Run function to include schema.CliConfiguration{}.
cmd/workflow.go Added import for schema, updated error handling in Run function.
examples/quick-start-advanced/Dockerfile Updated version arguments for Atmos and Terraform.
go.mod Updated dependency versions for several packages.
internal/exec/atlantis_generate_repo_config.go Added stack parameter to ExecuteAtlantisGenerateRepoConfigAffectedOnly.
internal/exec/atmos.go Minor comment addition in ExecuteAtmosCmd.
internal/exec/describe_affected.go Added Stack field to DescribeAffectedCmdArgs struct.
internal/exec/describe_affected_utils.go Added stack parameter to several functions.
internal/exec/describe_stacks.go Updated error handling in ExecuteDescribeStacks function.
internal/exec/file_utils.go Updated error logging in closeFile function.
internal/exec/oci_utils.go Updated error logging in processOciImage function.
internal/exec/stack_utils.go Added IsComponentEnabled function.
internal/exec/template_funcs_component.go Added import for cfg package.
internal/exec/terraform_generate_backends.go Updated error handling in ExecuteTerraformGenerateBackends.
internal/exec/terraform_generate_varfiles.go Updated error handling in ExecuteTerraformGenerateVarfiles.
internal/exec/utils.go Updated error logging in ProcessStacks function.
main.go Updated error handling in main function to include schema.CliConfiguration{}.
pkg/atlantis/atlantis_generate_repo_config_test.go Updated test function to include new parameter.
pkg/aws/aws_eks_update_kubeconfig.go Updated error logging to include schema.CliConfiguration{}.
pkg/component/component_processor.go Updated error logging in ProcessComponentInStack and ProcessComponentFromContext.
pkg/config/const.go Added constant WorkspaceSectionName.
pkg/describe/describe_affected_test.go Updated test functions to include new parameter.
pkg/spacelift/spacelift_stack_processor.go Updated error logging in CreateSpaceliftStacks and TransformStackConfigToSpaceliftStacks.
pkg/utils/log_utils.go Updated logging utility functions to include cliConfig.
pkg/validate/validate_component_test.go Updated error logging in multiple test functions.
pkg/validate/validate_stacks_test.go Updated error logging in test functions.
website/docs/cli/commands/describe/describe-affected.mdx Updated documentation to include --stack flag.
website/docs/integrations/atlantis.mdx Updated version in documentation.

Poem

In the garden of code, we hop with delight,
With schema.CliConfiguration, our errors take flight.
From LogErrorAndExit, a new path we weave,
As the --stack flag blooms, we joyfully believe.
So let’s celebrate changes, both big and small,
In the world of Atmos, we’re having a ball! 🐇✨


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

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

🧹 Outside diff range comments (20)
pkg/validate/validate_stacks_test.go (1)

Line range hint 1-24: Overall assessment: Changes improve error logging, with room for further enhancement.

The modifications in this file consistently improve error logging by including schema.CliConfiguration{} in the LogError calls. This aligns with the PR objectives to enhance error reporting.

To further improve these changes:

  1. Consider creating a helper function that generates a meaningful CliConfiguration for these test cases.
  2. Alternatively, if using an empty CliConfiguration is intentional, add a comment explaining why this is sufficient for these tests.

This would enhance the tests' clarity and potentially provide more valuable information during error logging.

cmd/pro_unlock.go (1)

Line range hint 1-34: Consider reviewing error handling consistency across commands.

While the changes in this file are appropriate and align with the PR objectives, it might be beneficial to ensure consistent error handling across all command implementations in the codebase.

Consider conducting a broader review of error handling in other command files to ensure they all follow this new pattern of passing schema.CliConfiguration{} to LogErrorAndExit. This would maintain consistency and fully leverage the enhanced error reporting capabilities.

internal/exec/file_utils.go (1)

Addressed Inconsistency in Error Logging

The verification confirms that there is an inconsistency in how errors are logged across different functions:

  • removeTempDir in internal/exec/file_utils.go uses the cliConfig parameter:

    u.LogWarning(cliConfig, err.Error())
  • closeFile in the same file uses an empty schema.CliConfiguration{}:

    u.LogError(schema.CliConfiguration{}, fmt.Errorf("error closing the file '%s': %v", fileName, err))

To ensure uniformity and improve maintainability, it's recommended to standardize the error logging approach across all functions in the codebase.

Next Steps:

  • Option 1: Update all LogWarning and LogError calls to consistently use schema.CliConfiguration{} if the cliConfig is not necessary.
  • Option 2: Modify all relevant functions to pass the actual cliConfig if it provides meaningful context for error logging.
🔗 Analysis chain

Line range hint 11-16: Address inconsistency in error logging across functions

There's an inconsistency in how errors are logged between the closeFile and removeTempDir functions:

  • closeFile now uses an empty schema.CliConfiguration{}.
  • removeTempDir still uses the cliConfig parameter.

To maintain consistency and improve code maintainability, consider aligning the error logging approach across all functions in this file. Either:

  1. Update removeTempDir to use an empty schema.CliConfiguration{} like closeFile, or
  2. Revert closeFile to use the cliConfig parameter and pass it from the calling function.

The chosen approach should be consistent with the broader error handling strategy in the project.

Here's a suggested change for option 1:

 func removeTempDir(cliConfig schema.CliConfiguration, path string) {
 	err := os.RemoveAll(path)
 	if err != nil {
-		u.LogWarning(cliConfig, err.Error())
+		u.LogWarning(schema.CliConfiguration{}, err.Error())
 	}
 }

To check the usage of LogWarning across the codebase, run:

This will help determine which approach is more consistent with the rest of the codebase.

Also applies to: 22-22

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check usage of LogWarning function

echo "Instances of LogWarning usage:"
rg --type go 'LogWarning\('

Length of output: 4311

cmd/pro_lock.go (1)

Line range hint 29-32: Existing --stack flag aligns with PR objectives.

While the PR objectives mention adding a new --stack flag to the atmos describe affected command, it's worth noting that the pro lock command already includes a --stack flag. This existing implementation aligns well with the overall direction of the PR.

Consider updating the PR description or documentation to clarify that the --stack flag is being added to the describe affected command specifically, to avoid any confusion with existing flags in other commands.

cmd/terraform.go (1)

No existing tests found for the terraform command.

It's recommended to add unit tests that trigger errors in the ExecuteTerraformCmd function and verify that LogErrorAndExit is called with the correct arguments to ensure robust error handling.

🔗 Analysis chain

Line range hint 8-34: Overall impact: Improved error handling with minimal changes.

The changes in this file align with the PR objective of enhancing error reporting. The core functionality of terraformCmd remains intact, with the only modification being to the error handling mechanism.

To ensure the error handling works as expected:

  1. Consider adding a unit test that triggers an error in the ExecuteTerraformCmd function and verifies that LogErrorAndExit is called with the correct arguments.
  2. Manually test the terraform command with invalid inputs to confirm improved error messages.

Let's check if there are existing tests for this command:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for test files related to the terraform command
fd -e go -e _test.go terraform

Length of output: 598

cmd/describe_workflows.go (1)

Line range hint 1-38: Overall, these changes enhance error handling capabilities.

The modifications in this file align well with the PR objectives. They improve error handling by allowing for more context to be passed to the error logging function. This sets the groundwork for potentially more detailed and helpful error messages in the future.

The changes are minimal and don't introduce any breaking changes to the existing functionality. They maintain backwards compatibility while enhancing the system's capabilities.

As the codebase evolves, consider standardizing this error handling approach across all commands. This will ensure consistent error reporting throughout the application and make it easier to add global error handling features in the future.

cmd/helmfile_generate_varfile.go (1)

Line range hint 1-39: Overall assessment: Changes improve error handling and align with PR objectives.

The modifications in this file consistently enhance error reporting by providing more context through the use of schema.CliConfiguration{}. These changes align well with the PR objectives and should improve debugging and error analysis capabilities.

Consider documenting the new error handling approach in the project's contribution guidelines or developer documentation to ensure consistent implementation across the codebase as it evolves.

cmd/terraform_generate_varfile.go (1)

Line range hint 1-39: Summary: Improved error handling with minor enhancement suggestion.

The changes in this file successfully implement enhanced error handling as per the PR objectives. The new import and consistent use of schema.CliConfiguration{} in error logging improve the overall structure and maintainability of the code.

To further improve the effectiveness of these changes, consider populating the CliConfiguration with relevant information when calling u.LogErrorAndExit. This would provide more context in error logs, potentially aiding in debugging and error resolution.

Overall, these changes are a positive step towards better error reporting in the Atmos CLI tool.

cmd/describe_component.go (1)

Line range hint 1-41: Overall assessment: Changes improve error handling consistency

The modifications in this file successfully enhance error reporting by consistently updating the error logging calls. These changes align well with the PR objectives.

To further improve error handling:

  1. Consider populating the schema.CliConfiguration{} struct with relevant information before passing it to LogErrorAndExit.
  2. Evaluate if there's any command-specific context that could be included in the error logging to aid in debugging or user understanding.

These enhancements would provide more detailed and context-rich error messages, potentially improving the debugging process and user experience.

pkg/describe/describe_affected_test.go (1)

Line range hint 1-82: Consider adding test cases for the new --stack flag functionality.

While the changes to both test functions are consistent and align with the PR objectives, it might be beneficial to add new test cases that explicitly test the functionality of the new --stack flag. This would ensure that the new feature is working as expected and provide better test coverage for the changes introduced in this PR.

Would you like assistance in drafting additional test cases for the --stack flag functionality?

cmd/describe_stacks.go (1)

Missing --stack flag implementation in atmos describe affected command.

The --stack flag is not implemented in the atmos describe affected command within cmd/describe_stacks.go. Please ensure that the flag is correctly added to this command.

🔗 Analysis chain

Line range hint 1-54: Verify implementation of --stack flag for atmos describe affected command.

The PR objectives mention adding a --stack flag to the atmos describe affected command, but this change is not visible in the current file.

Let's verify if this flag has been implemented in the correct file:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for the implementation of --stack flag in atmos describe affected command

# Test: Search for the implementation of --stack flag
rg --type go -A 5 'Use:\s+"affected".*\n.*\n.*\n.*\n.*--stack'

# Test: Search for any additions of --stack flag to cobra commands
rg --type go -A 2 'PersistentFlags\(\).*\n.*--stack'

Length of output: 503


Script:

#!/bin/bash
# Description: Check for the implementation of --stack flag in 'atmos describe affected' command with multiline support

# Test: Search for the implementation of --stack flag within the 'affected' command using multiline regex
rg -U --type go -A 5 'Use:\s+"affected".*\n.*\n.*\n.*\n.*--stack'

# Test: Search for any additions of --stack flag to cobra commands with multiline support
rg -U --type go -A 2 'PersistentFlags\(\).*\n.*--stack'

Length of output: 1258

cmd/validate_component.go (1)

Missing --stack flag implementation in atmos describe affected command.

The --stack flag is not implemented in the atmos describe affected command. Please implement the flag as per the PR objectives to ensure consistency across commands.

🔗 Analysis chain

Line range hint 1-51: Overall changes improve error handling, but --stack flag is missing.

The modifications in this file successfully enhance error reporting by providing more context to the LogErrorAndExit function. These changes align with the PR objectives and should improve error diagnostics without altering the core functionality of the command.

However, the PR objectives mention a new --stack flag for the atmos describe affected command, which is not implemented in this file. Let's verify if this flag is implemented elsewhere:

If the search doesn't yield results, we may need to implement this flag or update the PR objectives.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the implementation of the --stack flag in the atmos describe affected command
rg --type go -i "describe affected.*--stack"

Length of output: 46


Script:

#!/bin/bash
# Search for all occurrences of the --stack flag in Go files
rg --type go -- '--stack'

Length of output: 4082

cmd/terraform_generate_varfiles.go (1)

Missing Implementation for --stack Flag

The review confirms that the --stack flag is not implemented in the codebase. Therefore, one of the PR objectives has not been addressed.

  • Ensure implementation of the --stack flag across relevant commands.
🔗 Analysis chain

Line range hint 1-64: Summary: Error handling improvements implemented, other PR objectives not addressed in this file

The changes in this file successfully implement part of the PR objective to enhance error reporting. The modifications consistently improve error handling by including schema.CliConfiguration{} in error logging calls.

However, this file does not contain changes related to:

  1. The new --stack flag for the atmos describe affected command.
  2. Improvements to the atmos.Component template function.

These objectives are likely addressed in other files not included in this review. To ensure all PR objectives are met, please verify that these changes are implemented elsewhere in the codebase.

To confirm the implementation of the remaining objectives, you can run the following commands:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for --stack flag implementation
echo "Checking for --stack flag implementation:"
rg --type go "describe affected.*--stack"

# Check for atmos.Component template function improvements
echo "Checking for atmos.Component template function improvements:"
rg --type go "func.*atmos\.Component"

Length of output: 817

cmd/aws_eks_update_kubeconfig.go (1)

Line range hint 1-58: Overall assessment: Changes align with PR objectives and are consistent.

The modifications in this file are focused on enhancing error handling, which aligns well with the PR's objectives. The changes are minimal and do not alter the command's functionality. They appear to be part of a consistent effort to improve error reporting across the codebase.

To further improve the error handling architecture:

  1. Consider creating a helper function to construct the schema.CliConfiguration with relevant command information.
  2. Ensure that this pattern of error handling is applied consistently across all commands in the application.
website/docs/integrations/atlantis.mdx (3)

Line range hint 40-326: Great expansion of the Configuration section!

The reorganization and detailed explanation of the two configuration methods (in atmos.yaml and stack config files) significantly improve the document's clarity. The examples provided for each method are particularly helpful for users.

Consider adding a brief comparison table or summary at the end of this section to help users quickly understand the pros and cons of each configuration method.


Line range hint 328-426: Excellent addition of the Atlantis Workflows section!

This new section provides crucial information about defining Atlantis workflows, which was not present in the previous version. The examples for both Server Side Config and Repo Level Config are clear and helpful. The explanation of how these methods interact with Atmos configurations is particularly valuable.

Consider adding a brief note about best practices or common pitfalls when choosing between Server Side and Repo Level workflows. This could help users make more informed decisions about their workflow configuration.


Line range hint 428-506: Great addition of the Dynamic Repo Config Generation section!

This new section provides valuable information about dynamically generating the atlantis.yaml file, which is crucial for larger projects or those with frequently changing configurations. The explanation of the --affected-only flag and how it works with different command-line options is particularly helpful.

Consider adding a brief example of a use case where dynamic repo config generation would be particularly beneficial. This could help readers better understand when to apply this feature in their workflows.

website/docs/cli/commands/describe/describe-affected.mdx (3)

Line range hint 216-219: New --upload flag description added.

The description of the --upload flag is comprehensive and explains the feature well. It includes information about the HTTP POST request, environment variables, and the purpose of this functionality.

Consider adding a brief note about security considerations when using this feature, such as ensuring the endpoint is secure and the token is properly protected.


Line range hint 180-219: Consider reorganizing the flags list for improved readability.

While the new flags are well-documented, consider reorganizing the entire flags list either alphabetically or by grouping related flags together. This could improve readability and make it easier for users to find specific flags quickly.

For example, you could group flags related to output (--file, --format) together, and flags related to dependencies and settings (--include-dependents, --include-settings) together.


Line range hint 216-219: Consider creating a dedicated section for the upload functionality.

The --upload flag introduces significant new functionality that may benefit from a more detailed explanation. Consider creating a new section in the document specifically for this feature. This section could include:

  1. An overview of the upload functionality
  2. Detailed explanation of the HTTP POST request
  3. Description of the required environment variables
  4. Security considerations
  5. Example usage scenarios

This would provide users with a comprehensive understanding of this new feature while keeping the flags list concise.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 7c41087 and e8a0351.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (53)
  • cmd/atlantis_generate_repo_config.go (2 hunks)
  • cmd/aws_eks_update_kubeconfig.go (2 hunks)
  • cmd/cmd_utils.go (8 hunks)
  • cmd/completion.go (2 hunks)
  • cmd/describe_affected.go (3 hunks)
  • cmd/describe_component.go (3 hunks)
  • cmd/describe_config.go (2 hunks)
  • cmd/describe_dependents.go (3 hunks)
  • cmd/describe_stacks.go (2 hunks)
  • cmd/describe_workflows.go (2 hunks)
  • cmd/docs.go (2 hunks)
  • cmd/helmfile.go (2 hunks)
  • cmd/helmfile_generate_varfile.go (3 hunks)
  • cmd/pro_lock.go (2 hunks)
  • cmd/pro_unlock.go (2 hunks)
  • cmd/root.go (4 hunks)
  • cmd/terraform.go (2 hunks)
  • cmd/terraform_generate_backend.go (3 hunks)
  • cmd/terraform_generate_backends.go (2 hunks)
  • cmd/terraform_generate_varfile.go (3 hunks)
  • cmd/terraform_generate_varfiles.go (3 hunks)
  • cmd/validate_component.go (3 hunks)
  • cmd/validate_stacks.go (2 hunks)
  • cmd/vendor_diff.go (2 hunks)
  • cmd/vendor_pull.go (2 hunks)
  • cmd/version.go (2 hunks)
  • cmd/workflow.go (2 hunks)
  • examples/quick-start-advanced/Dockerfile (1 hunks)
  • go.mod (8 hunks)
  • internal/exec/atlantis_generate_repo_config.go (3 hunks)
  • internal/exec/atmos.go (1 hunks)
  • internal/exec/describe_affected.go (5 hunks)
  • internal/exec/describe_affected_utils.go (9 hunks)
  • internal/exec/describe_stacks.go (2 hunks)
  • internal/exec/file_utils.go (1 hunks)
  • internal/exec/oci_utils.go (1 hunks)
  • internal/exec/stack_utils.go (1 hunks)
  • internal/exec/template_funcs_component.go (4 hunks)
  • internal/exec/terraform_generate_backends.go (1 hunks)
  • internal/exec/terraform_generate_varfiles.go (1 hunks)
  • internal/exec/utils.go (3 hunks)
  • main.go (1 hunks)
  • pkg/atlantis/atlantis_generate_repo_config_test.go (1 hunks)
  • pkg/aws/aws_eks_update_kubeconfig.go (1 hunks)
  • pkg/component/component_processor.go (3 hunks)
  • pkg/config/const.go (1 hunks)
  • pkg/describe/describe_affected_test.go (2 hunks)
  • pkg/spacelift/spacelift_stack_processor.go (9 hunks)
  • pkg/utils/log_utils.go (3 hunks)
  • pkg/validate/validate_component_test.go (4 hunks)
  • pkg/validate/validate_stacks_test.go (2 hunks)
  • website/docs/cli/commands/describe/describe-affected.mdx (2 hunks)
  • website/docs/integrations/atlantis.mdx (1 hunks)
🧰 Additional context used
🔇 Additional comments (113)
main.go (1)

5-5: LGTM: New import added for schema package

The addition of the schema package import is necessary for the updated error handling logic. This change aligns with the PR objective of improving error reporting.

pkg/validate/validate_stacks_test.go (2)

4-4: LGTM: Import statement added correctly.

The addition of the schema package import is necessary and consistent with the changes made in the test functions.


22-22: Approved: Consistent with previous change.

This modification is consistent with the change made in the TestValidateStacksCommand function. It aligns with the PR objectives to enhance error reporting.

The same suggestion from the previous comment applies here regarding the use of an empty CliConfiguration struct.

cmd/describe_config.go (1)

7-7: LGTM: Import addition is appropriate.

The addition of the schema package import is consistent with its usage in the updated error handling. This follows the best practice of only importing packages that are actually used in the file.

cmd/pro_unlock.go (1)

7-7: LGTM: New import added correctly.

The new import for the schema package is necessary for the updated error handling and follows Go's import conventions.

cmd/docs.go (2)

10-10: LGTM: New import added correctly.

The new import for the schema package is correctly added and is necessary for the changes in error handling.


Line range hint 1-50: Overall: Changes align with PR objectives and maintain command functionality.

The modifications to this file are minimal and focused on enhancing error handling, which aligns well with the PR objectives. The core functionality of the docs command remains unchanged, ensuring that existing behavior is preserved.

The changes are consistent with modifications in other parts of the codebase, as mentioned in the AI summary. They contribute to a more standardized approach to error handling across the application.

cmd/completion.go (2)

4-4: LGTM: Import statement added correctly.

The addition of the schema package import is consistent with its usage in the modified error handling. This change is necessary and correctly implemented.


Line range hint 1-42: Summary: Changes improve error handling consistency.

The modifications in this file are minimal and focused, aligning well with the PR objectives. They improve consistency in error handling across the application by using the schema.CliConfiguration in the LogErrorAndExit function.

The changes don't introduce any new functionality to the completion command itself, maintaining its current behavior while enhancing the error reporting mechanism.

cmd/validate_stacks.go (2)

8-8: LGTM: Import addition is correct and necessary.

The new import for github.com/cloudposse/atmos/pkg/schema is correctly added and is required for the usage of schema.CliConfiguration{} in the error handling modification.


Line range hint 1-41: Overall assessment: Changes align with PR objectives and improve error handling.

The modifications in this file successfully contribute to enhancing error reporting as outlined in the PR objectives. The code remains clean, consistent, and follows the existing style. The addition of schema.CliConfiguration{} to the error logging function provides a foundation for more detailed error reporting, which can be further improved by passing a non-empty configuration when available.

cmd/version.go (2)

11-11: LGTM: New import added correctly

The new import for the schema package is correctly placed and necessary for the updated error handling logic.


Line range hint 1-46: Overall, changes align with PR objectives

The modifications in this file contribute to the PR's goal of enhancing error handling. The new import and updated error logging call are correctly implemented. However, the purpose of passing an empty schema.CliConfiguration{} object in the error logging call could benefit from further explanation.

The core functionality of the version command remains unchanged, which is good for maintaining consistency in the CLI's behavior.

cmd/pro_lock.go (2)

4-7: Import statements look good.

The changes to the import statements are appropriate. The cleanup of the cobra import and the addition of the schema package import align with the modifications in the code.


Line range hint 1-35: Overall, the changes improve error handling and align with PR objectives.

The modifications to this file enhance error reporting by providing more context to the LogErrorAndExit function. This aligns well with the PR's objective of improving error stack traces. The existing --stack flag in this command also complements the PR's goal of introducing stack-based filtering in other parts of the application.

The changes are generally good, with suggestions for further improvements in error context and documentation clarity. These modifications contribute to a more robust and user-friendly CLI tool.

cmd/terraform_generate_backend.go (3)

7-7: LGTM: Import addition is correct and necessary.

The new import for the schema package is correctly added and is required for the subsequent changes in error handling.


34-34: Approved, with reference to previous suggestion.

This change is consistent with the modification in the Run function and aligns with the PR objectives.

As mentioned in the previous comment, consider passing the actual CLI configuration if available, or add a comment explaining the use of an empty struct.


Line range hint 1-38: Overall, the changes look good and align with the PR objectives.

The modifications enhance error reporting by including schema.CliConfiguration{} in error logging calls. The changes are consistent throughout the file and don't introduce any apparent issues. Consider the suggestions about potentially using actual CLI configuration data or adding explanatory comments for a more informative error context.

cmd/workflow.go (2)

7-7: LGTM: Import addition is correct and necessary.

The addition of the schema package import is appropriate for using the schema.CliConfiguration{} type in the error handling modification.


Line range hint 1-38: Overall assessment: Changes align with PR objectives.

The modifications to this file successfully implement part of the error handling enhancement mentioned in the PR objectives. The changes are minimal and focused, affecting only the necessary parts of the code.

cmd/vendor_diff.go (2)

7-7: LGTM: Import statement added correctly.

The new import for the schema package is necessary and correctly placed. It supports the changes made in the error handling logic.


7-7: Verify consistency of error handling changes across the codebase.

The changes to error handling in this file seem to be part of a larger effort to enhance error reporting. It would be beneficial to ensure that similar changes have been made consistently across the codebase.

Run the following script to check for consistency:

This script will help identify if the changes have been applied consistently and if there are any remaining instances of the old error handling pattern.

Also applies to: 23-23

cmd/helmfile.go (1)

8-8: LGTM: New import added correctly

The new import for the schema package is correctly added and is necessary for the changes in the error handling.

cmd/terraform.go (2)

8-8: LGTM: New import statement added correctly.

The new import statement for the schema package is correctly placed and necessary for the updated LogErrorAndExit function call.


34-34: Approved, but clarification needed on empty configuration.

The update to LogErrorAndExit aligns with the new function signature. However, passing an empty schema.CliConfiguration{} might not provide additional context for error logging.

Could you clarify why an empty configuration is being passed here? Is there a way to provide a meaningful configuration that would enhance error reporting?

To understand the context better, let's check the implementation of LogErrorAndExit:

cmd/describe_workflows.go (1)

7-7: LGTM: New import statement is correctly added.

The new import for the schema package is necessary and correctly placed. It aligns with the PR objective of improving error handling.

examples/quick-start-advanced/Dockerfile (3)

9-9: LGTM: Atmos version update

The update of ATMOS_VERSION from 1.88.0 to 1.89.0 aligns with the PR objectives and follows good practices of keeping dependencies up-to-date.

Please ensure that version 1.89.0 of Atmos is stable and compatible with the rest of the project. You can verify this by running the following command:


12-12: LGTM: Terraform version update

The update of TF_VERSION from 1.9.5 to 1.9.7 is a good practice to keep dependencies up-to-date. This minor version update should maintain backwards compatibility.

Please ensure that version 1.9.7 of Terraform is compatible with your existing Terraform configurations. You can verify this by running the following command:


9-12: Summary of Dockerfile changes

The updates to ATMOS_VERSION (1.89.0) and TF_VERSION (1.9.7) are the only changes in this Dockerfile. These updates align with good practices for maintaining up-to-date dependencies.

To ensure these changes don't introduce any unexpected issues, please:

  1. Build and test the Docker image locally.
  2. Verify that all CI/CD pipelines and workflows that depend on this Dockerfile still function correctly with the updated versions.
  3. Update any relevant documentation or version references in other parts of the project to reflect these changes.
✅ Verification successful

Dockerfile Updates Verified

The changes to ATMOS_VERSION (1.89.0) and TF_VERSION (1.9.7) in examples/quick-start-advanced/Dockerfile have been verified. Only the specified lines were modified, ensuring dependencies are up-to-date without introducing unintended changes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Build and test the Docker image
# Expected result: Successful build and no errors in basic commands

# Build the Docker image
docker build -t atmos-tf-test .

# Test Atmos
docker run --rm atmos-tf-test atmos version

# Test Terraform
docker run --rm atmos-tf-test terraform version

# Optional: Run any project-specific tests or commands
# docker run --rm atmos-tf-test your-test-command

Length of output: 6132


Script:

#!/bin/bash
# Description: Verify changes in the Dockerfile
# Expected result: Show only lines 9-12 were modified

git diff origin/main...HEAD -- examples/quick-start-advanced/Dockerfile

Length of output: 671

cmd/helmfile_generate_varfile.go (2)

7-7: LGTM: Import statement added correctly.

The addition of the schema package import is consistent with the changes made in the error handling. This import is necessary to support the new error logging format using schema.CliConfiguration{}.


35-35: LGTM: Error handling updated consistently.

The modification to LogErrorAndExit in the flag requirement error handling is consistent with the previous change, maintaining the new error logging format throughout the file.

To ensure consistency across the codebase, let's verify if similar changes have been made in other files:

This script will help identify any inconsistencies in the error handling updates across the codebase.

cmd/terraform_generate_varfile.go (2)

7-7: LGTM: New import added correctly.

The new import for the schema package is necessary and correctly placed. It follows the existing import style and supports the changes in error handling.


35-35: Approved: Consistent error handling update.

This change is consistent with the modification in the Run function, maintaining a uniform approach to error handling throughout the file. As mentioned in the previous comment, consider populating the CliConfiguration with relevant information if available.

cmd/vendor_pull.go (2)

7-7: LGTM: New import statement added correctly.

The new import statement for the schema package is correctly added and is necessary for the changes in error handling.


Line range hint 1-38: Overall changes look good, aligned with PR objectives.

The modifications in this file are minimal and focused on enhancing error handling, which is consistent with the PR objectives. The changes don't introduce any apparent issues or conflicts with the existing code, and the overall structure and functionality of the vendorPullCmd remain intact.

The introduction of the schema.CliConfiguration{} parameter in error logging paves the way for more contextual error reporting, although its full potential isn't utilized in this specific instance.

cmd/describe_dependents.go (2)

4-4: LGTM: New import added correctly.

The new import for the schema package is correctly added and is necessary for the subsequent changes in error handling.


Line range hint 1-41: Overall assessment: Changes improve error handling as intended.

The modifications in this file successfully enhance error reporting by including schema.CliConfiguration{} in error logging calls. This aligns well with the PR objectives. The changes are consistent and maintain the overall structure of the command.

To further improve error context, consider populating the schema.CliConfiguration with relevant command information in both instances of LogErrorAndExit calls.

pkg/validate/validate_component_test.go (5)

29-29: Improved error logging with additional context

The update to u.LogError(cliConfig, err) enhances error reporting by including the CLI configuration. This change provides more context for error analysis, aligning with the PR's objective to improve error stack trace information.


48-48: Consistent error logging improvement

The change to u.LogError(cliConfig, err) is consistent with the update in TestValidateComponent. This uniformity in error handling across test functions is commendable.


67-67: Maintaining consistency in error logging

The update to u.LogError(cliConfig, err) in TestValidateComponent3 maintains the consistent approach to error logging seen in previous test functions. This uniformity aids in code readability and maintenance.


86-86: Consistent error logging with specific assertion

The update to u.LogError(cliConfig, err) in TestValidateComponent4 maintains the consistent approach to error logging. This test function also includes a specific assertion for the error message, which is good for validating particular component validation rules.


Line range hint 29-86: Summary: Consistent improvement in error logging across test functions

The changes in this file demonstrate a systematic approach to enhancing error logging across all test functions. By including the cliConfig in the u.LogError calls, these updates provide more context for error analysis, which aligns with the PR's objective to improve error reporting. The consistency of these changes across different test scenarios is commendable and will contribute to better debugging and error handling in the Atmos CLI tool.

cmd/describe_component.go (1)

4-4: LGTM: New import added correctly

The new import for the schema package is correctly added and is necessary for the changes made to error logging.

pkg/describe/describe_affected_test.go (2)

65-72: LGTM. Verify impact on other parts of the codebase.

The addition of the new parameter (empty string) to e.ExecuteDescribeAffectedWithTargetRepoPath is consistent with the PR objectives and the previous change. This modification likely relates to the new --stack flag for the atmos describe affected command.

To ensure this change doesn't introduce any issues, please run the following script to check for any other occurrences of this function call that might need updating:

✅ Verification successful

Verified: All calls to ExecuteDescribeAffectedWithTargetRepoPath have been updated with the new parameter. No further action needed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all occurrences of ExecuteDescribeAffectedWithTargetRepoPath
# to ensure they've been updated with the new parameter.

# Test: Search for the function usage. Expect: Only occurrences with 6 parameters.
rg --type go -A 10 'ExecuteDescribeAffectedWithTargetRepoPath\('

Length of output: 2984


31-41: LGTM. Verify impact on other parts of the codebase.

The addition of the new parameter (empty string) to e.ExecuteDescribeAffectedWithTargetRefClone is consistent with the PR objectives. This change likely relates to the new --stack flag for the atmos describe affected command.

To ensure this change doesn't introduce any issues, please run the following script to check for any other occurrences of this function call that might need updating:

✅ Verification successful

Verified: No additional modifications necessary.

The changes in pkg/describe/describe_affected_test.go have been correctly applied, and no other occurrences of ExecuteDescribeAffectedWithTargetRefClone require updates.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all occurrences of ExecuteDescribeAffectedWithTargetRefClone
# to ensure they've been updated with the new parameter.

# Test: Search for the function usage. Expect: Only occurrences with 9 parameters.
rg --type go -A 10 'ExecuteDescribeAffectedWithTargetRefClone\('

Length of output: 2984

cmd/describe_stacks.go (1)

7-7: LGTM: New import statement added correctly.

The new import for the schema package is necessary for the updated error handling and follows Go conventions.

cmd/validate_component.go (1)

10-10: LGTM: New import statement is correctly added.

The new import for the schema package is necessary for the subsequent changes in error handling. It's properly placed and follows the existing import structure.

pkg/component/component_processor.go (4)

28-28: Improved error logging with CLI configuration context

The change enhances error logging by including the cliConfig in the LogError call. This modification aligns with the PR objectives to improve error reporting and provides more context for debugging purposes.


38-38: Consistent improvement in error logging

This change follows the same pattern as the previous modification, enhancing error logging by including the cliConfig. This consistency in error handling improvements across the function is commendable.


64-64: Comprehensive enhancement of error logging in ProcessComponentFromContext

The changes on lines 64, 70, and 76 consistently improve error logging by including the cliConfig in all LogError calls within the ProcessComponentFromContext function. This comprehensive approach ensures that all error scenarios in this function now provide enhanced context for debugging, aligning well with the PR's objective to improve error reporting.

Also applies to: 70-70, 76-76


28-28: Summary: Consistent and beneficial error logging improvements

The changes in this file demonstrate a systematic approach to enhancing error logging by including the CLI configuration context in all LogError calls. This improvement is consistent across both ProcessComponentInStack and ProcessComponentFromContext functions, covering various error scenarios. These modifications align perfectly with the PR's objective to improve error reporting, which will significantly aid in debugging and troubleshooting. The consistency and comprehensiveness of these changes are commendable.

Also applies to: 38-38, 64-64, 70-70, 76-76

pkg/config/const.go (1)

58-58: LGTM: New constant added for workspace section.

The new constant WorkspaceSectionName with the value "workspace" has been added. This addition is consistent with the existing naming convention for section name constants in this file. It aligns well with other section names like ComponentSectionName, SettingsSectionName, etc.

While this change wasn't explicitly mentioned in the PR objectives, it appears to be a supporting modification for the improvements described, possibly related to the refinement of the atmos.Component template function or the new --stack flag functionality.

To ensure this constant is being utilized appropriately, let's check for its usage across the codebase:

✅ Verification successful

Verified: WorkspaceSectionName is properly utilized in the codebase.

The constant WorkspaceSectionName is correctly used in internal/exec/template_funcs_component.go, ensuring consistency with existing section name constants.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new WorkspaceSectionName constant

# Test: Search for WorkspaceSectionName usage
rg --type go "WorkspaceSectionName" --stats

Length of output: 377

cmd/terraform_generate_varfiles.go (1)

7-7: LGTM: Import added for enhanced error handling

The addition of the schema package import is appropriate and aligns with the PR's objective of improving error reporting.

cmd/terraform_generate_backends.go (2)

7-7: LGTM: New import statement added correctly.

The addition of the schema package import is consistent with the changes in the error handling logic. This import is necessary for using the schema.CliConfiguration{} type in the updated error handling.


Line range hint 1-70: Overall, changes improve error handling as intended.

The modifications in this file successfully enhance the error reporting capabilities of the terraformGenerateBackendsCmd command, aligning with the PR objectives. The addition of the schema package and the use of CliConfiguration in error handling provide a foundation for more contextual error reporting.

To fully realize the benefits of these changes:

  1. Ensure that the LogErrorAndExit function in the utils package has been updated to handle the new CliConfiguration parameter effectively.
  2. Consider creating a helper function to populate the CliConfiguration with relevant command context, as suggested in the previous comment.

To verify the implementation of LogErrorAndExit, you can run the following script:

This script will help ensure that the LogErrorAndExit function is consistently used across the codebase and that its implementation correctly handles the new CliConfiguration parameter.

✅ Verification successful

Verification Successful: LogErrorAndExit is Consistently Implemented

The LogErrorAndExit function is properly defined in the utils package and is consistently utilized across the codebase with the appropriate CliConfiguration parameter. This confirms that the error handling enhancements are correctly integrated and align with the PR objectives.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the implementation of LogErrorAndExit in the utils package

# Search for the LogErrorAndExit function definition
echo "Searching for LogErrorAndExit function definition:"
rg --type go -A 10 'func LogErrorAndExit'

# Search for other uses of LogErrorAndExit to ensure consistency
echo "Searching for other uses of LogErrorAndExit:"
rg --type go 'LogErrorAndExit\('

Length of output: 5565

cmd/aws_eks_update_kubeconfig.go (1)

7-7: LGTM: Import statement added for enhanced error handling.

The addition of the schema package import is appropriate and aligns with the PR's objective to improve error reporting.

cmd/describe_affected.go (3)

4-4: LGTM: New import added correctly.

The new import for the schema package is correctly added and is necessary for the changes in error handling.


Line range hint 1-50: Overall, changes align with PR objectives and improve functionality.

The modifications to cmd/describe_affected.go successfully implement the intended improvements:

  1. Enhanced error handling with the addition of schema.CliConfiguration{}.
  2. New --stack flag for filtering results based on a specific stack.

These changes align well with the PR objectives and enhance the functionality of the atmos describe affected command. Consider the suggestions for improving the --stack flag description and clarifying the use of an empty CliConfiguration in error handling to further refine the implementation.


23-23: Approve change, but clarification needed on empty configuration.

The error handling has been updated to include schema.CliConfiguration{} as per the PR objectives. However, an empty configuration is being passed, which might not provide additional context for error logging.

Could you clarify why an empty schema.CliConfiguration{} is being used instead of passing the actual CLI configuration?

To verify if this pattern is consistent across the codebase, let's run the following script:

✅ Verification successful

Verification Successful: Usage of schema.CliConfiguration{} is consistent across the codebase.

The pattern of passing an empty schema.CliConfiguration{} to LogErrorAndExit is consistently used in multiple files, ensuring uniform error handling without requiring additional context.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of LogErrorAndExit with empty CliConfiguration

# Test: Search for LogErrorAndExit usage with empty CliConfiguration
rg --type go 'LogErrorAndExit\(schema\.CliConfiguration\{\}'

Length of output: 3155

cmd/atlantis_generate_repo_config.go (2)

4-4: LGTM: New import statement for schema package

The addition of the schema package import is appropriate and necessary for the subsequent changes in error handling. This aligns with the PR objective of enhancing error reporting.


Line range hint 1-77: Summary: Improved error handling aligns with PR objectives

The changes in this file successfully implement part of the PR objectives by enhancing error reporting. The addition of the schema package import and the modification of the LogErrorAndExit call improve the error handling mechanism.

These changes lay the groundwork for more comprehensive error reporting. However, to fully realize the benefits of this change, consider passing the actual CLI configuration instead of an empty one in future iterations.

Overall, the modifications are appropriate and contribute positively to the codebase.

internal/exec/describe_affected.go (5)

34-34: LGTM: Addition of Stack field to DescribeAffectedCmdArgs

The new Stack string field has been correctly added to the DescribeAffectedCmdArgs struct. This addition aligns with the PR objective to introduce a new --stack flag and maintains backward compatibility by placing it at the end of the struct.


150-153: LGTM: Improved error handling for log level setting

The error handling for setting the log level has been improved. The code now correctly checks for errors when calling logger.SetLogLevel(l.LogLevelTrace) and returns any error that occurs. This change enhances the robustness of the logging setup.


172-172: LGTM: Addition of Stack field to DescribeAffectedCmdArgs initialization

The Stack field has been correctly added to the DescribeAffectedCmdArgs struct initialization, completing the integration of the new --stack flag.


190-197: LGTM: Updated function calls with Stack parameter

The Stack parameter has been correctly added to all three function calls: ExecuteDescribeAffectedWithTargetRepoPath, ExecuteDescribeAffectedWithTargetRefClone, and ExecuteDescribeAffectedWithTargetRefCheckout. This ensures that the stack information is consistently passed to the respective functions, aligning with the new --stack flag functionality.

Also applies to: 199-209, 211-219


Line range hint 1-279: Overall assessment: Changes implement the --stack flag successfully

The changes in this file successfully implement the new --stack flag as per the PR objectives. The DescribeAffectedCmdArgs struct has been updated, the flag is properly parsed, and the Stack information is passed to the relevant functions. Additionally, error handling for log level setting has been improved.

The implementation is consistent and well-integrated into the existing code structure. No major issues were found, and the changes align well with the PR's goals.

internal/exec/stack_utils.go (1)

184-192: Verify default behavior for component enablement

The current implementation returns true (enabled) when the "enabled" key is not present in the varsSection map. Please confirm if this is the intended default behavior.

To help verify the usage and impact of this new function, you can run the following script:

This script will help identify where the new function is being used and how components are currently configured with the "enabled" flag.

✅ Verification successful

Default behavior for component enablement is intentional and correctly implemented.

The IsComponentEnabled function appropriately defaults to true when the "enabled" key is absent, as evidenced by its consistent usage across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of IsComponentEnabled and potential impact

# Search for usage of IsComponentEnabled
echo "Searching for usage of IsComponentEnabled:"
rg --type go "IsComponentEnabled\(" -A 5

# Search for places where "enabled" is set in component configurations
echo "Searching for 'enabled' configurations in YAML files:"
rg --type yaml "enabled:\s*(true|false)" -A 5

Length of output: 44824

internal/exec/terraform_generate_varfiles.go (1)

270-270: LGTM: Enhanced error handling aligns with PR objectives.

This change improves error reporting by providing the CLI configuration to the LogErrorAndExit function. It's consistent with the PR's goal of enhancing the error stack trace in the CLI.

internal/exec/terraform_generate_backends.go (1)

Line range hint 1-354: Overall impact: Improved error handling without altering core logic.

The change to use u.LogErrorAndExit(cliConfig, err) instead of return err enhances error reporting without modifying the core functionality of the ExecuteTerraformGenerateBackends function. This improvement aligns with the PR objective of enhancing error handling across various commands and functions.

The localized nature of this change minimizes the risk of unintended side effects while improving the consistency of error handling throughout the codebase.

pkg/spacelift/spacelift_stack_processor.go (7)

33-33: LGTM: Enhanced error logging

The change improves error logging by including the cliConfig context. This aligns with the PR objective to enhance error reporting and provides more detailed information for troubleshooting.


49-49: LGTM: Consistent error logging enhancement

This change follows the same pattern as the previous one, improving error logging by including the cliConfig context. It maintains consistency in error handling throughout the function.


73-73: LGTM: Consistent error logging improvement

This change continues the pattern of enhancing error logging by including the cliConfig context. It ensures uniformity in error handling across different code paths within the function.


260-262: LGTM: Crucial error logging enhancement for Terraform workspace

This change improves error logging for a critical operation - building a Terraform workspace. Including the cliConfig context in this error log is particularly valuable as it can provide essential information for debugging workspace-related issues.


303-305: LGTM: Vital error logging improvement for stack dependencies

These changes enhance error logging for operations involving stack dependencies. Including the cliConfig context in these error logs is crucial as it can provide valuable information for troubleshooting issues related to stack relationships and dependencies, which are often complex and critical for proper stack management.

Also applies to: 363-365


381-383: LGTM: Critical error logging enhancement for Spacelift stack management

These changes improve error logging for crucial Spacelift stack operations, including stack name building and duplicate stack name detection. Including the cliConfig context in these error logs is essential as it can provide vital information for debugging issues related to Spacelift stack naming and uniqueness, which are fundamental to proper Spacelift integration and management.

Also applies to: 400-402


33-33: Overall assessment: Comprehensive enhancement of error logging

The changes in this file consistently improve error logging by including the cliConfig context across various critical operations, including:

  1. CLI configuration initialization
  2. YAML config file processing
  3. Terraform workspace building
  4. Stack dependency management
  5. Spacelift stack naming and uniqueness checks

These enhancements align perfectly with the PR objective to improve error reporting. By providing more context in error logs, these changes will significantly aid in debugging and troubleshooting issues related to Spacelift stack processing, particularly in complex scenarios involving multiple stacks and dependencies.

The systematic nature of these changes demonstrates a thorough approach to improving the overall robustness and maintainability of the codebase.

Also applies to: 49-49, 73-73, 260-262, 303-305, 363-365, 381-383, 400-402

go.mod (3)

98-98: Note new indirect dependencies.

The following new indirect dependencies have been introduced or made explicit:

  • github.com/containerd/errdefs
  • github.com/docker/docker-credential-helpers
  • golang.org/x/sys
  • golang.org/x/term
  • golang.org/x/text

These new indirect dependencies are likely introduced as a result of updating direct dependencies. While they don't require immediate action, it's good to be aware of them for future troubleshooting or dependency management.

Also applies to: 107-107, 236-238


10-12: Approve direct dependency updates with caution.

The following direct dependencies have been updated to newer versions:

  • github.com/bmatcuk/doublestar/v4 v4.6.1 → v4.7.1
  • github.com/charmbracelet/bubbles v0.19.0 → v0.20.0
  • github.com/charmbracelet/bubbletea v1.1.0 → v1.1.1
  • github.com/lrstanley/bubblezone v0.0.0-20240820044643-3964e2111228 → v0.0.0-20240914071701-b48c55a5e78e
  • github.com/open-policy-agent/opa v0.68.0 → v0.69.0

These updates are generally positive, as they often include bug fixes, performance improvements, and new features. However, it's crucial to ensure that these updates don't introduce breaking changes that could affect the project.

Please run the following script to check for any breaking changes or deprecation notices in the changelogs of the updated dependencies:

#!/bin/bash
# Description: Check for breaking changes in updated dependencies

# Function to fetch and display changelog
fetch_changelog() {
    local repo=$1
    local old_version=$2
    local new_version=$3
    echo "Checking $repo for changes between $old_version and $new_version"
    gh repo view $repo --json url -q .url | xargs -I {} gh api "{}/releases" --jq ".[] | select(.tag_name == \"$new_version\" or .tag_name == \"$old_version\") | {tag_name: .tag_name, body: .body}" | jq -r '.tag_name + ":\n" + .body + "\n"'
}

# Check each updated dependency
fetch_changelog "bmatcuk/doublestar" "v4.6.1" "v4.7.1"
fetch_changelog "charmbracelet/bubbles" "v0.19.0" "v0.20.0"
fetch_changelog "charmbracelet/bubbletea" "v1.1.0" "v1.1.1"
fetch_changelog "lrstanley/bubblezone" "v0.0.0-20240820044643-3964e2111228" "v0.0.0-20240914071701-b48c55a5e78e"
fetch_changelog "open-policy-agent/opa" "v0.68.0" "v0.69.0"

# Note: Review the output manually for any breaking changes or deprecation notices

After reviewing the changelogs, please ensure thorough testing is performed, especially in areas of the codebase that heavily rely on these updated dependencies.

Also applies to: 30-30, 33-33


Line range hint 1-258: Overall assessment of dependency updates.

The changes in this go.mod file represent a routine update of dependencies, which is a good practice for maintaining the health and security of the project. Here are some general observations:

  1. The Go module version remains unchanged at 1.23.
  2. Most updates are minor version bumps, which typically indicate bug fixes and non-breaking improvements.
  3. There's a good balance of updates to both direct and indirect dependencies.

Recommendations:

  1. Ensure that the project's CI/CD pipeline runs all tests with these updated dependencies.
  2. Review the project's documentation and make any necessary updates if new features or changes in dependencies affect usage instructions.
  3. Consider setting up automated dependency updates (if not already in place) to streamline this process in the future.

Run the following script to check if the updated dependencies align with the latest available versions:

#!/bin/bash
# Description: Check if updated dependencies are the latest available versions

check_latest_version() {
    local pkg=$1
    local current_version=$2
    echo "Checking latest version for $pkg (current: $current_version)"
    gh api "https://api.github.com/repos/$pkg/releases/latest" --jq '.tag_name'
}

# Check each updated direct dependency
check_latest_version "bmatcuk/doublestar" "v4.7.1"
check_latest_version "charmbracelet/bubbles" "v0.20.0"
check_latest_version "charmbracelet/bubbletea" "v1.1.1"
check_latest_version "lrstanley/bubblezone" "v0.0.0-20240914071701-b48c55a5e78e"
check_latest_version "open-policy-agent/opa" "v0.69.0"

# Note: Compare the output with the versions in go.mod to ensure they are the latest stable releases

This will help ensure that the project is using the most up-to-date and secure versions of its dependencies.

internal/exec/atlantis_generate_repo_config.go (2)

148-148: LGTM. Function signature updated correctly.

The addition of the stack string parameter to the ExecuteAtlantisGenerateRepoConfigAffectedOnly function signature is consistent with the changes described in the PR objectives. This modification allows for more granular control when generating Atlantis repo configurations.


Line range hint 1-687: Overall, the changes look good and achieve the PR objectives.

The modifications to internal/exec/atlantis_generate_repo_config.go successfully implement the --stack flag functionality for the atmos describe affected command. The changes are well-integrated into the existing codebase and maintain consistency with the overall structure of the project.

Key improvements:

  1. Added stack parameter to relevant function signatures.
  2. Updated function calls to include the new stack parameter.
  3. Maintained existing logic while incorporating the new functionality.

These changes enhance the flexibility of the Atlantis repo configuration generation process by allowing filtering based on specific stacks.

internal/exec/describe_stacks.go (3)

318-318: Improved error handling with CLI configuration context

The modification to include cliConfig in the u.LogErrorAndExit call enhances error reporting by providing more context when logging errors. This change aligns with the PR objective of improving error stack trace and is consistent with the updated function signature.


497-497: Consistent error handling improvement

This change mirrors the modification at line 318, maintaining consistency in error handling throughout the function. It enhances the error reporting for Go template processing in component sections by including the CLI configuration context.


Line range hint 1-524: Summary: Consistent improvement in error handling

The changes in this file focus on enhancing error reporting by modifying the u.LogErrorAndExit function calls to include the CLI configuration context. These modifications are consistent throughout the file and align with the PR objective of improving error stack trace handling. The core logic of the ExecuteDescribeStacks function remains unchanged, ensuring that existing functionality is preserved while error reporting is enhanced.

website/docs/integrations/atlantis.mdx (2)

Line range hint 1-38: Excellent improvements to the introduction and "How it Works" section!

The updated introduction clearly emphasizes Atmos's native support for Atlantis, which is crucial for users. The expanded "How it Works" section now provides a comprehensive overview of the three main commands used in the Atlantis integration. This addition significantly enhances the document's usefulness for readers.


676-676: LGTM: Atmos version updated in the GitHub Action example.

The ATMOS_VERSION has been updated to 1.89.0, which keeps the example current with the latest Atmos release.

internal/exec/utils.go (3)

416-416: Improved error logging with CLI configuration context.

This change enhances the error logging by including the cliConfig parameter in the LogErrorAndExit call. This addition provides more context for debugging, making it easier to troubleshoot issues related to duplicate configurations in stack manifests.


494-494: Enhanced error handling for template processing.

These changes improve the error logging for template processing errors in Atmos manifest sections. By including the cliConfig in the LogErrorAndExit calls, you're providing more context for debugging, which is particularly useful for complex template-related issues.

Also applies to: 506-506


Line range hint 1-1004: Overall improvement in error handling and logging.

The changes in this file consistently enhance the error logging mechanism by including the CLI configuration context. This improvement will provide more detailed information during error scenarios, facilitating easier debugging and troubleshooting. The modifications are well-implemented and align with best practices for error handling in Go.

website/docs/cli/commands/describe/describe-affected.mdx (4)

108-108: New flag --stack added to examples.

The addition of the --stack flag example is helpful for users who want to filter results for a specific stack. This aligns well with the new functionality described in the PR objectives.


209-211: New --stack flag description added.

The description of the --stack flag is clear and concise. It provides users with a good understanding of how to use this new feature.


Line range hint 212-213: New --include-dependents flag description added.

The description of the --include-dependents flag is clear and provides an example of usage. This addition is valuable for users who need to understand component dependencies.


Line range hint 214-215: New --include-settings flag description added.

The description of the --include-settings flag is straightforward and explains its purpose well. This addition will be useful for users who need to include the settings section for affected components.

pkg/utils/log_utils.go (4)

61-63: Conditional stack trace printing based on log level improves usability

The addition of conditional stack trace printing ensures that stack traces are only displayed when the log level is set to Trace. This enhancement improves user experience by reducing unnecessary output during error handling.


49-49: Ensure all calls to LogError include the new cliConfig parameter

Similarly, the LogError function now requires the cliConfig parameter. Verify that all usages of LogError in the codebase have been updated accordingly to prevent any issues during error logging.

Run the following command to identify calls that may not include the new parameter:

#!/bin/bash
# Description: Find all calls to 'LogError' that may not have been updated to include 'cliConfig'.

rg --type go 'LogError\(\s*err' -A 1

Line range hint 69-83: Verify that logging level checks cover all intended scenarios

The functions LogTrace, LogDebug, LogInfo, and LogWarning now conditionally log messages based on cliConfig.Logs.Level. Please ensure that the log level comparisons correctly include all intended levels and that there are no logical errors in the conditionals.

Consider running the following command to review the log level usage:

#!/bin/bash
# Description: List all occurrences of log level comparisons to verify correctness.

rg --type go 'cliConfig\.Logs\.Level\s*==\s*LogLevel\w+' -A 2

Suggestion: Simplify log level comparisons to enhance maintainability

To improve readability and maintainability, consider refactoring the log level checks. One approach is to assign numeric values to log levels and compare them using a centralized function. This reduces repetition and minimizes the risk of logical errors.

Apply the following diff as a starting point:

+func shouldLog(currentLevel string, targetLevel string) bool {
+    levels := map[string]int{
+        LogLevelTrace:   4,
+        LogLevelDebug:   3,
+        LogLevelInfo:    2,
+        LogLevelWarning: 1,
+        "":              2, // Default log level is Info
+    }
+    return levels[currentLevel] >= levels[targetLevel]
+}

 // LogTrace logs the provided trace message
-func LogTrace(cliConfig schema.CliConfiguration, message string) {
-    if cliConfig.Logs.Level == LogLevelTrace {
+func LogTrace(cliConfig schema.CliConfiguration, message string) {
+    if shouldLog(cliConfig.Logs.Level, LogLevelTrace) {
         log(cliConfig, color.New(color.FgCyan), message)
     }
 }

 // LogDebug logs the provided debug message
-func LogDebug(cliConfig schema.CliConfiguration, message string) {
-    if cliConfig.Logs.Level == LogLevelTrace ||
-        cliConfig.Logs.Level == LogLevelDebug {
+func LogDebug(cliConfig schema.CliConfiguration, message string) {
+    if shouldLog(cliConfig.Logs.Level, LogLevelDebug) {
         log(cliConfig, color.New(color.FgCyan), message)
     }
 }

 // LogInfo logs the provided info message
-func LogInfo(cliConfig schema.CliConfiguration, message string) {
-    // Info level is default, it's used if not set in `atmos.yaml` in the `logs.level` section
-    if cliConfig.Logs.Level == "" ||
-        cliConfig.Logs.Level == LogLevelTrace ||
-        cliConfig.Logs.Level == LogLevelDebug ||
-        cliConfig.Logs.Level == LogLevelInfo {
+func LogInfo(cliConfig schema.CliConfiguration, message string) {
+    if shouldLog(cliConfig.Logs.Level, LogLevelInfo) {
         log(cliConfig, color.New(color.Reset), message)
     }
 }

 // LogWarning logs the provided warning message
-func LogWarning(cliConfig schema.CliConfiguration, message string) {
-    if cliConfig.Logs.Level == LogLevelTrace ||
-        cliConfig.Logs.Level == LogLevelDebug ||
-        cliConfig.Logs.Level == LogLevelInfo ||
-        cliConfig.Logs.Level == LogLevelWarning {
+func LogWarning(cliConfig schema.CliConfiguration, message string) {
+    if shouldLog(cliConfig.Logs.Level, LogLevelWarning) {
         log(cliConfig, color.New(color.FgYellow), message)
     }
 }

33-35: Ensure all calls to LogErrorAndExit include the new cliConfig parameter

The function LogErrorAndExit now requires a cliConfig parameter of type schema.CliConfiguration. Please verify that all calls to this function throughout the codebase have been updated to include the new parameter to prevent compilation errors.

Run the following command to identify any calls that may not include the new parameter:

cmd/root.go (1)

35-35: Error handling updates enhance context and are acceptable

The modifications to include schema.CliConfiguration{} in u.LogErrorAndExit improve the error handling mechanism. At these points in the code, the CLI configuration may not be initialized or available, so passing an empty configuration object is appropriate.

Also applies to: 40-40, 63-63, 72-72, 112-112

internal/exec/template_funcs_component.go (6)

12-12: Import alias added for configuration constants

The import alias cfg is appropriately added to reference configuration constants throughout the code, improving readability and maintainability.


36-36: Proper error logging when YAML conversion fails

The error is correctly logged using u.LogError when the conversion to YAML fails, ensuring that issues are appropriately reported.


51-53: Initialization of variables for component processing

Variables outputProcessed, componentAbstract, and componentEnabled are initialized with appropriate default values to prepare for component processing.


71-72: Properly skipping processing for disabled or abstract components

The code correctly skips processing Terraform output for components that are disabled or abstract, ensuring resources are not unnecessarily consumed.


73-76: Validating and retrieving the executable command

The code correctly checks for the presence of the executable command (cfg.CommandSectionName) and returns an error if it's not defined, preventing potential runtime errors.


222-224: Proper error logging when YAML conversion fails

When converting outputProcessed to YAML for logging, the error is correctly handled and logged using u.LogError, ensuring that any issues are reported.

internal/exec/describe_affected_utils.go (9)

43-43: **Addition of 'stack' parameter enhances filtering functionality **

The inclusion of the stack string parameter in the ExecuteDescribeAffectedWithTargetRefClone function enables stack-specific filtering, aligning with the PR objectives.


168-168: **Passing 'stack' parameter to 'executeDescribeAffected' **

The stack parameter is correctly passed to the executeDescribeAffected function, ensuring the stack filter is applied during execution.


186-186: **Updated function signature to include 'stack' parameter **

Adding stack string to the ExecuteDescribeAffectedWithTargetRefCheckout function allows for consistent stack filtering across different execution paths.


320-320: **Forwarding 'stack' parameter in 'ExecuteDescribeAffectedWithTargetRefCheckout' **

The stack parameter is properly forwarded to executeDescribeAffected, ensuring proper stack filtering is maintained.


337-337: **Inclusion of 'stack' parameter in 'ExecuteDescribeAffectedWithTargetRepoPath' **

Including the stack string parameter enables stack-specific filtering when using a target repository path.


373-373: **Passing 'stack' parameter to 'executeDescribeAffected' **

The stack parameter is correctly passed to the executeDescribeAffected function within ExecuteDescribeAffectedWithTargetRepoPath.


391-391: **Enhancement of 'executeDescribeAffected' with 'stack' parameter **

Modifying executeDescribeAffected to accept the stack string parameter allows for stack-based filtering during the computation of affected components.


514-514: **Propagating 'stack' parameter to 'findAffected' function **

The stack parameter is successfully forwarded to the findAffected function, ensuring consistent stack filtering.


531-531: **Modification of 'findAffected' to filter by stack **

Adding the stackToFilter string parameter to findAffected enables filtering of affected components based on the specified stack.

main.go Show resolved Hide resolved
pkg/aws/aws_eks_update_kubeconfig.go Show resolved Hide resolved
pkg/validate/validate_stacks_test.go Show resolved Hide resolved
cmd/describe_config.go Show resolved Hide resolved
cmd/pro_unlock.go Show resolved Hide resolved
internal/exec/template_funcs_component.go Show resolved Hide resolved
internal/exec/template_funcs_component.go Show resolved Hide resolved
internal/exec/template_funcs_component.go Show resolved Hide resolved
cmd/cmd_utils.go Show resolved Hide resolved
internal/exec/describe_affected_utils.go Show resolved Hide resolved
Copy link
Contributor

@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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between e8a0351 and f0f4b28.

📒 Files selected for processing (1)
  • internal/exec/describe_affected_utils.go (11 hunks)
🧰 Additional context used
🔇 Additional comments (10)
internal/exec/describe_affected_utils.go (10)

168-168: Ensure 'stack' Parameter is Properly Passed to 'executeDescribeAffected'

The stack variable is now being passed to executeDescribeAffected. Verify that executeDescribeAffected correctly utilizes this parameter to filter stacks as intended.


186-186: Include 'stack' Parameter in Function Signature

The stack parameter has been added to ExecuteDescribeAffectedWithTargetRefCheckout. Ensure that this addition is consistent with other function signatures and that any calls to this function are updated accordingly.


320-320: Passing 'stack' to 'executeDescribeAffected'

Confirm that passing the stack variable to executeDescribeAffected maintains the desired functionality and that stack filtering operates correctly.


337-337: Addition of 'stack' Parameter to 'ExecuteDescribeAffectedWithTargetRepoPath'

The stack parameter has been added to the function signature. Please ensure that this parameter is utilized within the function to filter the affected components based on the specified stack.


373-373: Passing 'stack' to 'executeDescribeAffected'

Verify that the stack parameter is correctly passed and that executeDescribeAffected handles it appropriately to filter stacks.


391-391: Include 'stack' Parameter in 'executeDescribeAffected' Signature

The stack parameter has been added to executeDescribeAffected. Ensure that this function uses the parameter effectively to filter both current and remote stacks.


411-411: Filter Current Stacks Using 'stack' Parameter

In the call to ExecuteDescribeStacks, the stack parameter is used to filter the current stacks. Verify that the filtering logic correctly returns only the stacks matching the specified stack.


447-447: Filter Remote Stacks Using 'stack' Parameter

When retrieving remote stacks with ExecuteDescribeStacks, confirm that the stack parameter effectively filters the stacks as intended.


514-514: Pass 'stack' Parameter to 'findAffected' Function

The stack variable is passed to findAffected as stackToFilter. Ensure that findAffected uses this parameter to correctly filter affected components based on the specified stack.


531-531: Addition of 'stackToFilter' Parameter in 'findAffected'

The parameter stackToFilter string has been added to the findAffected function signature. Confirm that its usage within the function aligns with the intended stack filtering logic.

internal/exec/describe_affected_utils.go Show resolved Hide resolved
@aknysh aknysh merged commit 8c6591b into main Oct 12, 2024
20 of 23 checks passed
@aknysh aknysh deleted the fixes-3 branch October 12, 2024 17:08
Copy link

These changes were released in v1.89.0.

Copy link

These changes were released in v1.89.0.

1 similar comment
Copy link

These changes were released in v1.89.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants