yao/registry/README.md
Max 35ab1d1040 Refactor GitHub workflows for Registry Client SDK tests
- Add environment variables for registry initialization in both `pr-test.yml` and `unit-test.yml`.
- Implement a waiting mechanism for the registry service to ensure readiness before executing tests.
- Remove redundant steps for user creation and service restart, streamlining the test setup process.
- Enhance the client code to support auto-discovery of the API prefix, improving flexibility in server URL configuration.
- Introduce comprehensive error handling in client tests to cover various edge cases and improve test coverage.
2026-03-02 21:39:22 +08:00

56 lines
1.5 KiB
Markdown

# registry
Go client SDK for [Yao Registry](https://github.com/YaoApp/registry).
## Usage
```go
import "github.com/yaoapp/yao/registry"
// Only the server URL is required. API prefix is auto-discovered
// via /.well-known/yao-registry on the first call.
c := registry.New("https://registry.yaoagents.com",
registry.WithAuth("user", "pass"), // optional, for push/delete
)
// Push a .yao.zip package
result, err := c.Push("assistants", "@yao", "hello", "1.0.0", zipBytes)
// Pull (by version or dist-tag)
data, digest, err := c.Pull("assistants", "@yao", "hello", "latest")
// Query
pack, err := c.GetPackument("assistants", "@yao", "hello")
ver, err := c.GetVersion("assistants", "@yao", "hello", "1.0.0")
list, err := c.Search("hello", "assistants", 1, 20)
// Dependencies
deps, err := c.GetDependencies("assistants", "@yao", "hello", "1.0.0", true)
// Dist-tags
c.SetTag("assistants", "@yao", "hello", "stable", "1.0.0")
c.DeleteTag("assistants", "@yao", "hello", "stable")
// Delete
c.DeleteVersion("assistants", "@yao", "hello", "1.0.0")
```
## Options
| Option | Description |
|--------|-------------|
| `WithAuth(user, pass)` | Basic Auth for push/delete |
| `WithHTTPClient(hc)` | Custom `*http.Client` |
| `WithTimeout(d)` | HTTP timeout |
## Environment
Tests require a running registry server. Set `YAO_REGISTRY_URL` (default `http://localhost:8080`) and create user `yaoagents`/`yaoagents`.
```bash
# Start registry with test user
REGISTRY_INIT_USER=yaoagents REGISTRY_INIT_PASS=yaoagents registry start
# Run tests
go test ./registry/... -v
```