You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "teodorescuserban (via GitHub)" <gi...@apache.org> on 2024/08/15 10:12:29 UTC

[I] help request: use yaml anchors and aliases in the config. [apisix]

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

   ### Description
   
   I would like to use standard yaml anchors ans aliases to not repeat myself too much in the config.
   The only reference to anchors i found is https://github.com/apache/apisix/issues/10468
   
   Example:
   
   `include/variables.yaml`:
   
   ```
   variables:
     common_methods: &common_methods
       - GET
       - POST
       - PUT
       - DELETE
       ...
   ```
   
   `apisix.yaml`:
   
   ```
   include include/variables.yaml
   
   routes:
     -
       uri: /inbound/api/*
       name: API Route
       methods: *common_methods
       service_id: 'service_api'
       upstream_id: 'upstream_api'
       labels:
         API_VERSION: '1'
         api_name: api
         api_type: inbound
       status: 1
   ```
   
   This config will result in this error:
   
   ```
   [error] 34#34: *3 [lua] config_yaml.lua:210: failed to check item data of [routes] err:property "methods" validation failed: wrong type: expected array, got string ,val: {"priority":0,"labels":{"api_type":"inbound","API_VERSION":"1","api_name":"api"},"name":"API Route","uri":"/inbound/api/*","upstream_id":"upstream_api","methods":"*common_methods","service_id":"service_api","status":1}, context: init_worker_by_lua*
   ```
   
   I also tried:
   
   ```
   include include/variables.yaml
   
   routes:
     -
       uri: /inbound/api/*
       name: API Route
       methods:
         <<: *common_methods
       service_id: 'service_api'
       upstream_id: 'upstream_api'
       labels:
         API_VERSION: '1'
         api_name: api
         api_type: inbound
       status: 1
   ```
   which results in:
   
   ```
   [error] 35#35: *1 [lua] config_yaml.lua:210: failed to check item data of [routes] err:property "methods" validation failed: wrong type: expected array, got table ,val: {"priority":0,"service_id":"service_api","status":1,"name":"API Route","methods":{"<<":"*common_methods"},"uri":"/inbound/api/*","upstream_id":"upstream_api","labels":{"API_VERSION":"1","api_name":"api","api_type":"inbound"}}, context: init_worker_by_lua*
   ```
   
   Any ideas? Thank you!
   
   ### Environment
   
   Using the official docker image from DockerHub: apache/apisix:3.9.1-debian
   
   - APISIX version (run `apisix version`): 3.9.1
   - Operating system (run `uname -a`): Linux 3a2a54d2c5fc 6.1.41-63.114.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Aug  1 20:47:25 UTC 2023 x86_64 GNU/Linux
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`): nginx version: openresty/1.25.3.1
   built by gcc 10.2.1 20210110 (Debian 10.2.1-6)
   built with OpenSSL 3.2.0 23 Nov 2023
   TLS SNI support enabled
   configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DAPISIX_RUNTIME_VER=1.2.0 -DNGX_GRPC_CLI_ENGINE_PATH=/usr/local/openresty/libgrpc_engine.so -DNGX_HTTP_GRPC_CLI_ENGINE_PATH=/usr/local/openresty/libgrpc_engine.so -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl3/include' --add-module=../ngx_devel_kit-0.3.3 --add-module=../echo-nginx-module-0.63 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.33 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.09 --add-module=../srcache-nginx-module-0.33 --add-module=../ngx_lua-0.10.26 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.37 --add-module=../array-var-nginx-module-0.06 --add-module=../memc-nginx-module-0.20 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.9 --add-mo
 dule=../ngx_stream_lua-0.0.14 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -Wl,-rpath,/usr/local/openresty/wasmtime-c-api/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl3/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl3/lib' --add-module=/tmp/tmp.EQbG5FbABp/openresty-1.25.3.1/../mod_dubbo-1.0.2 --add-module=/tmp/tmp.EQbG5FbABp/openresty-1.25.3.1/../ngx_multi_upstream_module-1.2.0 --add-module=/tmp/tmp.EQbG5FbABp/openresty-1.25.3.1/../apisix-nginx-module-1.16.0 --add-module=/tmp/tmp.EQbG5FbABp/openresty-1.25.3.1/../apisix-nginx-module-1.16.0/src/stream --add-module=/tmp/tmp.EQbG5FbABp/openresty-1.25.3.1/../apisix-nginx-module-1.16.0/src/meta --add-module=/tmp/tmp.EQbG5FbABp/openresty-1.25.3.1/../wasm-nginx-module-0.7.0 --add-module=/tmp/tmp.EQbG5FbABp/openresty-1.25.3.1/../lua-var-nginx-module-v0.5.3 --add-module=/tmp/tmp.EQbG5FbABp/openresty-1.25.3.1/../grpc-client
 -nginx-module-v0.5.0 --add-module=/tmp/tmp.EQbG5FbABp/openresty-1.25.3.1/../lua-resty-events-0.2.0 --with-poll_module --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v2_module --with-http_v3_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_module --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-compat --with-stream --without-pcre2 --with-http_ssl_module
   


-- 
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] help request: use yaml anchors and aliases in the config. [apisix]

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

   this seems like a limitation from the yaml parser used by APISIX.


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