thor-tropo 2.0.1 → 2.0.2
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.
- data/Rakefile +2 -0
- data/lib/thor-tropo.rb +23 -187
- data/lib/thor-tropo/configuration.rb +9 -1
- data/lib/thor-tropo/packaging.rb +156 -0
- data/lib/thor-tropo/uploader.rb +2 -2
- data/thor-tropo.gemspec +2 -2
- metadata +11 -5
    
        data/Rakefile
    CHANGED
    
    
    
        data/lib/thor-tropo.rb
    CHANGED
    
    | @@ -14,53 +14,47 @@ module ThorTropo | |
| 14 14 | 
             
              require 'berkshelf/chef'
         | 
| 15 15 | 
             
              require 'uploader'
         | 
| 16 16 | 
             
              require 'configuration'
         | 
| 17 | 
            +
              require 'packaging'
         | 
| 17 18 |  | 
| 18 19 | 
             
              class Tasks < Thor
         | 
| 19 20 | 
             
                include Thor::Actions
         | 
| 20 | 
            -
             | 
| 21 | 
            +
                include Packaging
         | 
| 21 22 |  | 
| 22 23 | 
             
                @packaged_cookbook = nil
         | 
| 23 | 
            -
             | 
| 24 24 | 
             
                @working_directory = nil
         | 
| 25 25 | 
             
                @invoke_directory = Dir.pwd
         | 
| 26 26 |  | 
| 27 27 | 
             
                namespace "tropo"
         | 
| 28 28 |  | 
| 29 29 | 
             
                class_option "help",
         | 
| 30 | 
            -
                  :type | 
| 30 | 
            +
                  :type    => :boolean,
         | 
| 31 31 | 
             
                  :default => false,
         | 
| 32 32 | 
             
                  :aliases => "-h"
         | 
| 33 33 |  | 
| 34 34 | 
             
                class_option "version",
         | 
| 35 | 
            -
                  :type | 
| 35 | 
            +
                  :type    => :boolean,
         | 
| 36 36 | 
             
                  :default => false,
         | 
| 37 37 | 
             
                  :aliases => "-v"
         | 
| 38 38 |  | 
| 39 39 | 
             
                desc "package", "Package cookbooks using Berkshelf and upload file to s3 bucket"
         | 
| 40 40 |  | 
| 41 41 | 
             
                method_option :berkspath,
         | 
| 42 | 
            -
                  :type | 
| 43 | 
            -
                  :aliases | 
| 44 | 
            -
                  :default | 
| 45 | 
            -
                  :desc | 
| 46 | 
            -
             | 
| 47 | 
            -
                #:banner  => "Path to find your cookbook Berksfile"
         | 
| 42 | 
            +
                  :type     => :string,
         | 
| 43 | 
            +
                  :aliases  => "-b",
         | 
| 44 | 
            +
                  :default  => nil,
         | 
| 45 | 
            +
                  :desc     => "Berksfile path"
         | 
| 48 46 |  | 
| 49 47 | 
             
                method_option :"version-override",
         | 
| 50 | 
            -
                  :type | 
| 51 | 
            -
                  :aliases | 
| 52 | 
            -
                  :default | 
| 53 | 
            -
                  :desc | 
| 54 | 
            -
             | 
| 55 | 
            -
                #:banner  => "Provider a cookbook version rather then using metadata.rb"
         | 
| 48 | 
            +
                  :type     => :string,
         | 
| 49 | 
            +
                  :aliases  => "-V",
         | 
| 50 | 
            +
                  :default  => nil,
         | 
| 51 | 
            +
                  :desc     => "Provide a version for cookbook archive"
         | 
| 56 52 |  | 
| 57 53 | 
             
                method_option :force,
         | 
| 58 | 
            -
                  :type | 
| 59 | 
            -
                  :aliases | 
| 60 | 
            -
                  :default | 
| 61 | 
            -
                  :desc | 
| 62 | 
            -
             | 
| 63 | 
            -
                #:banner  => "Ignore existing files and overwrite without confirmation"
         | 
| 54 | 
            +
                  :type     => :boolean,
         | 
| 55 | 
            +
                  :aliases  => "-f",
         | 
| 56 | 
            +
                  :default  => false,
         | 
| 57 | 
            +
                  :desc     => "overwrite any files on s3 without confirmation"
         | 
| 64 58 |  | 
| 65 59 | 
             
                method_option :"iam-auth",
         | 
| 66 60 | 
             
                  :type     => :boolean,
         | 
| @@ -68,39 +62,29 @@ module ThorTropo | |
| 68 62 | 
             
                  :aliases  => "-I",
         | 
| 69 63 | 
             
                  :desc     => "Use IAM roles for AWS authorization"
         | 
| 70 64 |  | 
| 71 | 
            -
                #:banner   => "Will expect an IAM role is present for S3 Auth.  Useful for CI"
         | 
| 72 | 
            -
             | 
| 73 65 | 
             
                method_option :"ignore-dirty",
         | 
| 74 66 | 
             
                  :type     => :boolean,
         | 
| 75 67 | 
             
                  :aliases  => "-i",
         | 
| 76 68 | 
             
                  :default  => false,
         | 
| 77 69 | 
             
                  :desc     => "Will ignore any dirty files in git repo and continue to package cookbooks"
         | 
| 78 70 |  | 
| 79 | 
            -
                #:banner   => "Ignore dirty git repository"
         | 
| 80 | 
            -
             | 
| 81 71 | 
             
                method_option :keeplock,
         | 
| 82 72 | 
             
                  :type     => :boolean,
         | 
| 83 73 | 
             
                  :aliases  => "-k",
         | 
| 84 74 | 
             
                  :default  => false,
         | 
| 85 75 | 
             
                  :desc     => "Respect Berksfile.lock"
         | 
| 86 76 |  | 
| 87 | 
            -
                #:banner   => "Don't delete lockfile before running `Berks install`"
         | 
| 88 | 
            -
             | 
| 89 77 | 
             
                method_option :"clean-cache",
         | 
| 90 78 | 
             
                  :type     => :boolean,
         | 
| 91 79 | 
             
                  :aliases  => "-c",
         | 
| 92 80 | 
             
                  :default  => false,
         | 
| 93 | 
            -
             | 
| 94 | 
            -
                  #:banner     => "Delete Berkshelf cookbook cache",
         | 
| 95 81 | 
             
                  :desc     => "Delete local Berkshelf cookbook cache"
         | 
| 96 82 |  | 
| 97 83 | 
             
                method_option :"no-op",
         | 
| 98 | 
            -
                  :type | 
| 99 | 
            -
                  :aliases | 
| 100 | 
            -
                  :default | 
| 101 | 
            -
                  :desc | 
| 102 | 
            -
                #:banner    => "NO-OP mode",
         | 
| 103 | 
            -
             | 
| 84 | 
            +
                  :type     => :boolean,
         | 
| 85 | 
            +
                  :aliases  => "-n",
         | 
| 86 | 
            +
                  :default  => false,
         | 
| 87 | 
            +
                  :desc     => "NO-OP mode, Won't actually upload anything.  Useful to see what would have happened"
         | 
| 104 88 |  | 
| 105 89 | 
             
                def package
         | 
| 106 90 |  | 
| @@ -108,10 +92,7 @@ module ThorTropo | |
| 108 92 |  | 
| 109 93 | 
             
                  $config = ThorTropo::Configuration.new(source_root)
         | 
| 110 94 |  | 
| 111 | 
            -
                   | 
| 112 | 
            -
                    say "[ TROPO ] - There are files that need to be committed first.", :red
         | 
| 113 | 
            -
                    exit 1 unless options[:"ignore-dirty"]
         | 
| 114 | 
            -
                  end
         | 
| 95 | 
            +
                  clean?
         | 
| 115 96 |  | 
| 116 97 | 
             
                  clean_berks_cache if options[:"clean-cache"]
         | 
| 117 98 |  | 
| @@ -148,6 +129,8 @@ module ThorTropo | |
| 148 129 | 
             
                  :desc     => "Set a tag for the release and push to remote",
         | 
| 149 130 | 
             
                  :desc     => "Set a tag for the release and push to remote"
         | 
| 150 131 | 
             
                def tag
         | 
| 132 | 
            +
             | 
| 133 | 
            +
                  clean?
         | 
| 151 134 | 
             
                  print_help_or_version
         | 
| 152 135 |  | 
| 153 136 | 
             
                  if File.exists?(".git")
         | 
| @@ -158,152 +141,5 @@ module ThorTropo | |
| 158 141 | 
             
                  end
         | 
| 159 142 | 
             
                end
         | 
| 160 143 |  | 
| 161 | 
            -
                no_tasks do
         | 
| 162 | 
            -
             | 
| 163 | 
            -
             | 
| 164 | 
            -
                  def print_help_or_version
         | 
| 165 | 
            -
                    if options[:help]
         | 
| 166 | 
            -
                      help "package"
         | 
| 167 | 
            -
                      exit 0
         | 
| 168 | 
            -
                    elsif options[:version]
         | 
| 169 | 
            -
                      say "[ TROPO ] Version - #{ThorTropo::VERSION}", :blue
         | 
| 170 | 
            -
                      exit 0
         | 
| 171 | 
            -
                    end
         | 
| 172 | 
            -
                  end
         | 
| 173 | 
            -
                  def path_priorities
         | 
| 174 | 
            -
                    if options[:berkspath]
         | 
| 175 | 
            -
                      say "[ TROPO ] - Detected Berkspath was provided, so we will use this", :blue
         | 
| 176 | 
            -
                      ### User specified berkspath, this is highest priority
         | 
| 177 | 
            -
                      @working_directory = File.expand_path(options[:berkspath])
         | 
| 178 | 
            -
                    elsif Dir.glob("*").include?("Berksfile")
         | 
| 179 | 
            -
                      say "[ TROPO ] - Detected Berksfile in current directory and no --berkspath was provided.  We'll use local Berksfile.", :blue
         | 
| 180 | 
            -
                      ### Found berksfile in working directory
         | 
| 181 | 
            -
                      @working_directory = File.expand_path(".")
         | 
| 182 | 
            -
                    end
         | 
| 183 | 
            -
             | 
| 184 | 
            -
                  end
         | 
| 185 | 
            -
             | 
| 186 | 
            -
                  def upload_cookbook(local_file,path,opts={})
         | 
| 187 | 
            -
                    uploader = ThorTropo::Uploader.new({
         | 
| 188 | 
            -
                                                         :access_key => $config.aws_key,
         | 
| 189 | 
            -
                                                         :secret_key => $config.aws_secret,
         | 
| 190 | 
            -
                                                         :bucket     => $config.bucket_name,
         | 
| 191 | 
            -
                                                         :use_iam    => options[:"iam-auth"]
         | 
| 192 | 
            -
                    })
         | 
| 193 | 
            -
             | 
| 194 | 
            -
                    uploader.upload :local_file => local_file, :path => path, :force => options[:force], :noop => options[:"no-op"]
         | 
| 195 | 
            -
                  end
         | 
| 196 | 
            -
             | 
| 197 | 
            -
                  def clean_berks_cache
         | 
| 198 | 
            -
                    say "[ TROPO ] - Clearing local Berkshelf cookbook cache", :green
         | 
| 199 | 
            -
             | 
| 200 | 
            -
                    unless options[:"no-op"]
         | 
| 201 | 
            -
                      remove_dir (File.expand_path(File.join(Dir.home,".berkshelf","cookbooks")))
         | 
| 202 | 
            -
                    end
         | 
| 203 | 
            -
                  end
         | 
| 204 | 
            -
             | 
| 205 | 
            -
                  def clean?
         | 
| 206 | 
            -
                    sh_with_excode("cd #{source_root}; git diff --exit-code")[1] == 0
         | 
| 207 | 
            -
                  end
         | 
| 208 | 
            -
             | 
| 209 | 
            -
                  def clean_lockfile
         | 
| 210 | 
            -
                    berksfile = "#{source_root}/Berksfile.lock"
         | 
| 211 | 
            -
             | 
| 212 | 
            -
                    if File.exists? berksfile
         | 
| 213 | 
            -
                      say "[ TROPO ] - Removing Berksfile.lock before running Berkshelf", :blue
         | 
| 214 | 
            -
                      remove_file(berksfile) unless options[:"no-op"]
         | 
| 215 | 
            -
                    else
         | 
| 216 | 
            -
                      say "[ TROPO ] - Unable to find berksfile to delete - [ #{berksfile} ]", :yellow
         | 
| 217 | 
            -
                    end
         | 
| 218 | 
            -
                  end
         | 
| 219 | 
            -
             | 
| 220 | 
            -
                  def bundle_cookbook
         | 
| 221 | 
            -
                    clean_lockfile unless options[:keeplock]
         | 
| 222 | 
            -
                    berksfile = File.join(source_root,"/Berksfile")
         | 
| 223 | 
            -
                    say "[ TROPO ] - Packaging cookbooks using #{berksfile}", :blue
         | 
| 224 | 
            -
                    @tmp_dir = Dir.mktmpdir
         | 
| 225 | 
            -
                    opts = {
         | 
| 226 | 
            -
                      berksfile: berksfile,
         | 
| 227 | 
            -
                      path: "#{@tmp_dir}/cookbooks"
         | 
| 228 | 
            -
                    }
         | 
| 229 | 
            -
             | 
| 230 | 
            -
                    Dir.chdir File.dirname(berksfile)
         | 
| 231 | 
            -
                    invoke("berkshelf:install", [], opts)
         | 
| 232 | 
            -
             | 
| 233 | 
            -
                    @_invocations.except!(Berkshelf::Cli) ### Clear Berkshelf from invocations array, because apperently you can't invoke the same task twice...
         | 
| 234 | 
            -
             | 
| 235 | 
            -
                    output   = File.expand_path(File.join(@tmp_dir, "#{get_cookbook_name}-#{current_version}.tar.gz"))
         | 
| 236 | 
            -
             | 
| 237 | 
            -
                    Dir.chdir(@tmp_dir) do |dir|
         | 
| 238 | 
            -
                      tgz = Zlib::GzipWriter.new(File.open(output, 'wb'))
         | 
| 239 | 
            -
                      Archive::Tar::Minitar.pack('./cookbooks', tgz)
         | 
| 240 | 
            -
                    end
         | 
| 241 | 
            -
                    @packaged_cookbook = output
         | 
| 242 | 
            -
             | 
| 243 | 
            -
                  end
         | 
| 244 | 
            -
             | 
| 245 | 
            -
                  def get_cookbook_name
         | 
| 246 | 
            -
                    source_root.split("/")[-1]
         | 
| 247 | 
            -
                  end
         | 
| 248 | 
            -
             | 
| 249 | 
            -
                  def current_version
         | 
| 250 | 
            -
                    if options[:"version-override"]
         | 
| 251 | 
            -
                      options[:"version-override"]
         | 
| 252 | 
            -
                    else
         | 
| 253 | 
            -
             | 
| 254 | 
            -
                      metadata = Ridley::Chef::Cookbook::Metadata.from_file(File.join(source_root,"metadata.rb"))
         | 
| 255 | 
            -
                      metadata.version
         | 
| 256 | 
            -
                    end
         | 
| 257 | 
            -
                  end
         | 
| 258 | 
            -
             | 
| 259 | 
            -
                  def tag_version(version=nil)
         | 
| 260 | 
            -
                    git_tag = version || current_version
         | 
| 261 | 
            -
                    sh "git tag -a -m \"Version #{git_tag}\" #{git_tag}" unless options[:"no-op"]
         | 
| 262 | 
            -
                    say "[ TROPO ] - Tagged: #{git_tag}", :blue
         | 
| 263 | 
            -
                    yield if block_given?
         | 
| 264 | 
            -
                    sh "git push --tags" unless options[:"no-op"]
         | 
| 265 | 
            -
                  rescue => e
         | 
| 266 | 
            -
                    say "[ TROPO ] - Untagging: #{git_tag} due to error", :red
         | 
| 267 | 
            -
                    sh_with_excode "git tag -d #{git_tag}"
         | 
| 268 | 
            -
                    say "[ TROPO ] - #{e}", :red
         | 
| 269 | 
            -
                    exit 1
         | 
| 270 | 
            -
                  end
         | 
| 271 | 
            -
             | 
| 272 | 
            -
                  ## Get the directory to Berksfile
         | 
| 273 | 
            -
                  def source_root
         | 
| 274 | 
            -
                    berks_path = unless options[:berkspath]
         | 
| 275 | 
            -
                      Dir.pwd
         | 
| 276 | 
            -
                    else
         | 
| 277 | 
            -
                      @working_directory || File.expand_path(options[:berkspath])
         | 
| 278 | 
            -
                    end
         | 
| 279 | 
            -
             | 
| 280 | 
            -
                    if File.exists? berks_path
         | 
| 281 | 
            -
                      berks_path
         | 
| 282 | 
            -
                    else
         | 
| 283 | 
            -
                      raise Errno::ENOENT, "#{berks_path} does not contain a Berksfile"
         | 
| 284 | 
            -
                    end
         | 
| 285 | 
            -
                  end
         | 
| 286 | 
            -
             | 
| 287 | 
            -
                  def sh(cmd, dir = source_root, &block)
         | 
| 288 | 
            -
                    out, code = sh_with_excode(cmd, dir, &block)
         | 
| 289 | 
            -
                    code == 0 ? out : raise(out.empty? ? "Running `#{cmd}` failed. Run this command directly for more detailed output." : out)
         | 
| 290 | 
            -
                  end
         | 
| 291 | 
            -
             | 
| 292 | 
            -
                  def sh_with_excode(cmd, dir = source_root, &block)
         | 
| 293 | 
            -
                    cmd << " 2>&1"
         | 
| 294 | 
            -
                    outbuf = ''
         | 
| 295 | 
            -
             | 
| 296 | 
            -
                    Dir.chdir(dir) {
         | 
| 297 | 
            -
                      outbuf = `#{cmd}`
         | 
| 298 | 
            -
                      if $? == 0
         | 
| 299 | 
            -
                        block.call(outbuf) if block
         | 
| 300 | 
            -
                      end
         | 
| 301 | 
            -
                    }
         | 
| 302 | 
            -
             | 
| 303 | 
            -
                    [ outbuf, $? ]
         | 
| 304 | 
            -
                  end
         | 
| 305 | 
            -
             | 
| 306 | 
            -
                end
         | 
| 307 | 
            -
             | 
| 308 144 | 
             
              end
         | 
| 309 145 | 
             
            end
         | 
| @@ -6,7 +6,7 @@ module ThorTropo | |
| 6 6 | 
             
                require 'pathname'
         | 
| 7 7 | 
             
                require 'yaml'
         | 
| 8 8 |  | 
| 9 | 
            -
                attr_reader :bucket_name, :aws_secret, :aws_key, :project_name, :cookbooks
         | 
| 9 | 
            +
                attr_reader :bucket_name, :aws_secret, :aws_key, :project_name, :cookbooks, :model_name, :base_dir
         | 
| 10 10 |  | 
| 11 11 | 
             
                def initialize(path)
         | 
| 12 12 | 
             
                  file_name=".deployer"
         | 
| @@ -28,6 +28,14 @@ module ThorTropo | |
| 28 28 | 
             
                    @bucket_name = config['bucket_name'] unless @bucket_name
         | 
| 29 29 | 
             
                  end
         | 
| 30 30 |  | 
| 31 | 
            +
                  if config['base_dir']
         | 
| 32 | 
            +
                    @base_dir = config['base_dir'] unless @base_dir
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  if config['model_name']
         | 
| 36 | 
            +
                    @model_name = config['model_name'] unless @model_name
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
             | 
| 31 39 | 
             
                  if config['aws_secret']
         | 
| 32 40 | 
             
                    @aws_secret = config['aws_secret'] unless @aws_secret
         | 
| 33 41 | 
             
                  end
         | 
| @@ -0,0 +1,156 @@ | |
| 1 | 
            +
            module ThorTropo
         | 
| 2 | 
            +
              module Packaging
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                def sh(cmd, dir = source_root, &block)
         | 
| 5 | 
            +
                  out, code = sh_with_excode(cmd, dir, &block)
         | 
| 6 | 
            +
                  code == 0 ? out : raise(out.empty? ? "Running `#{cmd}` failed. Run this command directly for more detailed output." : out)
         | 
| 7 | 
            +
                end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                def sh_with_excode(cmd, dir = source_root, &block)
         | 
| 10 | 
            +
                  cmd << " 2>&1"
         | 
| 11 | 
            +
                  outbuf = ''
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  Dir.chdir(dir) {
         | 
| 14 | 
            +
                    outbuf = `#{cmd}`
         | 
| 15 | 
            +
                    if $? == 0
         | 
| 16 | 
            +
                      block.call(outbuf) if block
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
                  }
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  [ outbuf, $? ]
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                def print_help_or_version
         | 
| 24 | 
            +
                  if options[:help]
         | 
| 25 | 
            +
                    help "package"
         | 
| 26 | 
            +
                    exit 0
         | 
