-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: devenvs #101
Conversation
WalkthroughA 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 Changes
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
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (11)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (2)
🔇 Additional comments (10)
✨ Finishing Touches
🧪 Generate Unit Tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 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
⛔ 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.
# Formance SDK | ||
|
||
## Overview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ 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.
pkg/client/.devcontainer/setup.sh
Outdated
rmdir samples || true | ||
mkdir samples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ 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.
pkg/client/.devcontainer/setup.sh
Outdated
go mod tidy | ||
|
||
# Generate starter usage sample with speakeasy | ||
speakeasy generate usage -s openapi/v2.yaml -l go -o samples/root.go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ 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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (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 clientpkg/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
orshell
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 -->
No description provided.