Skip to content

Commit

Permalink
Add new template functions into README (closes #41)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeemster committed Nov 4, 2015
1 parent bcd670c commit dc95671
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,36 @@ guest> godep go build
Assuming **Building** complete:

```
guest> sudo -u postgres psql
psql# \password
psql# Enter password: postgres
psql# \q
guest> psql -c 'create database sql_runner_tests_1' -U postgres
guest> psql -c 'create database sql_runner_tests_2' -U postgres
guest> ./sql-runner -playbook ./integration-tests/postgres.yml
guest> ./sql-runner -playbook ./integration-tests/good-postgres.yml
```

### Publishing

Assuming **[Travis] [travis]** is green and versions updated:

```bash
guest> godep go build
host> vagrant push
```

This will build an individual artifact for Windows, OSX and Linux all in 64 bit. All artifacts are stored in the `dist/` directory.

## User guide

### CLI Arguments

There are several command line arguments that can be used:

* `-playbook` : This is a required argument and should point to the playbook you wish to run.
* `-fromStep` : Optional argument which will allow you to start the sql-runner from any step in your playbook.
* `-sqlroot` : Optional argument to change where we look for the sql statements to run, defaults to the directory of your playbook.
* `-var` : Optional argument which allows you to pass a dictionary of key-value pairs which will be used to flesh out your templates.

### Playbooks

A playbook consists of one of more _steps_, each of which consists of one or more _queries_. Steps are run in series, queries are run in parallel within the step.
Expand All @@ -77,7 +91,13 @@ Templates are run through Golang's [text template processor] [go-text-template].

The following custom functions are also supported:

* `nowWithFormat [timeFormat]` - where `timeFormat` is a valid Golang [time format] [go-time-format]
* `nowWithFormat [timeFormat]`: where `timeFormat` is a valid Golang [time format] [go-time-format]
* `awsEnvCredentials`: supports passing credentials through environment variables, such as `AWS_ACCESS_KEY_ID`, `AWS_ACCESS_KEY`, `AWS_SECRET_ACCESS_KEY` and `AWS_SECRET_KEY`
* `awsProfileCredentials`: supports getting credentials from a credentials file, also used by boto/awscli
* `awsEC2RoleCredentials`: supports getting role-based credentials, i.e. getting the automatically generated credentials in EC2 instances
* `awsChainCredentials`: tries to get credentials from each of the three methods above in order, using the first one returned

**Note**: All AWS functions output strings in the Redshift credentials format (`CREDENTIALS 'aws_access_key_id=%s;aws_secret_access_key=%s'`).

For an example query file using templating see: [integration-tests/postgres-sql/good/3.sql] [example-query]

Expand Down

0 comments on commit dc95671

Please sign in to comment.