cfhighlander 0.12.5.alpha.1620862522 → 0.12.6

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
  SHA256:
3
- metadata.gz: 5e34cde3f6ad0999503b44f5bd8fb03344d02d0eace4eed5ed0044837f62355a
4
- data.tar.gz: '0088fbf56d21e7cbd9d5f84f3039f0e383491a32e837b7eb411373e12b621273'
3
+ metadata.gz: 027f0a6c56f3a766b3e3a4a9d95bdfbc39b45c23b1611f486276778393096d83
4
+ data.tar.gz: b1d84694799ade5e1fbd1d3b0c4f3f6639415cc9f5fe26e2c71dc3b2d0844df8
5
5
  SHA512:
6
- metadata.gz: 0271d23aae856b674bb75bff5eca63d3004ce265042f3012f39ccb7ed76e508da04880c583934952cb03b4487f770d77f8a400c767d2cdc443d71aa5a686333a
7
- data.tar.gz: 29d8410d47e67bbaa45a7232b0f71e410e6ddaa71457576755de77a80d97317b4ef9c4bb94bf6bcff32d175181520d2d65e47972a21ddaf935d8bef46c492cc3
6
+ metadata.gz: '00423813c66c9fb442ae1fc56e8bae4479d2db9b2d4c0eaf55a55cdae59e4e0e9e582c2e14353e43fdbcb6e0531e33be3757892ce3a1929a5632b851d17e4e29'
7
+ data.tar.gz: d6ae0381d9707121d3c96eb3359828306aeef62220176d147bd1d44e20d1c536863f34f040ae44d619db83d7c291d16fe7f363ad32608a203e3790478069730f
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/theonestack/cfhighlander.svg?branch=develop)](https://travis-ci.org/theonestack/cfhighlander) [![Join the chat at https://gitter.im/theonestack/cfhighlander](https://badges.gitter.im/theonestack/cfhighlander.svg)](https://gitter.im/theonestack/cfhighlander?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1
+ ![Build Status](https://github.com/theonestack/cfhighlander/actions/workflows/build-gem.yml/badge.svg) [![Join the chat at https://gitter.im/theonestack/cfhighlander](https://badges.gitter.im/theonestack/cfhighlander.svg)](https://gitter.im/theonestack/cfhighlander?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2
2
 
3
3
  # Intro
4
4
 
@@ -863,6 +863,27 @@ end
863
863
 
864
864
  ```
865
865
 
866
+ ### Publishing Additonal Artifacts
867
+
868
+ If you need to publish additonal files along with your cloudformation templates you can use the following DSL:
869
+
870
+ ```ruby
871
+ CfhighlanderTemplate do
872
+ Name 'my_app'
873
+ PublishArtifact file: "my-apigateway-spec.yaml"
874
+ end
875
+ ```
876
+
877
+ This will upload the file `my-apigateway-spec.yaml` to the s3 destnation/distribution bucket using the default s3 prefix. If you want to override the s3 key you can use
878
+
879
+ ```ruby
880
+ CfhighlanderTemplate do
881
+ Name 'my_app'
882
+ PublishArtifact file: "my-apigateway-spec.yaml", key: '/my-custom-path/my-custom-file.yaml'
883
+ end
884
+ ```
885
+
886
+
866
887
  ## Finding templates and creating components
867
888
 
868
889
 
@@ -1038,3 +1059,4 @@ Test Highlander component with test case config
1038
1059
  ### Reports
1039
1060
 
1040
1061
  By default test will print the output to stdout. You can output to a file with a format of xml or json using the `-r` option
1062
+
@@ -155,7 +155,7 @@ module Cfhighlander
155
155
  param_ovr[:minLength] = minLength unless minLength.nil?
156
156
  param_ovr[:minValue] = minValue unless minValue.nil?
157
157
  @component_loaded.highlander_dsl.Parameters do
158
- ComponentParam name, value, param_ovr
158
+ ComponentParam name, value, **param_ovr
159
159
  end
160
160
  else
161
161
  parameter.default_value = defaultValue unless defaultValue.nil?
@@ -37,7 +37,8 @@ module Cfhighlander
37
37
  :lambda_functions_keys,
38
38
  :description,
39
39
  :dependson_components,
40
- :template_dir
40
+ :template_dir,
41
+ :publish_artifacts
41
42
 
42
43
  attr_reader :conditions,
43
44
  :subcomponents,
@@ -63,6 +64,7 @@ module Cfhighlander
63
64
  # execution blocks for subcomponents
64
65
  @subcomponents_exec = {}
65
66
  @template_dir = nil
67
+ @publish_artifacts = []
66
68
  end
67
69
 
68
70
  # DSL statements
@@ -207,6 +209,11 @@ module Cfhighlander
207
209
  @lambda_functions_keys << config_key
208
210
  end
209
211
 
212
+ def PublishArtifact(file: nil, key: key=nil)
213
+ puts "INFO: adding artifact #{file} to publishing list"
214
+ @publish_artifacts << {file: file, key: key}
215
+ end
216
+
210
217
  # Internal and interface functions
211
218
 
212
219
  def loadComponents
@@ -0,0 +1,3 @@
1
+ module Cfhighlander
2
+ class Error < StandardError; end
3
+ end
@@ -1,6 +1,6 @@
1
1
  require_relative './cfhighlander.compiler'
2
2
  require 'aws-sdk-s3'
3
- require 'uri'
3
+
4
4
  module Cfhighlander
5
5
 
6
6
  module Publisher
@@ -53,7 +53,7 @@ module Cfhighlander
53
53
  template_url = getTemplateUrl
54
54
  region = s3_bucket_region(@component.highlander_dsl.distribution_bucket)
55
55
  return "https://console.aws.amazon.com/cloudformation/home?region=#{region}#/stacks/create/review?filter=active&templateURL=" +
56
- "#{URI::encode(template_url)}&stackName=#{@component.name}"
56
+ "#{CGI::escape(template_url)}&stackName=#{@component.name}"
57
57
  end
58
58
 
59
59
  def publishFiles(file_list)
@@ -83,6 +83,16 @@ module Cfhighlander
83
83
  end
84
84
  print "\n"
85
85
 
86
+ @component.highlander_dsl.publish_artifacts.each do |artifact|
87
+ s3_key = artifact[:key].nil? ? "#{prefix}/#{version}/#{artifact[:file]}" : artifact[:key]
88
+ print "\nPublishing artifact: #{artifact[:file]} to s3://#{bucket}/#{s3_key} ..."
89
+ s3.put_object({
90
+ body: File.read(artifact[:file]),
91
+ bucket: bucket,
92
+ key: s3_key
93
+ })
94
+ print ' [OK] '
95
+ end
86
96
  end
87
97
 
88
98
  end
@@ -1,3 +1,3 @@
1
1
  module Cfhighlander
2
- VERSION="0.12.5".freeze
2
+ VERSION="0.12.6".freeze
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require_relative '../cfhighlander.model.component'
2
+ require_relative '../cfhighlander.error'
2
3
  require_relative './debug.util'
3
4
  require 'duplicate'
4
5
 
@@ -57,7 +58,6 @@ module Cfhighlander
57
58
  template.subcomponents.each do |sub_component|
58
59
  next unless sub_component.inlined
59
60
  model = sub_component.component_loaded.cfn_model_raw
60
-
61
61
  model[element_type].keys.each do |key|
62
62
  if keys_taken.include? key
63
63
  candidate = "#{sub_component.component_loaded.name}#{key}"
@@ -109,6 +109,16 @@ module Cfhighlander
109
109
  next unless sub_component.inlined
110
110
  model = sub_component.component_loaded.cfn_model_raw
111
111
  model[element_name].each do |resource, value|
112
+ if sub_component.conditional
113
+ # If the resource already has a conditon we need to combine it with the stack condition
114
+ if element_name == 'Conditions'
115
+ value = { "Fn::And" => [{"Condtion" => sub_component.condition}, value]}
116
+ end
117
+ # Adds the condition to the inlined resource if it doesn't already have a condition
118
+ if element_name == 'Resources'
119
+ value['Condition'] = sub_component.condition unless value.has_key?('Condition')
120
+ end
121
+ end
112
122
  # effective extraction of child resource into parent
113
123
  # allows for line components to use - or _ in the component name
114
124
  # and still generate valid references
@@ -295,6 +305,11 @@ module Cfhighlander
295
305
  outval_refs.each do |out_ref|
296
306
  component_name = out_ref[:component]
297
307
  ref_sub_component = template.subcomponents.find {|sc| sc.name == component_name}
308
+
309
+ if ref_sub_component.nil?
310
+ raise Cfhighlander::Error, "unable to find outputs from component #{component_name} reference by parameters in component #{sub_component.name}"
311
+ end
312
+
298
313
  if ref_sub_component.inlined
299
314
  # out refs here need to be replaced with actual values
300
315
  replacement = output_values[out_ref[:component]][out_ref[:outputName]]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfhighlander
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.5.alpha.1620862522
4
+ version: 0.12.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikola Tosic
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-05-12 00:00:00.000000000 Z
13
+ date: 2021-08-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: highline
@@ -247,6 +247,7 @@ files:
247
247
  - lib/cfhighlander.dsl.params.rb
248
248
  - lib/cfhighlander.dsl.subcomponent.rb
249
249
  - lib/cfhighlander.dsl.template.rb
250
+ - lib/cfhighlander.error.rb
250
251
  - lib/cfhighlander.factory.rb
251
252
  - lib/cfhighlander.factory.templatefinder.rb
252
253
  - lib/cfhighlander.helper.rb
@@ -277,11 +278,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
277
278
  version: '2.7'
278
279
  required_rubygems_version: !ruby/object:Gem::Requirement
279
280
  requirements:
280
- - - ">"
281
+ - - ">="
281
282
  - !ruby/object:Gem::Version
282
- version: 1.3.1
283
+ version: '0'
283
284
  requirements: []
284
- rubygems_version: 3.0.8
285
+ rubygems_version: 3.1.6
285
286
  signing_key:
286
287
  specification_version: 4
287
288
  summary: DSL on top of cfndsl. Manage libraries of cloudformation components