aws-cft-tools 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 153baa62a12a723ecc3749c8e64e04a005f48dd0
4
- data.tar.gz: ff49055bd3a98f3262fa9d3e890bf3f9f894ac61
3
+ metadata.gz: bf914a7a3004e1abd739897b4d1b91b65119c92a
4
+ data.tar.gz: c84ce2a9eeba3748c36b41833961c1645be38932
5
5
  SHA512:
6
- metadata.gz: d6ddab54a09a0dfe5bc2a3b5472cbf3cf89c42e1d1bd9780140784a39893ee18861287ad11307373caa6a2887e95f17ad8e5605a00694a595fe4abbec84a1253
7
- data.tar.gz: 8332135791348d11749c743e7e9342dee76b56aa1fc2f4dde2e35bc3aa0b31edeb75197d2ff617c9e6c2bc08af6240a2ffd9057e383150b47f259c743b7ff0f5
6
+ metadata.gz: 211496b26c6170e2c6ab5fab09947c3eecece848e811fe975dcbf0bb0ce0f3603bfe397ad6aa39c7f44a9a63655e407d14a909afc31e416fbf9ba28c45b5e23c
7
+ data.tar.gz: f9628f83d7e26613dfd8e7af0b513aff118287e0af11afae8436726b946c938101eae7488bb6da19d0d167eb06aa4d426a9e8a8c24eb0b66719539bfa53335c3
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.3] - 2018-01-05
4
+
5
+ ### Added
6
+
7
+ * Support for `AllowedPattern` in the `Environment` template parameter. (Issue #16)
8
+
9
+ * Support for parameter files to have environment names that resemble regular expressions. If the parameter
10
+ file doesn't have a key that matches the environment name exactly, then each of the top-level keys in the
11
+ file will be interpreted as a regular expression and matched against the environment being deployed. The
12
+ first match wins, so if multiple keys can match, then the result is undefined. (Issue #16)
13
+
3
14
  ## [0.1.2] - 2017-12-22
4
15
 
5
16
  ### Changed
@@ -24,10 +24,10 @@ module AwsCftTools
24
24
  #
25
25
  # === Allowed Environments
26
26
  #
27
- # The environments in which a template should be deployed is provided by the +AllowedValues+ key of the
28
- # +Environment+ template parameter.
27
+ # The environments in which a template should be deployed is provided by the +AllowedValues+ or the
28
+ # +AllowedPattern+ key of the +Environment+ template parameter.
29
29
  #
30
- # @example Allowed Environments
30
+ # @example Allowed Environments (explicit list)
31
31
  # ---
32
32
  # Parameters:
33
33
  # Environment:
@@ -36,6 +36,12 @@ module AwsCftTools
36
36
  # - Staging
37
37
  # - Production
38
38
  #
39
+ # @example Allowed Environments (implicit pattern)
40
+ # ---
41
+ # Parameters:
42
+ # Environment:
43
+ # AllowedPattern: ^(QA|Staging|Production|Dev-.+)$
44
+ #
39
45
  # === Allowed Regions
40
46
  #
41
47
  # A template can be pinned to a particular region or set of regions by providing a list of values for
@@ -114,8 +114,14 @@ module AwsCftTools
114
114
  def parameters_for_filename_and_environment!(param_source, env)
115
115
  return { Environment: env } unless param_source
116
116
 
117
- params = YAML.safe_load(process_erb_file(param_source), [], [], true)[env] || {}
118
- params.update(Environment: env)
117
+ params_for_all = YAML.safe_load(process_erb_file(param_source), [], [], true)
118
+ return params_for_all[env].update('Environment' => env) if params_for_all.key?(env)
119
+
120
+ # now check for regex match on keys
121
+ params_for_all.each do |env_name, params|
122
+ return params.update('Environment' => env) if Regexp.compile("\\A#{env_name}\\Z").match?(env)
123
+ end
124
+ { 'Environment' => env }
119
125
  end
120
126
 
121
127
  def process_erb_file(content)
@@ -15,8 +15,15 @@ module AwsCftTools
15
15
  template.dig('Parameters', 'Environment', 'AllowedValues') || []
16
16
  end
17
17
 
18
+ def allowed_environments_regex
19
+ source = template.dig('Parameters', 'Environment', 'AllowedPattern')
20
+ Regexp.compile(source) if source
21
+ end
22
+
18
23
  def environment?(value)
19
- allowed_environments.include?(value)
24
+ return allowed_environments.include?(value) if allowed_environments.any?
25
+ regex = allowed_environments_regex
26
+ return regex.match?(value) if regex
20
27
  end
21
28
 
22
29
  ##
@@ -4,5 +4,5 @@ module AwsCftTools
4
4
  ##
5
5
  # Version of AwsCftTools.
6
6
  #
7
- VERSION = '0.1.2'
7
+ VERSION = '0.1.3'
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-cft-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Small Business Administration
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-22 00:00:00.000000000 Z
11
+ date: 2018-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk