-
Notifications
You must be signed in to change notification settings - Fork 3
Implement bcloud CLI with YAML configuration and key-as-ref_id pattern #22
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
base: main
Are you sure you want to change the base?
Conversation
- Add cmd/bcloud directory structure with main.go and command files - Add cobra and viper dependencies for CLI framework - Implement bcloud <refId> <verb> command structure - Support YAML credential configuration in ~/.bcloud/credentials.yaml - Use YAML key as ref_id by default with optional explicit override - Implement YAML output format for all commands - Add core commands: create, terminate, list, get, types - Integrate with existing CloudClient interfaces and provider implementations - Support LambdaLabs provider with extensible factory pattern Co-Authored-By: Alec Fong <[email protected]>
Co-Authored-By: Alec Fong <[email protected]>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
I don't like how we are doing factory, config etc can we do something closer to this design?
|
lets test this method as well |
…eedback - Replace custom ProviderCredential with existing CloudCredential interface - Add DefaultLocationProvider interface for CLI-specific functionality - Update factory pattern to work with CloudCredential interface - Maintain key-as-ref_id pattern with improved architecture - All lint checks and tests pass Co-Authored-By: Alec Fong <[email protected]>
} | ||
cred := factory() | ||
|
||
if _, hasRefID := m["ref_id"]; !hasRefID { |
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.
lets write a test that says all registered providers must have a ref_id in struct
cmd/bcloud/config/providers.go
Outdated
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.
we don't need to recreate the credentials here this exactly logic lies in internal/lambda/v1... lets just register them. this file can probably removed and registration can happen in config.go
cmd/bcloud/providers/factory.go
Outdated
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.
i think this file can be deleted
…K implementations - Delete cmd/bcloud/providers/factory.go as requested - Remove cmd/bcloud/config/providers.go and move registration to config.go - Use existing LambdaLabsCredential and NebiusCredential from SDK with wrapper types - Add CLI-specific DefaultLocationProvider interface for default_location field - Add test ensuring all registered providers have RefID field in struct - Update all command files to work with simplified credential system - All lint checks and tests pass Co-Authored-By: Alec Fong <[email protected]>
…sing - Test LoadConfig with various scenarios: success, missing files, invalid YAML - Test credential parsing edge cases: missing provider, invalid provider, unknown provider - Test key-as-ref_id pattern with both explicit and implicit ref_id values - Test JSON/YAML marshaling and unmarshaling for credential entries - Test provider registry functionality and wrapper type validation - Test error handling for malformed configurations and nil values - Test default settings application and file path resolution - All tests use isolated temp directories and proper cleanup - Fixed lint issues: error checking for os.Setenv/os.Chdir, file permissions, formatting Co-Authored-By: Alec Fong <[email protected]>
cmd/bcloud/config/config.go
Outdated
var providerRegistry = map[string]func() v1.CloudCredential{} | ||
|
||
var providerIDToRegistryKey = map[string]string{ | ||
"lambda-labs": "lambdalabs", |
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.
these should be the same (provider id and registry key) strings lets refactor
cmd/bcloud/config/config.go
Outdated
|
||
if _, hasRefID := m["ref_id"]; !hasRefID { | ||
m["ref_id"] = yamlKey | ||
if _, hasRefID := m["RefID"]; !hasRefID { |
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.
lets go in to the provider credential and use tags to change them to ref_id api_key etc.
- Add JSON tags to LambdaLabsCredential and NebiusCredential structs - Use lowercase field names: ref_id, api_key, service_account_key, project_id - Unify Lambda Labs provider ID from 'lambda-labs' to 'lambdalabs' to match registry key - Remove providerIDToRegistryKey mapping from config.go (no longer needed) - Add provider constants (ProviderLambdaLabs, ProviderNebius) to eliminate goconst lint warnings - Update all tests to use new lowercase field names and provider constants - All tests pass and lint checks pass Co-Authored-By: Alec Fong <[email protected]>
Add comprehensive testing and implement GitHub feedback for CLI credential system
Summary
This PR adds extensive testing to the
bcloud
CLI configuration system and implements feedback to standardize credential field naming and provider IDs. The changes ensure robust error handling and edge case coverage for credential loading while maintaining backward compatibility patterns.Key Changes:
LoadConfig()
function covering success cases, fallback scenarios, and error conditionsLambdaLabsCredential
,NebiusCredential
) with standardized lowercase field names"lambda-labs"
to"lambdalabs"
to match registry keyReview & Testing Checklist for Human
Critical Items (3):
bcloud
commands work against live Lambda Labs API"lambda-labs"
provider ID~/.bcloud/credentials.yaml
and./bcloud.yaml
fallback works correctly with real config filesImportant Items (2):
Diagram
Notes
Testing Coverage Added:
Breaking Changes:
"lambda-labs"
to"lambdalabs"
Session Info: