Skip to content

Commit

Permalink
Merge pull request #188 from akutz/feature/gofig
Browse files Browse the repository at this point in the history
Gofig Integration / Namespace Change
  • Loading branch information
akutz committed Dec 1, 2015
2 parents b072958 + 23de2b7 commit 86c069e
Show file tree
Hide file tree
Showing 27 changed files with 288 additions and 1,466 deletions.
4 changes: 2 additions & 2 deletions .docs/about/release-notes.md
Expand Up @@ -208,8 +208,8 @@ users. The commands are now categorized into logical groups:
Global Flags:
-c, --config="/Users/akutz/.rexray/config.yaml": The REX-Ray configuration file
-?, --help[=false]: Help for rexray
-h, --host="tcp://:7979": The REX-Ray service address
-l, --logLevel="info": The log level (panic, fatal, error, warn, info, debug)
-h, --rexrayHost="tcp://:7979": The REX-Ray service address
-l, --rexrayLogLevel="info": The log level (panic, fatal, error, warn, info, debug)
-v, --verbose[=false]: Print verbose help information

Use "rexray [command] --help" for more information about a command.
Expand Down
4 changes: 2 additions & 2 deletions .docs/index.md
Expand Up @@ -12,8 +12,8 @@ list storage for a guest hosted on Amazon Web Services (AWS) with `REX-Ray`:

