fix
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
This commit is contained in:
parent
8755497869
commit
73d6e3013e
5 changed files with 53 additions and 15 deletions
|
|
@ -59,7 +59,8 @@ type BackupSpec struct {
|
|||
|
||||
// StrategyRef refers to the driver-specific BackupStrategy that was used
|
||||
// to create this backup. This allows the driver to later perform restores.
|
||||
StrategyRef corev1.TypedLocalObjectReference `json:"strategyRef"`
|
||||
// This references a cluster-scoped resource, so it does not include a namespace.
|
||||
StrategyRef TypedClusterObjectReference `json:"strategyRef"`
|
||||
|
||||
// TakenAt is the time at which the backup was taken (as reported by the
|
||||
// driver). It may differ slightly from metadata.creationTimestamp.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
package v1alpha1
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
|
@ -54,7 +53,8 @@ type BackupClassSpec struct {
|
|||
// BackupClassStrategy defines a backup strategy for a specific application type.
|
||||
type BackupClassStrategy struct {
|
||||
// StrategyRef references the driver-specific BackupStrategy (e.g., Velero).
|
||||
StrategyRef corev1.TypedLocalObjectReference `json:"strategyRef"`
|
||||
// This references a cluster-scoped resource, so it does not include a namespace.
|
||||
StrategyRef TypedClusterObjectReference `json:"strategyRef"`
|
||||
|
||||
// Application specifies which application types this strategy applies to.
|
||||
Application ApplicationSelector `json:"application"`
|
||||
|
|
@ -66,6 +66,43 @@ type BackupClassStrategy struct {
|
|||
Parameters map[string]string `json:"parameters,omitempty"`
|
||||
}
|
||||
|
||||
// TypedClusterObjectReference contains enough information to let you locate a
|
||||
// cluster-scoped typed resource. It does not include a namespace because
|
||||
// cluster-scoped resources do not have namespaces.
|
||||
type TypedClusterObjectReference struct {
|
||||
// APIGroup is the group for the resource being referenced.
|
||||
// If APIGroup is not specified, the specified Kind must be in the core API group.
|
||||
// For any other third-party types, APIGroup is required.
|
||||
// +optional
|
||||
APIGroup *string `json:"apiGroup,omitempty"`
|
||||
|
||||
// Kind is the type of resource being referenced.
|
||||
Kind string `json:"kind"`
|
||||
|
||||
// Name is the name of resource being referenced.
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *TypedClusterObjectReference) DeepCopyInto(out *TypedClusterObjectReference) {
|
||||
*out = *in
|
||||
if in.APIGroup != nil {
|
||||
in, out := &in.APIGroup, &out.APIGroup
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TypedClusterObjectReference.
|
||||
func (in *TypedClusterObjectReference) DeepCopy() *TypedClusterObjectReference {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(TypedClusterObjectReference)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// ApplicationSelector specifies which application types a strategy applies to.
|
||||
type ApplicationSelector struct {
|
||||
// APIGroup is the API group of the application.
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ func NormalizeApplicationRef(ref corev1.TypedLocalObjectReference) corev1.TypedL
|
|||
// ResolvedBackupConfig contains the resolved strategy and storage configuration
|
||||
// from a BackupClass.
|
||||
type ResolvedBackupConfig struct {
|
||||
StrategyRef corev1.TypedLocalObjectReference
|
||||
StrategyRef backupsv1alpha1.TypedClusterObjectReference
|
||||
Parameters map[string]string
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ func TestResolveBackupClass(t *testing.T) {
|
|||
applicationRef corev1.TypedLocalObjectReference
|
||||
backupClassName string
|
||||
wantErr bool
|
||||
expectedStrategyRef *corev1.TypedLocalObjectReference
|
||||
expectedStrategyRef *backupsv1alpha1.TypedClusterObjectReference
|
||||
expectedParams map[string]string
|
||||
}{
|
||||
{
|
||||
|
|
@ -125,7 +125,7 @@ func TestResolveBackupClass(t *testing.T) {
|
|||
Spec: backupsv1alpha1.BackupClassSpec{
|
||||
Strategies: []backupsv1alpha1.BackupClassStrategy{
|
||||
{
|
||||
StrategyRef: corev1.TypedLocalObjectReference{
|
||||
StrategyRef: backupsv1alpha1.TypedClusterObjectReference{
|
||||
APIGroup: stringPtr("strategy.backups.cozystack.io"),
|
||||
Kind: "Velero",
|
||||
Name: "velero-strategy-vm",
|
||||
|
|
@ -138,7 +138,7 @@ func TestResolveBackupClass(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
StrategyRef: corev1.TypedLocalObjectReference{
|
||||
StrategyRef: backupsv1alpha1.TypedClusterObjectReference{
|
||||
APIGroup: stringPtr("strategy.backups.cozystack.io"),
|
||||
Kind: "Velero",
|
||||
Name: "velero-strategy-mysql",
|
||||
|
|
@ -159,7 +159,7 @@ func TestResolveBackupClass(t *testing.T) {
|
|||
},
|
||||
backupClassName: "velero",
|
||||
wantErr: false,
|
||||
expectedStrategyRef: &corev1.TypedLocalObjectReference{
|
||||
expectedStrategyRef: &backupsv1alpha1.TypedClusterObjectReference{
|
||||
APIGroup: stringPtr("strategy.backups.cozystack.io"),
|
||||
Kind: "Velero",
|
||||
Name: "velero-strategy-vm",
|
||||
|
|
@ -177,7 +177,7 @@ func TestResolveBackupClass(t *testing.T) {
|
|||
Spec: backupsv1alpha1.BackupClassSpec{
|
||||
Strategies: []backupsv1alpha1.BackupClassStrategy{
|
||||
{
|
||||
StrategyRef: corev1.TypedLocalObjectReference{
|
||||
StrategyRef: backupsv1alpha1.TypedClusterObjectReference{
|
||||
APIGroup: stringPtr("strategy.backups.cozystack.io"),
|
||||
Kind: "Velero",
|
||||
Name: "velero-strategy-mysql",
|
||||
|
|
@ -200,7 +200,7 @@ func TestResolveBackupClass(t *testing.T) {
|
|||
},
|
||||
backupClassName: "velero",
|
||||
wantErr: false,
|
||||
expectedStrategyRef: &corev1.TypedLocalObjectReference{
|
||||
expectedStrategyRef: &backupsv1alpha1.TypedClusterObjectReference{
|
||||
APIGroup: stringPtr("strategy.backups.cozystack.io"),
|
||||
Kind: "Velero",
|
||||
Name: "velero-strategy-mysql",
|
||||
|
|
@ -218,7 +218,7 @@ func TestResolveBackupClass(t *testing.T) {
|
|||
Spec: backupsv1alpha1.BackupClassSpec{
|
||||
Strategies: []backupsv1alpha1.BackupClassStrategy{
|
||||
{
|
||||
StrategyRef: corev1.TypedLocalObjectReference{
|
||||
StrategyRef: backupsv1alpha1.TypedClusterObjectReference{
|
||||
APIGroup: stringPtr("strategy.backups.cozystack.io"),
|
||||
Kind: "Velero",
|
||||
Name: "velero-strategy-vm",
|
||||
|
|
@ -240,7 +240,7 @@ func TestResolveBackupClass(t *testing.T) {
|
|||
},
|
||||
backupClassName: "velero",
|
||||
wantErr: false,
|
||||
expectedStrategyRef: &corev1.TypedLocalObjectReference{
|
||||
expectedStrategyRef: &backupsv1alpha1.TypedClusterObjectReference{
|
||||
APIGroup: stringPtr("strategy.backups.cozystack.io"),
|
||||
Kind: "Velero",
|
||||
Name: "velero-strategy-vm",
|
||||
|
|
@ -275,7 +275,7 @@ func TestResolveBackupClass(t *testing.T) {
|
|||
Spec: backupsv1alpha1.BackupClassSpec{
|
||||
Strategies: []backupsv1alpha1.BackupClassStrategy{
|
||||
{
|
||||
StrategyRef: corev1.TypedLocalObjectReference{
|
||||
StrategyRef: backupsv1alpha1.TypedClusterObjectReference{
|
||||
APIGroup: stringPtr("strategy.backups.cozystack.io"),
|
||||
Kind: "Velero",
|
||||
Name: "velero-strategy-vm",
|
||||
|
|
@ -303,7 +303,7 @@ func TestResolveBackupClass(t *testing.T) {
|
|||
Spec: backupsv1alpha1.BackupClassSpec{
|
||||
Strategies: []backupsv1alpha1.BackupClassStrategy{
|
||||
{
|
||||
StrategyRef: corev1.TypedLocalObjectReference{
|
||||
StrategyRef: backupsv1alpha1.TypedClusterObjectReference{
|
||||
APIGroup: stringPtr("strategy.backups.cozystack.io"),
|
||||
Kind: "Velero",
|
||||
Name: "velero-strategy-vm",
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ func TestCreateVeleroBackup_TemplateContext(t *testing.T) {
|
|||
|
||||
// Create ResolvedBackupConfig with parameters
|
||||
resolved := &ResolvedBackupConfig{
|
||||
StrategyRef: corev1.TypedLocalObjectReference{
|
||||
StrategyRef: backupsv1alpha1.TypedClusterObjectReference{
|
||||
APIGroup: stringPtr("strategy.backups.cozystack.io"),
|
||||
Kind: "Velero",
|
||||
Name: "velero-strategy",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue