Skip to content

feat: devenvs #101

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

Merged
merged 1 commit into from
Jul 2, 2025
Merged

feat: devenvs #101

merged 1 commit into from
Jul 2, 2025

Conversation

gfyrag
Copy link
Contributor

@gfyrag gfyrag commented Jun 26, 2025

No description provided.

Copy link

coderabbitai bot commented Jun 26, 2025

Walkthrough

A new Go SDK client was introduced for interacting with the "Formance" service, featuring customizable configuration and security options. Several model structs and their documentation were updated to include an optional Version field. The Earthfile import was parameterized, and the SDK version and user agent were incremented.

Changes

File(s) Change Summary
Earthfile Made the core image import configurable via an argument, defaulting to the main branch.
pkg/client/formance.go Added a new Go SDK client for Formance with configuration, security, and extensibility options.
pkg/client/models/components/trigger.go
pkg/client/models/components/triggerdata.go
pkg/client/models/components/v2trigger.go
pkg/client/models/components/v2triggerdata.go
Added optional Version *string field to Trigger, TriggerData, V2Trigger, V2TriggerData structs and getters.
pkg/client/docs/models/components/trigger.md
pkg/client/docs/models/components/triggerdata.md
pkg/client/docs/models/components/v2trigger.md
pkg/client/docs/models/components/v2triggerdata.md
Documented new optional Version field in Trigger, TriggerData, V2Trigger, V2TriggerData components.
pkg/client/sdk.go Updated SDK version and UserAgent from "0.1.3" to "0.1.4".

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SDK (Formance)
    participant HTTPClient
    participant Orchestration Sub-client

    User->>SDK (Formance): New(opts...)
    SDK (Formance)->>SDK (Formance): Apply options, set config
    SDK (Formance)->>HTTPClient: (optional) Set custom HTTP client
    SDK (Formance)->>SDK (Formance): Set security, retry, timeout
    SDK (Formance)->>Orchestration Sub-client: Initialize with config
    User->>SDK (Formance): Use Orchestration sub-client
Loading

Poem

A hop and a leap, a version anew,
With triggers that know which version is true.
The SDK’s grown, with options galore,
And Earthfile imports are rigid no more!
From 0.1.3 to 0.1.4 we go,
As bunnies code onward, steady and slow.
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e50d864 and 11a1498.

⛔ Files ignored due to path filters (2)
  • pkg/client/.speakeasy/gen.lock is excluded by !**/*.lock, !**/*.lock
  • pkg/client/.speakeasy/gen.yaml is excluded by !**/*.yaml
📒 Files selected for processing (11)
  • Earthfile (1 hunks)
  • pkg/client/docs/models/components/trigger.md (1 hunks)
  • pkg/client/docs/models/components/triggerdata.md (1 hunks)
  • pkg/client/docs/models/components/v2trigger.md (1 hunks)
  • pkg/client/docs/models/components/v2triggerdata.md (1 hunks)
  • pkg/client/formance.go (1 hunks)
  • pkg/client/models/components/trigger.go (2 hunks)
  • pkg/client/models/components/triggerdata.go (2 hunks)
  • pkg/client/models/components/v2trigger.go (2 hunks)
  • pkg/client/models/components/v2triggerdata.go (2 hunks)
  • pkg/client/sdk.go (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • pkg/client/sdk.go
  • pkg/client/docs/models/components/triggerdata.md
  • pkg/client/docs/models/components/v2trigger.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/client/formance.go
  • Earthfile
🔇 Additional comments (10)
pkg/client/docs/models/components/trigger.md (1)

10-10: LGTM! Documentation correctly reflects the new optional Version field.

The addition of the Version field to the documentation is properly formatted and consistent with the existing table structure.

pkg/client/docs/models/components/v2triggerdata.md (1)

10-10: LGTM! Documentation correctly reflects the new optional Version field.

The addition of the Version field to the documentation is properly formatted and maintains consistency with other trigger model documentation.

pkg/client/models/components/trigger.go (2)

13-13: LGTM! Version field properly implemented as optional.

The Version field follows Go best practices using a pointer type with appropriate JSON tags for optional serialization.


46-51: LGTM! GetVersion() method correctly implemented.

The getter method properly handles nil receivers and follows the consistent pattern used by other getter methods in this struct.

pkg/client/models/components/v2trigger.go (2)

13-13: LGTM! Version field implementation is consistent.

The Version field follows the same pattern as the Trigger model with proper typing and JSON tags.


46-51: LGTM! GetVersion() method implementation is consistent.

The getter method implementation matches the pattern used in other trigger models and properly handles edge cases.

pkg/client/models/components/v2triggerdata.go (2)

8-8: LGTM! Version field properly integrated into the struct.

The Version field is correctly positioned and typed, maintaining consistency with other trigger models.


28-33: LGTM! GetVersion() method follows established patterns.

The getter method implementation is consistent with other trigger models and includes proper nil handling.

pkg/client/models/components/triggerdata.go (2)

8-8: Well-structured optional field addition.

The Version field follows the established pattern in the struct using *string for optional fields with the appropriate omitempty JSON tag. This is consistent with other optional fields like Filter and Name.


28-33: Consistent getter method implementation.

The GetVersion() method properly follows the established pattern used by other getter methods in the struct, including the necessary nil-check for the receiver. The implementation is safe and consistent.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in a Comment
  • Commit Unit Tests in branch feat/devenvs

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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this 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

@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 (3)
pkg/client/.devcontainer/README.md (2)

2-2: Fix grammar: use "shut down" as a verb.

"Shutdown" is a noun. When used as a verb, it should be "shut down" (two words).

-> **Remember to shut down a GitHub Codespace when it is not in use!**

12-14: Add language specifiers to code blocks.

The markdown linter correctly identifies that fenced code blocks should specify the language for better syntax highlighting and accessibility.

-```
+```bash
 go run root.go

- +bash
speakeasy generate usage -s openapi/v2.yaml -l go -i {INPUT_OPERATION_ID} -o ./samples


-```
+```bash
speakeasy generate usage -s openapi/v2.yaml -l go -n {INPUT_TAG_NAME} -o ./samples


Also applies to: 22-24, 28-30

</blockquote></details>
<details>
<summary>pkg/client/formance.go (1)</summary><blockquote>

`21-21`: **Fix typo in interface comment.**

There's a spelling error in the comment.


```diff
-// HTTPClient provides an interface for suplying the SDK with a custom HTTP client
+// HTTPClient provides an interface for supplying the SDK with a custom HTTP client
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6761a20 and f67ddab.

⛔ Files ignored due to path filters (1)
  • pkg/client/.devcontainer/devcontainer.json is excluded by !**/*.json
