docs: fix sample configuration formatting errors (#8030)
[apisix.git] / apisix / cli / file.lua
index 9c528005e1fd87faa0545ceb0f345c79c6ca3e55..13af90f4abb25293c061ace09e9e7b538b9d4f08 100644 (file)
@@ -133,7 +133,7 @@ local function path_is_multi_type(path, type_val)
         return true
     end
 
         return true
     end
 
-    if path == "apisix->ssl->listen_port" and type_val == "number" then
+    if path == "apisix->ssl->key_encrypt_salt" then
         return true
     end
 
         return true
     end
 
@@ -237,7 +237,39 @@ function _M.read_yaml_conf(apisix_home)
         end
     end
 
         end
     end
 
-    if default_conf.apisix.config_center == "yaml" then
+    if default_conf.deployment then
+        default_conf.deployment.config_provider = "etcd"
+        if default_conf.deployment.role == "traditional" then
+            default_conf.etcd = default_conf.deployment.etcd
+
+        elseif default_conf.deployment.role == "control_plane" then
+            default_conf.etcd = default_conf.deployment.etcd
+            default_conf.apisix.enable_admin = true
+
+        elseif default_conf.deployment.role == "data_plane" then
+            if default_conf.deployment.role_data_plane.config_provider == "yaml" then
+                default_conf.deployment.config_provider = "yaml"
+            elseif default_conf.deployment.role_data_plane.config_provider == "xds" then
+                default_conf.deployment.config_provider = "xds"
+            else
+                default_conf.etcd = default_conf.deployment.role_data_plane.control_plane
+            end
+            default_conf.apisix.enable_admin = false
+        end
+
+        if default_conf.etcd and default_conf.deployment.certs then
+            -- copy certs configuration to keep backward compatible
+            local certs = default_conf.deployment.certs
+            local etcd = default_conf.etcd
+            if not etcd.tls then
+                etcd.tls = {}
+            end
+            etcd.tls.cert = certs.cert
+            etcd.tls.key = certs.cert_key
+        end
+    end
+
+    if default_conf.deployment.config_provider == "yaml" then
         local apisix_conf_path = profile:yaml_path("apisix")
         local apisix_conf_yaml, _ = util.read_file(apisix_conf_path)
         if apisix_conf_yaml then
         local apisix_conf_path = profile:yaml_path("apisix")
         local apisix_conf_yaml, _ = util.read_file(apisix_conf_path)
         if apisix_conf_yaml then
@@ -251,13 +283,6 @@ function _M.read_yaml_conf(apisix_home)
         end
     end
 
         end
     end
 
-    if default_conf.deployment
-        and default_conf.deployment.role == "traditional"
-        and default_conf.deployment.etcd
-    then
-        default_conf.etcd = default_conf.deployment.etcd
-    end
-
     return default_conf
 end
 
     return default_conf
 end