-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs for
environment
block, setting and variable
- Loading branch information
1 parent
a4f2b69
commit 7d72a8d
Showing
4 changed files
with
40 additions
and
33 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
56 changes: 29 additions & 27 deletions
56
docs/website/content/2.configuration/4.block/environment.md
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 |
---|---|---|
@@ -1,52 +1,54 @@ | ||
# Environment Block | ||
# Environment | ||
|
||
The `environment` block lets you refine the Couper configuration based on the set | ||
[environment](/configuration/command-linemd#global-options). | ||
[environment](../command-line#global-options). | ||
|
||
| Block name | Context | Label | Nested block(s) | | ||
| :------------ | :------- | :----------------------------------------------- | :---------------------------------- | | ||
| `environment` | Overall. | ⚠ required, multiple labels are supported. | All configuration blocks of Couper. | | ||
|
||
The `environment` block works like a preprocessor. If the label of an `environment` | ||
block do not match the set [environment](./CLI.md#global-options) value, the preprocessor | ||
removes this block and their content. Otherwise, the content of the block is applied | ||
block does not match the set [`COUPER_ENVIRONMENT`](../command-line#global-options) value, the preprocessor | ||
removes this block and its content. Otherwise, the content of the block is added | ||
to the configuration. | ||
|
||
If the [environment](/configuration/command-linemd#global-options) value set to `prod`, the following configuration | ||
## Example | ||
|
||
Considering the following configuration with the `COUPER_ENVIRONMENT` value set to `prod` | ||
|
||
```hcl | ||
server { | ||
api "protected" { | ||
endpoint "/secure" { | ||
environment "prod" { | ||
access_control = ["jwt"] | ||
} | ||
proxy { | ||
environment "prod" { | ||
url = "https://protected-resource.org" | ||
} | ||
environment "stage" { | ||
url = "https://test-resource.org" | ||
} | ||
} | ||
api "protected" { | ||
endpoint "/secure" { | ||
environment "prod" { | ||
access_control = ["jwt"] | ||
} | ||
proxy { | ||
environment "prod" { | ||
url = "https://protected-resource.org" | ||
} | ||
environment "stage" { | ||
url = "https://test-resource.org" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
produces after the preprocessing the following configuration: | ||
the result will be: | ||
|
||
```hcl | ||
server { | ||
api "protected" { | ||
endpoint "/secure" { | ||
access_control = ["jwt"] | ||
api "protected" { | ||
endpoint "/secure" { | ||
access_control = ["jwt"] | ||
proxy { | ||
url = "https://protected-resource.org" | ||
} | ||
} | ||
proxy { | ||
url = "https://protected-resource.org" | ||
} | ||
} | ||
} | ||
} | ||
``` |
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
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