Restructure SDK to follow industry standards and remove Fern dependency#18
Open
larisoncarvalho wants to merge 2 commits intoStackGuardian:mainfrom
Conversation
## Major Changes ### Architecture Redesign - Moved from Fern auto-generated structure to industry-standard Go SDK pattern - Eliminated need for git patches (all fixes now built into the code) - Clean separation: api (types) → stackguardian (client) → services (endpoints) ### Key Features - **No patches needed**: Nested workflow group support, optional fields, etc. built-in - **HTTP client with retry**: Exponential backoff with jitter for failed requests - **Clean configuration**: Simple Config struct replacing functional options - **Typed errors**: IsNotFoundError(), IsUnauthorizedError() helpers - **Context support**: All methods accept context.Context - **Better maintainability**: Easy to update when API evolves ### Package Structure - `api` (root): All type definitions from OpenAPI spec - `stackguardian/`: Main client, config, entry point - `services/`: 18 service implementations (organizations, stacks, workflows, etc.) - `internal/`: HTTP client, URL utilities, retry logic ### Nested Workflow Group Support Built-in URL handling for nested groups (e.g., "parent/child") in internal.BuildURL() - No special patches needed - Works transparently across all services ### Updated Components - New Makefile (removed patch dependencies) - Comprehensive README with examples - Example applications (basic + workflow_run) - All 18 services migrated to new pattern ### Migration Path ```go // Old import "github.com/StackGuardian/sg-sdk-go/client" c := client.NewClient(option.WithApiKey(key)) // New import sg "github.com/StackGuardian/sg-sdk-go/stackguardian" config := sg.DefaultConfig() config.APIKey = key client, err := sg.NewClient(config) ``` ### Known Issues - Minor compilation errors in query parameter handling (easily fixable) - Some field name case mismatches in a few services - Detailed in RESTRUCTURE_NOTES.md ### Files Changed - 30+ new files (services, internal utilities, examples) - Updated: README.md, Makefile - Removed dependency: git patches, Fern generation See RESTRUCTURE_NOTES.md for detailed migration guide and remaining work.
## Query Parameter Fixes - Fixed all services to use internal.QueryValues() for proper query encoding - Removed direct field access (request.Filter, etc.) in favor of reflection-based approach - Fixed field name mismatches (FileName → Filename) - Removed invalid Headers field from templates service ## Documentation & Best Practices - Added comprehensive CONTRIBUTING.md with: - Step-by-step guides for common changes - Testing guidelines and examples - Code style rules - PR submission process - Added package documentation (stackguardian/doc.go) with examples - Added Version constant (2.0.0) - Updated README with detailed testing section following AWS SDK v2 patterns ## Testing Infrastructure - Added internal/urlutil_test.go with comprehensive URL building tests - Added stackguardian/client_test.go with config and client tests - Added tests/integration_test.go for integration testing - All tests passing (internal: ✅, stackguardian: ✅) - Example of AWS SDK v2 pattern: caller-defined interfaces for mocking ## Code Quality - ✅ SDK compiles without errors - ✅ No Fern dependencies remaining - ✅ Follows AWS SDK v2 best practices - ✅ Proper error handling patterns - ✅ Context-first function signatures - ✅ Query parameter encoding via reflection ## Removed Issues - Removed unused api imports from stackworkflowrunfacts and workflowrunfacts - Added missing api import to stackguardian/config.go for error types All services now follow industry-standard Go SDK patterns as used by: - AWS SDK v2 - Azure SDK for Go - Stripe Go SDK - Google Cloud Go SDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Major Changes
Architecture Redesign
Key Features
Package Structure
api(root): All type definitions from OpenAPI specstackguardian/: Main client, config, entry pointservices/: 18 service implementations (organizations, stacks, workflows, etc.)internal/: HTTP client, URL utilities, retry logicNested Workflow Group Support
Built-in URL handling for nested groups (e.g., "parent/child") in internal.BuildURL()
Updated Components
Migration Path
Known Issues
Files Changed
See RESTRUCTURE_NOTES.md for detailed migration guide and remaining work.