makemespiffy 0.1.0
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 +7 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +2 -0
- data/bin/makemespiffy +47 -0
- data/lib/makemespiffy.rb +7 -0
- data/lib/makemespiffy/input_manifest.rb +58 -0
- data/lib/makemespiffy/output_template_manifest.rb +36 -0
- data/lib/makemespiffy/version.rb +3 -0
- data/makemespiffy.gemspec +24 -0
- data/spec/fixtures/concourse.yml +121 -0
- data/spec/fixtures/just_name.yml +2 -0
- data/spec/input_manifest_spec.rb +62 -0
- data/spec/integration_test.sh +27 -0
- data/spec/output_template_manifest_spec.rb +13 -0
- data/spec/spec_helper.rb +26 -0
- metadata +112 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 9ca618f5b75c3126fe81406bc1730fad8669d9d5
         | 
| 4 | 
            +
              data.tar.gz: c4c7144a3327bed3ea0482bd1f310946a9d6e219
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 410bf36d64d0abe4c23febe497eb4e3a4a2b377ec9b69684c7e7b7266d6e444a1779bf7f970d8c2d32e6931ea3e685eabbad829e06eaf3ad3cc05146c8ce9695
         | 
| 7 | 
            +
              data.tar.gz: 2c765d06fc74cdbf31718611e818c79718946dcbd3d7fc45eaae41f30fc408a6f7743fc8b5c41e9aa8e1a75a98ee4a29715f01372d78725cab84b3d7964c0fed
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            Copyright (c) 2015 Dr Nic Williams
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            MIT License
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 6 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 7 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 8 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 9 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 10 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 11 | 
            +
            the following conditions:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 14 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 17 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 18 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 19 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 20 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 21 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 22 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,51 @@ | |
| 1 | 
            +
            Make Me Spiffy
         | 
| 2 | 
            +
            ==============
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            Convert a flat BOSH manifest for something into a set of Spiff templates.
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            This is being developed to help migrate flat BOSH manifests into a standardised Concourse pipeline that could deploy anything.
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            The plan
         | 
| 9 | 
            +
            --------
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            Given a BOSH manifest `manifest.yml`, run the command multiple times to extract data into spiff templates:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            ```
         | 
| 14 | 
            +
            makemespiffy manifest.yml name environment/name.yml meta.name
         | 
| 15 | 
            +
            ```
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            This will take the root level key `name` from `manifest.yml` and replace it with `(( meta.name ))`.
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            ```
         | 
| 20 | 
            +
            name: manifest-name
         | 
| 21 | 
            +
            ```
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            Becomes:
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            ```yaml
         | 
| 26 | 
            +
            meta:
         | 
| 27 | 
            +
              name: (( merge ))
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            name: (( meta.name ))
         | 
| 30 | 
            +
            ```
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            It will also create `environment/name.yml` (if not yet created) and add the extracted value:
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            ```yaml
         | 
| 35 | 
            +
            meta:
         | 
| 36 | 
            +
              name: manifest-name
         | 
| 37 | 
            +
            ```
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            Multiple fields can be extracted into the same target file.
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            Reference items from lists by their `name:` field (like `spiff` itself does):
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            ```
         | 
| 44 | 
            +
            makemespiffy manifest.yml "jobs.runner_z1.instances" environment/scaling.yml meta.instances.runner_z1
         | 
| 45 | 
            +
            ```
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            Complex objects can be extracted too:
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            ```
         | 
| 50 | 
            +
            makemespiffy manifest.yml "networks.cf1.subnets" environment/networking.yml meta.subnets.cf1
         | 
| 51 | 
            +
            ```
         | 
    
        data/Rakefile
    ADDED
    
    
    
        data/bin/makemespiffy
    ADDED
    
    | @@ -0,0 +1,47 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'makemespiffy'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            input_manifest_path=ARGV[0]
         | 
| 6 | 
            +
            input_scope=ARGV[1]
         | 
| 7 | 
            +
            output_spiff_template_path=ARGV[2]
         | 
| 8 | 
            +
            output_meta_scope=ARGV[3]
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            if ARGV[3].nil? || ARGV[3].length == 0
         | 
| 11 | 
            +
              $stderr.puts "USAGE: makemespiffy manifest.yml properties.something templates/properties.yml meta.something"
         | 
| 12 | 
            +
              exit 1
         | 
| 13 | 
            +
            end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            input_manifest = MakeMeSpiffy::InputManifest.from_file(input_manifest_path)
         | 
| 16 | 
            +
            value = input_manifest.spiffy(input_scope, output_meta_scope)
         | 
| 17 | 
            +
            input_manifest.insert_scope_value(output_meta_scope, "(( merge ))")
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            output_manifest = MakeMeSpiffy::OutputTemplateManifest.from_file(output_spiff_template_path)
         | 
| 20 | 
            +
            output_manifest.insert_scope_value(output_meta_scope, value)
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            #
         | 
| 23 | 
            +
            # (( x.y.z )) is rendered as "(( x.y.z ))" in to_yaml; so explicitly
         | 
| 24 | 
            +
            # construct the YAMLTree
         | 
| 25 | 
            +
            #
         | 
| 26 | 
            +
            # Thanks @tenderlove for https://gist.github.com/tenderlove/8c3988b8f797dfee0a3a
         | 
| 27 | 
            +
            #
         | 
| 28 | 
            +
            def tree o, options = {}
         | 
| 29 | 
            +
              visitor = Psych::Visitors::YAMLTree.create options
         | 
| 30 | 
            +
              visitor << o
         | 
| 31 | 
            +
              visitor.tree
         | 
| 32 | 
            +
            end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            t = tree(input_manifest.manifest)
         | 
| 35 | 
            +
            # find scalar nodes and modify them
         | 
| 36 | 
            +
            t.grep(Psych::Nodes::Scalar).each do |node|
         | 
| 37 | 
            +
              node.plain  = true
         | 
| 38 | 
            +
              node.quoted = false
         | 
| 39 | 
            +
              node.style  = Psych::Nodes::Scalar::PLAIN
         | 
| 40 | 
            +
            end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            File.open(input_manifest_path, "w") do |file|
         | 
| 43 | 
            +
              file << t.yaml
         | 
| 44 | 
            +
            end
         | 
| 45 | 
            +
            File.open(output_spiff_template_path, "w") do |file|
         | 
| 46 | 
            +
              file << output_manifest.manifest.to_yaml
         | 
| 47 | 
            +
            end
         | 
    
        data/lib/makemespiffy.rb
    ADDED
    
    
| @@ -0,0 +1,58 @@ | |
| 1 | 
            +
            require "yaml"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module MakeMeSpiffy
         | 
| 4 | 
            +
              class InputManifest
         | 
| 5 | 
            +
                attr_reader :manifest
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                class UnknownScopeError < Exception; end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                def self.from_file(manifest_path)
         | 
| 10 | 
            +
                  file = YAML.load_file(manifest_path)
         | 
| 11 | 
            +
                  self.new(file)
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                def initialize(bosh_manifest_yaml)
         | 
| 15 | 
            +
                  @manifest = bosh_manifest_yaml
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                # Primary method to replace a chunk of manifest with a (( meta.scope ))
         | 
| 19 | 
            +
                def spiffy(extraction_scope, meta_scope)
         | 
| 20 | 
            +
                  part, *other_parts = extraction_scope.split('.')
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  if manifest.is_a?(Array)
         | 
| 23 | 
            +
                    part_value = manifest.find { |item| item["name"] == part }
         | 
| 24 | 
            +
                  else
         | 
| 25 | 
            +
                    part_value = manifest[part]
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  if other_parts.size == 0
         | 
| 29 | 
            +
                    if part_value
         | 
| 30 | 
            +
                      manifest[extraction_scope] = "(( #{meta_scope} ))"
         | 
| 31 | 
            +
                    end
         | 
| 32 | 
            +
                    return part_value
         | 
| 33 | 
            +
                  else
         | 
| 34 | 
            +
                    unless part_value
         | 
| 35 | 
            +
                      raise UnknownScopeError, extraction_scope
         | 
| 36 | 
            +
                    end
         | 
| 37 | 
            +
                    inner_manifest = InputManifest.new(part_value)
         | 
| 38 | 
            +
                    return inner_manifest.spiffy(other_parts.join("."), meta_scope)
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                # Usage: insert_scope_value("meta.foo.bar", 1234)
         | 
| 43 | 
            +
                # Will add the following into manifest YAML
         | 
| 44 | 
            +
                #     meta:
         | 
| 45 | 
            +
                #       foo:
         | 
| 46 | 
            +
                #         bar: 1234
         | 
| 47 | 
            +
                def insert_scope_value(meta_scope, value)
         | 
| 48 | 
            +
                  parts = meta_scope.split('.')
         | 
| 49 | 
            +
                  submanifest = manifest
         | 
| 50 | 
            +
                  scoping_parts, key = parts[0..-2], parts[-1]
         | 
| 51 | 
            +
                  for part in scoping_parts
         | 
| 52 | 
            +
                    submanifest[part] ||= {}
         | 
| 53 | 
            +
                    submanifest = submanifest[part]
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
                  submanifest[key] = value
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
              end
         | 
| 58 | 
            +
            end
         | 
| @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            require "yaml"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module MakeMeSpiffy
         | 
| 4 | 
            +
              class OutputTemplateManifest
         | 
| 5 | 
            +
                attr_reader :manifest
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                def self.from_file(manifest_path)
         | 
| 8 | 
            +
                  if File.exist?(manifest_path)
         | 
| 9 | 
            +
                    file = YAML.load_file(manifest_path)
         | 
| 10 | 
            +
                  else
         | 
| 11 | 
            +
                    file = {}
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                  self.new(file)
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                def initialize(bosh_manifest_yaml)
         | 
| 17 | 
            +
                  @manifest = bosh_manifest_yaml
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                # Usage: insert_scope_value("meta.foo.bar", 1234)
         | 
| 21 | 
            +
                # Will add the following into manifest YAML
         | 
| 22 | 
            +
                #     meta:
         | 
| 23 | 
            +
                #       foo:
         | 
| 24 | 
            +
                #         bar: 1234
         | 
| 25 | 
            +
                def insert_scope_value(meta_scope, value)
         | 
| 26 | 
            +
                  parts = meta_scope.split('.')
         | 
| 27 | 
            +
                  submanifest = manifest
         | 
| 28 | 
            +
                  scoping_parts, key = parts[0..-2], parts[-1]
         | 
| 29 | 
            +
                  for part in scoping_parts
         | 
| 30 | 
            +
                    submanifest[part] ||= {}
         | 
| 31 | 
            +
                    submanifest = submanifest[part]
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                  submanifest[key] = value
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
            end
         | 
| @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'makemespiffy/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = "makemespiffy"
         | 
| 8 | 
            +
              spec.version       = MakeMeSpiffy::VERSION
         | 
| 9 | 
            +
              spec.authors       = ["Dr Nic Williams"]
         | 
| 10 | 
            +
              spec.email         = ["drnicwilliams@gmail.com"]
         | 
| 11 | 
            +
              spec.summary       = %q{Convert a flat BOSH manifest for something into a set of Spiff templates.}
         | 
| 12 | 
            +
              spec.description   = %q{Convert a flat BOSH manifest for something into a set of Spiff templates.}
         | 
| 13 | 
            +
              spec.homepage      = "https://github.com/cloudfoundry-community/makemespiffy"
         | 
| 14 | 
            +
              spec.license       = "MIT"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              spec.files         = `git ls-files -z`.split("\x0")
         | 
| 17 | 
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         | 
| 18 | 
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 19 | 
            +
              spec.require_paths = ["lib"]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              spec.add_development_dependency "bundler", "~> 1.7"
         | 
| 22 | 
            +
              spec.add_development_dependency "rake", "~> 10.0"
         | 
| 23 | 
            +
              spec.add_development_dependency "rspec"
         | 
| 24 | 
            +
            end
         | 
| @@ -0,0 +1,121 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            name: concourse
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            director_uuid: 3b9806e6-f540-11e4-a153-6c4008a663f0
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            releases:
         | 
| 7 | 
            +
              - name: concourse
         | 
| 8 | 
            +
                version: latest
         | 
| 9 | 
            +
              - name: garden-linux
         | 
| 10 | 
            +
                version: latest
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            jobs:
         | 
| 13 | 
            +
              - name: web
         | 
| 14 | 
            +
                instances: 1
         | 
| 15 | 
            +
                resource_pool: concourse
         | 
| 16 | 
            +
                networks:
         | 
| 17 | 
            +
                  - name: concourse
         | 
| 18 | 
            +
                    static_ips: &web-ips [10.244.8.2]
         | 
