Revert "fix about wrong strategy ref type" (#1903)

This reverts commit 73d6e3013e.

<!-- Thank you for making a contribution! Here are some tips for you:
- Start the PR title with the [label] of Cozystack component:
- For system components: [platform], [system], [linstor], [cilium],
[kube-ovn], [dashboard], [cluster-api], etc.
- For managed apps: [apps], [tenant], [kubernetes], [postgres],
[virtual-machine] etc.
- For development and maintenance: [tests], [ci], [docs], [maintenance].
- If it's a work in progress, consider creating this PR as a draft.
- Don't hesistate to ask for opinion and review in the community chats,
even if it's still a draft.
- Add the label `backport` if it's a bugfix that needs to be backported
to a previous version.
-->

## What this PR does
Revert wrong type change according review
[request](https://github.com/cozystack/cozystack/pull/1873#discussion_r2717088708)

### Release note

<!--  Write a release note:
- Explain what has changed internally and for users.
- Start with the same [label] as in the PR title
- Follow the guidelines at
https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md.
-->

```release-note
[fix strategyRef type in backups]
```

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

* **Breaking Changes**
* Backup strategy references have been updated from cluster-scoped to
namespace-scoped references. This change enables better namespace
isolation and control. Update your backup configurations to reference
strategies within the appropriate namespace.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Andrei Kvapil authored and GitHub committed 2026-01-22 23:16:14 +01:00
commit cde5873617
5 files changed
+15 -53

No files matched your search

+1 -2
View File
@@ -59,8 +59,7 @@ 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.
// This references a cluster-scoped resource, so it does not include a namespace.
StrategyRef TypedClusterObjectReference `json:"strategyRef"`
StrategyRef corev1.TypedLocalObjectReference `json:"strategyRef"`
// TakenAt is the time at which the backup was taken (as reported by the
// driver). It may differ slightly from metadata.creationTimestamp.
+2 -39
View File
@@ -6,6 +6,7 @@
package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
@@ -53,8 +54,7 @@ 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).
// This references a cluster-scoped resource, so it does not include a namespace.
StrategyRef TypedClusterObjectReference `json:"strategyRef"`
StrategyRef corev1.TypedLocalObjectReference `json:"strategyRef"`
// Application specifies which application types this strategy applies to.
Application ApplicationSelector `json:"application"`
@@ -66,43 +66,6 @@ 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 backupsv1alpha1.TypedClusterObjectReference
StrategyRef corev1.TypedLocalObjectReference
Parameters map[string]string
}
@@ -113,7 +113,7 @@ func TestResolveBackupClass(t *testing.T) {
applicationRef corev1.TypedLocalObjectReference
backupClassName string
wantErr bool
expectedStrategyRef *backupsv1alpha1.TypedClusterObjectReference
expectedStrategyRef *corev1.TypedLocalObjectReference
expectedParams map[string]string
}{
{
@@ -125,7 +125,7 @@ func TestResolveBackupClass(t *testing.T) {
Spec: backupsv1alpha1.BackupClassSpec{
Strategies: []backupsv1alpha1.BackupClassStrategy{
{
StrategyRef: backupsv1alpha1.TypedClusterObjectReference{
StrategyRef: corev1.TypedLocalObjectReference{
APIGroup: stringPtr("strategy.backups.cozystack.io"),
Kind: "Velero",
Name: "velero-strategy-vm",
@@ -138,7 +138,7 @@ func TestResolveBackupClass(t *testing.T) {
},
},
{
StrategyRef: backupsv1alpha1.TypedClusterObjectReference{
StrategyRef: corev1.TypedLocalObjectReference{
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: &backupsv1alpha1.TypedClusterObjectReference{
expectedStrategyRef: &corev1.TypedLocalObjectReference{
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: backupsv1alpha1.TypedClusterObjectReference{
StrategyRef: corev1.TypedLocalObjectReference{
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: &backupsv1alpha1.TypedClusterObjectReference{
expectedStrategyRef: &corev1.TypedLocalObjectReference{
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: backupsv1alpha1.TypedClusterObjectReference{
StrategyRef: corev1.TypedLocalObjectReference{
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: &backupsv1alpha1.TypedClusterObjectReference{
expectedStrategyRef: &corev1.TypedLocalObjectReference{
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: backupsv1alpha1.TypedClusterObjectReference{
StrategyRef: corev1.TypedLocalObjectReference{
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: backupsv1alpha1.TypedClusterObjectReference{
StrategyRef: corev1.TypedLocalObjectReference{
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: backupsv1alpha1.TypedClusterObjectReference{
StrategyRef: corev1.TypedLocalObjectReference{
APIGroup: stringPtr("strategy.backups.cozystack.io"),
Kind: "Velero",
Name: "velero-strategy",