Skip to content

Commit b757692

Browse files
committed
chore: Provide ability to configure backup job retry limit in DevWorkspaceOperatorConfig
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
1 parent c8e0c73 commit b757692

2 files changed

Lines changed: 0 additions & 128 deletions

File tree

pkg/library/env/workspaceenv.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -228,29 +228,3 @@ func getSourceForComponent(component dw.Component) string {
228228
}
229229
return fmt.Sprintf("component %s", component.Name)
230230
}
231-
232-
// MergeEnvVars merges two slices of environment variables, with variables in
233-
// 'toAdd' taking precedence over those in 'existing' when names conflict.
234-
// The order of variables in the result is non-deterministic due to map usage.
235-
// Returns a new slice without modifying the input slices.
236-
func MergeEnvVars(existing, toAdd []corev1.EnvVar) []corev1.EnvVar {
237-
envMap := make(map[string]corev1.EnvVar, len(existing)+len(toAdd))
238-
239-
// Add existing env vars first
240-
for _, env := range existing {
241-
envMap[env.Name] = env
242-
}
243-
244-
// Add new env vars (overrides existing with same name)
245-
for _, env := range toAdd {
246-
envMap[env.Name] = env
247-
}
248-
249-
// Convert map back to slice
250-
result := make([]corev1.EnvVar, 0, len(envMap))
251-
for _, env := range envMap {
252-
result = append(result, env)
253-
}
254-
255-
return result
256-
}

pkg/library/env/workspaceenv_test.go

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -86,105 +86,3 @@ func loadAllTestsOrPanic(t *testing.T, fromDir string) []TestCase {
8686
}
8787
return tests
8888
}
89-
90-
func TestMergeEnvVars(t *testing.T) {
91-
tests := []struct {
92-
name string
93-
existing []corev1.EnvVar
94-
toAdd []corev1.EnvVar
95-
expected map[string]string // Using map for easier assertion since order is non-deterministic
96-
}{
97-
{
98-
name: "no duplicates - variables are combined",
99-
existing: []corev1.EnvVar{
100-
{Name: "VAR1", Value: "value1"},
101-
{Name: "VAR2", Value: "value2"},
102-
},
103-
toAdd: []corev1.EnvVar{
104-
{Name: "VAR3", Value: "value3"},
105-
},
106-
expected: map[string]string{
107-
"VAR1": "value1",
108-
"VAR2": "value2",
109-
"VAR3": "value3",
110-
},
111-
},
112-
{
113-
name: "toAdd overrides existing - new value wins",
114-
existing: []corev1.EnvVar{
115-
{Name: "VAR1", Value: "old"},
116-
{Name: "VAR2", Value: "keep"},
117-
},
118-
toAdd: []corev1.EnvVar{
119-
{Name: "VAR1", Value: "new"},
120-
},
121-
expected: map[string]string{
122-
"VAR1": "new",
123-
"VAR2": "keep",
124-
},
125-
},
126-
{
127-
name: "empty existing - only toAdd returned",
128-
existing: []corev1.EnvVar{},
129-
toAdd: []corev1.EnvVar{
130-
{Name: "VAR1", Value: "value1"},
131-
},
132-
expected: map[string]string{
133-
"VAR1": "value1",
134-
},
135-
},
136-
{
137-
name: "empty toAdd - only existing returned",
138-
existing: []corev1.EnvVar{
139-
{Name: "VAR1", Value: "value1"},
140-
},
141-
toAdd: []corev1.EnvVar{},
142-
expected: map[string]string{
143-
"VAR1": "value1",
144-
},
145-
},
146-
{
147-
name: "both empty - empty result",
148-
existing: []corev1.EnvVar{},
149-
toAdd: []corev1.EnvVar{},
150-
expected: map[string]string{},
151-
},
152-
{
153-
name: "multiple duplicates - all overridden",
154-
existing: []corev1.EnvVar{
155-
{Name: "VAR1", Value: "old1"},
156-
{Name: "VAR2", Value: "old2"},
157-
{Name: "VAR3", Value: "keep"},
158-
},
159-
toAdd: []corev1.EnvVar{
160-
{Name: "VAR1", Value: "new1"},
161-
{Name: "VAR2", Value: "new2"},
162-
},
163-
expected: map[string]string{
164-
"VAR1": "new1",
165-
"VAR2": "new2",
166-
"VAR3": "keep",
167-
},
168-
},
169-
}
170-
171-
for _, tt := range tests {
172-
t.Run(tt.name, func(t *testing.T) {
173-
result := MergeEnvVars(tt.existing, tt.toAdd)
174-
175-
// Convert result to map for comparison (order doesn't matter)
176-
resultMap := make(map[string]string)
177-
for _, env := range result {
178-
resultMap[env.Name] = env.Value
179-
}
180-
181-
// Verify length matches
182-
assert.Equal(t, len(tt.expected), len(resultMap), "Result should have correct number of env vars")
183-
184-
// Verify each expected env var
185-
for name, value := range tt.expected {
186-
assert.Equal(t, value, resultMap[name], "Env var %s should have correct value", name)
187-
}
188-
})
189-
}
190-
}

0 commit comments

Comments
 (0)