| 19 | 
            +
                persistent_disk: 1024 # for consul
         | 
| 20 | 
            +
                templates:
         | 
| 21 | 
            +
                  - {release: concourse, name: consul-agent}
         | 
| 22 | 
            +
                  - {release: concourse, name: atc}
         | 
| 23 | 
            +
                  - {release: concourse, name: tsa}
         | 
| 24 | 
            +
                properties:
         | 
| 25 | 
            +
                  atc:
         | 
| 26 | 
            +
                    development_mode: true
         | 
| 27 | 
            +
                    publicly_viewable: true
         | 
| 28 | 
            +
                    postgresql:
         | 
| 29 | 
            +
                      database: &atc-db atc
         | 
| 30 | 
            +
                      role: &atc-role
         | 
| 31 | 
            +
                        name: atc
         | 
| 32 | 
            +
                        password: dummy-postgres-password
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  consul:
         | 
| 35 | 
            +
                    agent:
         | 
| 36 | 
            +
                      mode: server
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              - name: db
         | 
| 39 | 
            +
                instances: 1
         | 
| 40 | 
            +
                resource_pool: concourse
         | 
| 41 | 
            +
                networks: [{name: concourse}]
         | 
| 42 | 
            +
                persistent_disk: 10240
         | 
| 43 | 
            +
                templates:
         | 
| 44 | 
            +
                  - {release: concourse, name: consul-agent}
         | 
| 45 | 
            +
                  - {release: concourse, name: postgresql}
         | 
| 46 | 
            +
                properties:
         | 
| 47 | 
            +
                  postgresql:
         | 
| 48 | 
            +
                    databases: [{name: *atc-db}]
         | 
| 49 | 
            +
                    roles: [*atc-role]
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                  consul:
         | 
| 52 | 
            +
                    agent:
         | 
| 53 | 
            +
                      servers: {lan: *web-ips}
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              - name: worker
         | 
| 56 | 
            +
                instances: 1
         | 
| 57 | 
            +
                resource_pool: concourse
         | 
| 58 | 
            +
                networks: [{name: concourse}]
         | 
| 59 | 
            +
                templates:
         | 
| 60 | 
            +
                  - {release: concourse, name: consul-agent}
         | 
| 61 | 
            +
                  - {release: garden-linux, name: garden}
         | 
| 62 | 
            +
                  - {release: concourse, name: groundcrew}
         | 
| 63 | 
            +
                properties:
         | 
| 64 | 
            +
                  garden:
         | 
| 65 | 
            +
                    # cannot enforce quotas in bosh-lite
         | 
| 66 | 
            +
                    disk_quota_enabled: false
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                    listen_network: tcp
         | 
| 69 | 
            +
                    listen_address: 0.0.0.0:7777
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                    allow_host_access: true
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                  consul:
         | 
| 74 | 
            +
                    agent:
         | 
| 75 | 
            +
                      servers: {lan: *web-ips}
         | 
| 76 | 
            +
             | 
| 77 | 
            +
            networks:
         | 
| 78 | 
            +
              - name: concourse
         | 
| 79 | 
            +
                subnets:
         | 
| 80 | 
            +
                  # network with static ip used for web
         | 
| 81 | 
            +
                  - range: 10.244.8.0/30
         | 
| 82 | 
            +
                    reserved: [10.244.8.1]
         | 
| 83 | 
            +
                    static: [10.244.8.2]
         | 
| 84 | 
            +
                    cloud_properties: {}
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                  # networks for dynamic ips (db, workers, compilation vms)
         | 
| 87 | 
            +
                  - range: 10.244.8.4/30
         | 
| 88 | 
            +
                    reserved: [10.244.8.5]
         | 
| 89 | 
            +
                    cloud_properties: {}
         | 
| 90 | 
            +
                  - range: 10.244.8.8/30
         | 
| 91 | 
            +
                    reserved: [10.244.8.9]
         | 
| 92 | 
            +
                    cloud_properties: {}
         | 
| 93 | 
            +
                  - range: 10.244.8.12/30
         | 
| 94 | 
            +
                    reserved: [10.244.8.13]
         | 
| 95 | 
            +
                    cloud_properties: {}
         | 
| 96 | 
            +
                  - range: 10.244.8.16/30
         | 
| 97 | 
            +
                    reserved: [10.244.8.17]
         | 
| 98 | 
            +
                    cloud_properties: {}
         | 
| 99 | 
            +
                  - range: 10.244.8.20/30
         | 
| 100 | 
            +
                    reserved: [10.244.8.21]
         | 
| 101 | 
            +
                    cloud_properties: {}
         | 
| 102 | 
            +
             | 
| 103 | 
            +
            resource_pools:
         | 
| 104 | 
            +
              - name: concourse
         | 
| 105 | 
            +
                network: concourse
         | 
| 106 | 
            +
                cloud_properties: {}
         | 
| 107 | 
            +
                stemcell:
         | 
| 108 | 
            +
                  name: bosh-warden-boshlite-ubuntu-trusty-go_agent
         | 
| 109 | 
            +
                  version: latest
         | 
| 110 | 
            +
             | 
| 111 | 
            +
            compilation:
         | 
| 112 | 
            +
              workers: 3
         | 
| 113 | 
            +
              network: concourse
         | 
| 114 | 
            +
              cloud_properties: {}
         | 
| 115 | 
            +
             | 
| 116 | 
            +
            update:
         | 
| 117 | 
            +
              canaries: 1
         | 
| 118 | 
            +
              max_in_flight: 3
         | 
| 119 | 
            +
              serial: false
         | 
| 120 | 
            +
              canary_watch_time: 1000-60000
         | 
| 121 | 
            +
              update_watch_time: 1000-60000
         | 
| @@ -0,0 +1,62 @@ | |
| 1 | 
            +
            describe MakeMeSpiffy::InputManifest do
         | 
| 2 | 
            +
              describe 'concourse.yml' do
         | 
| 3 | 
            +
                let(:fixture) { fixture_path("concourse.yml") }
         | 
| 4 | 
            +
                subject { MakeMeSpiffy::InputManifest.from_file(fixture) }
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                describe "simple scope" do
         | 
| 7 | 
            +
                  it { expect(subject.manifest["name"]).to eq "concourse" }
         | 
| 8 | 
            +
                  describe "spiffy" do
         | 
| 9 | 
            +
                    before do
         | 
| 10 | 
            +
                      @value = subject.spiffy("name", "meta.name")
         | 
| 11 | 
            +
                    end
         | 
| 12 | 
            +
                    it {expect(subject.manifest["name"]).to eq "(( meta.name ))"}
         | 
| 13 | 
            +
                    it {expect(@value).to eq "concourse"}
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  describe "insert_scope_value" do
         | 
| 17 | 
            +
                    before do
         | 
| 18 | 
            +
                      subject.insert_scope_value("meta.name", "(( merge ))")
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
                    it {expect(subject.manifest["meta"]).to_not be_nil }
         | 
| 21 | 
            +
                    it {expect(subject.manifest["meta"]["name"]).to eq("(( merge ))") }
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                describe "nested scope" do
         | 
| 26 | 
            +
                  it { expect(subject.manifest["compilation"]["workers"]).to eq 3 }
         | 
| 27 | 
            +
                  describe "spiffy" do
         | 
| 28 | 
            +
                    before do
         | 
| 29 | 
            +
                      @value = subject.spiffy("compilation.workers", "meta.instances.workers")
         | 
| 30 | 
            +
                    end
         | 
| 31 | 
            +
                    it {expect(subject.manifest["compilation"]["workers"]).to eq "(( meta.instances.workers ))"}
         | 
| 32 | 
            +
                    it {expect(@value).to eq 3}
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  describe "insert_scope_value" do
         | 
| 36 | 
            +
                    before do
         | 
| 37 | 
            +
                      subject.insert_scope_value("meta.instances.workers", "(( merge ))")
         | 
| 38 | 
            +
                    end
         | 
| 39 | 
            +
                    it {expect(subject.manifest["meta"]).to_not be_nil }
         | 
| 40 | 
            +
                    it {expect(subject.manifest["meta"]["instances"]).to_not be_nil }
         | 
| 41 | 
            +
                    it {expect(subject.manifest["meta"]["instances"]["workers"]).to eq("(( merge ))") }
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  describe "bad input scope" do
         | 
| 45 | 
            +
                    xit { expect(subject.manifest["compilation"]["foobar"]).to be_nil }
         | 
