Repository: lyraproj/hiera (go)

Issue:
Configuration option `data_dir` should be `datadir`
For compatibility with the puppet hiera docs, `data_dir` needs to be renamed to `datadir`.

https://puppet.com/docs/puppet/5.0/hiera_config_yaml_5.html#the-defaults-key

Pull request description:
Rename data_dir to be datadir
This is necessary for compatibility with the hiera 5 docs.
(Though it is inconsistent with the other keys, the benefit
of consistency with the existing implementation is more important)

Fixes #11 

Patch:
diff --git a/internal/config.go b/internal/config.go
index 04d95c9..a68af9a 100644
--- a/internal/config.go
+++ b/internal/config.go
@@ -302,7 +302,7 @@ func (hc *hieraCfg) createHierarchyEntry(ic hieraapi.Invocation, name string, en
 	entry.initialize(ic, name, entryHash)
 	entryHash.EachPair(func(k, v px.Value) {
 		ks := k.String()
-		if ks == `data_dir` {
+		if ks == `datadir` {
 			entry.dataDir = v.String()
 		}
 		if utils.ContainsString(hieraapi.LocationKeys, ks) {
diff --git a/internal/init.go b/internal/init.go
index c4ee7ae..f63fb74 100644
--- a/internal/init.go
+++ b/internal/init.go
@@ -22,7 +22,7 @@ func init() {
 				Optional[data_dig] => String[1],
 				Optional[data_hash] => String[1],
 				Optional[lookup_key] => String[1],
-				Optional[data_dir] => String[1],
+				Optional[datadir] => String[1],
 			}],
 			Entry => Struct[{
 				name => String[1],
@@ -30,7 +30,7 @@ func init() {
 				Optional[data_dig] => String[1],
 				Optional[data_hash] => String[1],
 				Optional[lookup_key] => String[1],
-				Optional[data_dir] => String[1],
+				Optional[datadir] => String[1],
 				Optional[path] => String[1],
 				Optional[paths] => Array[String[1], 1],
 				Optional[glob] => String[1],


Test patch:
diff --git a/internal/testdata/explicit/hiera.yaml b/internal/testdata/explicit/hiera.yaml
index 137d9ad..61e7446 100644
--- a/internal/testdata/explicit/hiera.yaml
+++ b/internal/testdata/explicit/hiera.yaml
@@ -2,9 +2,9 @@ version: 5
 hierarchy:
   - name: Test 1
     data_hash: yaml_data
-    data_dir: hiera_data
+    datadir: hiera_data
     path: data.yaml
   - name: Test 2
     data_hash: json_data
-    data_dir: hiera_data
+    datadir: hiera_data
     path: data2.json