cfhighlander 0.2.1.alpha.32 → 0.2.1.alpha.34
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 +4 -4
- data/bin/cfhighlander.rb +13 -13
- data/hl_ext/mapping_helper.rb +6 -4
- data/lib/{highlander.compiler.rb → cfhighlander.compiler.rb} +3 -3
- data/lib/{highlander.dsl.base.rb → cfhighlander.dsl.base.rb} +2 -2
- data/lib/{highlander.dsl.component.rb → cfhighlander.dsl.component.rb} +11 -11
- data/lib/{highlander.dsl.params.rb → cfhighlander.dsl.params.rb} +2 -2
- data/lib/{highlander.dsl.rb → cfhighlander.dsl.rb} +13 -13
- data/lib/{highlander.factory.rb → cfhighlander.factory.rb} +9 -7
- data/lib/{highlander.factory.templatefinder.rb → cfhighlander.factory.templatefinder.rb} +29 -12
- data/lib/{highlander.helper.rb → cfhighlander.helper.rb} +1 -1
- data/lib/{highlander.mapproviders.rb → cfhighlander.mapproviders.rb} +1 -1
- data/lib/{highlander.model.component.rb → cfhighlander.model.component.rb} +9 -3
- data/lib/{highlander.model.templatemeta.rb → cfhighlander.model.templatemeta.rb} +1 -1
- data/lib/{highlander.publisher.rb → cfhighlander.publisher.rb} +2 -2
- data/lib/{highlander.validator.rb → cfhighlander.validator.rb} +1 -1
- data/lib/util/zip.util.rb +1 -1
- metadata +14 -14
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 57345cb7494a630f82ccc0be2eab077f1362a5d5bf3bea22619ad17e43f7297c
         | 
| 4 | 
            +
              data.tar.gz: aefc4bebf4b709dd299c5f7a79c266674a4697f9ef64bd1b87d11ea0c031ec30
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: cea97fa74dcf7bec3d87d559499a674cc1a4546502c7a14f589f6bbfef73dbe74a1f8d2ebb21d7f0ee69438fd35b222590d01f3e35d95e922430ea2d2f09ccc0
         | 
| 7 | 
            +
              data.tar.gz: d16b3eaab44a8a08754768106de95c7d412c8a449902f4ca9279e536422f164c9667deb95f74fcb5c012f4b34e8a2a46bdc435cfe6db9ead84830c89fb3b702b
         | 
    
        data/bin/cfhighlander.rb
    CHANGED
    
    | @@ -9,10 +9,10 @@ | |
| 9 9 |  | 
| 10 10 | 
             
            require 'thor'
         | 
| 11 11 | 
             
            require 'rubygems'
         | 
| 12 | 
            -
            require_relative '../lib/ | 
| 13 | 
            -
            require_relative '../lib/ | 
| 14 | 
            -
            require_relative '../lib/ | 
| 15 | 
            -
            require_relative '../lib/ | 
| 12 | 
            +
            require_relative '../lib/cfhighlander.compiler'
         | 
| 13 | 
            +
            require_relative '../lib/cfhighlander.factory'
         | 
| 14 | 
            +
            require_relative '../lib/cfhighlander.publisher'
         | 
| 15 | 
            +
            require_relative '../lib/cfhighlander.validator'
         | 
| 16 16 |  | 
| 17 17 | 
             
            class HighlanderCli < Thor
         | 
| 18 18 |  | 
| @@ -25,12 +25,12 @@ class HighlanderCli < Thor | |
| 25 25 | 
             
              def configcompile(template_name)
         | 
| 26 26 |  | 
| 27 27 | 
             
                # find and load component
         | 
| 28 | 
            -
                component_loader =  | 
| 28 | 
            +
                component_loader = Cfhighlander::Factory::ComponentFactory.new
         | 
| 29 29 | 
             
                component = component_loader.loadComponentFromTemplate(template_name)
         | 
| 30 30 | 
             
                component.load
         | 
| 31 31 |  | 
| 32 32 | 
             
                # compile cfndsl template
         | 
| 33 | 
            -
                component_compiler =  | 
| 33 | 
            +
                component_compiler = Cfhighlander::Compiler::ComponentCompiler.new(component)
         | 
| 34 34 | 
             
                component_compiler.writeConfig(true)
         | 
| 35 35 | 
             
              end
         | 
| 36 36 |  | 
| @@ -50,7 +50,7 @@ class HighlanderCli < Thor | |
| 50 50 | 
             
                component = build_component(options, component_name)
         | 
| 51 51 |  | 
| 52 52 | 
             
                # compile cfndsl template
         | 
| 53 | 
            -
                component_compiler =  | 
| 53 | 
            +
                component_compiler = Cfhighlander::Compiler::ComponentCompiler.new(component)
         | 
| 54 54 | 
             
                component_compiler.silent_mode = options[:quiet]
         | 
| 55 55 | 
             
                out_format = options[:format]
         | 
| 56 56 | 
             
                component_compiler.compileCfnDsl out_format
         | 
