Skip to content

Commit

Permalink
Make pkg/install/Deployment podTemplateOptions bool functions accept …
Browse files Browse the repository at this point in the history
…bool param

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
  • Loading branch information
kaovilai committed Jul 12, 2024
1 parent c827fd0 commit bd2008c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
20 changes: 10 additions & 10 deletions pkg/install/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ func WithSecret(secretPresent bool) podTemplateOption {
}
}

func WithRestoreOnly() podTemplateOption {
func WithRestoreOnly(b bool) podTemplateOption {
return func(c *podTemplateConfig) {
c.restoreOnly = true
c.restoreOnly = b
}
}

Expand Down Expand Up @@ -143,21 +143,21 @@ func WithUploaderType(t string) podTemplateOption {
}
}

func WithDefaultVolumesToFsBackup() podTemplateOption {
func WithDefaultVolumesToFsBackup(b bool) podTemplateOption {

Check warning on line 146 in pkg/install/deployment.go

View check run for this annotation

Codecov / codecov/patch

pkg/install/deployment.go#L146

Added line #L146 was not covered by tests
return func(c *podTemplateConfig) {
c.defaultVolumesToFsBackup = true
c.defaultVolumesToFsBackup = b

Check warning on line 148 in pkg/install/deployment.go

View check run for this annotation

Codecov / codecov/patch

pkg/install/deployment.go#L148

Added line #L148 was not covered by tests
}
}

func WithDefaultSnapshotMoveData() podTemplateOption {
func WithDefaultSnapshotMoveData(b bool) podTemplateOption {

Check warning on line 152 in pkg/install/deployment.go

View check run for this annotation

Codecov / codecov/patch

pkg/install/deployment.go#L152

Added line #L152 was not covered by tests
return func(c *podTemplateConfig) {
c.defaultSnapshotMoveData = true
c.defaultSnapshotMoveData = b

Check warning on line 154 in pkg/install/deployment.go

View check run for this annotation

Codecov / codecov/patch

pkg/install/deployment.go#L154

Added line #L154 was not covered by tests
}
}

func WithDisableInformerCache() podTemplateOption {
func WithDisableInformerCache(b bool) podTemplateOption {
return func(c *podTemplateConfig) {
c.disableInformerCache = true
c.disableInformerCache = b
}
}

Expand All @@ -167,9 +167,9 @@ func WithServiceAccountName(sa string) podTemplateOption {
}
}

func WithPrivilegedNodeAgent() podTemplateOption {
func WithPrivilegedNodeAgent(b bool) podTemplateOption {

Check warning on line 170 in pkg/install/deployment.go

View check run for this annotation

Codecov / codecov/patch

pkg/install/deployment.go#L170

Added line #L170 was not covered by tests
return func(c *podTemplateConfig) {
c.privilegedNodeAgent = true
c.privilegedNodeAgent = b

Check warning on line 172 in pkg/install/deployment.go

View check run for this annotation

Codecov / codecov/patch

pkg/install/deployment.go#L172

Added line #L172 was not covered by tests
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/install/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestDeployment(t *testing.T) {

assert.Equal(t, "velero", deploy.ObjectMeta.Namespace)

deploy = Deployment("velero", WithRestoreOnly())
deploy = Deployment("velero", WithRestoreOnly(true))
assert.Equal(t, "--restore-only", deploy.Spec.Template.Spec.Containers[0].Args[1])

deploy = Deployment("velero", WithEnvFromSecretKey("my-var", "my-secret", "my-key"))
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestDeployment(t *testing.T) {
deploy = Deployment("velero", WithServiceAccountName("test-sa"))
assert.Equal(t, "test-sa", deploy.Spec.Template.Spec.ServiceAccountName)

deploy = Deployment("velero", WithDisableInformerCache())
deploy = Deployment("velero", WithDisableInformerCache(true))
assert.Len(t, deploy.Spec.Template.Spec.Containers[0].Args, 2)
assert.Equal(t, "--disable-informer-cache=true", deploy.Spec.Template.Spec.Containers[0].Args[1])

Expand Down
10 changes: 5 additions & 5 deletions pkg/install/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,23 +358,23 @@ func AllResources(o *VeleroOptions) *unstructured.UnstructuredList {
}

if o.RestoreOnly {
deployOpts = append(deployOpts, WithRestoreOnly())
deployOpts = append(deployOpts, WithRestoreOnly(true))

Check warning on line 361 in pkg/install/resources.go

View check run for this annotation

Codecov / codecov/patch

pkg/install/resources.go#L361

Added line #L361 was not covered by tests
}

if len(o.Plugins) > 0 {
deployOpts = append(deployOpts, WithPlugins(o.Plugins))
}

if o.DefaultVolumesToFsBackup {
deployOpts = append(deployOpts, WithDefaultVolumesToFsBackup())
deployOpts = append(deployOpts, WithDefaultVolumesToFsBackup(true))

Check warning on line 369 in pkg/install/resources.go

View check run for this annotation

Codecov / codecov/patch

pkg/install/resources.go#L369

Added line #L369 was not covered by tests
}

if o.DefaultSnapshotMoveData {
deployOpts = append(deployOpts, WithDefaultSnapshotMoveData())
deployOpts = append(deployOpts, WithDefaultSnapshotMoveData(true))

Check warning on line 373 in pkg/install/resources.go

View check run for this annotation

Codecov / codecov/patch

pkg/install/resources.go#L373

Added line #L373 was not covered by tests
}

if o.DisableInformerCache {
deployOpts = append(deployOpts, WithDisableInformerCache())
deployOpts = append(deployOpts, WithDisableInformerCache(true))

Check warning on line 377 in pkg/install/resources.go

View check run for this annotation

Codecov / codecov/patch

pkg/install/resources.go#L377

Added line #L377 was not covered by tests
}

deploy := Deployment(o.Namespace, deployOpts...)
Expand All @@ -396,7 +396,7 @@ func AllResources(o *VeleroOptions) *unstructured.UnstructuredList {
dsOpts = append(dsOpts, WithFeatures(o.Features))
}
if o.PrivilegedNodeAgent {
dsOpts = append(dsOpts, WithPrivilegedNodeAgent())
dsOpts = append(dsOpts, WithPrivilegedNodeAgent(true))

Check warning on line 399 in pkg/install/resources.go

View check run for this annotation

Codecov / codecov/patch

pkg/install/resources.go#L399

Added line #L399 was not covered by tests
}
ds := DaemonSet(o.Namespace, dsOpts...)
if err := appendUnstructured(resources, ds); err != nil {
Expand Down

0 comments on commit bd2008c

Please sign in to comment.