CRD and CLI changes

Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
This commit is contained in:
Anshul Ahuja
2023-06-28 12:15:55 +05:30
parent ee22125f9c
commit 9ea54c81fe
5 changed files with 62 additions and 23 deletions
@@ -359,6 +359,27 @@ spec:
from backup.
nullable: true
type: boolean
resourceModifier:
description: ResourceModifier specifies the reference to JSON resource
patches that should be applied to resources before restoration.
properties:
apiGroup:
description: 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.
type: string
kind:
description: Kind is the type of resource being referenced
type: string
name:
description: Name is the name of resource being referenced
type: string
required:
- kind
- name
type: object
x-kubernetes-map-type: atomic
restorePVs:
description: RestorePVs specifies whether to restore all included
PVs from snapshot
File diff suppressed because one or more lines are too long
+5
View File
@@ -17,6 +17,7 @@ limitations under the License.
package v1
import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
@@ -117,6 +118,10 @@ type RestoreSpec struct {
// The default value is 1 hour.
// +optional
ItemOperationTimeout metav1.Duration `json:"itemOperationTimeout,omitempty"`
// ResourceModifier specifies the reference to JSON resource patches that should be applied to resources before restoration.
// +optional
ResourceModifier *v1.TypedLocalObjectReference `json:"resourceModifier,omitempty"`
}
// RestoreHooks contains custom behaviors that should be executed during or post restore.
@@ -1317,6 +1317,11 @@ func (in *RestoreSpec) DeepCopyInto(out *RestoreSpec) {
}
in.Hooks.DeepCopyInto(&out.Hooks)
out.ItemOperationTimeout = in.ItemOperationTimeout
if in.ResourceModifier != nil {
in, out := &in.ResourceModifier, &out.ResourceModifier
*out = new(corev1.TypedLocalObjectReference)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RestoreSpec.
+30 -22
View File
@@ -25,9 +25,7 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
"github.com/vmware-tanzu/velero/internal/resourcemodifiers"
api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
"github.com/vmware-tanzu/velero/pkg/client"
"github.com/vmware-tanzu/velero/pkg/cmd"
@@ -36,6 +34,9 @@ import (
veleroclient "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned"
v1 "github.com/vmware-tanzu/velero/pkg/generated/informers/externalversions/velero/v1"
"github.com/vmware-tanzu/velero/pkg/util/boolptr"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
)
func NewCreateCommand(f client.Factory, use string) *cobra.Command {
@@ -74,25 +75,26 @@ func NewCreateCommand(f client.Factory, use string) *cobra.Command {
}
type CreateOptions struct {
BackupName string
ScheduleName string
RestoreName string
RestoreVolumes flag.OptionalBool
PreserveNodePorts flag.OptionalBool
Labels flag.Map
IncludeNamespaces flag.StringArray
ExcludeNamespaces flag.StringArray
ExistingResourcePolicy string
IncludeResources flag.StringArray
ExcludeResources flag.StringArray
StatusIncludeResources flag.StringArray
StatusExcludeResources flag.StringArray
NamespaceMappings flag.Map
Selector flag.LabelSelector
IncludeClusterResources flag.OptionalBool
Wait bool
AllowPartiallyFailed flag.OptionalBool
ItemOperationTimeout time.Duration
BackupName string
ScheduleName string
RestoreName string
RestoreVolumes flag.OptionalBool
PreserveNodePorts flag.OptionalBool
Labels flag.Map
IncludeNamespaces flag.StringArray
ExcludeNamespaces flag.StringArray
ExistingResourcePolicy string
IncludeResources flag.StringArray
ExcludeResources flag.StringArray
StatusIncludeResources flag.StringArray
StatusExcludeResources flag.StringArray
NamespaceMappings flag.Map
Selector flag.LabelSelector
IncludeClusterResources flag.OptionalBool
Wait bool
AllowPartiallyFailed flag.OptionalBool
ItemOperationTimeout time.Duration
ResourceModifierConfigMap string
client veleroclient.Interface
}
@@ -139,6 +141,8 @@ func (o *CreateOptions) BindFlags(flags *pflag.FlagSet) {
f.NoOptDefVal = cmd.TRUE
flags.BoolVarP(&o.Wait, "wait", "w", o.Wait, "Wait for the operation to complete.")
flags.StringVar(&o.ResourceModifierConfigMap, "resource-modifier-configmap", "", "Reference to the resource modifier configmap that restore will use")
}
func (o *CreateOptions) Complete(args []string, f client.Factory) error {
@@ -282,6 +286,10 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
RestorePVs: o.RestoreVolumes.Value,
PreserveNodePorts: o.PreserveNodePorts.Value,
IncludeClusterResources: o.IncludeClusterResources.Value,
ResourceModifier: &corev1.TypedLocalObjectReference{
Kind: resourcemodifiers.ConfigmapRefType,
Name: o.ResourceModifierConfigMap,
},
ItemOperationTimeout: metav1.Duration{
Duration: o.ItemOperationTimeout,
},