| 46 | 
            +
                    xit { expect(subject.manifest["foobar"]["workers"]).to be_nil }
         | 
| 47 | 
            +
                  end
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                describe "complex scope through named array" do
         | 
| 51 | 
            +
                  it { expect(subject.manifest["jobs"][0]["name"]).to eq "web" }
         | 
| 52 | 
            +
                  describe "spiffy" do
         | 
| 53 | 
            +
                    before do
         | 
| 54 | 
            +
                      @value = subject.spiffy("jobs.web.instances", "meta.instances.web")
         | 
| 55 | 
            +
                    end
         | 
| 56 | 
            +
                    it {expect(subject.manifest["jobs"][0]["name"]).to eq "web"}
         | 
| 57 | 
            +
                    it {expect(subject.manifest["jobs"][0]["instances"]).to eq "(( meta.instances.web ))"}
         | 
| 58 | 
            +
                    it {expect(@value).to eq 1}
         | 
| 59 | 
            +
                  end
         | 
| 60 | 
            +
                end
         | 
| 61 | 
            +
              end
         | 
| 62 | 
            +
            end
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            #!/bin/bash
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
         | 
| 4 | 
            +
            cd $DIR/..
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            set -e
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            source_manifest=${source_manifest:-spec/fixtures/concourse.yml}
         | 
| 9 | 
            +
            manifest=tmp/manifest.yml
         | 
| 10 | 
            +
            makemespiffy() {
         | 
| 11 | 
            +
              bundle exec bin/makemespiffy $@
         | 
| 12 | 
            +
            }
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            rm -rf tmp
         | 
| 15 | 
            +
            mkdir -p tmp
         | 
| 16 | 
            +
            cp ${source_manifest} tmp/manifest.yml
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            makemespiffy ${manifest} name tmp/name.yml meta.name
         | 
| 19 | 
            +
            makemespiffy ${manifest} director_uuid tmp/director.yml meta.director_uuid
         | 
| 20 | 
            +
            makemespiffy ${manifest} releases tmp/stub.yml meta.releases
         | 
| 21 | 
            +
            makemespiffy ${manifest} resource_pools.concourse.stemcell tmp/stub.yml meta.stemcell
         | 
| 22 | 
            +
            makemespiffy ${manifest} networks.concourse.subnets tmp/networks.yml meta.subnets
         | 
| 23 | 
            +
            makemespiffy ${manifest} jobs.web.instances tmp/scaling.yml meta.instances.web
         | 
| 24 | 
            +
            makemespiffy ${manifest} jobs.worker.instances tmp/scaling.yml meta.instances.worker
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            spiff merge tmp/manifest.yml tmp/networks.yml tmp/scaling.yml tmp/name.yml tmp/director.yml tmp/stub.yml > tmp/spiffy.yml
         | 
| 27 | 
            +
            spiff diff ${source_manifest} tmp/spiffy.yml
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            describe MakeMeSpiffy::OutputTemplateManifest do
         | 
| 2 | 
            +
              describe 'concourse.yml' do
         | 
| 3 | 
            +
                subject { MakeMeSpiffy::OutputTemplateManifest.from_file("tmp/new.yml") }
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                it { expect(subject.manifest).to eq({}) }
         | 
| 6 | 
            +
                it {
         | 
| 7 | 
            +
                  subject.insert_scope_value("meta.top.bottom", 123)
         | 
| 8 | 
            +
                  expect(subject.manifest["meta"]).not_to be_nil
         | 
| 9 | 
            +
                  expect(subject.manifest["meta"]["top"]).not_to be_nil
         | 
| 10 | 
            +
                  expect(subject.manifest["meta"]["top"]["bottom"]).to eq(123)
         | 
| 11 | 
            +
                }
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            # Copyright (c) 2015 Stark & Wayne, LLC
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require "rubygems"
         | 
| 6 | 
            +
            require "bundler"
         | 
| 7 | 
            +
            Bundler.setup(:default, :test)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            $:.unshift(File.expand_path("../../lib", __FILE__))
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            require "rspec/core"
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            require "makemespiffy"
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            # load all files in spec/support/* (but not lower down)
         | 
| 16 | 
            +
            Dir[File.dirname(__FILE__) + '/support/*'].each do |path|
         | 
| 17 | 
            +
              require path unless File.directory?(path)
         | 
