docs for users and devs regarding reading the config elements from the config file

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2019-08-20 17:51:17 -04:00
parent 82acec957e
commit 6a6bf2595c
2 changed files with 34 additions and 1 deletions

View file

@ -1,6 +1,6 @@
# The Chef InSpec Configuration File
This documents the Chef InSpec configuration file format introduced in version 3.5 of InSpec.
This documents the Chef InSpec configuration file format introduced in version 3.5 of InSpec and extended in later versions.
## Config File Location
@ -83,3 +83,30 @@ Credential sets are intended to work hand-in-hand with the underlying credential
### reporter
You may also set output (reporter) options in the config file. See the [Reporters Page](https://www.inspec.io/docs/reference/reporters/) for details.
## Version 1.2
Version 1.2 adds a top-level field, "plugins".
### plugins
Use the `plugins` top-level configuration field to provide configuration settings to plugins that you use with Chef InSpec. Refer to the documentation of the plugin you are using for details regarding which settings are available.
To use this new feature, add a new top-level key in your config file named `plugins`. Then create a sub-key named for each plugin you wish to configure. Each plugin will have a key-value are that it may use as it sees fit - Chef Inspec does not specify the structure. Here is an example, using contrived plugins:
```
{
"version":"1.2",
"plugins": {
"inspec-training-wheels": {
"diameter": "4 inches"
},
"inspec-input-secrets": {
"security-tokens: [
"123456789".
"abcdef252875"
]
}
}
}
```

View file

@ -68,6 +68,12 @@ Putting this all together, here is a plugins.json file from the Chef InSpec test
}
```
### Plugin Runtime Configuration
You can read runtime configuration data from your user using `Inspec::Config.cached.fetch_plugin_config("your-plugin-name")`, which will return a hash with indifferent access representing the user's config file `plugins` section pertaining to your plugin. See [the config file](https://www.inspec.io/docs/reference/config/) for more information.
Do not store or read configuration information from plugins.json.
## Plugin Parts
### A Typical Plugin File Layout