canzea 0.1.91 → 0.1.93
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/lib/canzea/version.rb +1 -1
 - data/lib/canzea.rb +7 -1
 - data/lib/commands/get-catalog.rb +25 -5
 - data/lib/commands/register-metadata.rb +68 -0
 - metadata +3 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 86d48a2e1e860761c041034ec274886a8a1ceced
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 33b402d0f21c40d3036c79b09883e2582fbc3e1a
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 5a628c054b3280dc50e6efa794355da08a8c867416c3ac08abbf47412117a7a8212bf8d956a8397493d0df0581cc28687863199e36615ad77e7caa04d0389878
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: c104f110c889f4e018f0fd21297b68f9c160a7cc783e44139abfb94766b8505ec6075669af4a73ea996461817548171b074ada412e83a1779ad0a76734225c8d
         
     | 
    
        data/lib/canzea/version.rb
    CHANGED
    
    
    
        data/lib/canzea.rb
    CHANGED
    
    | 
         @@ -18,6 +18,7 @@ require "commands/update-config" 
     | 
|
| 
       18 
18 
     | 
    
         
             
            require "commands/apply-config"
         
     | 
| 
       19 
19 
     | 
    
         
             
            require "commands/add-env"
         
     | 
| 
       20 
20 
     | 
    
         
             
            require "commands/prepare-plan"
         
     | 
| 
      
 21 
     | 
    
         
            +
            require "commands/register-metadata"
         
     | 
| 
       21 
22 
     | 
    
         | 
| 
       22 
23 
     | 
    
         
             
            module Canzea
         
     | 
| 
       23 
24 
     | 
    
         
             
              command = Cri::Command.define do
         
     | 
| 
         @@ -107,6 +108,8 @@ module Canzea 
     | 
|
| 
       107 
108 
     | 
    
         
             
                        GetCatalog.new.do(opts.fetch(:catalogTag, nil));
         
     | 
| 
       108 
109 
     | 
    
         
             
                    end
         
     | 
| 
       109 
110 
     | 
    
         | 
| 
      
 111 
     | 
    
         
            +
                    GetCatalog.new.state
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
       110 
113 
     | 
    
         
             
                    if (opts[:util])
         
     | 
| 
       111 
114 
     | 
    
         
             
                        AddEnv.new.injectEnvironmentVariables()
         
     | 
| 
       112 
115 
     | 
    
         | 
| 
         @@ -117,6 +120,9 @@ module Canzea 
     | 
|
| 
       117 
120 
     | 
    
         
             
                        if (util == "add-env-secret")
         
     | 
| 
       118 
121 
     | 
    
         
             
                            AddEnv.new.addSecret(args[0], args[1])
         
     | 
| 
       119 
122 
     | 
    
         
             
                        end
         
     | 
| 
      
 123 
     | 
    
         
            +
                        if (util == "register-metadata")
         
     | 
| 
      
 124 
     | 
    
         
            +
                            RegisterMetadata.new.do(opts[:role], opts[:solution], test)
         
     | 
| 
      
 125 
     | 
    
         
            +
                        end
         
     | 
| 
       120 
126 
     | 
    
         | 
| 
       121 
127 
     | 
    
         
             
                        if (util == "gen-user")
         
     | 
| 
       122 
128 
     | 
    
         
             
                            GenUser.new.do(args[0])
         
     | 
| 
         @@ -192,7 +198,7 @@ module Canzea 
     | 
|
| 
       192 
198 
     | 
    
         
             
                        if lifecycle == 'wire'
         
     | 
| 
       193 
199 
     | 
    
         
             
                          puts "-- Running helper #{opts[:solution]} #{opts[:action]}"
         
     | 
| 
       194 
200 
     | 
    
         
             
                          ps = HelperRun.new
         
     | 
| 
       195 
     | 
    
         
            -
                          ps.run opts[:solution], opts[:action], opts.fetch(:args, {}), opts.fetch(:status,nil)
         
     | 
| 
      
 201 
     | 
    
         
            +
                          ps.run opts[:solution], opts[:action], opts.fetch(:args, '{}'), opts.fetch(:status,nil)
         
     | 
| 
       196 
202 
     | 
    
         
             
                        end
         
     | 
| 
       197 