| 18 | 
            +
            end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            def fixture_path(path)
         | 
| 21 | 
            +
              File.join(File.expand_path("../fixtures", __FILE__), path)
         | 
| 22 | 
            +
            end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            RSpec.configure do |c|
         | 
| 25 | 
            +
              c.color = true
         | 
| 26 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,112 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: makemespiffy
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Dr Nic Williams
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2015-05-08 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: bundler
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '1.7'
         | 
| 20 | 
            +
              type: :development
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '1.7'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rake
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '10.0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '10.0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rspec
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ">="
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '0'
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ">="
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '0'
         | 
| 55 | 
            +
            description: Convert a flat BOSH manifest for something into a set of Spiff templates.
         | 
| 56 | 
            +
            email:
         | 
| 57 | 
            +
            - drnicwilliams@gmail.com
         | 
| 58 | 
            +
            executables:
         | 
| 59 | 
            +
            - makemespiffy
         | 
| 60 | 
            +
            extensions: []
         | 
| 61 | 
            +
            extra_rdoc_files: []
         | 
| 62 | 
            +
            files:
         | 
| 63 | 
            +
            - ".gitignore"
         | 
| 64 | 
            +
            - ".rspec"
         | 
| 65 | 
            +
            - ".travis.yml"
         | 
| 66 | 
            +
            - Gemfile
         | 
| 67 | 
            +
            - LICENSE.txt
         | 
| 68 | 
            +
            - README.md
         | 
| 69 | 
            +
            - Rakefile
         | 
| 70 | 
            +
            - bin/makemespiffy
         | 
| 71 | 
            +
            - lib/makemespiffy.rb
         | 
| 72 | 
            +
            - lib/makemespiffy/input_manifest.rb
         | 
| 73 | 
            +
            - lib/makemespiffy/output_template_manifest.rb
         | 
| 74 | 
            +
            - lib/makemespiffy/version.rb
         | 
| 75 | 
            +
            - makemespiffy.gemspec
         | 
| 76 | 
            +
            - spec/fixtures/concourse.yml
         | 
| 77 | 
            +
            - spec/fixtures/just_name.yml
         | 
| 78 | 
            +
            - spec/input_manifest_spec.rb
         | 
| 79 | 
            +
            - spec/integration_test.sh
         | 
| 80 | 
            +
            - spec/output_template_manifest_spec.rb
         | 
| 81 | 
            +
            - spec/spec_helper.rb
         | 
| 82 | 
            +
            homepage: https://github.com/cloudfoundry-community/makemespiffy
         | 
| 83 | 
            +
            licenses:
         | 
| 84 | 
            +
            - MIT
         | 
| 85 | 
            +
            metadata: {}
         | 
| 86 | 
            +
            post_install_message: 
         | 
| 87 | 
            +
            rdoc_options: []
         | 
| 88 | 
            +
            require_paths:
         | 
| 89 | 
            +
            - lib
         | 
| 90 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 91 | 
            +
              requirements:
         | 
| 92 | 
            +
              - - ">="
         | 
| 93 | 
            +
                - !ruby/object:Gem::Version
         | 
| 94 | 
            +
                  version: '0'
         | 
| 95 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 96 | 
            +
              requirements:
         | 
| 97 | 
            +
              - - ">="
         | 
| 98 | 
            +
                - !ruby/object:Gem::Version
         | 
| 99 | 
            +
                  version: '0'
         | 
| 100 | 
            +
            requirements: []
         | 
| 101 | 
            +
            rubyforge_project: 
         | 
| 102 | 
            +
            rubygems_version: 2.4.3
         | 
| 103 | 
            +
            signing_key: 
         | 
| 104 | 
            +
            specification_version: 4
         | 
| 105 | 
            +
            summary: Convert a flat BOSH manifest for something into a set of Spiff templates.
         | 
| 106 | 
            +
            test_files:
         | 
| 107 | 
            +
            - spec/fixtures/concourse.yml
         | 
| 108 | 
            +
            - spec/fixtures/just_name.yml
         | 
| 109 | 
            +
            - spec/input_manifest_spec.rb
         | 
| 110 | 
            +
            - spec/integration_test.sh
         | 
| 111 | 
            +
            - spec/output_template_manifest_spec.rb
         | 
| 112 | 
            +
            - spec/spec_helper.rb
         |