-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1c04d3
commit bbc707b
Showing
15 changed files
with
168 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package utils | ||
|
||
// ServiceArgsFromMap processes a map of string pointers and categorizes them into update and delete lists. | ||
// - If the value pointer is nil, it adds the argument name to the delete list. | ||
// - If the value pointer is not nil, it adds the argument and its value to the update map. | ||
func ServiceArgsFromMap(args map[string]*string) (map[string]string, []string) { | ||
updateArgs := make(map[string]string) | ||
deleteArgs := make([]string, 0) | ||
|
||
for arg, val := range args { | ||
if val == nil { | ||
deleteArgs = append(deleteArgs, arg) | ||
} else { | ||
updateArgs[arg] = *val | ||
} | ||
} | ||
return updateArgs, deleteArgs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package utils | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestServiceArgsFromMap(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
input map[string]*string | ||
expected struct { | ||
updateArgs map[string]string | ||
deleteArgs []string | ||
} | ||
}{ | ||
{ | ||
name: "NilValue", | ||
input: map[string]*string{"arg1": nil}, | ||
expected: struct { | ||
updateArgs map[string]string | ||
deleteArgs []string | ||
}{ | ||
updateArgs: map[string]string{}, | ||
deleteArgs: []string{"arg1"}, | ||
}, | ||
}, | ||
{ | ||
name: "EmptyString", // Should be threated as normal string | ||
input: map[string]*string{"arg1": Pointer("")}, | ||
expected: struct { | ||
updateArgs map[string]string | ||
deleteArgs []string | ||
}{ | ||
updateArgs: map[string]string{"arg1": ""}, | ||
deleteArgs: []string{}, | ||
}, | ||
}, | ||
{ | ||
name: "NonEmptyString", | ||
input: map[string]*string{"arg1": Pointer("value1")}, | ||
expected: struct { | ||
updateArgs map[string]string | ||
deleteArgs []string | ||
}{ | ||
updateArgs: map[string]string{"arg1": "value1"}, | ||
deleteArgs: []string{}, | ||
}, | ||
}, | ||
{ | ||
name: "MixedValues", | ||
input: map[string]*string{ | ||
"arg1": Pointer("value1"), | ||
"arg2": Pointer(""), | ||
"arg3": nil, | ||
}, | ||
expected: struct { | ||
updateArgs map[string]string | ||
deleteArgs []string | ||
}{ | ||
updateArgs: map[string]string{"arg1": "value1", "arg2": ""}, | ||
deleteArgs: []string{"arg3"}, | ||
}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
g := NewWithT(t) | ||
|
||
updateArgs, deleteArgs := ServiceArgsFromMap(tt.input) | ||
g.Expect(updateArgs).To(Equal(tt.expected.updateArgs)) | ||
g.Expect(deleteArgs).To(Equal(tt.expected.deleteArgs)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Contains the bootstrap configuration for the smoke test. | ||
cluster-config: | ||
network: | ||
enabled: true | ||
dns: | ||
enabled: true | ||
ingress: | ||
enabled: true | ||
load-balancer: | ||
enabled: true | ||
local-storage: | ||
enabled: true | ||
gateway: | ||
enabled: true | ||
metrics-server: | ||
enabled: true | ||
extra-node-config-files: | ||
bootstrap-extra-file.yaml: extra-args-test-file-content | ||
extra-node-kube-apiserver-args: | ||
--request-timeout: 2m | ||
extra-node-kube-controller-manager-args: | ||
--leader-elect-retry-period: 3s | ||
extra-node-kube-scheduler-args: | ||
--authorization-webhook-cache-authorized-ttl: 11s | ||
extra-node-kube-proxy-args: | ||
--config-sync-period: 14m | ||
extra-node-kubelet-args: | ||
--authentication-token-webhook-cache-ttl: 3m | ||
extra-node-containerd-args: | ||
--log-level: debug | ||
extra-node-k8s-dqlite-args: | ||
--watch-storage-available-size-interval: 6s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters