Add parameter "uploader-type" to velero server (#5212)

This commit adds the parameter "uploader-type" to velero server, add exposes the
setting via "velero install" in CLI.

fixes #5062

Signed-off-by: Daniel Jiang <jiangd@vmware.com>

Signed-off-by: Daniel Jiang <jiangd@vmware.com>
This commit is contained in:
Daniel Jiang
2022-08-16 13:50:28 +08:00
committed by GitHub
parent 71e4430840
commit 4e25f59dc1
8 changed files with 95 additions and 5 deletions
+11 -1
View File
@@ -44,6 +44,7 @@ type podTemplateConfig struct {
plugins []string
features []string
defaultVolumesToRestic bool
uploaderType string
}
func WithImage(image string) podTemplateOption {
@@ -83,7 +84,6 @@ func WithEnvFromSecretKey(varName, secret, key string) podTemplateOption {
func WithSecret(secretPresent bool) podTemplateOption {
return func(c *podTemplateConfig) {
c.withSecret = secretPresent
}
}
@@ -123,6 +123,12 @@ func WithFeatures(features []string) podTemplateOption {
}
}
func WithUploaderType(t string) podTemplateOption {
return func(c *podTemplateConfig) {
c.uploaderType = t
}
}
func WithDefaultVolumesToRestic() podTemplateOption {
return func(c *podTemplateConfig) {
c.defaultVolumesToRestic = true
@@ -155,6 +161,10 @@ func Deployment(namespace string, opts ...podTemplateOption) *appsv1.Deployment
args = append(args, "--default-volumes-to-restic=true")
}
if len(c.uploaderType) > 0 {
args = append(args, fmt.Sprintf("--uploader-type=%s", c.uploaderType))
}
deployment := &appsv1.Deployment{
ObjectMeta: objectMeta(namespace, "velero"),
TypeMeta: metav1.TypeMeta{
+4
View File
@@ -57,4 +57,8 @@ func TestDeployment(t *testing.T) {
deploy = Deployment("velero", WithFeatures([]string{"EnableCSI", "foo", "bar", "baz"}))
assert.Len(t, deploy.Spec.Template.Spec.Containers[0].Args, 2)
assert.Equal(t, "--features=EnableCSI,foo,bar,baz", deploy.Spec.Template.Spec.Containers[0].Args[1])
deploy = Deployment("velero", WithUploaderType("kopia"))
assert.Len(t, deploy.Spec.Template.Spec.Containers[0].Args, 2)
assert.Equal(t, "--uploader-type=kopia", deploy.Spec.Template.Spec.Containers[0].Args[1])
}
+2
View File
@@ -232,6 +232,7 @@ type VeleroOptions struct {
CACertData []byte
Features []string
DefaultVolumesToRestic bool
UploaderType string
}
func AllCRDs() *unstructured.UnstructuredList {
@@ -287,6 +288,7 @@ func AllResources(o *VeleroOptions) *unstructured.UnstructuredList {
WithSecret(secretPresent),
WithDefaultResticMaintenanceFrequency(o.DefaultResticMaintenanceFrequency),
WithGarbageCollectionFrequency(o.GarbageCollectionFrequency),
WithUploaderType(o.UploaderType),
}
if len(o.Features) > 0 {