Skip to content

Conversation

@larisoncarvalho
Copy link
Collaborator

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

// 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.

## 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
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