| 27 | 
            +
                  elsif options[:version]
         | 
| 28 | 
            +
                    say "[ TROPO ] Version - #{ThorTropo::VERSION}", :blue
         | 
| 29 | 
            +
                    exit 0
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                def get_cookbook_name
         | 
| 34 | 
            +
                  source_root.split("/")[-1]
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                def current_version
         | 
| 38 | 
            +
                  if options[:"version-override"]
         | 
| 39 | 
            +
                    options[:"version-override"]
         | 
| 40 | 
            +
                  else
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                    metadata = Ridley::Chef::Cookbook::Metadata.from_file(File.join(source_root,"metadata.rb"))
         | 
| 43 | 
            +
                    metadata.version
         | 
| 44 | 
            +
                  end
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
             | 
| 48 | 
            +
                def path_priorities
         | 
| 49 | 
            +
                  if options[:berkspath]
         | 
| 50 | 
            +
                    say "[ TROPO ] - Detected Berkspath was provided, so we will use this", :blue
         | 
| 51 | 
            +
                    ### User specified berkspath, this is highest priority
         | 
| 52 | 
            +
                    @working_directory = File.expand_path(options[:berkspath])
         | 
| 53 | 
            +
                  elsif Dir.glob("*").include?("Berksfile")
         | 
| 54 | 
            +
                    say "[ TROPO ] - Detected Berksfile in current directory and no --berkspath was provided.  We'll use local Berksfile.", :blue
         | 
| 55 | 
            +
                    ### Found berksfile in working directory
         | 
| 56 | 
            +
                    @working_directory = File.expand_path(".")
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
             | 
| 62 | 
            +
                def clean_berks_cache
         | 
| 63 | 
            +
                  say "[ TROPO ] - Clearing local Berkshelf cookbook cache", :green
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  unless options[:"no-op"]
         | 
| 66 | 
            +
                    remove_dir (File.expand_path(File.join(Dir.home,".berkshelf","cookbooks")))
         | 
| 67 | 
            +
                  end
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                def clean?
         | 
| 71 | 
            +
                  if sh_with_excode("cd #{source_root}; git diff --exit-code")[1] == 0
         | 
| 72 | 
            +
                    true
         | 
| 73 | 
            +
                  else
         | 
| 74 | 
            +
                    say "[ TROPO ] - There are files that need to be committed first.", :red
         | 
| 75 | 
            +
                  end
         | 
| 76 | 
            +
                  exit 1 unless options[:"ignore-dirty"]
         | 
| 77 | 
            +
                  return true
         | 
| 78 | 
            +
                end
         | 
| 79 | 
            +
             | 
| 80 | 
            +
                def clean_lockfile
         | 
| 81 | 
            +
                  berksfile = "#{source_root}/Berksfile.lock"
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                  if File.exists? berksfile
         | 
| 84 | 
            +
                    say "[ TROPO ] - Removing Berksfile.lock before running Berkshelf", :blue
         | 
| 85 | 
            +
                    remove_file(berksfile) unless options[:"no-op"]
         | 
| 86 | 
            +
                  else
         | 
| 87 | 
            +
                    say "[ TROPO ] - Unable to find berksfile to delete - [ #{berksfile} ]", :yellow
         | 
| 88 | 
            +
                  end
         | 
| 89 | 
            +
                end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                def upload_cookbook(local_file,path,opts={})
         | 
| 92 | 
            +
                  uploader = ThorTropo::Uploader.new({
         | 
| 93 | 
            +
                                                       :access_key => $config.aws_key,
         | 
| 94 | 
            +
                                                       :secret_key => $config.aws_secret,
         | 
| 95 | 
            +
                                                       :bucket     => $config.bucket_name,
         | 
| 96 | 
            +
                                                       :use_iam    => options[:"iam-auth"]
         | 
| 97 | 
            +
                  })
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                  uploader.upload :local_file => local_file, :path => path, :force => options[:force], :noop => options[:"no-op"]
         | 
| 100 | 
            +
                end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                def bundle_cookbook
         | 
| 103 | 
            +
                  clean_lockfile unless options[:keeplock]
         | 
| 104 | 
            +
                  berksfile = File.join(source_root,"/Berksfile")
         | 
| 105 | 
            +
                  say "[ TROPO ] - Packaging cookbooks using #{berksfile}", :blue
         | 