```bash
$ export REXRAY_STORAGEDRIVERS=ec2
$ export AWS_ACCESS_KEY=access_key
$ export AWS_SECRET_KEY=secret_key
$ export AWS_ACCESSKEY=access_key
$ export AWS_SECRETKEY=secret_key
$ rexray volume get

- providername: ec2
Expand Down
254 changes: 79 additions & 175 deletions .docs/user-guide/config.md
Expand Up @@ -70,11 +70,37 @@ This is an example configuration with the default configuration for the general
options as described in the following section:

```yaml
logLevel: warn
osDrivers:
- linux
volumeDrivers:
- docker
rexray:
logLevel: warn
osDrivers:
- linux
volumeDrivers:
- docker
```

## Configuration Files
There are two `REX-Ray` configuration files - global and user:

* `/etc/rexray/config.yml`
* `$HOME/.rexray/config.yml`

Please note that while the user configuration file is located inside the user's
home directory, this is the directory of the user that starts `REX-Ray`. And
if `REX-Ray` is being started as a service, then `sudo` is likely being used,
which means that `$HOME/.rexray/config.yml` won't point to *your* home
directory, but rather `/root/.rexray/config.yml`.

This is an example configuration with the default configuration for the general
options as described in the following section:

```yaml
rexray:
logLevel: warn
osDrivers:
- linux
storageDrivers:
volumeDrivers:
- docker
```

## Configuration Properties
Expand All @@ -88,58 +114,27 @@ These are the global configuration properties with their default values as
represented in a a YAML configuration file:

```yaml
logLevel: warn
osDrivers:
- linux
storageDrivers:
volumeDrivers:
- docker
rexray:
logLevel: warn
osDrivers:
- linux
storageDrivers:
volumeDrivers:
- docker
```

The property `logLevel` is a string and the properties `osDrivers`,
`storageDrivers`, and `volumeDrivers` are all arrays of strings. These values
can also be set via environment variables or the command line, but to do so
requires knowing the names of the environment variables or CLI flags to use.
Luckily those are very easy to figure out just by knowing the property names.

### Top-Level Properties
For any configuration file property there is really only one exception to
consider when deriving the name of the property's equivalent environment
variable or CLI flag: is the property a top-level property? The top-level
properties are:

* `logLevel`
* `osDrivers`
* `storageDrivers`
* `volumeDrivers`

For any top-level property the name of its equivalent environment variable is
the name of the property, in all caps, prefixed with `REXRAY_`. Additionally,
the name of the property's CLI flag is equivalent to the property name, as is.
The following table illustrates the transformations:

Property Name | Environment Variable | CLI Flag
--------------|----------------------|-------------
`logLevel` | `REXRAY_LOGLEVEL` | `--logLevel`
`osDrivers` | `REXRAY_OSDRIVERS` | `--osDrivers`
`storageDrivers` | `REXRAY_STORAGEDRIVERS` | `--storageDrivers`
`volumeDrivers` | `REXRAY_VOLUMEDRIVERS` | `--volumeDrivers`

### All Other Properties
The other properties that might appear in the `REX-Ray` configuration file all
fall under some type of heading. For example, a possible configuration of the
Amazon Web Services (AWS) Elastic Compute Cloud (EC2) storage driver might look
like this:
The property `rexray.logLevel` is a string and the properties
`rexray.osDrivers`, `rexray.storageDrivers`, and `rexray.volumeDrivers` are all
arrays of strings. These values can also be set via environment variables or the
command line, but to do so requires knowing the names of the environment
variables or CLI flags to use. Luckily those are very easy to figure out just
by knowing the property names.

```yaml
aws:
accessKey: MyAccessKey
secretKey: MySecretKey
region: USNW
```
All properties that might appear in the `REX-Ray` configuration file
fall under some type of heading. For example, take the default configuration
above.

For any property that's nested, the rule for environment variables is as
follows:
The rule for environment variables is as follows:

* Each nested level becomes a part of the environment variable name followed
by an underscore `_` except for the terminating part.
Expand All @@ -155,6 +150,23 @@ Nested properties follow these rules for CLI flags:

The following table illustrates the transformations:

Property Name | Environment Variable | CLI Flag
--------------|----------------------|-------------
`rexray.logLevel` | `REXRAY_LOGLEVEL` | `--rexrayLogLevel`
`rexray.osDrivers` | `REXRAY_OSDRIVERS` | `--rexrayOsDrivers`
`rexray.storageDrivers` | `REXRAY_STORAGEDRIVERS` | `--rexrayStorageDrivers`
`rexray.volumeDrivers` | `REXRAY_VOLUMEDRIVERS` | `--rexrayVolumeDrivers`

Another example is a possible configuration of the Amazon Web Services (AWS)
Elastic Compute Cloud (EC2) storage driver:

```yaml
aws:
accessKey: MyAccessKey
secretKey: MySecretKey
region: USNW
```

Property Name | Environment Variable | CLI Flag
--------------|----------------------|-------------
`aws.accessKey` | `AWS_ACCESSKEY` | `--awsAccessKey`
Expand All @@ -163,24 +175,25 @@ Property Name | Environment Variable | CLI Flag

### String Arrays
Please note that properties that are represented as arrays in a configuration
file, such as the `osDrivers`, `storageDrivers`, and `volumeDrivers` above, are
not arrays, but multi-valued strings where a space acts as a delimiter. This is
because the Viper project
file, such as the `rexray.osDrivers`, `rexray.storageDrivers`, and
`rexray.volumeDrivers` above, are not arrays, but multi-valued strings where a
space acts as a delimiter. This is because the Viper project
[does not bind](https://github.com/spf13/viper/issues/112) Go StringSlices
(string arrays) correctly to [PFlags](https://github.com/spf13/pflag).

For example, this is how one would specify the storage drivers `ec2` and
`xtremio` in a configuration file:

```yaml
storageDrivers:
rexray:
storageDrivers:
- ec2
- xtremio
```

However, to specify the same values in an environment variable,
`REXRAY_STORAGEDRIVERS="ec2 xtremio"`, and as a CLI flag,
`--storageDrivers="ec2 xtremio"`.
`--rexrayStorageDrivers="ec2 xtremio"`.

## Logging
The `REX-Ray` log level determines the level of verbosity emitted by the
Expand All @@ -194,13 +207,6 @@ as well:
`info` | Log errors, warnings, and workflow messages
`debug` | Log everything

The log level can be set by environment variable, a configuration file, or via
the command line:

Environment Variable | Config File Property | CLI Flag(s)
---------------------|----------------------|-------------
`REXRAY_LOGLEVEL` | `logLevel` | `--logLevel`, `-l`

For example, the following two commands may look slightly different, but they
are functionally the same, both printing a list of volumes using the `debug`
log level:
Expand All @@ -215,57 +221,20 @@ rexray volume get -l debug
env REXRAY_LOGLEVEL=debug rexray volume get
```

