From 38a7707ce32f9063987fc18050b7f1fbd293a6c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=88=9A=20=20=28=E6=88=90=E9=83=BD=29?= Date: Wed, 8 Mar 2023 10:29:30 +0800 Subject: [PATCH] Unify pkg/install deployment args array. (#5961) Signed-off-by: yanggang --- pkg/install/deployment.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/install/deployment.go b/pkg/install/deployment.go index 1c16e4cb3e..11740c5f54 100644 --- a/pkg/install/deployment.go +++ b/pkg/install/deployment.go @@ -172,6 +172,18 @@ func Deployment(namespace string, opts ...podTemplateOption) *appsv1.Deployment args = append(args, fmt.Sprintf("--uploader-type=%s", c.uploaderType)) } + if c.restoreOnly { + args = append(args, "--restore-only") + } + + if c.defaultRepoMaintenanceFrequency > 0 { + args = append(args, fmt.Sprintf("--default-repo-maintain-frequency=%v", c.defaultRepoMaintenanceFrequency)) + } + + if c.garbageCollectionFrequency > 0 { + args = append(args, fmt.Sprintf("--garbage-collection-frequency=%v", c.garbageCollectionFrequency)) + } + deployment := &appsv1.Deployment{ ObjectMeta: objectMeta(namespace, "velero"), TypeMeta: metav1.TypeMeta{ @@ -291,18 +303,6 @@ func Deployment(namespace string, opts ...podTemplateOption) *appsv1.Deployment deployment.Spec.Template.Spec.Containers[0].Env = append(deployment.Spec.Template.Spec.Containers[0].Env, c.envVars...) - if c.restoreOnly { - deployment.Spec.Template.Spec.Containers[0].Args = append(deployment.Spec.Template.Spec.Containers[0].Args, "--restore-only") - } - - if c.defaultRepoMaintenanceFrequency > 0 { - deployment.Spec.Template.Spec.Containers[0].Args = append(deployment.Spec.Template.Spec.Containers[0].Args, fmt.Sprintf("--default-repo-maintain-frequency=%v", c.defaultRepoMaintenanceFrequency)) - } - - if c.garbageCollectionFrequency > 0 { - deployment.Spec.Template.Spec.Containers[0].Args = append(deployment.Spec.Template.Spec.Containers[0].Args, fmt.Sprintf("--garbage-collection-frequency=%v", c.garbageCollectionFrequency)) - } - if len(c.plugins) > 0 { for _, image := range c.plugins { container := *builder.ForPluginContainer(image, pullPolicy).Result()