Files
ocdp-go/backend/internal/adapter/input/http/dto/instance_dto.go
Ivan087 985369d40f fix: resolve deployment API errors and enable E2E deployment flow
Backend fixes:
- instance_dto: add Version field with Normalize() to support both 'version'
  and 'tag' field names from frontend
- instance_handler: add version empty validation before creating instance
- authz.go: fix unused variable compilation error
- registry_repository: fix GetByID/GetByName to use correct DB schema
  (add workspace_id, owner_id, is_shared fields); decrypt password
  gracefully when encryption key mismatches instead of returning error

Frontend:
- charts/page: add Template and Storage dropdown selectors to Deploy Modal

Testing:
- add e2e_test.py: 5-step Playwright E2E test (admin login → create
  workspace → create user → user login → deploy chart)
- add tasks/lesson.md: document 4 bug root causes and fixes
- add tasks/todo.md: track implementation progress
- add PLAN_E2E_DEPLOYMENT.md: comprehensive implementation plan

Verification: confirmed deployment creates instance with status=deployed,
chart downloads from Harbor OCI to /tmp/charts/, Helm release deploys to K8s
2026-04-16 18:39:23 +08:00

139 lines
5.2 KiB
Go

package dto
// CreateInstanceRequest 创建实例请求
type CreateInstanceRequest struct {
Name string `json:"name" binding:"required"`
Namespace string `json:"namespace" binding:"required"`
RegistryID string `json:"registryId" binding:"required"`
RegistryIDAlt string `json:"registry_id"`
Repository string `json:"repository" binding:"required"`
Tag string `json:"tag"`
Version string `json:"version"`
Description string `json:"description"`
Values map[string]interface{} `json:"values"`
ValuesYAML string `json:"valuesYaml"`
}
// UpdateInstanceRequest 更新实例请求
type UpdateInstanceRequest struct {
Version string `json:"version"`
Description string `json:"description"`
Values map[string]interface{} `json:"values"`
ValuesYAML string `json:"valuesYaml"`
}
// Normalize 将多种命名风格的字段合并到统一字段
func (r *CreateInstanceRequest) Normalize() {
if r.RegistryID == "" {
r.RegistryID = r.RegistryIDAlt
}
// Support both "tag" and "version" field names from frontend
if r.Tag == "" {
r.Tag = r.Version
}
}
// RollbackInstanceRequest 回滚实例请求
type RollbackInstanceRequest struct {
Revision int `json:"revision" binding:"required"`
Wait bool `json:"wait"`
Timeout int `json:"timeout"` // seconds
}
// DeleteInstanceRequest 删除实例请求
type DeleteInstanceRequest struct {
KeepHistory bool `json:"keepHistory"`
Timeout int `json:"timeout"` // seconds
}
// InstanceResponse 实例响应
type InstanceResponse struct {
ID string `json:"id"`
ClusterID string `json:"clusterId"`
Name string `json:"name"`
Namespace string `json:"namespace"`
RegistryID string `json:"registryId"`
Repository string `json:"repository"`
Chart string `json:"chart"`
Version string `json:"version"`
Description string `json:"description"`
Status string `json:"status"`
StatusReason string `json:"statusReason,omitempty"`
LastOperation string `json:"lastOperation,omitempty"`
LastError string `json:"lastError,omitempty"`
Revision int `json:"revision"`
Values map[string]interface{} `json:"values,omitempty"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
// InstanceStatusResponse 实例状态响应
type InstanceStatusResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Namespace string `json:"namespace"`
Status string `json:"status"`
Revision int `json:"revision"`
Chart string `json:"chart"`
Version string `json:"version"`
UpdatedAt string `json:"updatedAt"`
}
// ReleaseHistoryResponse Release 历史响应
type ReleaseHistoryResponse struct {
Revision int `json:"revision"`
Updated string `json:"updated"`
Status string `json:"status"`
Chart string `json:"chart"`
AppVersion string `json:"appVersion"`
Description string `json:"description"`
}
// InstanceListResponse 实例列表响应
type InstanceListResponse struct {
Instances []*InstanceResponse `json:"instances"`
Total int `json:"total"`
}
// InstanceEntryPortResponse Service 端口响应
type InstanceEntryPortResponse struct {
Name string `json:"name,omitempty"`
Protocol string `json:"protocol"`
Port int32 `json:"port"`
TargetPort string `json:"targetPort,omitempty"`
NodePort int32 `json:"nodePort,omitempty"`
}
// InstanceEntryPathResponse Ingress path 响应
type InstanceEntryPathResponse struct {
Path string `json:"path"`
ServiceName string `json:"serviceName,omitempty"`
ServicePort string `json:"servicePort,omitempty"`
}
// InstanceEntryHostResponse Ingress host 响应
type InstanceEntryHostResponse struct {
Host string `json:"host"`
Paths []InstanceEntryPathResponse `json:"paths,omitempty"`
}
// InstanceEntryTLSResponse Ingress TLS 响应
type InstanceEntryTLSResponse struct {
Hosts []string `json:"hosts,omitempty"`
SecretName string `json:"secretName,omitempty"`
}
// InstanceEntryResponse 实例入口响应
type InstanceEntryResponse struct {
Kind string `json:"kind"`
Name string `json:"name"`
Namespace string `json:"namespace"`
Type string `json:"type,omitempty"`
ClusterIP string `json:"clusterIP,omitempty"`
ExternalIPs []string `json:"externalIPs,omitempty"`
LoadBalancerIngress []string `json:"loadBalancerIngress,omitempty"`
Ports []InstanceEntryPortResponse `json:"ports,omitempty"`
Hosts []InstanceEntryHostResponse `json:"hosts,omitempty"`
TLS []InstanceEntryTLSResponse `json:"tls,omitempty"`
}