Skip to content

Commit

Permalink
Unify pkg/install deployment args array. (#5961)
Browse files Browse the repository at this point in the history
Signed-off-by: yanggang <[email protected]>
  • Loading branch information
杨刚 (成都) authored Mar 8, 2023
1 parent 2dab344 commit 38a7707
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions pkg/install/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 38a7707

Please sign in to comment.