📒 Files selected for processing (5)
  • Earthfile (1 hunks)
  • pkg/client/.devcontainer/README.md (1 hunks)
  • pkg/client/.devcontainer/setup.sh (1 hunks)
  • pkg/client/docs/sdks/formance/README.md (1 hunks)
  • pkg/client/formance.go (1 hunks)
🧰 Additional context used
🪛 LanguageTool
pkg/client/.devcontainer/README.md

[grammar] ~2-~2: The word “shutdown” is a noun. The verb is spelled with a white space.
Context: > **Remember to shutdown a GitHub Codespace when it is not in us...

(NOUN_VERB_CONFUSION)

🪛 markdownlint-cli2 (0.17.2)
pkg/client/.devcontainer/README.md

12-12: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


22-22: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


28-28: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

🔇 Additional comments (4)
Earthfile (1)

3-4: Excellent improvement for build flexibility.

The parameterized import using ARG and $core variable substitution is a great enhancement. This allows overriding the core image version via --build-arg core=<custom-image> while maintaining backward compatibility with the default value.

pkg/client/.devcontainer/setup.sh (1)

4-4: Consider security implications of downloading and executing scripts.

Downloading and executing scripts directly from the internet poses security risks. Consider:

  • Pinning to a specific version/commit hash
  • Verifying checksums
  • Or using package managers when available
#!/bin/bash
# Check if speakeasy is available via package managers
curl -s https://api.github.com/repos/speakeasy-api/speakeasy/releases/latest | jq -r '.tag_name'
pkg/client/formance.go (2)

94-102: Server index validation approach is appropriate.

Using panic for invalid server index configuration is the right approach here, as this represents a programming error during SDK initialization rather than a runtime error that should be handled gracefully.


140-178: Well-designed SDK constructor with comprehensive configuration.

The New function demonstrates excellent SDK design patterns:

  • Functional options pattern for flexibility
  • Sensible defaults with override capability
  • Environment-based security fallback
  • Hook system integration
  • Proper initialization sequence

The security fallback logic (lines 156-161) and default HTTP client setup (lines 164-166) are particularly well-implemented.

Comment on lines 1 to 3
# Formance SDK

## Overview
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add meaningful content to the SDK documentation.

This README appears to be a placeholder with no actual content in the Overview section. Consider adding:

  • Installation instructions
  • Basic usage examples
  • API reference links
  • Configuration options
  • Authentication details
🤖 Prompt for AI Agents
In pkg/client/docs/sdks/formance/README.md at lines 1 to 3, the README currently
only contains a title and an empty Overview section, which lacks useful
information. Enhance this documentation by adding meaningful content such as
installation instructions, basic usage examples, links to the API reference,
configuration options, and authentication details to provide a comprehensive
guide for users of the Formance SDK.

Comment on lines 7 to 8
rmdir samples || true
mkdir samples
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve directory cleanup robustness.

Using rmdir will fail if the samples directory contains files. Use rm -rf for more reliable cleanup.

-rmdir samples || true
-mkdir samples
+rm -rf samples
+mkdir -p samples
🤖 Prompt for AI Agents
In pkg/client/.devcontainer/setup.sh at lines 7 to 8, replace the use of `rmdir
samples || true` with `rm -rf samples` to ensure the samples directory is
removed even if it contains files, making the cleanup more robust before
recreating the directory.

go mod tidy

