sf-hiera-aws 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 743247150dec1c5548e31200315a1fdd765afd22
4
- data.tar.gz: ad06bef85101602ce5b65565289a60a5b13d2920
3
+ metadata.gz: b73f19d1e2fa60079f083fc811a93d31e1809e05
4
+ data.tar.gz: 973b153e2fd3e28aa3428ae1851ceeed1c122be1
5
5
  SHA512:
6
- metadata.gz: 5ab644f595db9b4752aac825b44286dd181282ba06d24ae1e4228a7b539c9a93c7aa9afc4c208b77a2c923f7d2412fea1728261f5124a253dfeb86c3556dc2d5
7
- data.tar.gz: 1e701867da2da23d371b5d43f2b8c2e08f3663a06c9afcd5f71fbcae3138c59c912a6779f6d6086894ed375b4fe363af0ac94faccefdbdc28443f37b44fff673
6
+ metadata.gz: 7de055c8caff12473c42334a667ee1fd8a1dcb279dc3feb6290bceede10a41ad45332975d99f4a1b54008e5ea3e6d530eb477d6398b326304a629f1970ab21f2
7
+ data.tar.gz: 0a4d000856825e1acf1fe686cf185a3734d0f9358f7f2e9ec03eb03ab8adc044b7e84ee5b6a485f641ff16286590b36480e08b1c6b86a3738bba04014590884b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.4 (15 March 2016)
2
+
3
+ * Support lists of single items returned by ec2 instances
4
+
1
5
  ## 0.0.3 (16 December 2015)
2
6
 
3
7
  * Add rspec tests
data/README.md CHANGED
@@ -58,7 +58,21 @@ aws_am_search_nodes:
58
58
  - :private_dns_name
59
59
  ```
60
60
 
61
- The value of `return` here is also the default, and so can be omitted. You can use any of the methods listed at http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Instance.html to obtain other details from the Instance object.
61
+ The value of `return` here is also the default, and so can be omitted. You can use any of the methods listed at http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Instance.html to obtain other details from the Instance object. Calls to this key will return a list of hashes, each containing `instace_id`, `private_ip_address` and `private_dns_name` keys.
62
+
63
+ ### Example - EC2 nodes by tag, single item list
64
+
65
+ ```
66
+ aws_am_search_nodes:
67
+ type: :ec2_instance
68
+ filters:
69
+ - name: tag:aws:autoscaling:groupName
70
+ values: [ "%{::sf_location}-%{::sf_environment}-search" ]
71
+ return: :private_ip_address
72
+ ```
73
+
74
+ Here, we pass a single symbol to the `return` argument. In this case, we'll get back a list of strings containing private ip addresses (rather than a list of hashes).
75
+
62
76
 
63
77
 
64
78
  ### Example - RDS instance by name
@@ -164,9 +164,25 @@ class Hiera
164
164
  end
165
165
 
166
166
  instances.collect do |i|
167
- Hash[options['return'].map do |f|
168
- [f.to_s, i.key?(f) ? i[f] : nil]
169
- end]
167
+ if options['return'].is_a?(Array)
168
+
169
+ # If the 'return' option is a list, we treat these
170
+ # as a list of desired hash keys, and return a hash
171
+ # containing only those keys from the API call
172
+
173
+ Hash[options['return'].map do |f|
174
+ [f.to_s, i.key?(f) ? i[f] : nil]
175
+ end]
176
+
177
+ elsif options['return'].is_a?(Symbol)
178
+
179
+ # If the 'return' option is a symbol, we treat that
180
+ # as the one hash key we care about, and return a list
181
+ # of that.
182
+
183
+ i.key?(options['return']) ? i[options['return']] : nil
184
+
185
+ end
170
186
  end
171
187
  end
172
188
 
data/sf-hiera-aws.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'sf-hiera-aws'
7
- spec.version = '0.0.3'
7
+ spec.version = '0.0.4'
8
8
  spec.authors = ['Jon Topper']
9
9
  spec.email = ['jon@scalefactory.com']
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sf-hiera-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Topper
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-16 00:00:00.000000000 Z
11
+ date: 2016-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler