ap: refactor deployment apis to provider+id-based model#209
Conversation
894ea1c to
c612482
Compare
internal/client/client.go
Outdated
| if err != nil { | ||
| return nil, err | ||
| // DeployServer deploys a server with configuration. | ||
| func (c *Client) DeployServer(name, version string, config map[string]string, preferRemote bool, provider string) (*DeploymentResponse, error) { |
There was a problem hiding this comment.
while you're at it here, can we remove the prefereRemote?
There was a problem hiding this comment.
later we should think about adding a similar arg that would tell us whether the user prefers OCI, Github source, npx/pypi, remote, etc. (basically different package types a server can have)
internal/client/client.go
Outdated
| func (c *Client) DeployAgent(name, version string, config map[string]string, runtimeTarget string) (*DeploymentResponse, error) { | ||
| func (c *Client) DeployAgent(name, version string, config map[string]string, provider string) (*DeploymentResponse, error) { | ||
| if provider == "" { | ||
| provider = "docker" |
There was a problem hiding this comment.
could you define an enum for the providers
| DefaultKubernetesProviderID = "kubernetes-default" | ||
| ) | ||
|
|
||
| var errBuiltinProviderReadOnly = errors.New("builtin providers are read-only") |
There was a problem hiding this comment.
What is the purpose of this? What does read-only refer to?
| if err != nil { | ||
| return nil, huma.Error400BadRequest("Invalid version encoding", err) | ||
| if adapter, ok := extensions.ResolveDeploymentAdapter(deployment.Provider); ok { | ||
| err = adapter.Undeploy(ctx, deployment) |
There was a problem hiding this comment.
can we rename this "Undeploy" to "Remove"?
| return &struct{}{}, nil | ||
| } | ||
|
|
||
| if deployment.Provider == "docker" || deployment.Provider == "kubernetes" { |
There was a problem hiding this comment.
could we do this check early on?
There was a problem hiding this comment.
I mean before we resolve for deployment adapters
| provider, err := adapter.CreateProvider(ctx, &input.Body) | ||
| if err != nil { | ||
| if errors.Is(err, errBuiltinProviderReadOnly) { | ||
| return nil, huma.Error400BadRequest("Provider is read-only") |
There was a problem hiding this comment.
what's the concept of "read-only"?
pkg/models/deployment.go
Outdated
| Runtime string `json:"runtime"` // "local" or "kubernetes" | ||
| IsExternal bool `json:"isExternal"` // true if not managed by registry | ||
| ID string `json:"id"` | ||
| ServerName string `json:"serverName"` // resource name (legacy field name retained for compatibility) |
There was a problem hiding this comment.
can we remove the ServerName is we aren't using it anymore?
pkg/models/deployment.go
Outdated
| Version string `json:"version"` | ||
| Provider string `json:"provider"` // "docker", "kubernetes", "gcp", "aws" |
There was a problem hiding this comment.
| Version string `json:"version"` | |
| Provider string `json:"provider"` // "docker", "kubernetes", "gcp", "aws" | |
| Provider string `json:"provider"` // "docker", "kubernetes" |
pkg/models/deployment.go
Outdated
| type DeploymentFilter struct { | ||
| Runtime *string // "local" or "kubernetes" | ||
| ResourceType *string // "mcp" or "agent" | ||
| Provider *string // docker, kubernetes, gcp, aws |
There was a problem hiding this comment.
| Provider *string // docker, kubernetes, gcp, aws | |
| Provider *string // docker, kubernetes |
pkg/models/provider.go
Outdated
| type Provider struct { | ||
| ID string `json:"id"` | ||
| Name string `json:"name"` | ||
| Platform string `json:"platform"` // local, kubernetes, gcp, aws |
There was a problem hiding this comment.
| Platform string `json:"platform"` // local, kubernetes, gcp, aws | |
| Platform string `json:"platform"` // local, kubernetes |
|
|
||
| func mapProviderToBackend(provider string) string { | ||
| if provider == "kubernetes" { | ||
| return "kubernetes" |
There was a problem hiding this comment.
is there a way we could ahe these as consts as we're referring to them in a lot of places
7cc723e to
c922bf9
Compare
| arctl agent deploy my-agent --version latest | ||
| arctl agent deploy my-agent --version 1.2.3 | ||
| arctl agent deploy my-agent --version latest --runtime kubernetes`, | ||
| arctl agent deploy my-agent --version latest --provider-id kubernetes-default`, |
There was a problem hiding this comment.
can't this just be 'kubernetes' instead of 'kubernetes-default'?
| if runtime == "" { | ||
| runtime = "local" | ||
| if providerID == "" { | ||
| providerID = "local" |
There was a problem hiding this comment.
is local docker or is provider local and then platform is docker? (we'll need to make sure we document these terms)
| Runtime string `json:"runtime"` // "local" or "kubernetes" | ||
| IsExternal bool `json:"isExternal"` // true if not managed by registry | ||
| ID string `json:"id"` | ||
| ServerName string `json:"serverName"` // resource name (legacy field name retained for compatibility) |
There was a problem hiding this comment.
can we remove this ServerName?
…y-dev#209) <!-- Thanks for opening a PR! Please delete any sections that don't apply. --> # Description <!-- A concise explanation of the change. You may include: - **Motivation:** why this change is needed - **What changed:** key implementation details - **Related issues:** e.g., `Fixes agentregistry-dev#123` --> The deployments API had mixed identity models (name/version vs ID), outdated update semantics, and duplicated client/server code paths. This refactor aligns deployments on a single provider-based, ID-first model and removes legacy flows. # Change Type <!-- Select one or more of the following by including the corresponding slash-command: ``` /kind breaking_change /kind bump /kind cleanup /kind design /kind deprecation /kind documentation /kind feature /kind fix /kind flake /kind install ``` --> /kind breaking_change /kind cleanup /kind design # Changelog <!-- Provide the exact line to appear in release notes for the chosen changelog type. If no, just write "NONE" in the release-note block below. If yes, a release note is required: --> ```release-note refactor deployment apis to provider+id-based model ```
Description
The deployments API had mixed identity models (name/version vs ID), outdated update semantics, and duplicated client/server code paths. This refactor aligns deployments on a single provider-based, ID-first model and removes legacy flows.
Change Type
/kind breaking_change
/kind cleanup
/kind design
Changelog