This is an automated email from the ASF dual-hosted git repository.
zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git
The following commit(s) were added to refs/heads/master by this push:
new f1bd4c02 fix config missing default_cluster_name yaml (#1277)
f1bd4c02 is described below
commit f1bd4c026f1652318afc7b2aabe9590c2882247b
Author: xiangtianyu <[email protected]>
AuthorDate: Mon Aug 29 22:29:37 2022 +0800
fix config missing default_cluster_name yaml (#1277)
---
pkg/config/config.go | 2 +-
pkg/config/config_test.go | 11 ++++++++---
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/pkg/config/config.go b/pkg/config/config.go
index a3997e0f..43b54b08 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -110,7 +110,7 @@ type KubernetesConfig struct {
// APISIXConfig contains all APISIX related config items.
type APISIXConfig struct {
// DefaultClusterName is the name of default cluster.
- DefaultClusterName string `json:"default_cluster_name"`
+ DefaultClusterName string `json:"default_cluster_name"
yaml:"default_cluster_name"`
// DefaultClusterBaseURL is the base url configuration for the default
cluster.
DefaultClusterBaseURL string `json:"default_cluster_base_url"
yaml:"default_cluster_base_url"`
// DefaultClusterAdminKey is the admin key for the default cluster.
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
index 55861149..2114b682 100644
--- a/pkg/config/config_test.go
+++ b/pkg/config/config_test.go
@@ -52,7 +52,7 @@ func TestNewConfigFromFile(t *testing.T) {
APIVersion: DefaultAPIVersion,
},
APISIX: APISIXConfig{
- DefaultClusterName: "default",
+ DefaultClusterName: "apisix",
DefaultClusterBaseURL: "http://127.0.0.1:8080/apisix",
DefaultClusterAdminKey: "123456",
},
@@ -98,6 +98,7 @@ kubernetes:
apisix:
default_cluster_base_url: http://127.0.0.1:8080/apisix
default_cluster_admin_key: "123456"
+ default_cluster_name: "apisix"
`
tmpYAML, err := ioutil.TempFile("/tmp", "config-*.yaml")
assert.Nil(t, err, "failed to create temporary yaml configuration file:
", err)
@@ -140,7 +141,7 @@ func TestConfigWithEnvVar(t *testing.T) {
APIVersion: DefaultAPIVersion,
},
APISIX: APISIXConfig{
- DefaultClusterName: "default",
+ DefaultClusterName: "apisix",
DefaultClusterBaseURL: "http://127.0.0.1:8080/apisix",
DefaultClusterAdminKey: "123456",
},
@@ -148,12 +149,14 @@ func TestConfigWithEnvVar(t *testing.T) {
defaultClusterBaseURLEnvName := "DEFAULT_CLUSTER_BASE_URL"
defaultClusterAdminKeyEnvName := "DEFAULT_CLUSTER_ADMIN_KEY"
+ defaultClusterNameEnvName := "DEFAULT_CLUSTER_NAME"
kubeconfigEnvName := "KUBECONFIG"
err := os.Setenv(defaultClusterBaseURLEnvName,
"http://127.0.0.1:8080/apisix")
assert.Nil(t, err, "failed to set env variable: ", err)
_ = os.Setenv(defaultClusterAdminKeyEnvName, "123456")
_ = os.Setenv(kubeconfigEnvName, "")
+ _ = os.Setenv(defaultClusterNameEnvName, "apisix")
jsonData := `
{
@@ -174,7 +177,8 @@ func TestConfigWithEnvVar(t *testing.T) {
},
"apisix": {
"default_cluster_base_url": "{{.DEFAULT_CLUSTER_BASE_URL}}",
- "default_cluster_admin_key": "{{.DEFAULT_CLUSTER_ADMIN_KEY}}"
+ "default_cluster_admin_key": "{{.DEFAULT_CLUSTER_ADMIN_KEY}}",
+ "default_cluster_name": "{{.DEFAULT_CLUSTER_NAME}}"
}
}
`
@@ -210,6 +214,7 @@ kubernetes:
apisix:
default_cluster_base_url: {{.DEFAULT_CLUSTER_BASE_URL}}
default_cluster_admin_key: "{{.DEFAULT_CLUSTER_ADMIN_KEY}}"
+ default_cluster_name: "{{.DEFAULT_CLUSTER_NAME}}"
`
tmpYAML, err := ioutil.TempFile("/tmp", "config-*.yaml")
assert.Nil(t, err, "failed to create temporary yaml configuration file:
", err)