No description
Implemented dynamic token authentication using existing RetrieveToken pattern: ## Authentication Enhancements: - **UsernamePasswordProvider**: Implements existing `POST /api/v1/login` flow - **Token Caching**: 1-hour cache with thread-safe refresh logic - **NewClientWithCredentials()**: Convenience constructor for username/password auth - **Dual Auth Support**: Both static token and dynamic username/password flows ## Key Features: - **Exact API Match**: Mirrors existing `client/client.go RetrieveToken()` implementation - **Thread Safety**: Concurrent token refresh with mutex protection - **Caching Strategy**: Reduces login calls, configurable expiry - **Error Handling**: Structured login failures with context - **Token Invalidation**: Manual cache clearing for token refresh ## Implementation Details: ```go // Static token (existing) client := client.NewClient(baseURL, client.WithAuthProvider(client.NewStaticTokenProvider(token))) // Username/password (new - matches existing pattern) client := client.NewClientWithCredentials(baseURL, username, password) ``` ## Testing: - **Comprehensive Auth Tests**: Login success/failure, caching, expiry - **Mock Server Tests**: httptest-based token flow validation - **Concurrent Safety**: Token refresh under concurrent access - **Updated Examples**: Support both auth methods ## Backward Compatibility: - Existing StaticTokenProvider unchanged - All existing APIs maintain same signatures - Example updated to support both auth methods via environment variables This matches the existing prototype's authentication exactly while adding production features like caching and thread safety. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| .claude | ||
| api | ||
| client | ||
| cmd | ||
| sdk | ||
| .gitignore | ||
| config.yaml.example | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| main.go | ||
| Makefile | ||
| oapi-codegen.yaml | ||
| plan.md | ||
| project.md | ||
| README.md | ||
Edge Connect CLI
A command-line interface for managing Edge Connect applications and their instances.
Installation
go install
Configuration
The CLI can be configured using a configuration file or environment variables. The default configuration file location is $HOME/.edge-connect.yaml.
You can also specify a different configuration file using the --config flag.
Configuration File Format
Create a YAML file with the following structure:
base_url: "https://api.edge-connect.example.com"
username: "your-username"
password: "your-password"
Environment Variables
You can also use environment variables to configure the CLI:
EDGE_CONNECT_BASE_URL: Base URL for the Edge Connect APIEDGE_CONNECT_USERNAME: Username for authenticationEDGE_CONNECT_PASSWORD: Password for authentication
Usage
Managing Applications
Create a new application:
edge-connect app create --org myorg --name myapp --version 1.0.0 --region us-west
Show application details:
edge-connect app show --org myorg --name myapp --version 1.0.0 --region us-west
List applications:
edge-connect app list --org myorg --region us-west
Delete an application:
edge-connect app delete --org myorg --name myapp --version 1.0.0 --region us-west
Managing Application Instances
Create a new application instance:
edge-connect instance create \
--org myorg \
--name myinstance \
--cloudlet mycloudlet \
--cloudlet-org cloudletorg \
--region us-west \
--app myapp \
--version 1.0.0 \
--flavor myflavor
Show instance details:
edge-connect instance show \
--org myorg \
--name myinstance \
--cloudlet mycloudlet \
--cloudlet-org cloudletorg \
--region us-west
List instances:
edge-connect instance list \
--org myorg \
--cloudlet mycloudlet \
--cloudlet-org cloudletorg \
--region us-west
Delete an instance:
edge-connect instance delete \
--org myorg \
--name myinstance \
--cloudlet mycloudlet \
--cloudlet-org cloudletorg \
--region us-west
Global Flags
--config: Config file (default is $HOME/.edge-connect.yaml)--base-url: Base URL for the Edge Connect API--username: Username for authentication--password: Password for authentication