From 80ac71264c5f388f2d181f17ab1f14c7062aec8f Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Mon, 4 Sep 2023 08:45:55 +0000
Subject: [PATCH 134/145] !2169 using macros to isolate isulad's enable_plugin
 configuration option * using macros to isolate isulad's enable_plugin
 configuration option

---
 src/cmd/isulad/isulad_commands.h  | 15 +++++++++++----
 src/common/constants.h            |  2 ++
 src/daemon/config/isulad_config.c |  4 ++++
 src/daemon/config/isulad_config.h |  2 ++
 4 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/cmd/isulad/isulad_commands.h b/src/cmd/isulad/isulad_commands.h
index e5bcb6c8..3b12fa3e 100644
--- a/src/cmd/isulad/isulad_commands.h
+++ b/src/cmd/isulad/isulad_commands.h
@@ -65,6 +65,16 @@ int command_default_ulimit_append(command_option_t *option, const char *arg);
 #define USERNS_REMAP_OPT(cmdargs)
 #endif
 
+#ifdef ENABLE_PLUGIN
+#define PLUGINS_OPT(cmdargs)                                                                                \
+    { CMD_OPT_TYPE_STRING_DUP,                                                                              \
+      false, "enable-plugins", 0, &(cmdargs)->json_confs->enable_plugins,                                   \
+      "Enable plugins for all containers", NULL                                                             \
+    }, 
+#else
+#define PLUGINS_OPT(cmdargs)
+#endif
+
 #ifdef ENABLE_GRPC_REMOTE_CONNECT
 #define ISULAD_TLS_OPTIONS(cmdargs)                                                                               \
     { CMD_OPT_TYPE_STRING_DUP,                                                                                    \
@@ -314,10 +324,7 @@ int command_default_ulimit_append(command_option_t *option, const char *arg);
       false, "cpu-rt-runtime", 0, &(cmdargs)->json_confs->cpu_rt_runtime,                                         \
       "Limit CPU real-time runtime in microseconds for all containers", command_convert_llong                     \
     },                                                                                                            \
-    { CMD_OPT_TYPE_STRING_DUP,                                                                                    \
-      false, "enable-plugins", 0, &(cmdargs)->json_confs->enable_plugins,                                         \
-      "Enable plugins for all containers", NULL                                                                   \
-    },                                                                                                            \
+    PLUGINS_OPT(cmdargs)                                                                                          \
     { CMD_OPT_TYPE_CALLBACK,                                                                                      \
       false, "cri-runtime", 0, (cmdargs),                                                                         \
       "CRI runtime class transform", server_callback_cri_runtime                                                  \
diff --git a/src/common/constants.h b/src/common/constants.h
index 7460e169..efb2951a 100644
--- a/src/common/constants.h
+++ b/src/common/constants.h
@@ -134,9 +134,11 @@ extern "C" {
 
 #define AUTH_PLUGIN "authz-broker"
 
+#ifdef ENABLE_PLUGIN
 #define ISULAD_ENABLE_PLUGINS "ISULAD_ENABLE_PLUGINS"
 #define ISULAD_ENABLE_PLUGINS_SEPERATOR ","
 #define ISULAD_ENABLE_PLUGINS_SEPERATOR_CHAR ','
+#endif
 
 #ifdef ENABLE_SHIM_V2
 #define SHIM_V2_LOG "/log"
diff --git a/src/daemon/config/isulad_config.c b/src/daemon/config/isulad_config.c
index c9e64617..0e389dd1 100644
--- a/src/daemon/config/isulad_config.c
+++ b/src/daemon/config/isulad_config.c
@@ -1209,6 +1209,7 @@ out:
     return result;
 }
 
+#ifdef ENABLE_PLUGIN
 char *conf_get_enable_plugins(void)
 {
     struct service_arguments *conf = NULL;
@@ -1230,6 +1231,7 @@ out:
     (void)isulad_server_conf_unlock();
     return plugins;
 }
+#endif
 
 #ifdef ENABLE_USERNS_REMAP
 char *conf_get_isulad_userns_remap(void)
@@ -1634,7 +1636,9 @@ int merge_json_confs_into_global(struct service_arguments *args)
     // iSulad runtime execution options
     override_string_value(&args->json_confs->engine, &tmp_json_confs->engine);
     override_string_value(&args->json_confs->hook_spec, &tmp_json_confs->hook_spec);
+#ifdef ENABLE_PLUGIN
     override_string_value(&args->json_confs->enable_plugins, &tmp_json_confs->enable_plugins);
+#endif
 #ifdef ENABLE_USERNS_REMAP
     override_string_value(&args->json_confs->userns_remap, &tmp_json_confs->userns_remap);
 #endif
diff --git a/src/daemon/config/isulad_config.h b/src/daemon/config/isulad_config.h
index cf0cd2a4..397da8a4 100644
--- a/src/daemon/config/isulad_config.h
+++ b/src/daemon/config/isulad_config.h
@@ -55,7 +55,9 @@ int conf_get_container_log_opts(isulad_daemon_configs_container_log **opts);
 
 char *conf_get_isulad_log_file(void);
 char *conf_get_engine_log_file(void);
+#ifdef ENABLE_PLUGIN
 char *conf_get_enable_plugins(void);
+#endif
 #ifdef ENABLE_USERNS_REMAP
 char *conf_get_isulad_userns_remap(void);
 #endif
-- 
2.40.1

