chore: the directories in Makefile should be listed in alphabetical order
[apisix.git] / apisix / cli / file.lua
index 9c528005e1fd87faa0545ceb0f345c79c6ca3e55..85207233bfdf9f0522f724a66f0f33c39eb33c0b 100644 (file)
@@ -251,11 +251,33 @@ function _M.read_yaml_conf(apisix_home)
         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
+    if default_conf.deployment then
+        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.apisix.config_center = "yaml"
+            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
 
     return default_conf