package entity import ( "time" ) // Registry OCI Registry 领域实体 type Registry struct { ID string WorkspaceID string OwnerID string Visibility string Name string URL string Description string Username string Password string Insecure bool // 是否跳过 TLS 验证 CreatedAt time.Time UpdatedAt time.Time } // NewRegistry 创建新 Registry func NewRegistry(name, url string) *Registry { now := time.Now() return &Registry{ Name: name, URL: url, Visibility: "private", CreatedAt: now, UpdatedAt: now, } } // Update 更新 Registry 信息 func (r *Registry) Update(name, url, description string) { if name != "" { r.Name = name } if url != "" { r.URL = url } r.Description = description r.UpdatedAt = time.Now() } // SetCredentials 设置认证凭据 func (r *Registry) SetCredentials(username, password string) { r.Username = username r.Password = password r.UpdatedAt = time.Now() } // Validate 验证 Registry 配置 func (r *Registry) Validate() error { if r.Name == "" { return ErrInvalidRegistryName } if r.URL == "" { return ErrInvalidRegistryURL } if r.Visibility == "" { r.Visibility = "private" } return nil }