Skip to content

Commit

Permalink
test(cmd/root):Added support for kubernetes provider config
Browse files Browse the repository at this point in the history
  • Loading branch information
avysochin256 authored and acouvreur committed Oct 10, 2023
1 parent f4e88ae commit acf672e
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ It provides an integrations with multiple reverse proxies and different loading
// Provider flags
startCmd.Flags().StringVar(&conf.Provider.Name, "provider.name", "docker", fmt.Sprintf("Provider to use to manage containers %v", config.GetProviders()))
viper.BindPFlag("provider.name", startCmd.Flags().Lookup("provider.name"))
startCmd.Flags().Float32Var(&conf.Provider.Kubernetes.QPS, "provider.kubernetes.QPS", 5, fmt.Sprintf("QPS limit for K8S API access client-side throttling"))
startCmd.Flags().Float32Var(&conf.Provider.Kubernetes.QPS, "provider.kubernetes.qps", 5, fmt.Sprintf("QPS limit for K8S API access client-side throttling"))
viper.BindPFlag("provider.kubernetes.qps", startCmd.Flags().Lookup("provider.kubernetes.qps"))
startCmd.Flags().IntVar(&conf.Provider.Kubernetes.Burst, "provider.kubernetes.burst", 10, fmt.Sprintf("Maximum burst for K8S API acees client-side throttling"))
viper.BindPFlag("provider.kubernetes.burst", startCmd.Flags().Lookup("provider.kubernetes.Burst"))
viper.BindPFlag("provider.kubernetes.burst", startCmd.Flags().Lookup("provider.kubernetes.burst"))
// Server flags
startCmd.Flags().IntVar(&conf.Server.Port, "server.port", 10000, "The server port to use")
viper.BindPFlag("server.port", startCmd.Flags().Lookup("server.port"))
Expand Down
2 changes: 2 additions & 0 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ func TestPrecedence(t *testing.T) {
"--configFile", filepath.Join(testDir, "testdata", "config.yml"),
"start",
"--provider.name", "cli",
"--provider.kubernetes.qps", "256",
"--provider.kubernetes.burst", "512",
"--server.port", "3333",
"--server.base-path", "/cli/",
"--storage.file", "/tmp/cli.json",
Expand Down
2 changes: 2 additions & 0 deletions cmd/testdata/config.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
PROVIDER_NAME=envvar
PROVIDER_KUBERNETES_QPS=16
PROVIDER_KUBERNETES_BURST=32
SERVER_PORT=2222
SERVER_BASE_PATH=/envvar/
STORAGE_FILE=/tmp/envvar.json
Expand Down
3 changes: 3 additions & 0 deletions cmd/testdata/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
provider:
name: configfile
kubernetes:
qps: 64
burst: 128
server:
port: 1111
base-path: /configfile/
Expand Down
6 changes: 5 additions & 1 deletion cmd/testdata/config_cli_wanted.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"File": "/tmp/cli.json"
},
"Provider": {
"Name": "cli"
"Name": "cli",
"Kubernetes": {
"QPS": 256,
"Burst": 512
}
},
"Sessions": {
"DefaultDuration": 10800000000000,
Expand Down
6 changes: 5 additions & 1 deletion cmd/testdata/config_env_wanted.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"File": "/tmp/envvar.json"
},
"Provider": {
"Name": "envvar"
"Name": "envvar",
"Kubernetes": {
"QPS": 16,
"Burst": 32
}
},
"Sessions": {
"DefaultDuration": 7200000000000,
Expand Down
6 changes: 5 additions & 1 deletion cmd/testdata/config_yaml_wanted.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"File": "/tmp/configfile.json"
},
"Provider": {
"Name": "configfile"
"Name": "configfile",
"Kubernetes": {
"QPS": 64,
"Burst": 128
}
},
"Sessions": {
"DefaultDuration": 3600000000000,
Expand Down

0 comments on commit acf672e

Please sign in to comment.