203 
     | 
    
         
             
                    end
         
     | 
| 
       198 
204 
     | 
    
         | 
    
        data/lib/commands/get-catalog.rb
    CHANGED
    
    | 
         @@ -14,13 +14,33 @@ class GetCatalog 
     | 
|
| 
       14 
14 
     | 
    
         
             
                    FileUtils.mkdir_p "#{catalogLocation}"
         
     | 
| 
       15 
15 
     | 
    
         
             
                    catalogLocation = Pathname.new(catalogLocation).parent().realpath
         
     | 
| 
       16 
16 
     | 
    
         
             
                    g = Git.clone(Canzea::config[:catalog_git], "catalog", :path => catalogLocation)
         
     | 
| 
       17 
     | 
    
         
            -
                    g.branch Canzea::config[:catalog_branch]
         
     | 
| 
       18 
17 
     | 
    
         
             
                    if (tag != nil)
         
     | 
| 
       19 
     | 
    
         
            -
                        puts "-- For tag #{tag}"
         
     | 
| 
       20 
     | 
    
         
            -
                        g.tag 
     | 
| 
      
 18 
     | 
    
         
            +
                        puts "-- (RESET) For tag #{tag}"
         
     | 
| 
      
 19 
     | 
    
         
            +
                        g.checkout(tag)
         
     | 
| 
      
 20 
     | 
    
         
            +
                    else
         
     | 
| 
      
 21 
     | 
    
         
            +
                        g.checkout(g.branch(Canzea::config[:catalog_branch]))
         
     | 
| 
       21 
22 
     | 
    
         
             
                    end
         
     | 
| 
       22 
     | 
    
         
            -
                     
     | 
| 
       23 
     | 
    
         
            -
                    puts "--  
     | 
| 
      
 23 
     | 
    
         
            +
                    branch = g.current_branch
         
     | 
| 
      
 24 
     | 
    
         
            +
                    puts "-- (RESET) Branch '#{branch}' Commit #{g.log[0]}"
         
     | 
| 
      
 25 
     | 
    
         
            +
                    puts "-- (RESET) Source #{catalogLocation}/catalog"
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                def state()
         
     | 
| 
      
 29 
     | 
    
         
            +
                    g = Git.open(Canzea::config[:catalog_location])
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                    branch = g.current_branch
         
     | 
| 
      
 32 
     | 
    
         
            +
                    commit = g.log[0]
         
     | 
| 
      
 33 
     | 
    
         
            +
                    g.tags.each do | c |
         
     | 
| 
      
 34 
     | 
    
         
            +
                        # Doesn't seem to link tag to the branch so excluding for now
         
     | 
| 
      
 35 
     | 
    
         
            +
                        # ENV.store('CATALOG_TAG', c.name)
         
     | 
| 
      
 36 
     | 
    
         
            +
                        # puts "-- Tag #{c.name}"
         
     | 
| 
      
 37 
     | 
    
         
            +
                    end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                    ENV.store('CATALOG_BRANCH', branch)
         
     | 
| 
      
 40 
     | 
    
         
            +
                    ENV.store('CATALOG_COMMIT', "#{g.log[0]}")
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                    puts "-- Branch '#{ENV['CATALOG_BRANCH']}' Commit #{ENV['CATALOG_COMMIT']}"
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
       24 
44 
     | 
    
         
             
                end
         
     | 
| 
       25 
45 
     | 
    
         | 
| 
       26 
46 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,68 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'json'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'logger'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'pathname'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'trace-component'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'helper-run-class'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'prepare-environment'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            class RegisterMetadata
         
     | 
| 
      
 9 
     | 
    
         
            +
                def initialize ()
         
     | 
| 
      
 10 
     | 
    
         
            +
                    @basePath = "#{Pathname.new(Canzea::config[:catalog_location]).realpath}/"
         
     | 
| 
      
 11 
     | 
    
         
            +
                    @log = Logger.new(Canzea::config[:logging_root] + '/plans.log')
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                def do (role, solution, test)
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                    plan = JSON.parse("{ \"plan\": [ { \"role\": \"#{role}\", \"solution\": \"#{solution}\" } ] }")
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                    n = Worker.new
         
     | 
