mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-05 13:05:17 +00:00
add use-node-agent-windows
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
@@ -246,6 +246,7 @@ type VeleroOptions struct {
|
||||
SecretData []byte
|
||||
RestoreOnly bool
|
||||
UseNodeAgent bool
|
||||
UseNodeAgentWindows bool
|
||||
PrivilegedNodeAgent bool
|
||||
UseVolumeSnapshots bool
|
||||
BSLConfig map[string]string
|
||||
@@ -395,7 +396,7 @@ func AllResources(o *VeleroOptions) *unstructured.UnstructuredList {
|
||||
fmt.Printf("error appending Deployment %s: %s\n", deploy.GetName(), err.Error())
|
||||
}
|
||||
|
||||
if o.UseNodeAgent {
|
||||
if o.UseNodeAgent || o.UseNodeAgentWindows {
|
||||
dsOpts := []podTemplateOption{
|
||||
WithAnnotations(o.PodAnnotations),
|
||||
WithLabels(o.PodLabels),
|
||||
@@ -414,16 +415,20 @@ func AllResources(o *VeleroOptions) *unstructured.UnstructuredList {
|
||||
dsOpts = append(dsOpts, WithNodeAgentConfigMap(o.NodeAgentConfigMap))
|
||||
}
|
||||
|
||||
ds := DaemonSet(o.Namespace, dsOpts...)
|
||||
if err := appendUnstructured(resources, ds); err != nil {
|
||||
fmt.Printf("error appending DaemonSet %s: %s\n", ds.GetName(), err.Error())
|
||||
if o.UseNodeAgent {
|
||||
ds := DaemonSet(o.Namespace, dsOpts...)
|
||||
if err := appendUnstructured(resources, ds); err != nil {
|
||||
fmt.Printf("error appending DaemonSet %s: %s\n", ds.GetName(), err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
dsOpts = append(dsOpts, WithForWindows())
|
||||
if o.UseNodeAgentWindows {
|
||||
dsOpts = append(dsOpts, WithForWindows())
|
||||
|
||||
dsWin := DaemonSet(o.Namespace, dsOpts...)
|
||||
if err := appendUnstructured(resources, dsWin); err != nil {
|
||||
fmt.Printf("error appending DaemonSet %s: %s\n", dsWin.GetName(), err.Error())
|
||||
dsWin := DaemonSet(o.Namespace, dsOpts...)
|
||||
if err := appendUnstructured(resources, dsWin); err != nil {
|
||||
fmt.Printf("error appending DaemonSet %s: %s\n", dsWin.GetName(), err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,21 +77,22 @@ func TestAllCRDs(t *testing.T) {
|
||||
|
||||
func TestAllResources(t *testing.T) {
|
||||
option := &VeleroOptions{
|
||||
Namespace: "velero",
|
||||
SecretData: []byte{'a'},
|
||||
UseVolumeSnapshots: true,
|
||||
UseNodeAgent: true,
|
||||
Namespace: "velero",
|
||||
SecretData: []byte{'a'},
|
||||
UseVolumeSnapshots: true,
|
||||
UseNodeAgent: true,
|
||||
UseNodeAgentWindows: true,
|
||||
}
|
||||
list := AllResources(option)
|
||||
|
||||
objects := map[string]unstructured.Unstructured{}
|
||||
objects := map[string][]unstructured.Unstructured{}
|
||||
for _, item := range list.Items {
|
||||
objects[item.GetKind()] = item
|
||||
objects[item.GetKind()] = append(objects[item.GetKind()], item)
|
||||
}
|
||||
|
||||
ns, exist := objects["Namespace"]
|
||||
require.True(t, exist)
|
||||
assert.Equal(t, "velero", ns.GetName())
|
||||
assert.Equal(t, "velero", ns[0].GetName())
|
||||
|
||||
_, exist = objects["ClusterRoleBinding"]
|
||||
assert.True(t, exist)
|
||||
@@ -111,6 +112,8 @@ func TestAllResources(t *testing.T) {
|
||||
_, exist = objects["Deployment"]
|
||||
assert.True(t, exist)
|
||||
|
||||
_, exist = objects["DaemonSet"]
|
||||
ds, exist := objects["DaemonSet"]
|
||||
assert.True(t, exist)
|
||||
|
||||
assert.Equal(t, 2, len(ds))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user