You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "150149 (via GitHub)" <gi...@apache.org> on 2024/06/04 02:44:22 UTC

[I] bug: yml conf could not use $env to set plugin properties [apisix]

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: notifications-unsubscribe@apisix.apache.org.apache.org

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


Re: [I] bug: yml conf could not use $env to set plugin properties [apisix]

Posted by "kayx23 (via GitHub)" <gi...@apache.org>.
kayx23 commented on issue #11319:
URL: https://github.com/apache/apisix/issues/11319#issuecomment-2148891999

   Could you change `$env:` to all caps and try again? I remember some time ago there was a PR allowing `ENV` to be lower case, but that was definitely available after 3.2.0.


-- 
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


Re: [I] bug: yml conf could not use $env to set plugin properties [apisix]

Posted by "darkSheep404 (via GitHub)" <gi...@apache.org>.
darkSheep404 commented on issue #11319:
URL: https://github.com/apache/apisix/issues/11319#issuecomment-2277406286

   By checking
   you need to add 
   `local fetch_secrets = require("apisix.secret").fetch_secrets`
   and
   ```lua
   function _M.rewrite(plugin_conf, ctx)
       local conf = core.table.clone(plugin_conf)
       local conf = fetch_secrets(plugin_conf)
      ```
   
   https://github.com/apache/apisix/pull/11451


-- 
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


Re: [I] bug: openid-connect yml conf could not use $env to set plugin properties [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop commented on issue #11319:
URL: https://github.com/apache/apisix/issues/11319#issuecomment-2947977766

   Duplicate of #12219 


-- 
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


Re: [I] bug: yml conf could not use $env to set plugin properties [apisix]

Posted by "150149 (via GitHub)" <gi...@apache.org>.
150149 commented on issue #11319:
URL: https://github.com/apache/apisix/issues/11319#issuecomment-2148894505

   > Could you change `$env:` to all caps and try again? I remember some time ago there was a PR allowing `ENV` to be lower case, but that was definitely available after 3.2.0.
   
   redis_password: $ENV://REDIS_PWD
   
   Emmmm.....I've tried all caps and it doesn't work.


-- 
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


Re: [I] bug: openid-connect yml conf could not use $env to set plugin properties [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop closed issue #11319: bug: openid-connect yml conf could not use $env to set plugin properties
URL: https://github.com/apache/apisix/issues/11319


-- 
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