mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-08 14:21:18 +00:00
Add new flag --crds-version of default CRD version to generated
If the Velero CLI can't discover the Kubernetes preferred CRD API version, use the flag --crds-version to determine the CRDs version. Signed-off-by: JenTing Hsiao <jenting.hsiao@suse.com>
This commit is contained in:
committed by
Bridget McErlean
parent
616676edc2
commit
fca2b5c417
@@ -19,8 +19,6 @@ package install
|
||||
import (
|
||||
"time"
|
||||
|
||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -28,7 +26,9 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
"github.com/vmware-tanzu/velero/config/crd/crds"
|
||||
v1crds "github.com/vmware-tanzu/velero/config/crd/v1/crds"
|
||||
v1beta1crds "github.com/vmware-tanzu/velero/config/crd/v1beta1/crds"
|
||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -216,17 +216,26 @@ type VeleroOptions struct {
|
||||
NoDefaultBackupLocation bool
|
||||
CACertData []byte
|
||||
Features []string
|
||||
CRDsVersion string
|
||||
DefaultVolumesToRestic bool
|
||||
}
|
||||
|
||||
func AllCRDs() *unstructured.UnstructuredList {
|
||||
func AllCRDs(perferredAPIVersion string) *unstructured.UnstructuredList {
|
||||
resources := new(unstructured.UnstructuredList)
|
||||
// Set the GVK so that the serialization framework outputs the list properly
|
||||
resources.SetGroupVersionKind(schema.GroupVersionKind{Group: "", Version: "v1", Kind: "List"})
|
||||
|
||||
for _, crd := range crds.CRDs {
|
||||
crd.SetLabels(Labels())
|
||||
appendUnstructured(resources, crd)
|
||||
switch perferredAPIVersion {
|
||||
case "v1beta1":
|
||||
for _, crd := range v1beta1crds.CRDs {
|
||||
crd.SetLabels(Labels())
|
||||
appendUnstructured(resources, crd)
|
||||
}
|
||||
case "v1":
|
||||
for _, crd := range v1crds.CRDs {
|
||||
crd.SetLabels(Labels())
|
||||
appendUnstructured(resources, crd)
|
||||
}
|
||||
}
|
||||
|
||||
return resources
|
||||
@@ -235,7 +244,7 @@ func AllCRDs() *unstructured.UnstructuredList {
|
||||
// AllResources returns a list of all resources necessary to install Velero, in the appropriate order, into a Kubernetes cluster.
|
||||
// Items are unstructured, since there are different data types returned.
|
||||
func AllResources(o *VeleroOptions) *unstructured.UnstructuredList {
|
||||
resources := AllCRDs()
|
||||
resources := AllCRDs(o.CRDsVersion)
|
||||
|
||||
ns := Namespace(o.Namespace)
|
||||
appendUnstructured(resources, ns)
|
||||
|
||||
Reference in New Issue
Block a user