150149 opened a new issue, #11319:
URL: https://github.com/apache/apisix/issues/11319

   ### Current Behavior
   
   When I use yaml config to set plugin properties, apisix could not read 
$env://REDIS_PWD value.
   Environment variable can be seen through linux cmd:
   ```sh
   echo $REDIS_PWD
   ```
   But apisix plugin could not read those config properties
   
   ### Expected Behavior
   
   Apisix plugin can read those config properties
   
   ### Error Logs
   
   _No response_
   
   ### Steps to Reproduce
   
   1. Create config(Show only key code)
   ```yaml
   services:
     - id: abc-service
       upstream_id: abc-upstream
       plugins:
         my-redis-plugin:
           policy: redis
           redis_timeout: 1000
           redis_password: $env://REDIS_PWD
           redis_session_prefix: xxx:spring:session:sessions
           redis_host: xxxxxxx
           redis_port: xxx
   ```
   
   2.create plugin(Show only key code)
   ```lua
   local core = require("apisix.core")
   
   local schema = {
     type = "object",
     properties = {
       redis_session_prefix = {
         type = "string", minLength = 0, default = "xxx:spring:session:sessions"
       },
       policy = {
         type = "string",
         enum = {"redis", "redis-cluster"},
         default = "redis",
       }
     },
     dependencies = {
       policy = {
         oneOf = {
           {
             properties = {
               policy = {
                 enum = {"redis"},
               },
               redis_host = {
                 type = "string", minLength = 2
               },
               redis_port = {
                 type = "integer", minimum = 1, default = 6379,
               },
               redis_password = {
                 type = "string", minLength = 0,
               },
               redis_database = {
                 type = "integer", minimum = 0, default = 0,
               },
               redis_timeout = {
                 type = "integer", minimum = 1, default = 1000,
               },
             },
             required = {"redis_host"},
           },
           {
             properties = {
               policy = {
                 enum = {"redis-cluster"},
               },
               redis_cluster_nodes = {
                 type = "array",
                 minItems = 2,
                 items = {
                   type = "string", minLength = 2, maxLength = 100
                 },
               },
               redis_password = {
                 type = "string", minLength = 0,
               },
               redis_timeout = {
                 type = "integer", minimum = 1, default = 1000,
               },
               redis_cluster_name = {
                 type = "string",
               },
             },
             required = {"redis_cluster_nodes", "redis_cluster_name"},
           }
         }
       }
     }
   }
   
   function _M.rewrite(conf, ctx)
     core.log.error("redis Password: " .. conf.redis_password)
   end
   
   return _M
   ```
   
   ### Environment
   
   - APISIX version (3.2.0):
   - Operating system (Linux 3.10.0-1160.118.1.el7.x86_64 SMP Thu Apr 4 
03:33:23 EDT 2024 x86_64 x86_64 x86_64 GNU/Linux):
   - OpenResty / Nginx version (openresty/1.21.4.2):
   - etcd version, if relevant (not use):
   - APISIX Dashboard version, if relevant(not use)
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to