| 
      
 19 
     | 
    
         
            +
                    n.test ( test )
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    lines = 1
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                    cmd = "undefined"
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                        plan['plan'].each do |item|
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                            root = "#{@basePath}/roles/#{item['role']}/#{item['solution']}"
         
     | 
| 
      
 30 
     | 
    
         
            +
                            if File.exist?(root) == false
         
     | 
| 
      
 31 
     | 
    
         
            +
                                log "-- ERROR #{root} does not exist!"
         
     | 
| 
      
 32 
     | 
    
         
            +
                                raise "#{root} does not exist!"
         
     | 
| 
      
 33 
     | 
    
         
            +
                            end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                            # Register the service with Consul, if consul is ready
         
     | 
| 
      
 36 
     | 
    
         
            +
                            # If metadata.json exists, then use the information to register
         
     | 
| 
      
 37 
     | 
    
         
            +
                            cmd = "#{@basePath}/roles/#{item['role']}/#{item['solution']}/metadata.json"
         
     | 
| 
      
 38 
     | 
    
         
            +
                            if File.exist?(cmd)
         
     | 
| 
      
 39 
     | 
    
         
            +
                                md = File.read(cmd)
         
     | 
| 
      
 40 
     | 
    
         
            +
                                md = JSON.parse(md)
         
     | 
| 
      
 41 
     | 
    
         
            +
                                if (md['services'].size() > 0)
         
     | 
| 
      
 42 
     | 
    
         
            +
                                    svc = md['services'][0]
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                                    adef = {"listener"=>svc['listener'], "service"=>svc['name'], "tags"=>[ item['role'] ], "port"=>svc['port']}
         
     | 
| 
      
 45 
     | 
    
         
            +
                                    log "-- Registering Service: #{svc['name']}"
         
     | 
| 
      
 46 
     | 
    
         
            +
                                    h = HelperRun.new
         
     | 
| 
      
 47 
     | 
    
         
            +
                                    if test
         
     | 
| 
      
 48 
     | 
    
         
            +
                                        log "--  TEST ONLY"
         
     | 
| 
      
 49 
     | 
    
         
            +
                                    else
         
     | 
| 
      
 50 
     | 
    
         
            +
                                        h.run "consul", "register_service", JSON.generate(adef)
         
     | 
| 
      
 51 
     | 
    
         
            +
                                    end
         
     | 
| 
      
 52 
     | 
    
         
            +
                                end
         
     | 
| 
      
 53 
     | 
    
         
            +
                            end
         
     | 
| 
      
 54 
     | 
    
         
            +
                        end
         
     | 
| 
      
 55 
     | 
    
         
            +
                    rescue => exception
         
     | 
| 
      
 56 
     | 
    
         
            +
                        @log.error(cmd)
         
     | 
| 
      
 57 
     | 
    
         
            +
                        @log.error(exception.to_s)
         
     | 
| 
      
 58 
     | 
    
         
            +
                        @log.error(exception.backtrace)
         
     | 
| 
      
 59 
     | 
    
         
            +
                        abort()
         
     | 
| 
      
 60 
     | 
    
         
            +
                    end
         
     | 
| 
      
 61 
     | 
    
         
            +
                end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                def log (msg)
         
     | 
| 
      
 64 
     | 
    
         
            +
                    puts msg
         
     | 
| 
      
 65 
     | 
    
         
            +
                    @log.info(msg)
         
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: canzea
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.93
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Canzea Technologies
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017-04- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-04-24 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -172,6 +172,7 @@ files: 
     | 
|
| 
       172 
172 
     | 
    
         
             
            - lib/commands/gen-user.rb
         
     | 
| 
       173 
173 
     | 
    
         
             
            - lib/commands/get-catalog.rb
         
     | 
| 
       174 
174 
     | 
    
         
             
            - lib/commands/prepare-plan.rb
         
     | 
| 
      
 175 
     | 
    
         
            +
            - lib/commands/register-metadata.rb
         
     | 
| 
       175 
176 
     | 
    
         
             
            - lib/commands/remote-bootstrap.rb
         
     | 
| 
       176 
177 
     | 
    
         
             
            - lib/commands/remote-run.rb
         
     | 
| 
       177 
178 
     | 
    
         
             
            - lib/commands/update-config.rb
         
     |