| @@ -75,12 +75,12 @@ class HighlanderCli < Thor | |
| 75 75 | 
             
                component = build_component(options, component_name)
         | 
| 76 76 |  | 
| 77 77 | 
             
                # compile cloud formation
         | 
| 78 | 
            -
                component_compiler =  | 
| 78 | 
            +
                component_compiler = Cfhighlander::Compiler::ComponentCompiler.new(component)
         | 
| 79 79 | 
             
                component_compiler.silent_mode = options[:quiet]
         | 
| 80 80 | 
             
                out_format = options[:format]
         | 
| 81 81 | 
             
                component_compiler.compileCloudFormation out_format
         | 
| 82 82 | 
             
                if options[:validate]
         | 
| 83 | 
            -
                  component_validator =  | 
| 83 | 
            +
                  component_validator = Cfhighlander::Cloudformation::Validator.new(component)
         | 
| 84 84 | 
             
                  component_validator.validate(component_compiler.cfn_template_paths, out_format)
         | 
| 85 85 | 
             
                end
         | 
| 86 86 | 
             
                component_compiler
         | 
| @@ -103,7 +103,7 @@ class HighlanderCli < Thor | |
| 103 103 |  | 
| 104 104 | 
             
              def cfpublish(component_name)
         | 
| 105 105 | 
             
                compiler = cfcompile(component_name)
         | 
| 106 | 
            -
                publisher =  | 
| 106 | 
            +
                publisher = Cfhighlander::Publisher::ComponentPublisher.new(compiler.component, false)
         | 
| 107 107 | 
             
                publisher.publishFiles(compiler.cfn_template_paths + compiler.lambda_src_paths)
         | 
| 108 108 | 
             
              end
         | 
| 109 109 |  | 
| @@ -123,14 +123,14 @@ class HighlanderCli < Thor | |
| 123 123 | 
             
                distribution_prefix = options[:dstprefix]
         | 
| 124 124 |  | 
| 125 125 | 
             
                # find and load component
         | 
| 126 | 
            -
                component_loader =  | 
| 126 | 
            +
                component_loader = Cfhighlander::Factory::ComponentFactory.new
         | 
| 127 127 | 
             
                component = component_loader.loadComponentFromTemplate(template_name)
         | 
| 128 128 | 
             
                component.version = component_version
         | 
| 129 129 | 
             
                component.distribution_bucket = distribution_bucket unless distribution_bucket.nil?
         | 
| 130 130 | 
             
                component.distribution_prefix = distribution_prefix unless distribution_prefix.nil?
         | 
| 131 131 | 
             
                component.load
         | 
| 132 132 |  | 
| 133 | 
            -
                publisher =  | 
| 133 | 
            +
                publisher = Cfhighlander::Publisher::ComponentPublisher.new(component, true)
         | 
| 134 134 | 
             
                publisher.publishComponent
         | 
| 135 135 | 
             
              end
         | 
| 136 136 |  | 
| @@ -144,7 +144,7 @@ def build_component(options, template_name) | |
| 144 144 | 
             
              distribution_prefix = options[:dstprefix]
         | 
| 145 145 |  | 
| 146 146 | 
             
              # find and load component
         | 
| 147 | 
            -
              component_loader =  | 
| 147 | 
            +
              component_loader = Cfhighlander::Factory::ComponentFactory.new
         | 
| 148 148 | 
             
              component = component_loader.loadComponentFromTemplate(template_name)
         | 
| 149 149 | 
             
              component.version = component_version unless component_version.nil?
         | 
| 150 150 | 
             
              component.distribution_bucket = distribution_bucket unless distribution_bucket.nil?
         | 
    
        data/hl_ext/mapping_helper.rb
    CHANGED
    
    | @@ -1,14 +1,16 @@ | |
| 1 | 
            -
            require_relative '../lib/ | 
| 1 | 
            +
            require_relative '../lib/cfhighlander.mapproviders'
         | 
| 2 2 |  | 
| 3 3 | 
             
            # Return mapping provider as class
         | 
| 4 | 
            -
            def mappings_provider(provider_name)
         | 
| 4 | 
            +
            def mappings_provider(provider_name, is_legacy = false)
         | 
| 5 5 | 
             
              return nil if provider_name.nil?
         | 
| 6 6 | 
             
              provider = nil
         | 
| 7 | 
            -
               | 
| 7 | 
            +
              module_name = is_legacy ? 'Highlander': 'Cfhighlander'
         | 
| 8 | 
            +
              providers = Object.const_get(module_name).const_get('MapProviders')
         | 
| 8 9 | 
             
              begin
         | 
| 9 10 | 
             
                providers.const_get(provider_name)
         | 
| 10 11 | 
             
              rescue NameError => e
         | 
| 11 | 
            -
                if e.to_s.include?  | 
| 12 | 
            +
                if e.to_s.include? "uninitialized constant #{module_name}::MapProviders::"
         | 
| 13 | 
            +
                  return mappings_provider(provider_name, true) unless is_legacy
         | 
| 12 14 | 
             
                  return nil
         | 
| 13 15 | 
             
                end
         | 