| 106 | 
            +
                  @tmp_dir = Dir.mktmpdir
         | 
| 107 | 
            +
                  opts = {
         | 
| 108 | 
            +
                    berksfile: berksfile,
         | 
| 109 | 
            +
                    path: "#{@tmp_dir}/cookbooks"
         | 
| 110 | 
            +
                  }
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                  Dir.chdir File.dirname(berksfile)
         | 
| 113 | 
            +
                  invoke("berkshelf:install", [], opts)
         | 
| 114 | 
            +
             | 
| 115 | 
            +
                  @_invocations.except!(Berkshelf::Cli) ### Clear Berkshelf from invocations array, because apperently you can't invoke the same task twice...
         | 
| 116 | 
            +
             | 
| 117 | 
            +
                  output   = File.expand_path(File.join(@tmp_dir, "#{get_cookbook_name}-#{current_version}.tar.gz"))
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                  Dir.chdir(@tmp_dir) do |dir|
         | 
| 120 | 
            +
                    tgz = Zlib::GzipWriter.new(File.open(output, 'wb'))
         | 
| 121 | 
            +
                    Archive::Tar::Minitar.pack('./cookbooks', tgz)
         | 
| 122 | 
            +
                  end
         | 
| 123 | 
            +
                  @packaged_cookbook = output
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                end
         | 
| 126 | 
            +
             | 
| 127 | 
            +
             | 
| 128 | 
            +
                def tag_version(version=nil)
         | 
| 129 | 
            +
                  git_tag = version || current_version
         | 
| 130 | 
            +
                  sh "git tag -a -m \"Version #{git_tag}\" #{git_tag}" unless options[:"no-op"]
         | 
| 131 | 
            +
                  say "[ TROPO ] - Tagged: #{git_tag}", :blue
         | 
| 132 | 
            +
                  yield if block_given?
         | 
| 133 | 
            +
                  sh "git push --tags" unless options[:"no-op"]
         | 
| 134 | 
            +
                rescue => e
         | 
| 135 | 
            +
                  say "[ TROPO ] - Untagging: #{git_tag} due to error", :red
         | 
| 136 | 
            +
                  sh_with_excode "git tag -d #{git_tag}"
         | 
| 137 | 
            +
                  say "[ TROPO ] - #{e}", :red
         | 
| 138 | 
            +
                  exit 1
         | 
| 139 | 
            +
                end
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                ## Get the directory to Berksfile
         | 
| 142 | 
            +
                def source_root
         | 
| 143 | 
            +
                  berks_path = unless options[:berkspath]
         | 
| 144 | 
            +
                    Dir.pwd
         | 
| 145 | 
            +
                  else
         | 
| 146 | 
            +
                    @working_directory || File.expand_path(options[:berkspath])
         | 
| 147 | 
            +
                  end
         | 
| 148 | 
            +
             | 
| 149 | 
            +
                  if File.exists? berks_path
         | 
| 150 | 
            +
                    berks_path
         | 
| 151 | 
            +
                  else
         | 
| 152 | 
            +
                    raise Errno::ENOENT, "#{berks_path} does not contain a Berksfile"
         | 
| 153 | 
            +
                  end
         | 
| 154 | 
            +
                end
         | 
| 155 | 
            +
              end
         | 
| 156 | 
            +
            end
         | 
    
        data/lib/thor-tropo/uploader.rb
    CHANGED
    
    | @@ -60,7 +60,7 @@ module ThorTropo | |
| 60 60 |  | 
| 61 61 | 
             
                  def setup_connection(u,p)
         | 
| 62 62 |  | 
| 63 | 
            -
                    fog_args = { :provider => 'AWS' }
         | 
| 63 | 
            +
                    fog_args = { :provider => 'AWS', path_style: !ENV['FOG_USE_PATH_STYLE'].nil? }
         | 
| 64 64 |  | 
| 65 65 | 
             
                    if @use_iam
         | 
| 66 66 | 
             
                      fog_args[:use_iam_profile] = true
         | 
| @@ -105,7 +105,7 @@ module ThorTropo | |
| 105 105 | 
             
                      public_url = " *** NOOP ** /#{remote_file}"
         | 
| 106 106 |  | 
| 107 107 | 
             
                    end
         | 
