-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
caddyfile: Pass blocks to
import
for snippets (#6130)
* a * a * a * a * a * a
- Loading branch information
Showing
5 changed files
with
337 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
caddytest/integration/caddyfile_adapt/import_block_snippet.caddyfiletest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
(snippet) { | ||
header { | ||
{block} | ||
} | ||
} | ||
|
||
example.com { | ||
import snippet { | ||
foo bar | ||
} | ||
} | ||
---------- | ||
{ | ||
"apps": { | ||
"http": { | ||
"servers": { | ||
"srv0": { | ||
"listen": [ | ||
":443" | ||
], | ||
"routes": [ | ||
{ | ||
"match": [ | ||
{ | ||
"host": [ | ||
"example.com" | ||
] | ||
} | ||
], | ||
"handle": [ | ||
{ | ||
"handler": "subroute", | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"handler": "headers", | ||
"response": { | ||
"set": { | ||
"Foo": [ | ||
"bar" | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"terminal": true | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
caddytest/integration/caddyfile_adapt/import_block_snippet_args.caddyfiletest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
(snippet) { | ||
{block} | ||
} | ||
|
||
example.com { | ||
import snippet { | ||
header foo bar | ||
} | ||
} | ||
---------- | ||
{ | ||
"apps": { | ||
"http": { | ||
"servers": { | ||
"srv0": { | ||
"listen": [ | ||
":443" | ||
], | ||
"routes": [ | ||
{ | ||
"match": [ | ||
{ | ||
"host": [ | ||
"example.com" | ||
] | ||
} | ||
], | ||
"handle": [ | ||
{ | ||
"handler": "subroute", | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"handler": "headers", | ||
"response": { | ||
"set": { | ||
"Foo": [ | ||
"bar" | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"terminal": true | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
caddytest/integration/caddyfile_adapt/import_blocks_snippet.caddyfiletest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
(snippet) { | ||
header { | ||
{blocks.foo} | ||
} | ||
header { | ||
{blocks.bar} | ||
} | ||
} | ||
|
||
example.com { | ||
import snippet { | ||
foo { | ||
foo a | ||
} | ||
bar { | ||
bar b | ||
} | ||
} | ||
} | ||
---------- | ||
{ | ||
"apps": { | ||
"http": { | ||
"servers": { | ||
"srv0": { | ||
"listen": [ | ||
":443" | ||
], | ||
"routes": [ | ||
{ | ||
"match": [ | ||
{ | ||
"host": [ | ||
"example.com" | ||
] | ||
} | ||
], | ||
"handle": [ | ||
{ | ||
"handler": "subroute", | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"handler": "headers", | ||
"response": { | ||
"set": { | ||
"Foo": [ | ||
"a" | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"handler": "headers", | ||
"response": { | ||
"set": { | ||
"Bar": [ | ||
"b" | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"terminal": true | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
caddytest/integration/caddyfile_adapt/import_blocks_snippet_nested.caddyfiletest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
(snippet) { | ||
header { | ||
{blocks.bar} | ||
} | ||
import sub_snippet { | ||
bar { | ||
{blocks.foo} | ||
} | ||
} | ||
} | ||
(sub_snippet) { | ||
header { | ||
{blocks.bar} | ||
} | ||
} | ||
example.com { | ||
import snippet { | ||
foo { | ||
foo a | ||
} | ||
bar { | ||
bar b | ||
} | ||
} | ||
} | ||
---------- | ||
{ | ||
"apps": { | ||
"http": { | ||
"servers": { | ||
"srv0": { | ||
"listen": [ | ||
":443" | ||
], | ||
"routes": [ | ||
{ | ||
"match": [ | ||
{ | ||
"host": [ | ||
"example.com" | ||
] | ||
} | ||
], | ||
"handle": [ | ||
{ | ||
"handler": "subroute", | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"handler": "headers", | ||
"response": { | ||
"set": { | ||
"Bar": [ | ||
"b" | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"handler": "headers", | ||
"response": { | ||
"set": { | ||
"Foo": [ | ||
"a" | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"terminal": true | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} |