| 14 16 | 
             
                STDERR.puts(e.to_s)
         | 
| @@ -12,7 +12,7 @@ require 'highline/import' | |
| 12 12 | 
             
            require 'zip'
         | 
| 13 13 | 
             
            require_relative './util/zip.util'
         | 
| 14 14 |  | 
| 15 | 
            -
            module  | 
| 15 | 
            +
            module Cfhighlander
         | 
| 16 16 |  | 
| 17 17 | 
             
              module Compiler
         | 
| 18 18 |  | 
| @@ -50,7 +50,7 @@ module Highlander | |
| 50 50 | 
             
                    end
         | 
| 51 51 |  | 
| 52 52 | 
             
                    @component.highlander_dsl.components.each do |sub_component|
         | 
| 53 | 
            -
                      sub_component_compiler =  | 
| 53 | 
            +
                      sub_component_compiler = Cfhighlander::Compiler::ComponentCompiler.new(sub_component.component_loaded)
         | 
| 54 54 | 
             
                      sub_component_compiler.component_name = sub_component.name
         | 
| 55 55 | 
             
                      @sub_components << sub_component_compiler
         | 
| 56 56 | 
             
                    end
         | 
| @@ -281,7 +281,7 @@ module Highlander | |
| 281 281 | 
             
                          end
         | 
| 282 282 | 
             
                        end
         | 
| 283 283 | 
             
                        File.delete full_destination_path if File.exist? full_destination_path
         | 
| 284 | 
            -
                        zip_generator =  | 
| 284 | 
            +
                        zip_generator = Cfhighlander::Util::ZipFileGenerator.new(lambda_source_dir, full_destination_path)
         | 
| 285 285 | 
             
                        zip_generator.write
         | 
| 286 286 |  | 
| 287 287 | 
             
                      end
         | 
| @@ -1,5 +1,5 @@ | |
| 1 1 |  | 
| 2 | 
            -
            module  | 
| 2 | 
            +
            module Cfhighlander
         | 
| 3 3 |  | 
| 4 4 | 
             
              module Dsl
         | 
| 5 5 | 
             
                class DslBase
         | 
| @@ -15,7 +15,7 @@ module Highlander | |
| 15 15 | 
             
                      raise StandardError, "#{self} no config!"
         | 
| 16 16 | 
             
                    end
         | 
| 17 17 | 
             
                    return @config["#{method}"] unless @config["#{method}"].nil?
         | 
| 18 | 
            -
                    raise StandardError, "#{self}Unknown method or variable #{method} in  | 
| 18 | 
            +
                    raise StandardError, "#{self} Unknown method or variable #{method} in Cfhighlander template"
         | 
| 19 19 | 
             
                  end
         | 
| 20 20 |  | 
| 21 21 | 
             
                end
         | 
| @@ -1,8 +1,8 @@ | |
| 1 | 
            -
            require_relative './ | 
| 2 | 
            -
            require_relative './ | 
| 3 | 
            -
            require_relative './ | 
| 1 | 
            +
            require_relative './cfhighlander.helper'
         | 
| 2 | 
            +
            require_relative './cfhighlander.dsl.base'
         | 
| 3 | 
            +
            require_relative './cfhighlander.factory'
         | 
| 4 4 |  | 
| 5 | 
            -
            module  | 
| 5 | 
            +
            module Cfhighlander
         | 
| 6 6 |  | 
| 7 7 | 
             
              module Dsl
         | 
| 8 8 |  | 
| @@ -65,7 +65,7 @@ module Highlander | |
| 65 65 | 
             
                    build_distribution_url
         | 
| 66 66 |  | 
| 67 67 | 
             
                    # load component
         | 
| 68 | 
            -
                    factory =  | 
| 68 | 
            +
                    factory = Cfhighlander::Factory::ComponentFactory.new(@component_sources)
         | 
