8000 Update `!store` YAML function by aknysh · Pull Request #1185 · cloudposse/atmos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update !store YAML function #1185

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

Closed
wants to merge 4 commits into from
Closed

Update !store YAML function #1185

wants to merge 4 commits into from

Conversation

aknysh
Copy link
Member
@aknysh aknysh commented Apr 4, 2025

what

  • Update !store YAML function
  • Update tests
  • Update docs

why

  • In the !store YAML function, when the user configured the function with 4 parameters (<store>, <component>, <stack>, <key>), the component and stack parameters were swapped, causing the function to fail to retrieve a value from the store. (!store with 3 parameters, <store>, <component>, <key>, worked without issues)

Summary by CodeRabbit

  • Chores
    • Upgraded the Atmos version in configuration files and updated several dependency versions for improved compatibility.
  • Refactor
    • Streamlined error reporting and adjusted the ordering of parameters in internal processing.
  • Tests
    • Revised test inputs to match the new parameter order and enhanced logging for clearer results.
  • Documentation
    • Corrected a function name and made minor formatting adjustments in workflow and integration guides for improved clarity.

@aknysh aknysh added the minor New features that do not break anything label Apr 4, 2025
@aknysh aknysh requested review from osterman and mcalhoun April 4, 2025 01:53
@aknysh aknysh self-assigned this Apr 4, 2025
@aknysh aknysh requested a review from a team as a code owner April 4, 2025 01:53
@github-actions github-actions bot added the size/s label Apr 4, 2025
Copy link
mergify bot commented Apr 4, 2025

Important

Cloud Posse Engineering Team Review Required

This pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes.

To expedite this process, reach out to us on Slack in the #pr-reviews channel.

@mergify mergify bot added the needs-cloudposse Needs Cloud Posse assistance label Apr 4, 2025
Copy link
Contributor
coderabbitai bot commented Apr 4, 2025
📝 Walkthrough

Walkthrough

This pull request updates the Atmos tool version and several dependency versions across multiple files. The update changes the ATMOS_VERSION from 1.169.0 to 1.170.0 in both the Dockerfile and GitHub Actions workflow. Additionally, dependency revisions are made in go.mod. Modifications in internal execution functions and corresponding tests adjust error handling by replacing a utility call with log.Fatal and reorder parameter assignments. Minor documentation updates correct a function name and adjust YAML formatting and titles.

Changes

File(s) Change Summary
examples/quick-start-advanced/Dockerfile, website/docs/integrations/atlantis.mdx Updated ATMOS_VERSION from 1.169.0 to 1.170.0 in Docker and CI configuration files.
go.mod Upgraded dependency versions for AWS SDK, terraform-config-inspect, gRPC, and related libraries.
internal/exec/yaml_func_store.go, internal/exec/yaml_func_store_test.go Replaced u.LogErrorAndExit with log.Fatal for error handling and reordered parameter assignments in the function and tests.
website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx, website/docs/core-concepts/workflows/workflows.mdx Corrected the function name from !temolate to !terraform.output and applied minor YAML formatting and title updates.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant Process as processTagStore
    participant Logger as log.Fatal

    Caller->>Process: Invoke processTagStore with input
    alt Successful Processing
        Process-->>Caller: Return processed parameters
    else Error Occurs
        Process->>Logger: log.Fatal(error)
        Logger-->>Caller: Terminate execution
    end
Loading

Possibly related PRs

Suggested labels

patch

Suggested reviewers

  • osterman
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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 or @auto-summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @auto-title anywhere in the PR title to generate the title automatically.

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: 3

🧹 Nitpick comments (1)
website/docs/core-concepts/workflows/workflows.mdx (1)

