mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #17925 from zexi/specific-methods
fix(apigateway): add GetSpecificMethods to resource manager
This commit is contained in:
@@ -33,6 +33,7 @@ func initContainerRegistry() {
|
||||
cmd := NewK8sResourceCmd(k8s.ContainerRegistries)
|
||||
cmd.List(new(o.RegistryListOptions))
|
||||
cmd.Show(new(o.RegistryGetOptions))
|
||||
cmd.Delete(new(o.RegistryGetOptions))
|
||||
cmd.Create(new(o.RegistryCreateOptions))
|
||||
cmd.Get("images", new(o.RegistryGetImagesOptions))
|
||||
cmd.Get("image-tags", new(o.RegistryGetImageTagsOptions))
|
||||
|
||||
@@ -311,7 +311,7 @@ func (f *ResourceHandlers) getSpecHandler(ctx context.Context, w http.ResponseWr
|
||||
query := req.Query()
|
||||
|
||||
module2, e := modulebase.GetModule(session, req.Spec())
|
||||
if e != nil {
|
||||
if e != nil || module.GetSpecificMethods().Has(req.Spec()) {
|
||||
obj, e := module.GetSpecific(session, req.ResID(), req.Spec(), query)
|
||||
if e != nil {
|
||||
httperrors.GeneralServerError(ctx, w, e)
|
||||
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/httputils"
|
||||
"yunion.io/x/pkg/util/printutils"
|
||||
"yunion.io/x/pkg/util/sets"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -41,6 +42,8 @@ type BaseManager struct {
|
||||
|
||||
columns []string
|
||||
adminColumns []string
|
||||
|
||||
specificMethods sets.String
|
||||
}
|
||||
|
||||
func NewBaseManager(serviceType, endpointType, version string, columns, adminColumns []string) *BaseManager {
|
||||
@@ -49,11 +52,20 @@ func NewBaseManager(serviceType, endpointType, version string, columns, adminCol
|
||||
endpointType: endpointType,
|
||||
version: version,
|
||||
// apiVersion: apiVersion,
|
||||
columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
columns: columns,
|
||||
adminColumns: adminColumns,
|
||||
specificMethods: sets.NewString(),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *BaseManager) GetSpecificMethods() sets.String {
|
||||
return m.specificMethods
|
||||
}
|
||||
|
||||
func (m *BaseManager) SetSpecificMethods(ms ...string) {
|
||||
m.specificMethods = sets.NewString(ms...)
|
||||
}
|
||||
|
||||
func (this *BaseManager) GetColumns(session *mcclient.ClientSession) []string {
|
||||
cols := this.columns
|
||||
if session.HasSystemAdminPrivilege() && len(this.adminColumns) > 0 {
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/printutils"
|
||||
"yunion.io/x/pkg/util/sets"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
@@ -142,6 +143,8 @@ type Manager interface {
|
||||
BatchDeleteInContextWithParam(session *mcclient.ClientSession, idlist []string, query jsonutils.JSONObject, body jsonutils.JSONObject, ctx Manager, ctxid string) []printutils.SubmitResult
|
||||
BatchDeleteInContexts(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject, ctxs []ManagerContext) []printutils.SubmitResult
|
||||
BatchDeleteInContextsWithParam(session *mcclient.ClientSession, idlist []string, query jsonutils.JSONObject, body jsonutils.JSONObject, ctxs []ManagerContext) []printutils.SubmitResult
|
||||
|
||||
GetSpecificMethods() sets.String
|
||||
}
|
||||
|
||||
type IResourceManager interface {
|
||||
|
||||
@@ -44,11 +44,13 @@ type ContainerRegistryManager struct {
|
||||
}
|
||||
|
||||
func NewContainerRegistryManager() *ContainerRegistryManager {
|
||||
return &ContainerRegistryManager{
|
||||
man := &ContainerRegistryManager{
|
||||
ResourceManager: NewResourceManager("container_registry", "container_registries",
|
||||
NewResourceCols("Url", "Type"),
|
||||
NewColumns()),
|
||||
}
|
||||
man.SetSpecificMethods("images")
|
||||
return man
|
||||
}
|
||||
|
||||
func (m *ContainerRegistryManager) UploadImage(s *mcclient.ClientSession, id string, params jsonutils.JSONObject, body io.Reader, size int64) (jsonutils.JSONObject, error) {
|
||||
|
||||
Reference in New Issue
Block a user