| 69 69 | 
             
                    @component_loaded = factory.loadComponentFromTemplate(
         | 
| 70 70 | 
             
                        @template,
         | 
| 71 71 | 
             
                        @template_version,
         | 
| @@ -116,7 +116,7 @@ module Highlander | |
| 116 116 | 
             
                  def load_parameters
         | 
| 117 117 | 
             
                    component_dsl = @component_loaded.highlander_dsl
         | 
| 118 118 | 
             
                    component_dsl.parameters.param_list.each do |component_param|
         | 
| 119 | 
            -
                      param =  | 
| 119 | 
            +
                      param = Cfhighlander::Dsl::SubcomponentParameter.new
         | 
| 120 120 | 
             
                      param.name = component_param.name
         | 
| 121 121 | 
             
                      param.cfndsl_value = SubcomponentParamValueResolver.resolveValue(
         | 
| 122 122 | 
             
                          @parent,
         | 
| @@ -135,16 +135,16 @@ module Highlander | |
| 135 135 |  | 
| 136 136 | 
             
                    # check if there are values defined on component itself
         | 
| 137 137 | 
             
                    if sub_component.param_values.key?(param.name)
         | 
| 138 | 
            -
                      return  | 
| 138 | 
            +
                      return Cfhighlander::Helper.parameter_cfndsl_value(sub_component.param_values[param.name])
         | 
| 139 139 | 
             
                    end
         | 
| 140 140 |  | 
| 141 | 
            -
                    if param.class ==  | 
| 141 | 
            +
                    if param.class == Cfhighlander::Dsl::StackParam
         | 
| 142 142 | 
             
                      return self.resolveStackParamValue(component, sub_component, param)
         | 
| 143 | 
            -
                    elsif param.class ==  | 
| 143 | 
            +
                    elsif param.class == Cfhighlander::Dsl::ComponentParam
         | 
| 144 144 | 
             
                      return self.resolveComponentParamValue(component, sub_component, param)
         | 
| 145 | 
            -
                    elsif param.class ==  | 
| 145 | 
            +
                    elsif param.class == Cfhighlander::Dsl::MappingParam
         | 
| 146 146 | 
             
                      return self.resolveMappingParamValue(component, sub_component, param)
         | 
| 147 | 
            -
                    elsif param.class ==  | 
| 147 | 
            +
                    elsif param.class == Cfhighlander::Dsl::OutputParam
         | 
| 148 148 | 
             
                      return self.resolveOutputParamValue(component, sub_component, param)
         | 
| 149 149 | 
             
                    else
         | 
| 150 150 | 
             
                      raise "#{param.class} not resolvable to parameter value"
         | 
| @@ -8,11 +8,11 @@ Dir["#{extensions_folder}/*.rb"].each { |f| | |
| 8 8 |  | 
| 9 9 | 
             
            # require libraries
         | 
| 10 10 |  | 
| 11 | 
            -
            require_relative './ | 
| 12 | 
            -
            require_relative './ | 
| 13 | 
            -
            require_relative './ | 
| 11 | 
            +
            require_relative './cfhighlander.dsl.base'
         | 
| 12 | 
            +
            require_relative './cfhighlander.dsl.params'
         | 
| 13 | 
            +
            require_relative './cfhighlander.dsl.component'
         | 
| 14 14 |  | 
| 15 | 
            -
            module  | 
| 15 | 
            +
            module Cfhighlander
         | 
| 16 16 |  | 
| 17 17 | 
             
              module Dsl
         | 
| 18 18 |  | 
| @@ -83,10 +83,10 @@ module Highlander | |
| 83 83 |  | 
| 84 84 |  | 
| 85 85 | 
             
                  def Component(template:, name: template, param_values: {}, config: {}, export_config: {}, &block)
         | 
| 86 | 
            -
                    puts " | 
| 86 | 
            +
                    puts "INFO: Requested subcomponent #{name} with template #{template}"
         | 
| 87 87 |  | 
| 88 88 | 
             
                    # load component
         | 
| 89 | 
            -
                    component =  | 
| 89 | 
            +
                    component = Cfhighlander::Dsl::Subcomponent.new(self,
         | 
| 90 90 | 
             
                        name,
         | 
| 91 91 | 
             
                        template,
         | 
| 92 92 | 
             
                        param_values,
         | 
| @@ -185,10 +185,10 @@ module Highlander | |
| 185 185 | 
             
                          .param_list.each do |param|
         | 
| 186 186 |  | 
| 187 187 | 
             
                        # add stack parameters
         | 
| 188 | 
            -
                        if param.class ==  | 
| 188 | 
            +
                        if param.class == Cfhighlander::Dsl::StackParam
         | 
| 189 189 | 
             
                          # sub-component stack param becomes top-level component param
         | 
| 190 190 | 
             
                          param_name = param.is_global ? param.name : "#{component.name}#{param.name}"
         | 
| 191 | 
            -
                          stack_param =  | 
| 191 | 
            +
                          stack_param = Cfhighlander::Dsl::ComponentParam.new(
         | 
| 192 192 | 
             
                              param_name,
         | 
| 193 193 | 
             
                              param.type,
         | 
| 194 194 | 
             
                              param.default_value,
         | 
| @@ -198,7 +198,7 @@ module Highlander | |
| 198 198 | 
             
                        end unless component.param_values.key? param.name
         | 
| 199 199 |  | 
| 200 200 | 
             
                        # for map parameters add maps
         | 
| 201 | 
            -
                        if param.class ==  | 
| 201 | 
            +
                        if param.class == Cfhighlander::Dsl::MappingParam
         | 
| 202 202 | 
             
                          if not param.mapProvider.nil?
         | 
| 203 203 | 
             
                            maps = param.mapProvider.getMaps(component.component_loaded.config)
         | 
| 204 204 | 
             
                            maps.each do |name, map|
         | 
| @@ -220,7 +220,7 @@ module Highlander | |
| 220 220 | 
             
                    }
         | 
| 221 221 |  | 
| 222 222 | 
             
                    @dependson_components_templates.each do |template|
         | 
| 223 | 
            -
                      component =  | 
| 223 | 
            +
                      component = Cfhighlander::Dsl::Subcomponent.new(self,
         | 
| 224 224 | 
             
                          template,
         | 
| 225 225 | 
             
                          template,
         | 
| 226 226 | 
             
                          {},
         | 
| @@ -303,11 +303,11 @@ module Highlander | |
| 303 303 | 
             
                                  if (not config_receiver_component.export_config.nil?) and (config_receiver_component.export_config.key? component.template)
         | 
| 304 304 | 
             
                                    allow_from_component_name = config_receiver_component.export_config[component.template]
         | 
| 305 305 | 
             
                                    if allow_from_component_name == component.name
         | 
| 306 | 
            -
                                      puts("Exporting key #{global_export_key} from component #{component.name} to #{cname}")
         | 
| 306 | 
            +
                                      puts("INFO: Exporting key #{global_export_key} from component #{component.name} to #{cname}")
         | 
| 307 307 | 
             
                                      co[global_export_key] = cl.config[global_export_key]
         | 
| 308 308 | 
             
                                    end
         | 
| 309 309 | 
             
                                  else
         | 
| 310 | 
            -
                                    puts("Exporting key #{global_export_key} from component #{component.name} to #{cname}")
         | 
| 310 | 
            +
                                    puts("INFO: Exporting key #{global_export_key} from component #{component.name} to #{cname}")
         | 
| 311 311 | 
             
                                    co[global_export_key] = cl.config[global_export_key]
         | 
| 312 312 | 
             
                                  end
         | 
| 313 313 | 
             
                                end
         | 
| @@ -400,7 +400,7 @@ module Highlander | |
| 400 400 | 
             
            end
         | 
| 401 401 |  | 
| 402 402 | 
             
            def HighlanderComponent(&block)
         | 
| 403 | 
            -
              instance =  | 
| 403 | 
            +
              instance = Cfhighlander::Dsl::HighlanderTemplate.new
         | 
| 404 404 |  | 
| 405 405 | 
             
              puts "Processing higlander component #{@name}\n\tLocation:#{@highlander_dsl_path}" +
         | 
| 406 406 | 
             
                  "\n\tConfig:#{@config}"
         | 
| @@ -1,11 +1,11 @@ | |
| 1 | 
            -
            require_relative './ | 
| 2 | 
            -
            require_relative './ | 
| 3 | 
            -
            require_relative './ | 
| 1 | 
            +
            require_relative './cfhighlander.dsl'
         | 
| 2 | 
            +
            require_relative './cfhighlander.factory.templatefinder'
         | 
| 3 | 
            +
            require_relative './cfhighlander.model.component'
         | 
| 4 4 | 
             
            require 'fileutils'
         | 
| 5 5 | 
             
            require 'git'
         | 
| 6 6 |  | 
| 7 7 |  | 
| 8 | 
            -
            module  | 
| 8 | 
            +
            module Cfhighlander
         | 
| 9 9 |  | 
| 10 10 | 
             
              module Factory
         | 
| 11 11 |  | 
| @@ -14,18 +14,20 @@ module Highlander | |
| 14 14 | 
             
                  attr_accessor :component_sources
         | 
| 15 15 |  | 
| 16 16 | 
             
                  def initialize(component_sources = [])
         | 
| 17 | 
            -
                    @template_finder =  | 
| 17 | 
            +
                    @template_finder = Cfhighlander::Factory::TemplateFinder.new(component_sources)
         | 
| 18 | 
            +
                    @component_sources = component_sources
         | 
| 18 19 | 
             
                  end
         | 
| 19 20 |  | 
| 20 21 | 
             
                  # Find component and given list of sources
         | 
| 21 | 
            -
                  # @return [ | 
| 22 | 
            +
                  # @return [Cfhighlander::Factory::Component]
         | 
| 22 23 | 
             
                  def loadComponentFromTemplate(template_name, template_version = nil, component_name = nil)
         | 
| 23 24 |  | 
| 24 25 | 
             
                    template_meta = @template_finder.findTemplate(template_name, template_version)
         | 
| 25 26 |  | 
| 26 | 
            -
                    raise StandardError, "highlander template #{template_name}@#{ | 
| 27 | 
            +
                    raise StandardError, "highlander template #{template_name}@#{template_version} not located" +
         | 
| 27 28 | 
             
                        " in sources #{@component_sources}" if template_meta.nil?
         | 
| 28 29 |  | 
| 30 | 
            +
                    component_name = template_name if component_name.nil?
         | 
| 29 31 | 
             
                    return buildComponentFromLocation(template_meta, component_name)
         | 
| 30 32 |  | 
| 31 33 | 
             
                  end
         | 
| @@ -1,8 +1,8 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            LOCAL_CFHIGHLANDER_CACHE_LOCATION = "#{ENV['HOME']}/.cfhighlander/components"
         | 
| 2 2 |  | 
| 3 | 
            -
            require_relative './ | 
| 3 | 
            +
            require_relative './cfhighlander.model.templatemeta'
         | 
| 4 4 |  | 
| 5 | 
            -
            module  | 
| 5 | 
            +
            module Cfhighlander
         | 
| 6 6 |  | 
| 7 7 | 
             
              module Factory
         | 
| 8 8 |  | 
| @@ -13,7 +13,7 @@ module Highlander | |
| 13 13 | 
             
                    ## Then search for cached $HOME/.highlander/components
         | 
| 14 14 | 
             
                    ## Then search in sources given by dsl
         | 
| 15 15 | 
             
                    default_locations = [
         | 
| 16 | 
            -
                         | 
| 16 | 
            +
                        LOCAL_CFHIGHLANDER_CACHE_LOCATION,
         | 
| 17 17 | 
             
                        File.expand_path('components'),
         | 
| 18 18 | 
             
                        File.expand_path('.')
         | 
| 19 19 | 
             
                    ]
         | 
| @@ -27,6 +27,7 @@ module Highlander | |
| 27 27 | 
             
                  def findTemplateDefault(template_name, component_version)
         | 
| 28 28 | 
             
                    default_lookup_url = 'https://github.com/theonestack'
         | 
| 29 29 | 
             
                    default_lookup_url = ENV['HIGHLANDER_DEFAULT_COMPONENT_GIT_LOOKUP'] if ENV.key? 'HIGHLANDER_DEFAULT_COMPONENT_GIT_LOOKUP'
         | 
| 30 | 
            +
                    default_lookup_url = ENV['CFHIGHLANDER_DEFAULT_COMPONENT_GIT_LOOKUP'] if ENV.key? 'CFHIGHLANDER_DEFAULT_COMPONENT_GIT_LOOKUP'
         | 
| 30 31 |  | 
| 31 32 | 
             
                    git_url = "#{default_lookup_url}/hl-component-#{template_name}"
         | 
| 32 33 |  | 
| @@ -35,7 +36,7 @@ module Highlander | |
| 35 36 | 
             
                    else
         | 
| 36 37 | 
             
                      branch = component_version
         | 
| 37 38 | 
             
                    end
         | 
| 38 | 
            -
                    local_path = "#{ | 
| 39 | 
            +
                    local_path = "#{LOCAL_CFHIGHLANDER_CACHE_LOCATION}/#{template_name}/#{component_version}"
         | 
| 39 40 | 
             
                    return findTemplateGit(local_path, template_name, component_version, git_url, branch)
         | 
| 40 41 |  | 
| 41 42 | 
             
                  end
         | 
| @@ -53,6 +54,13 @@ module Highlander | |
| 53 54 | 
             
                      if not Dir.glob("#{cache_path}*.highlander.rb").empty?
         | 
| 54 55 | 
             
                        # if cache exists, just return from cache
         | 
| 55 56 | 
             
                        component_name = Dir.glob("#{cache_path}*.highlander.rb")[0].gsub(cache_path, '').gsub('.highlander.rb', '')
         | 
| 57 | 
            +
                        STDERR.puts("DEPRECATED: #{component_name}: Use *.cfhighlander.rb template file name pattern")
         | 
| 58 | 
            +
                        return component_name, cache_path
         | 
| 59 | 
            +
                      end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                      if not Dir.glob("#{cache_path}*.cfhighlander.rb").empty?
         | 
| 62 | 
            +
                        # if cache exists, just return from cache
         | 
| 63 | 
            +
                        component_name = Dir.glob("#{cache_path}*.cfhighlander.rb")[0].gsub(cache_path, '').gsub('.highlander.rb', '')
         | 
| 56 64 | 
             
                        return component_name, cache_path
         | 
| 57 65 | 
             
                      end
         | 
| 58 66 |  | 
| @@ -71,20 +79,20 @@ module Highlander | |
| 71 79 | 
             
                    end
         | 
| 72 80 | 
             
                  end
         | 
| 73 81 |  | 
| 74 | 
            -
                  def findTemplateS3(s3_location, component_name, component_version)
         | 
| 82 | 
            +
                  def findTemplateS3(s3_location, component_name, component_version, use_legacy_extension = true)
         | 
| 75 83 | 
             
                    parts = s3_location.split('/')
         | 
| 76 84 | 
             
                    bucket = parts[2]
         | 
| 77 85 | 
             
                    prefix = parts[3]
         | 
| 78 86 | 
             
                    s3_key = "#{prefix}/#{component_name}/#{component_version}/#{component_name}.highlander.rb"
         | 
| 79 87 | 
             
                    s3_prefix = "#{prefix}/#{component_name}/#{component_version}/"
         | 
| 80 | 
            -
                    local_destination = "#{ | 
| 88 | 
            +
                    local_destination = "#{LOCAL_CFHIGHLANDER_CACHE_LOCATION}/#{component_name}/#{component_version}"
         | 
| 81 89 | 
             
                    begin
         | 
| 82 90 | 
             
                      s3 = Aws::S3::Client.new({ region: s3_bucket_region(bucket) })
         | 
| 83 91 | 
             
                      FileUtils.mkdir_p local_destination unless Dir.exist? local_destination
         | 
| 84 92 |  | 
| 85 93 | 
             
                      hl_content = s3.get_object({ bucket: bucket,
         | 
| 86 94 | 
             
                          key: s3_key,
         | 
| 87 | 
            -
                          response_target: "#{local_destination}/#{component_name} | 
| 95 | 
            +
                          response_target: "#{local_destination}/#{component_name}.#{use_legacy_extension ? 'highlander' : 'cfhighlander'}.rb"
         | 
| 88 96 | 
             
                      })
         | 
| 89 97 | 
             
                      # if code execution got so far we consider file exists and download it locally
         | 
| 90 98 | 
             
                      component_files = s3.list_objects_v2({ bucket: bucket, prefix: s3_prefix })
         | 
| @@ -98,9 +106,15 @@ module Highlander | |
| 98 106 | 
             
                        s3.get_object({ bucket: bucket, key: s3_object.key, response_target: destination_file })
         | 
| 99 107 | 
             
                        print " [OK] \n"
         | 
| 100 108 | 
             
                      }
         | 
| 109 | 
            +
                      if use_legacy_extension
         | 
| 110 | 
            +
                        STDERR.puts "DEPRECATED: s3 load #{component_name} with *.highlander.rb template file name pattern"
         | 
| 111 | 
            +
                      end
         | 
| 101 112 | 
             
                      return local_destination
         | 
| 102 113 | 
             
                    rescue => e
         | 
| 103 114 | 
             
                      # this handles both nonexisting key and bucket
         | 
| 115 | 
            +
                      if use_legacy_extension
         | 
| 116 | 
            +
                        return findTemplateS3(s3_location, component_name, component_version, false)
         | 
| 117 | 
            +
                      end
         | 
| 104 118 | 
             
                      puts("#{component_name} not found in s3://#{bucket}/#{prefix}")
         | 
| 105 119 | 
             
                      STDERR.puts(e.to_s) unless e.message.include? 'does not exist'
         | 
| 106 120 | 
             
                      return nil
         | 
| @@ -134,7 +148,7 @@ module Highlander | |
| 134 148 |  | 
| 135 149 |  | 
| 136 150 | 
             
                    if not git_url.nil?
         | 
| 137 | 
            -
                      local_path = "#{ | 
| 151 | 
            +
                      local_path = "#{LOCAL_CFHIGHLANDER_CACHE_LOCATION}/#{template_location.gsub(':', '_').gsub(/\/+/, '/')}/#{template_version}"
         | 
| 138 152 | 
             
                      template_name, location = findTemplateGit(local_path, template_location, template_version, git_url, branch)
         | 
| 139 153 | 
             
                      if location.nil?
         | 
| 140 154 | 
             
                        raise "Could not resolve component #{template_location}@#{template_version}"
         | 
| @@ -196,15 +210,18 @@ module Highlander | |
| 196 210 | 
             
                        candidate = "#{source}/#{template_name}"
         | 
| 197 211 | 
             
                        candidate = "#{candidate}/#{template_version}" unless template_version.nil?
         | 
| 198 212 | 
             
                        candidate_hl_path = "#{candidate}/#{template_name}.highlander.rb"
         | 
| 213 | 
            +
                        candidate_cfhl_path = "#{candidate}/#{template_name}.cfhighlander.rb"
         | 
| 199 214 | 
             
                        candidate2_hl_path = "#{source}/#{template_name}.highlander.rb"
         | 
| 215 | 
            +
                        candidate2_cfhl_path = "#{source}/#{template_name}.cfhighlander.rb"
         | 
| 200 216 | 
             
                        puts "TRACE: Trying to load #{template_full_name} from #{candidate} ... "
         | 
| 201 | 
            -
                        if File.exist?(candidate_hl_path)
         | 
| 217 | 
            +
                        if (File.exist?(candidate_hl_path) or File.exist?(candidate_cfhl_path))
         | 
| 202 218 | 
             
                          return build_meta(template_name, template_version_s, candidate)
         | 
| 203 219 | 
             
                        end
         | 
| 220 | 
            +
             | 
| 204 221 | 
             
                        puts "TRACE: Trying to load #{template_full_name} from #{source} ... "
         | 
| 205 222 | 
             
                        # if component version is latest it is allowed to search in path
         | 
| 206 223 | 
             
                        # with no version component in it
         | 
| 207 | 
            -
                        if File.exist?(candidate2_hl_path)
         | 
| 224 | 
            +
                        if (File.exist?(candidate2_hl_path) or File.exist?(candidate2_cfhl_path))
         | 
| 208 225 | 
             
                          return build_meta(template_name, 'latest', source)
         | 
| 209 226 | 
             
                        end unless template_version_s != 'latest'
         | 
| 210 227 | 
             
                      end
         | 
| @@ -218,7 +235,7 @@ module Highlander | |
| 218 235 | 
             
                  end
         | 
| 219 236 |  | 
| 220 237 | 
             
                  def build_meta(template_name, template_version, template_location)
         | 
| 221 | 
            -
                    return  | 
| 238 | 
            +
                    return Cfhighlander::Model::TemplateMetadata.new(
         | 
| 222 239 | 
             
                        template_name: template_name,
         | 
| 223 240 | 
             
                        template_version: template_version,
         | 
| 224 241 | 
             
                        template_location: template_location)
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            require 'yaml'
         | 
| 2 2 |  | 
| 3 | 
            -
            module  | 
| 3 | 
            +
            module Cfhighlander
         | 
| 4 4 |  | 
| 5 5 | 
             
              module Model
         | 
| 6 6 |  | 
| @@ -39,7 +39,7 @@ module Highlander | |
| 39 39 | 
             
                  def load_config()
         | 
| 40 40 | 
             
                    @config = {} if @config.nil?
         | 
| 41 41 | 
             
                    Dir["#{@component_dir}/*.config.yaml"].each do |config_file|
         | 
| 42 | 
            -
                      puts "Loading config for #{@name} | 
| 42 | 
            +
                      puts "INFO Loading config for #{@name}: read file:#{config_file} "
         | 
| 43 43 | 
             
                      partial_config = YAML.load(File.read(config_file))
         | 
| 44 44 | 
             
                      unless partial_config.nil?
         | 
| 45 45 | 
             
                        @config.extend(partial_config)
         | 
| @@ -64,8 +64,14 @@ module Highlander | |
| 64 64 | 
             
                      raise StandardError, 'http(s) sources not supported yet'
         | 
| 65 65 | 
             
                    end
         | 
| 66 66 |  | 
| 67 | 
            +
                    legacy_cfhighlander_path = "#{@component_dir}/#{@template.template_name}.highlander.rb"
         | 
| 68 | 
            +
                    if File.exist? legacy_cfhighlander_path
         | 
| 69 | 
            +
                      STDERR.puts "DEPRECATED: #{legacy_cfhighlander_path} - Use *.cfhiglander.rb"
         | 
| 70 | 
            +
                      @highlander_dsl_path = legacy_cfhighlander_path
         | 
| 71 | 
            +
                    else
         | 
| 72 | 
            +
                      @highlander_dsl_path =  "#{@component_dir}/#{@template.template_name}.cfhighlander.rb"
         | 
| 73 | 
            +
                    end
         | 
| 67 74 |  | 
| 68 | 
            -
                    @highlander_dsl_path = "#{@component_dir}/#{@template.template_name}.highlander.rb"
         | 
| 69 75 | 
             
                    @cfndsl_path = "#{@component_dir}/#{@template.template_name}.cfndsl.rb"
         | 
| 70 76 | 
             
                    candidate_mappings_path = "#{@component_dir}/*.mappings.yaml"
         | 
| 71 77 | 
             
                    candidate_dynamic_mappings_path = "#{@component_dir}/#{@template.template_name}.mappings.rb"
         | 
    
        data/lib/util/zip.util.rb
    CHANGED
    
    
    
        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.2.1.alpha. | 
| 4 | 
            +
              version: 0.2.1.alpha.34
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Nikola Tosic
         | 
| @@ -243,19 +243,19 @@ files: | |
| 243 243 | 
             
            - hl_ext/common_helper.rb
         | 
| 244 244 | 
             
            - hl_ext/mapping_helper.rb
         | 
| 245 245 | 
             
            - hl_ext/vpc.rb
         | 
| 246 | 
            -
            - lib/ | 
| 247 | 
            -
            - lib/ | 
| 248 | 
            -
            - lib/ | 
| 249 | 
            -
            - lib/ | 
| 250 | 
            -
            - lib/ | 
| 251 | 
            -
            - lib/ | 
| 252 | 
            -
            - lib/ | 
| 253 | 
            -
            - lib/ | 
| 254 | 
            -
            - lib/ | 
| 255 | 
            -
            - lib/ | 
| 256 | 
            -
            - lib/ | 
| 257 | 
            -
            - lib/ | 
| 258 | 
            -
            - lib/ | 
| 246 | 
            +
            - lib/cfhighlander.compiler.rb
         | 
| 247 | 
            +
            - lib/cfhighlander.dsl.base.rb
         | 
| 248 | 
            +
            - lib/cfhighlander.dsl.component.rb
         | 
| 249 | 
            +
            - lib/cfhighlander.dsl.params.rb
         | 
| 250 | 
            +
            - lib/cfhighlander.dsl.rb
         | 
| 251 | 
            +
            - lib/cfhighlander.factory.rb
         | 
| 252 | 
            +
            - lib/cfhighlander.factory.templatefinder.rb
         | 
| 253 | 
            +
            - lib/cfhighlander.helper.rb
         | 
| 254 | 
            +
            - lib/cfhighlander.mapproviders.rb
         | 
| 255 | 
            +
            - lib/cfhighlander.model.component.rb
         | 
| 256 | 
            +
            - lib/cfhighlander.model.templatemeta.rb
         | 
| 257 | 
            +
            - lib/cfhighlander.publisher.rb
         | 
| 258 | 
            +
            - lib/cfhighlander.validator.rb
         | 
| 259 259 | 
             
            - lib/util/zip.util.rb
         | 
| 260 260 | 
             
            - templates/cfndsl.component.template.erb
         | 
| 261 261 | 
             
            homepage: https://github.com/theonestack/cfhighlander/blob/master/README.md
         |