fix issue 6560

Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
Lyndon-Li
2023-08-01 21:37:51 +08:00
parent 3e631ca466
commit 7cf3559fab
4 changed files with 73 additions and 29 deletions
+13
View File
@@ -20,6 +20,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"
)
// Resource gets a Velero GroupResource for a specified resource
@@ -59,6 +60,18 @@ func CustomResources() map[string]typeInfo {
}
}
// CustomResourceKinds returns a list of all custom resources kinds within the Velero
func CustomResourceKinds() sets.String {
kinds := sets.NewString()
resources := CustomResources()
for kind := range resources {
kinds.Insert(kind)
}
return kinds
}
func addKnownTypes(scheme *runtime.Scheme) error {
for _, typeInfo := range CustomResources() {
scheme.AddKnownTypes(SchemeGroupVersion, typeInfo.ItemType, typeInfo.ItemListType)
+13
View File
@@ -20,6 +20,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"
)
// Resource gets a Velero GroupResource for a specified resource
@@ -50,6 +51,18 @@ func CustomResources() map[string]typeInfo {
}
}
// CustomResourceKinds returns a list of all custom resources kinds within the Velero
func CustomResourceKinds() sets.String {
kinds := sets.NewString()
resources := CustomResources()
for kind := range resources {
kinds.Insert(kind)
}
return kinds
}
func addKnownTypes(scheme *runtime.Scheme) error {
for _, typeInfo := range CustomResources() {
scheme.AddKnownTypes(SchemeGroupVersion, typeInfo.ItemType, typeInfo.ItemListType)