|
| 1 | +# API Sync-Agent SDK |
| 2 | + |
| 3 | +This directory contains the syncagent's SDK: re-usable Go API types and generated functions for |
| 4 | +integrating the syncagent into 3rd-party applications. |
| 5 | + |
| 6 | +## Usage |
| 7 | + |
| 8 | +To install the SDK, simply `go get` it: |
| 9 | + |
| 10 | +```bash |
| 11 | +go get github.com/kcp-dev/api-syncagent/sdk@latest |
| 12 | +``` |
| 13 | + |
| 14 | +and then in your code import the desired types: |
| 15 | + |
| 16 | +```go |
| 17 | +package main |
| 18 | + |
| 19 | +import apisyncagentv1alpha1 "github.com/kcp-dev/api-syncagent/sdk/apis/syncagent/v1alpha1" |
| 20 | + |
| 21 | +func createPublishedResource() *apisyncagentv1alpha1.PublishedResource { |
| 22 | + pr := &apisyncagentv1alpha1.PublishedResource{} |
| 23 | + pr.Name = "publish-crontabs" |
| 24 | + pr.Namespace = "default" |
| 25 | + |
| 26 | + return pr |
| 27 | +} |
| 28 | +``` |
| 29 | + |
| 30 | +## SDK Design |
| 31 | + |
| 32 | +The SDK comes as a standalone Go module: `github.com/kcp-dev/api-syncagent/sdk` |
| 33 | + |
| 34 | +The module reduces the transitive dependencies that consumers have to worry about when they want to |
| 35 | +integrate the syncagent. To that end, the SDK is meant to provide the broadest possible |
| 36 | +compatibility: dependencies are on the *lowest* version that is usable by the syncagent. This drift |
| 37 | +between the syncagent's dependencies and those of the SDK is an intended feature of the SDK. |
| 38 | + |
| 39 | +The actual dependency versions used in the syncagent binaries are controlled exclusively via the |
| 40 | +root directory's `go.mod`. Specifically, the SDK is not meant to propagate security fixes to |
| 41 | +consumers and force them to upgrade when it might be inconvenient to them. |
| 42 | + |
| 43 | +## Development Guidelines |
| 44 | + |
| 45 | +* Do not update the `go` constraint in the `go.mod` file manually, let `go mod tidy` update it only |
| 46 | + when necessary. The `go` constraint has no influence on what Go version the syncagent is actually |
| 47 | + built with. It can, however, cause serious annoyances for downstream consumers. |
| 48 | +* Likewise, only bump dependencies to keep the SDK compatible with the main module. |
0 commit comments