## OS Drivers
### OS Drivers
Operating system (OS) drivers enable `REX-Ray` to manage storage on
the underlying OS.

### OS Driver Types
Currently the following OS drivers are supported:
the underlying OS. Currently the following OS drivers are supported:

Driver | Driver Name
--------|------------
Linux | linux

### Automatic OS Drivers
The OS driver `linux` is automatically activated when `REX-Ray` is running on
the Linux OS.

### Activating OS Drivers
While all drivers are automatically registered, they are not all automatically
activated. OS drivers can be activated by by environment variable, a
configuration file, or via the command line:

Environment Variable | Config File Property | CLI Flag(s)
---------------------|----------------------|-------------
`REXRAY_OSDRIVERS` | `osDrivers` | `--osDrivers`

The environment variable and CLI flag both expect a space-delimited list of
OS driver names such as:

```bash
env REXRAY_OSDRIVERS=linux rexray volume get
```

or

```bash
rexray volume get --osDrivers=linux
```

However, when specifying the `osDrivers` option in a configuration file, since
the option is multi-valued, it would look like the following:

```yaml
osDrivers:
- linux
```

## Storage Drivers
### Storage Drivers
Storage drivers enable `REX-Ray` to communicate with direct-attached or remote
storage systems.

### Storage Driver Types
Currently the following storage drivers are supported:
storage systems. Currently the following storage drivers are supported:

Driver | Driver Name
--------|------------
Expand All @@ -275,80 +244,15 @@ Rackspace | rackspace
ScaleIO | scaleio
XtremIO | xtremio

### Automatic Storage Drivers
No storage drivers are automatically activated.

### Activating Storage Drivers
While all drivers are automatically registered, not all are automatically
activated. Storage drivers can be activated by by environment variable, a
configuration file, or via the command line:

Environment Variable | Config File Property | CLI Flag(s)
---------------------|----------------------|-------------
`REXRAY_STORAGEDRIVERS` | `storageDrivers` | `--storageDrivers`

The environment variable and CLI flag both expect a space-delimited list of
storage driver names such as:
The `rexray.storageDrivers` property can be used to activate storage drivers..

```bash
env REXRAY_STORAGEDRIVERS="ec2 xtremio" rexray volume get
```

or

```bash
rexray volume get --osDrivers="ec2 xtremio"
```

However, when specifying the `storageDrivers` option in a configuration file,
since the option is multi-valued, it would look like the following:

```yaml
storageDrivers:
- ec2
- xtremio
```

## Volume Drivers
### Volume Drivers
Volume drivers enable `REX-Ray` to manage volumes for consumers of the storage,
such as `Docker` or `Mesos`.

### Volume Driver Types
Currently the following volume drivers are supported:
such as `Docker` or `Mesos`. Currently the following volume drivers are
supported:

Driver | Driver Name
--------|------------
Docker | docker

### Automatic Volume Drivers
The volume driver `docker` is automatically activated.

### Activating Volume Drivers
While all drivers are automatically registered, they are not all automatically
activated. Volume drivers can be activated by by environment variable, a
configuration file, or via the command line:

Environment Variable | Config File Property | CLI Flag(s)
---------------------|----------------------|-------------
`REXRAY_VOLUMEDRIVERS` | `volumeDrivers` | `--volumeDrivers`

The environment variable and CLI flag both expect a space-delimited list of
volume driver names such as:

```bash
env REXRAY_VOLUMEDRIVERS=docker rexray volume get
```

or

```bash
rexray volume get --volumeDrivers=docker
```

However, when specifying the `volumeDrivers` option in a configuration file,
since the option is multi-valued, it would look like the following:

```yaml
volumeDrivers:
- docker
```

0 comments on commit 86c069e

Please sign in to comment.