| 108 | 
            -
                      say "[ TROPO ] - Public URL: #{public_url}", :blue
         | 
| 108 | 
            +
                      say "[ TROPO ] - Public URL: #{public_url.gsub("https","http")}", :blue
         | 
| 109 109 |  | 
| 110 110 | 
             
                  end
         | 
| 111 111 |  | 
    
        data/thor-tropo.gemspec
    CHANGED
    
    | @@ -16,9 +16,9 @@ Gem::Specification.new do |gem| | |
| 16 16 | 
             
              gem.version       = ThorTropo::VERSION
         | 
| 17 17 |  | 
| 18 18 | 
             
              #gem.add_dependency 'json', ">= 1.7.0"
         | 
| 19 | 
            -
              gem.add_dependency 'chef', "~> 11. | 
| 19 | 
            +
              gem.add_dependency 'chef', "~> 11.6"
         | 
| 20 20 | 
             
              gem.add_dependency 'berkshelf'
         | 
| 21 | 
            -
              gem.add_dependency 'minitar', | 
| 21 | 
            +
              gem.add_dependency 'minitar', '~> 0.5.4'
         | 
| 22 22 | 
             
              gem.add_dependency 'fog'
         | 
| 23 23 | 
             
              gem.add_dependency 'thor'
         | 
| 24 24 | 
             
              gem.add_dependency 'thor-scmversion'
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: thor-tropo
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.0. | 
| 4 | 
            +
              version: 2.0.2
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 12 | 
            +
            date: 2014-04-11 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: chef
         | 
| @@ -18,7 +18,7 @@ dependencies: | |
| 18 18 | 
             
                requirements:
         | 
| 19 19 | 
             
                - - ~>
         | 
| 20 20 | 
             
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            -
                    version: '11. | 
| 21 | 
            +
                    version: '11.6'
         | 
| 22 22 | 
             
              type: :runtime
         | 
| 23 23 | 
             
              prerelease: false
         | 
| 24 24 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| @@ -26,7 +26,7 @@ dependencies: | |
| 26 26 | 
             
                requirements:
         | 
| 27 27 | 
             
                - - ~>
         | 
| 28 28 | 
             
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            -
                    version: '11. | 
| 29 | 
            +
                    version: '11.6'
         | 
| 30 30 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 31 31 | 
             
              name: berkshelf
         | 
| 32 32 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -302,6 +302,7 @@ files: | |
| 302 302 | 
             
            - changelog.md
         | 
| 303 303 | 
             
            - lib/thor-tropo.rb
         | 
| 304 304 | 
             
            - lib/thor-tropo/configuration.rb
         | 
| 305 | 
            +
            - lib/thor-tropo/packaging.rb
         | 
| 305 306 | 
             
            - lib/thor-tropo/uploader.rb
         | 
| 306 307 | 
             
            - lib/thor-tropo/version.rb
         | 
| 307 308 | 
             
            - lib/thor/tropo.rb
         | 
| @@ -319,12 +320,18 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 319 320 | 
             
              - - ! '>='
         | 
| 320 321 | 
             
                - !ruby/object:Gem::Version
         | 
| 321 322 | 
             
                  version: '0'
         | 
| 323 | 
            +
                  segments:
         | 
| 324 | 
            +
                  - 0
         | 
| 325 | 
            +
                  hash: 4522265901803536206
         | 
| 322 326 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 323 327 | 
             
              none: false
         | 
| 324 328 | 
             
              requirements:
         | 
| 325 329 | 
             
              - - ! '>='
         | 
| 326 330 | 
             
                - !ruby/object:Gem::Version
         | 
| 327 331 | 
             
                  version: '0'
         | 
| 332 | 
            +
                  segments:
         | 
| 333 | 
            +
                  - 0
         | 
| 334 | 
            +
                  hash: 4522265901803536206
         | 
| 328 335 | 
             
            requirements: []
         | 
| 329 336 | 
             
            rubyforge_project: 
         | 
| 330 337 | 
             
            rubygems_version: 1.8.23
         | 
| @@ -332,4 +339,3 @@ signing_key: | |
| 332 339 | 
             
            specification_version: 3
         | 
| 333 340 | 
             
            summary: Set of tasks to assist in making packages from a git controlled project.
         | 
| 334 341 | 
             
            test_files: []
         | 
| 335 | 
            -
            has_rdoc: 
         |