You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/10/17 05:09:51 UTC

[GitHub] [apisix-ingress-controller] tokers commented on a change in pull request #713: feat: support environment variable in config file

tokers commented on a change in pull request #713:
URL: https://github.com/apache/apisix-ingress-controller/pull/713#discussion_r730354720



##########
File path: pkg/config/config_test.go
##########
@@ -103,6 +103,111 @@ apisix:
 	assert.Equal(t, cfg, newCfg, "bad configuration")
 }
 
+func TestConfigWithEnvVar(t *testing.T) {
+	cfg := &Config{
+		LogLevel:        "warn",
+		LogOutput:       "stdout",
+		HTTPListen:      ":9090",
+		HTTPSListen:     ":9443",
+		CertFilePath:    "/etc/webhook/certs/cert.pem",
+		KeyFilePath:     "/etc/webhook/certs/key.pem",
+		EnableProfiling: true,
+		Kubernetes: KubernetesConfig{
+			ResyncInterval:     types.TimeDuration{Duration: time.Hour},
+			Kubeconfig:         "/path/to/foo/baz",
+			AppNamespaces:      []string{""},
+			ElectionID:         "my-election-id",
+			IngressClass:       IngressClass,
+			IngressVersion:     IngressNetworkingV1,
+			ApisixRouteVersion: ApisixRouteV2alpha1,
+		},
+		APISIX: APISIXConfig{
+			DefaultClusterName:     "default",
+			DefaultClusterBaseURL:  "http://127.0.0.1:8080/apisix",
+			DefaultClusterAdminKey: "123456",
+		},
+	}
+
+	defaultClusterBaseURLEnvName := "DEFAULT_CLUSTER_BASE_URL"
+	defaultClusterAdminKeyEnvName := "DEFAULT_CLUSTER_ADMIN_KEY"
+
+	err := os.Setenv(defaultClusterBaseURLEnvName, "http://127.0.0.1:8080/apisix")

Review comment:
       Could you also try to test non-existent environment variables and variabels with empty value?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org