Skip to content

Commit 3d53505

Browse files
authored
Add getenv to template function map (#213)
* Add getenv to template function map
1 parent 5f1e541 commit 3d53505

File tree

10 files changed

+474
-427
lines changed

10 files changed

+474
-427
lines changed

docs/settingup.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,6 +2347,7 @@ The following functions are supported:
23472347
* `hostname`: Hostname of the local machine.
23482348
* `timestamp`: Timestamp in `yyyyMMddhhmmss` format.
23492349
* `uuid`: Generate an uuid.
2350+
* `env`: Retrieve a specific environment variable. Takes one argument - the name of the environment variable to expand.
23502351

23512352
### Example
23522353
```json
@@ -2379,6 +2380,16 @@ The following functions are supported:
23792380
}
23802381
}
23812382

2383+
```
2384+
2385+
```json
2386+
{
2387+
"action": "createbookmark",
2388+
"settings": {
2389+
"title": "{{env \"TITLE\"}}",
2390+
"description": "This bookmark contains some interesting selections"
2391+
}
2392+
}
23822393
```
23832394
</details>
23842395

generatedocs/data/extra/sessionvariables/description.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The following functions are supported:
2424
* `hostname`: Hostname of the local machine.
2525
* `timestamp`: Timestamp in `yyyyMMddhhmmss` format.
2626
* `uuid`: Generate an uuid.
27+
* `env`: Retrieve a specific environment variable. Takes one argument - the name of the environment variable to expand.
2728

2829
### Example
2930
```json
@@ -56,5 +57,15 @@ The following functions are supported:
5657
}
5758
}
5859

60+
```
61+
62+
```json
63+
{
64+
"action": "createbookmark",
65+
"settings": {
66+
"title": "{{env \"TITLE\"}}",
67+
"description": "This bookmark contains some interesting selections"
68+
}
69+
}
5970
```
6071
</details>

generatedocs/generated/documentation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ var (
455455

456456
Extra = map[string]common.DocEntry{
457457
"sessionvariables": {
458-
Description: "\n## Session variables\n\nThis section describes the session variables that can be used with some of the actions.\n\n<details>\n<summary><a name=\"session_variables\"></a>Session variables</summary>\n\nSome action parameters support session variables. A session variable is defined by putting the variable, prefixed by a dot, within double curly brackets, such as `{{.UserName}}`.\n\nThe following session variables are supported in actions:\n\n* `UserName`: The simulated username. This is not the same as the authenticated user, but rather how the username was defined by [Login settings](#login_settings). \n* `Session`: The enumeration of the currently simulated session.\n* `Thread`: The enumeration of the currently simulated \"thread\" or \"concurrent user\".\n\nThe following variable is supported in the filename of the log file:\n\n* `ConfigFile`: The filename of the config file, without file extension.\n\nThe following functions are supported:\n\n* `now`: Evaluates Golang [time.Now()](https://golang.org/pkg/time/). \n* `hostname`: Hostname of the local machine.\n* `timestamp`: Timestamp in `yyyyMMddhhmmss` format.\n* `uuid`: Generate an uuid.\n\n### Example\n```json\n{\n \"action\": \"ElasticCreateApp\",\n \"label\": \"Create new app\",\n \"settings\": {\n \"title\": \"CreateApp {{.Thread}}-{{.Session}} ({{.UserName}})\",\n \"stream\": \"mystream\",\n \"groups\": [\n \"mygroup\"\n ]\n }\n},\n{\n \"label\": \"OpenApp\",\n \"action\": \"OpenApp\",\n \"settings\": {\n \"appname\": \"CreateApp {{.Thread}}-{{.Session}} ({{.UserName}})\"\n }\n},\n{\n \"action\": \"elasticexportapp\",\n \"label\": \"Export app\",\n \"settings\": {\n \"appmode\" : \"name\",\n \"app\" : \"CreateApp {{.Thread}}-{{.Session}} ({{.UserName}})\",\n \"savetofile\": true,\n \"exportname\": \"Exported app {{.Thread}}-{{.Session}} {{now.UTC}}\"\n }\n}\n\n```\n</details>\n",
458+
Description: "\n## Session variables\n\nThis section describes the session variables that can be used with some of the actions.\n\n<details>\n<summary><a name=\"session_variables\"></a>Session variables</summary>\n\nSome action parameters support session variables. A session variable is defined by putting the variable, prefixed by a dot, within double curly brackets, such as `{{.UserName}}`.\n\nThe following session variables are supported in actions:\n\n* `UserName`: The simulated username. This is not the same as the authenticated user, but rather how the username was defined by [Login settings](#login_settings). \n* `Session`: The enumeration of the currently simulated session.\n* `Thread`: The enumeration of the currently simulated \"thread\" or \"concurrent user\".\n\nThe following variable is supported in the filename of the log file:\n\n* `ConfigFile`: The filename of the config file, without file extension.\n\nThe following functions are supported:\n\n* `now`: Evaluates Golang [time.Now()](https://golang.org/pkg/time/). \n* `hostname`: Hostname of the local machine.\n* `timestamp`: Timestamp in `yyyyMMddhhmmss` format.\n* `uuid`: Generate an uuid.\n* `env`: Retrieve a specific environment variable. Takes one argument - the name of the environment variable to expand.\n\n### Example\n```json\n{\n \"action\": \"ElasticCreateApp\",\n \"label\": \"Create new app\",\n \"settings\": {\n \"title\": \"CreateApp {{.Thread}}-{{.Session}} ({{.UserName}})\",\n \"stream\": \"mystream\",\n \"groups\": [\n \"mygroup\"\n ]\n }\n},\n{\n \"label\": \"OpenApp\",\n \"action\": \"OpenApp\",\n \"settings\": {\n \"appname\": \"CreateApp {{.Thread}}-{{.Session}} ({{.UserName}})\"\n }\n},\n{\n \"action\": \"elasticexportapp\",\n \"label\": \"Export app\",\n \"settings\": {\n \"appmode\" : \"name\",\n \"app\" : \"CreateApp {{.Thread}}-{{.Session}} ({{.UserName}})\",\n \"savetofile\": true,\n \"exportname\": \"Exported app {{.Thread}}-{{.Session}} {{now.UTC}}\"\n }\n}\n\n```\n\n```json\n{\n \"action\": \"createbookmark\",\n \"settings\": {\n \"title\": \"{{env \\\"TITLE\\\"}}\",\n \"description\": \"This bookmark contains some interesting selections\"\n }\n}\n```\n</details>\n",
459459
Examples: "",
460460
},
461461
}

generatedocs/pkg/doccompiler/testdata/base/data/extra/sessionvariables/description.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The following functions are supported:
2424
* `hostname`: Hostname of the local machine.
2525
* `timestamp`: Timestamp in `yyyyMMddhhmmss` format.
2626
* `uuid`: Generate an uuid.
27+
* `env`: Retrieve a specific environment variable. Takes one argument - the name of the environment variable to expand.
2728

2829
### Example
2930
```json
@@ -56,5 +57,15 @@ The following functions are supported:
5657
}
5758
}
5859

60+
```
61+
62+
```json
63+
{
64+
"action": "createbookmark",
65+
"settings": {
66+
"title": "{{env \"TITLE\"}}",
67+
"description": "This bookmark contains some interesting selections"
68+
}
69+
}
5970
```
6071
</details>

0 commit comments

Comments
 (0)