-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from hairyhenderson/aws-namespace
Namespacing the aws funcs
- Loading branch information
Showing
13 changed files
with
282 additions
and
170 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
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
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,75 @@ | ||
--- | ||
title: aws functions | ||
menu: | ||
main: | ||
parent: functions | ||
--- | ||
|
||
|
||
## `aws.EC2Meta` | ||
|
||
**Alias:** _(to be deprecated)_ `ec2meta` | ||
|
||
Queries AWS [EC2 Instance Metadata](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html) for information. This only retrieves data in the `meta-data` path -- for data in the `dynamic` path use `aws.EC2Dynamic`. | ||
|
||
This only works when running `gomplate` on an EC2 instance. If the EC2 instance metadata API isn't available, the tool will timeout and fail. | ||
|
||
#### Example | ||
|
||
```console | ||
$ echo '{{aws.EC2Meta "instance-id"}}' | gomplate | ||
i-12345678 | ||
``` | ||
|
||
## `aws.EC2Dynamic` | ||
|
||
**Alias:** _(to be deprecated)_ `ec2dynamic` | ||
|
||
Queries AWS [EC2 Instance Dynamic Metadata](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html) for information. This only retrieves data in the `dynamic` path -- for data in the `meta-data` path use `aws.EC2Meta`. | ||
|
||
This only works when running `gomplate` on an EC2 instance. If the EC2 instance metadata API isn't available, the tool will timeout and fail. | ||
|
||
#### Example | ||
|
||
```console | ||
$ echo '{{ (aws.EC2Dynamic "instance-identity/document" | json).region }}' | ./gomplate | ||
us-east-1 | ||
``` | ||
|
||
## `aws.EC2Region` | ||
|
||
**Alias:** _(to be deprecated)_ `ec2region` | ||
|
||
Queries AWS to get the region. An optional default can be provided, or returns | ||
`unknown` if it can't be determined for some reason. | ||
|
||
#### Example | ||
|
||
_In EC2_ | ||
```console | ||
$ echo '{{ aws.EC2Region }}' | ./gomplate | ||
us-east-1 | ||
``` | ||
_Not in EC2_ | ||
```console | ||
$ echo '{{ aws.EC2Region }}' | ./gomplate | ||
unknown | ||
$ echo '{{ aws.EC2Region "foo" }}' | ./gomplate | ||
foo | ||
``` | ||
|
||
## `aws.EC2Tag` | ||
|
||
**Alias:** _(to be deprecated)_ `ec2tag` | ||
|
||
Queries the AWS EC2 API to find the value of the given [user-defined tag](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html). An optional default | ||
can be provided. | ||
|
||
#### Example | ||
|
||
```console | ||
$ echo 'This server is in the {{ aws.EC2Tag "Account" }} account.' | ./gomplate | ||
foo | ||
$ echo 'I am a {{ aws.EC2Tag "classification" "meat popsicle" }}.' | ./gomplate | ||
I am a meat popsicle. | ||
``` |
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
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,6 +1,7 @@ | ||
--- | ||
title: Installing | ||
weight: 10 | ||
menu: main | ||
--- | ||
# Installing | ||
|
||
|
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
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 @@ | ||
package main | ||
|
||
import ( | ||
"net/url" | ||
"strings" | ||
"text/template" | ||
|
||
"github.com/hairyhenderson/gomplate/funcs" | ||
) | ||
|
||
// initFuncs - The function mappings are defined here! | ||
func initFuncs(data *Data) template.FuncMap { | ||
env := &Env{} | ||
typeconv := &TypeConv{} | ||
stringfunc := &stringFunc{} | ||
|
||
f := template.FuncMap{ | ||
"getenv": env.Getenv, | ||
"bool": typeconv.Bool, | ||
"has": typeconv.Has, | ||
"json": typeconv.JSON, | ||
"jsonArray": typeconv.JSONArray, | ||
"yaml": typeconv.YAML, | ||
"yamlArray": typeconv.YAMLArray, | ||
"toml": typeconv.TOML, | ||
"csv": typeconv.CSV, | ||
"csvByRow": typeconv.CSVByRow, | ||
"csvByColumn": typeconv.CSVByColumn, | ||
"slice": typeconv.Slice, | ||
"indent": typeconv.indent, | ||
"join": typeconv.Join, | ||
"toJSON": typeconv.ToJSON, | ||
"toJSONPretty": typeconv.toJSONPretty, | ||
"toYAML": typeconv.ToYAML, | ||
"toTOML": typeconv.ToTOML, | ||
"toCSV": typeconv.ToCSV, | ||
"contains": strings.Contains, | ||
"hasPrefix": strings.HasPrefix, | ||
"hasSuffix": strings.HasSuffix, | ||
"replaceAll": stringfunc.replaceAll, | ||
"split": strings.Split, | ||
"splitN": strings.SplitN, | ||
"title": strings.Title, | ||
"toUpper": strings.ToUpper, | ||
"toLower": strings.ToLower, | ||
"trim": strings.Trim, | ||
"trimSpace": strings.TrimSpace, | ||
"urlParse": url.Parse, | ||
"datasource": data.Datasource, | ||
"ds": data.Datasource, | ||
"datasourceExists": data.DatasourceExists, | ||
"include": data.include, | ||
} | ||
funcs.AWSFuncs(f) | ||
return f | ||
} |
Oops, something went wrong.