# Generate starter usage sample with speakeasy
speakeasy generate usage -s openapi/v2.yaml -l go -o samples/root.go
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for critical operations.

The script should verify that required files exist and handle potential failures gracefully.

+# Verify OpenAPI spec exists
+if [ ! -f "openapi/v2.yaml" ]; then
+    echo "Error: openapi/v2.yaml not found"
+    exit 1
+fi
+
 # Generate starter usage sample with speakeasy
-speakeasy generate usage -s openapi/v2.yaml -l go -o samples/root.go
+speakeasy generate usage -s openapi/v2.yaml -l go -o samples/root.go || {
+    echo "Error: Failed to generate usage sample"
+    exit 1
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
speakeasy generate usage -s openapi/v2.yaml -l go -o samples/root.go
# Verify OpenAPI spec exists
if [ ! -f "openapi/v2.yaml" ]; then
echo "Error: openapi/v2.yaml not found"
exit 1
fi
# Generate starter usage sample with speakeasy
speakeasy generate usage -s openapi/v2.yaml -l go -o samples/root.go || {
echo "Error: Failed to generate usage sample"
exit 1
}
🤖 Prompt for AI Agents
In pkg/client/.devcontainer/setup.sh at line 15, the script runs a command
without checking if the required input file exists or if the command succeeds.
Add checks before running the command to verify that the file openapi/v2.yaml
exists, and after running the command, check the exit status. If the file is
missing or the command fails, output an error message and exit the script with a
non-zero status to handle failures gracefully.

cursor[bot]

This comment was marked as outdated.

Copy link

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

🧹 Nitpick comments (3)
pkg/client/formance.go (1)

21-21: Fix typo in comment.

"suplying" should be "supplying".

-// HTTPClient provides an interface for suplying the SDK with a custom HTTP client
+// HTTPClient provides an interface for supplying the SDK with a custom HTTP client
pkg/client/.devcontainer/README.md (2)

2-2: Fix grammar: use "shut down" as a verb.

The word "shutdown" is a noun. When used as a verb, it should be two words.

-> **Remember to shutdown a GitHub Codespace when it is not in use!**
+> **Remember to shut down a GitHub Codespace when it is not in use!**

12-14: Add language specifications to code blocks for better syntax highlighting.

All three code blocks should specify bash or shell as the language.

-```
+```bash
 go run root.go

- +bash
speakeasy generate usage -s openapi/v2.yaml -l go -i {INPUT_OPERATION_ID} -o ./samples


-```
+```bash
speakeasy generate usage -s openapi/v2.yaml -l go -n {INPUT_TAG_NAME} -o ./samples


Also applies to: 22-24, 28-30

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between f67ddab55b380bd986f114642b1552fcb21af34a and e50d864392a98e1678ddec68d4eac4357fb0d678.

</details>

<details>
<summary>⛔ Files ignored due to path filters (1)</summary>

* `pkg/client/.devcontainer/devcontainer.json` is excluded by `!**/*.json`

</details>

<details>
<summary>📒 Files selected for processing (5)</summary>

* `Earthfile` (1 hunks)
* `pkg/client/.devcontainer/README.md` (1 hunks)
* `pkg/client/.devcontainer/setup.sh` (1 hunks)
* `pkg/client/docs/sdks/formance/README.md` (1 hunks)
* `pkg/client/formance.go` (1 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (3)</summary>

* pkg/client/.devcontainer/setup.sh
* pkg/client/docs/sdks/formance/README.md
* Earthfile

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🪛 LanguageTool</summary>

<details>
<summary>pkg/client/.devcontainer/README.md</summary>

[grammar] ~2-~2: The word “shutdown” is a noun. The verb is spelled with a white space.
Context:  > **Remember to shutdown a GitHub Codespace when it is not in us...

(NOUN_VERB_CONFUSION)

</details>

</details>
<details>
<summary>🪛 markdownlint-cli2 (0.17.2)</summary>

<details>
<summary>pkg/client/.devcontainer/README.md</summary>

12-12: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

---

22-22: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

---

28-28: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

</details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (1)</summary>

* GitHub Check: Tests

</details>

<details>
<summary>🔇 Additional comments (3)</summary><blockquote>

<details>
<summary>pkg/client/formance.go (3)</summary>

`26-42`: **LGTM!**

Good set of helper functions for creating pointers to basic types. This is a common pattern in Go SDKs.

---

`73-138`: **Well-designed SDK configuration options.**

The functional options pattern is properly implemented with:
- Good validation in `WithServerIndex` (panics on out-of-bounds)
- Support for both static and templated server URLs
- Flexible security configuration
- Proper timeout and retry configuration support

---

`140-178`: **Well-structured SDK initialization.**

The constructor properly:
- Sets sensible defaults
- Falls back to environment variables for security credentials
- Configures a default HTTP client with 60s timeout
- Initializes hooks and sub-clients in the correct order

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@gfyrag gfyrag merged commit 09fe727 into main Jul 2, 2025
6 of 7 checks passed
@gfyrag gfyrag deleted the feat/devenvs branch July 2, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants