mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-07 13:55:20 +00:00
Make pkg/install/Deployment podTemplateOptions bool functions accept bool param
Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
This commit is contained in:
@@ -95,9 +95,9 @@ func WithSecret(secretPresent bool) podTemplateOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithRestoreOnly() podTemplateOption {
|
func WithRestoreOnly(b bool) podTemplateOption {
|
||||||
return func(c *podTemplateConfig) {
|
return func(c *podTemplateConfig) {
|
||||||
c.restoreOnly = true
|
c.restoreOnly = b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,21 +143,21 @@ func WithUploaderType(t string) podTemplateOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithDefaultVolumesToFsBackup() podTemplateOption {
|
func WithDefaultVolumesToFsBackup(b bool) podTemplateOption {
|
||||||
return func(c *podTemplateConfig) {
|
return func(c *podTemplateConfig) {
|
||||||
c.defaultVolumesToFsBackup = true
|
c.defaultVolumesToFsBackup = b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithDefaultSnapshotMoveData() podTemplateOption {
|
func WithDefaultSnapshotMoveData(b bool) podTemplateOption {
|
||||||
return func(c *podTemplateConfig) {
|
return func(c *podTemplateConfig) {
|
||||||
c.defaultSnapshotMoveData = true
|
c.defaultSnapshotMoveData = b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithDisableInformerCache() podTemplateOption {
|
func WithDisableInformerCache(b bool) podTemplateOption {
|
||||||
return func(c *podTemplateConfig) {
|
return func(c *podTemplateConfig) {
|
||||||
c.disableInformerCache = true
|
c.disableInformerCache = b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,9 +167,9 @@ func WithServiceAccountName(sa string) podTemplateOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithPrivilegedNodeAgent() podTemplateOption {
|
func WithPrivilegedNodeAgent(b bool) podTemplateOption {
|
||||||
return func(c *podTemplateConfig) {
|
return func(c *podTemplateConfig) {
|
||||||
c.privilegedNodeAgent = true
|
c.privilegedNodeAgent = b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func TestDeployment(t *testing.T) {
|
|||||||
|
|
||||||
assert.Equal(t, "velero", deploy.ObjectMeta.Namespace)
|
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])
|
assert.Equal(t, "--restore-only", deploy.Spec.Template.Spec.Containers[0].Args[1])
|
||||||
|
|
||||||
deploy = Deployment("velero", WithEnvFromSecretKey("my-var", "my-secret", "my-key"))
|
deploy = Deployment("velero", WithEnvFromSecretKey("my-var", "my-secret", "my-key"))
|
||||||
@@ -67,7 +67,7 @@ func TestDeployment(t *testing.T) {
|
|||||||
deploy = Deployment("velero", WithServiceAccountName("test-sa"))
|
deploy = Deployment("velero", WithServiceAccountName("test-sa"))
|
||||||
assert.Equal(t, "test-sa", deploy.Spec.Template.Spec.ServiceAccountName)
|
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.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])
|
assert.Equal(t, "--disable-informer-cache=true", deploy.Spec.Template.Spec.Containers[0].Args[1])
|
||||||
|
|
||||||
|
|||||||
@@ -358,7 +358,7 @@ func AllResources(o *VeleroOptions) *unstructured.UnstructuredList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if o.RestoreOnly {
|
if o.RestoreOnly {
|
||||||
deployOpts = append(deployOpts, WithRestoreOnly())
|
deployOpts = append(deployOpts, WithRestoreOnly(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(o.Plugins) > 0 {
|
if len(o.Plugins) > 0 {
|
||||||
@@ -366,15 +366,15 @@ func AllResources(o *VeleroOptions) *unstructured.UnstructuredList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if o.DefaultVolumesToFsBackup {
|
if o.DefaultVolumesToFsBackup {
|
||||||
deployOpts = append(deployOpts, WithDefaultVolumesToFsBackup())
|
deployOpts = append(deployOpts, WithDefaultVolumesToFsBackup(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.DefaultSnapshotMoveData {
|
if o.DefaultSnapshotMoveData {
|
||||||
deployOpts = append(deployOpts, WithDefaultSnapshotMoveData())
|
deployOpts = append(deployOpts, WithDefaultSnapshotMoveData(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.DisableInformerCache {
|
if o.DisableInformerCache {
|
||||||
deployOpts = append(deployOpts, WithDisableInformerCache())
|
deployOpts = append(deployOpts, WithDisableInformerCache(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
deploy := Deployment(o.Namespace, deployOpts...)
|
deploy := Deployment(o.Namespace, deployOpts...)
|
||||||
@@ -396,7 +396,7 @@ func AllResources(o *VeleroOptions) *unstructured.UnstructuredList {
|
|||||||
dsOpts = append(dsOpts, WithFeatures(o.Features))
|
dsOpts = append(dsOpts, WithFeatures(o.Features))
|
||||||
}
|
}
|
||||||
if o.PrivilegedNodeAgent {
|
if o.PrivilegedNodeAgent {
|
||||||
dsOpts = append(dsOpts, WithPrivilegedNodeAgent())
|
dsOpts = append(dsOpts, WithPrivilegedNodeAgent(true))
|
||||||
}
|
}
|
||||||
ds := DaemonSet(o.Namespace, dsOpts...)
|
ds := DaemonSet(o.Namespace, dsOpts...)
|
||||||
if err := appendUnstructured(resources, ds); err != nil {
|
if err := appendUnstructured(resources, ds); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user