116-121: Consistent Empty List Formatting
The modifications in the code snippets (using steps: [] instead of a spaced version) improve consistency in YAML formatting. Although functionally equivalent, this tiny nitpick makes the documentation cleaner.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d8158d and 7620f5c.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (7)
  • examples/quick-start-advanced/Dockerfile (1 hunks)
  • go.mod (4 hunks)
  • internal/exec/yaml_func_store.go (5 hunks)
  • internal/exec/yaml_func_store_test.go (2 hunks)
  • website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx (1 hunks)
  • website/docs/core-concepts/workflows/workflows.mdx (2 hunks)
  • website/docs/integrations/atlantis.mdx (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx (2)
Learnt from: aknysh
PR: cloudposse/atmos#810
File: website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx:0-0
Timestamp: 2025-04-03T12:14:28.671Z
Learning: In the `terraform.output.mdx` documentation file (`website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx`), the cache invalidation and cache scope behavior for the `!terraform.output` function are already described.
Learnt from: aknysh
PR: cloudposse/atmos#810
File: website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx:104-110
Timestamp: 2025-04-03T12:14:28.671Z
Learning: In the documentation for `!terraform.output`, warnings about template variable availability are already covered in other sections, so no need to suggest adding them here.
examples/quick-start-advanced/Dockerfile (2)
Learnt from: aknysh
PR: cloudposse/atmos#775
File: examples/quick-start-advanced/Dockerfile:9-9
Timestamp: 2025-04-03T12:14:28.671Z
Learning: It is acceptable to set `ARG ATMOS_VERSION` to a future version like `1.105.0` in `examples/quick-start-advanced/Dockerfile` if that will be the next release.
Learnt from: osterman
PR: cloudposse/atmos#801
File: examples/quick-start-advanced/Dockerfile:9-9
Timestamp: 2025-04-03T12:14:28.671Z
Learning: When updating the `ATMOS_VERSION` in Dockerfiles, the team prefers to pin to the next future version when the PR merges, even if the version is not yet released.
🪛 GitHub Check: golangci-lint
internal/exec/yaml_func_store.go

[failure] 26-26:
deep-exit: calls to log.Fatal only in main() or init() functions


[failure] 71-71:
deep-exit: calls to log.Fatal only in main() or init() functions


[failure] 80-80:
deep-exit: calls to log.Fatal only in main() or init() functions

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Summary
🔇 Additional comments (16)
website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx (1)

98-100: Clarify Parameter Ordering in Documentation
The added line at 98 clearly explains that when calling !terraform.output with three parameters, the stack must be specified as the second argument. This clarification improves the overall usability of the documentation.

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

675-677: Update Atmos Version in GitHub Actions Workflow
The update of the ATMOS_VERSION environment variable from 1.169.0 to 1.170.0 ensures consistency with other parts of the repository. This change is straightforward and aligns with our versioning strategy.

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

9-9: Align Dockerfile with Updated Atmos Version
Updating the ARG ATMOS_VERSION to 1.170.0 maintains consistency with the GitHub Actions workflow configuration and other parts of the codebase. Good job keeping everything in sync!

website/docs/core-concepts/workflows/workflows.mdx (1)

374-378: Refine Workflow Failure Handling Section Title
The updated section title from “Workflow Failure Handling and Resume” to “Workflow Failure Handling and Resuming” is a nice grammatical improvement that enhances clarity.

go.mod (2)

14-17: Bump AWS SDK and Other Dependency Versions in go.mod
The updates for dependencies such as github.com/aws/aws-sdk-go-v2/config, credentials, ssm, and sts as well as minor version bumps for other libraries (including the update for terraform-config-inspect and google.golang.org/grpc) are clear maintenance updates. They appear to align with the latest available versions and ensure compatibility with the current Atmos CLI tool release.


121-123: Update SSO Dependencies
The updates to github.com/aws/aws-sdk-go-v2/service/sso and ssooidc reflect the latest minor improvements. It’s a good practice to keep these dependencies current.

internal/exec/yaml_func_store_test.go (8)

11-13: Imports section is properly organized.

Clean import organization with standard libraries first, followed by third-party packages.


58-58: Parameter order correctly updated to fix the issue.

The input parameter order has been fixed from redis dev vpc cidr to redis vpc dev cidr, which properly aligns with the PR objective to fix the swapped component and stack parameters.


64-65: Fixed parameter order in test case with defaults.

Correctly updated to use the new parameter order (vpc staging cidr instead of staging vpc cidr).


70-71: Consistent parameter ordering in test with single quotes.

Parameter ordering properly maintained across all test cases.


76-77: Parameter order fixed in test with double quotes.

Consistent update to the parameter ordering pattern.


82-85: Error case test inputs and expected values properly updated.

Both the input string and expected error message now correctly reflect the new parameter ordering.


88-91: Fixed parameter order in extra parameters test case.

Input and expected error message have been updated to match the new parameter order.


97-97: Added useful logging to improve test diagnostics.

The additional logging statement is helpful for debugging and understanding test results.

internal/exec/yaml_func_store.go (2)

7-7: Import alias for log package improves readability.

Good practice to use an alias for the charmbracelet log package to avoid confusion with the standard log package.


58-60: Fixed parameter order to correctly assign component and stack.

This is the key fix for the reported issue - now component is correctly assigned before stack when four parameters are provided. The previous implementation had these swapped, causing retrieval failures.

Copy link
codecov bot commented Apr 4, 2025

Codecov Report

Attention: Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 29.50%. Comparing base (7d8158d) to head (7620f5c).

Files with missing lines Patch % Lines
internal/exec/yaml_func_store.go 40.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1185   +/-   ##
=======================================
  Coverage   29.50%   29.50%           
=======================================
  Files         196      196           
  Lines       22549    22549           
=======================================
  Hits         6652     6652           
  Misses      14880    14880           
  Partials     1017     1017           
Flag Coverage Δ
unittests 29.50% <40.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mcalhoun
Copy link
Member
mcalhoun commented Apr 4, 2025

I have chosen to update the docs in #1186 instead of changing code. I think it makes more sense to order the parameters the way the code currently does it from least specific -> more specific (store -> stack -> component -> key).

@mcalhoun mcalhoun closed this Apr 4, 2025
@mergify mergify bot removed the needs-cloudposse Needs Cloud Posse assistance label Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor New features that do not break anything
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0