Skip to content

Commit

Permalink
t3c: use mustache templating for remap.config lines (#7155)
Browse files Browse the repository at this point in the history
  • Loading branch information
traeak committed Jan 6, 2023
1 parent 098354c commit 47098fb
Show file tree
Hide file tree
Showing 15 changed files with 2,003 additions and 128 deletions.
5 changes: 5 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -712,3 +712,8 @@ This product bundles jcmturner/rpc.v1, which is available under an Apache-2.0 li
@vendor/gopkg.in/jcmturner/rpc.v1/*
./vendor/gopkg.in/jcmturner/rpc.v1/LICENSE
Refer to the above license for the full text.

This product bundles cbroglie/mustache which is available under an MIT license.
@vendor/github.com/cbroglie/mustache/*
./vendor/github.com/cbroglie/mustache/LICENSE
Refer to the above license for the full text.
8 changes: 4 additions & 4 deletions cache-config/testing/ort-tests/baseline-configs/remap.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# DO NOT EDIT - Generated for atlanta-edge-03 by () on Fri Nov 13 18:49:10 UTC 2020
map http://atlanta-edge-03.ds-origin-ip-0.test.cdn1.net/ http://192.0.2.1/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-origin-ip-0.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # ds 'ds-origin-ip-0' topology 'mso-topology'
map https://atlanta-edge-03.ds-origin-ip-0.test.cdn1.net/ http://192.0.2.1/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-origin-ip-0.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # ds 'ds-origin-ip-0' topology 'mso-topology'
map http://atlanta-edge-03.ds-top.test.cdn1.net/ http://origin.topology.example.net/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-top.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # ds 'ds-top' topology 'mso-topology'
map https://atlanta-edge-03.ds-top.test.cdn1.net/ http://origin.topology.example.net/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-top.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # ds 'ds-top' topology 'mso-topology'
map http://atlanta-edge-03.ds-origin-ip-0.test.cdn1.net/ http://192.0.2.1/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-origin-ip-0.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # ds 'ds-origin-ip-0' topology 'mso-topology'
map https://atlanta-edge-03.ds-origin-ip-0.test.cdn1.net/ http://192.0.2.1/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-origin-ip-0.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # ds 'ds-origin-ip-0' topology 'mso-topology'
map http://atlanta-edge-03.ds-top.test.cdn1.net/ http://origin.topology.example.net/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-top.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # ds 'ds-top' topology 'mso-topology'
map https://atlanta-edge-03.ds-top.test.cdn1.net/ http://origin.topology.example.net/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-top.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # ds 'ds-top' topology 'mso-topology'
55 changes: 54 additions & 1 deletion docs/source/overview/profiles_and_parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,60 @@ In order to support difficult configurations at MID/LAST, a
and Value the raw remap lines. The Value in this parameter will be pre
or post pended to the end of ``remap.config``.

.. seealso:: For an explanation of the syntax of this configuration file, refer to `the Apache Traffic Server remap.config documentation <https://docs.trafficserver.apache.org/en/7.1.x/admin-guide/files/remap.config.en.html>`_.
To provide the most flexibility for managing :term:`Delivery Service` generated ``remap.config`` lines there are options for redefining the internal mustache template used to generate these ``remap.config`` lines.

- ``template.first``
- ``template.inner``
- ``template.last``


.. table:: ``remap.config`` Template Tags

+------------------+-----------------------------------+-------------------------------+
| :ref:`tag-name` | Value_ | Associated plugin/directive |
+==================+===================================+===============================+
| Source | Target, or request "from" URL | |
+------------------+-----------------------------------+-------------------------------+
| Destination | Replacement, or origin (“to”) URL | |
+------------------+-----------------------------------+-------------------------------+
| Strategy | NextHop selection strategy | parent_select.so |
+------------------+-----------------------------------+-------------------------------+
| Dscp | IP packet marking | header_rewrite.so |
+------------------+-----------------------------------+-------------------------------+
| HeaderRewrite | Header rewrite rules | header_rewrite.so |
+------------------+-----------------------------------+-------------------------------+
| DropQstring | Query string handling at edge | regex_remap.so |
+------------------+-----------------------------------+-------------------------------+
| Signing | URL Signing method | url_sig.so, uri_signing.so |
+------------------+-----------------------------------+-------------------------------+
| RegexRemap | Regex remap expressions | regex_remap.so |
+------------------+-----------------------------------+-------------------------------+
| Cachekey | Cachekey plugin parameters | cachekey.so |
+------------------+-----------------------------------+-------------------------------+
| RangeRequests | Range request handling | background_fetch.so, slice.so |
+------------------+-----------------------------------+-------------------------------+
| Pacing | Fair-Queuing Pacing Rate | fq_pacing.so |
+------------------+-----------------------------------+-------------------------------+
| RawText | Raw remap text for edge | |
+------------------+-----------------------------------+-------------------------------+

Default internal template values:

.. code-block:: text
:caption: Default for template.first
map {{{Source}}} {{{Destination}}} {{{Strategy}}} {{{Dscp}}} {{{HeaderRewrite}}} {{{DropQstring}}} {{{Signing}}} {{{RegexRemap}}} {{{Cachekey}}} {{{RangeRequests}}} {{{Pacing}}} {{{RawText}}}
.. code-block:: text
:caption: Default for template.inner, template.last
map {{{Source}}} {{{Destination}}} {{{Strategy}}} {{{HeaderRewrite}}} {{{Cachekey}}} {{{RangeRequests}}} {{{RawText}}}
Users may use the above templates do things like manipulate the inputs to the cachekey via other plugins or modify the rule type from ``map`` to ``map_with_recv_port``.

.. seealso:: For an explanation of the mustache syntax of the template, refer to `the mustache spec documentation <https://github.com/mustache/spec>`_.

.. seealso:: For an explanation of the syntax of this ``remap.config`` file, refer to `the Apache Traffic Server remap.config documentation <https://docs.trafficserver.apache.org/en/7.1.x/admin-guide/files/remap.config.en.html>`_.

:file:`set_dscp_{anything}.config`
''''''''''''''''''''''''''''''''''
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require (
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
github.com/basho/riak-go-client v1.7.1-0.20170327205844-5587c16e0b8b
github.com/cbroglie/mustache v1.4.0
github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575
github.com/dchest/siphash v1.2.2
github.com/fsnotify/fsnotify v1.5.1
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44/go.mod h1:bbYlZJ7
github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8=
github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50=
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
github.com/cbroglie/mustache v1.4.0 h1:Azg0dVhxTml5me+7PsZ7WPrQq1Gkf3WApcHMjMprYoU=
github.com/cbroglie/mustache v1.4.0/go.mod h1:SS1FTIghy0sjse4DUVGV1k/40B1qE1XkD9DtDsHo9iM=
github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34=
github.com/cactus/go-statsd-client/statsd v0.0.0-20191106001114-12b4e2b38748/go.mod h1:l/bIBLeOl9eX+wxJAzxS4TveKRtAqlyDpHjhkfO0MEI=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
Expand Down Expand Up @@ -421,7 +423,6 @@ github.com/eapache/go-resiliency v1.2.0 h1:v7g92e/KSN71Rq7vSThKaWIq68fL4YHvWyiUK
github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8/yCZMuEPMUDHG0CW/brkkEp8mzqk2+ODEitlw=
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts=
Expand Down

0 comments on commit 47098fb

Please sign in to comment.