punt 0.0.6 → 0.0.7
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/punt/cmd/cmd_deploy.rb +5 -1
 - data/lib/punt/deploy.rb +9 -4
 - data/lib/punt/mode/mode_scp.rb +47 -12
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 6c44be7df1cf91c7b83ed7583f1e052620655145
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 4fe8396030c059c359824d1f240373774e366e9a
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 0cb4f36fe49c046e51af865c808d0d195053115a639916fd31852b51a55a4fa3c2af20d6b08acbb7dcd80aef4f10df43d7a3f1dc5b3836f2c6f825a9b557053e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 373aa2997001a4660635cde238c57a62aa76795eca5deedde37a2e4755db1ccd74da6a6ec9e5949d15f1f5d579977d4611ac456a765bfc7cf00891cc84ded1b4
         
     | 
    
        data/lib/punt/cmd/cmd_deploy.rb
    CHANGED
    
    | 
         @@ -11,7 +11,7 @@ class CmdDeploy < Cmd 
     | 
|
| 
       11 
11 
     | 
    
         
             
                    env = argv.shift
         
     | 
| 
       12 
12 
     | 
    
         
             
                    repo_ref = argv.shift
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
                    Deploy.new.deploy(env: env, repo_ref: repo_ref, dry_run: opts[:dry_run], force_local: opts[:force_local])
         
     | 
| 
      
 14 
     | 
    
         
            +
                    Deploy.new.deploy(env: env, repo_ref: repo_ref, dry_run: opts[:dry_run], verbose: opts[:verbose], force_local: opts[:force_local])
         
     | 
| 
       15 
15 
     | 
    
         
             
                end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                private
         
     | 
| 
         @@ -26,6 +26,10 @@ class CmdDeploy < Cmd 
     | 
|
| 
       26 
26 
     | 
    
         
             
                            options[:dry_run] = d
         
     | 
| 
       27 
27 
     | 
    
         
             
                        end
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
      
 29 
     | 
    
         
            +
                        opts.on("-v", "--verbose", "Run in verbose mode") do |v|
         
     | 
| 
      
 30 
     | 
    
         
            +
                            options[:verbose] = v
         
     | 
| 
      
 31 
     | 
    
         
            +
                        end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
       29 
33 
     | 
    
         
             
                        opts.on("-l", "--force-local", "Try and push commits even if there are local changes") do |f|
         
     | 
| 
       30 
34 
     | 
    
         
             
                            options[:force_local] = f
         
     | 
| 
       31 
35 
     | 
    
         
             
                        end
         
     | 
    
        data/lib/punt/deploy.rb
    CHANGED
    
    | 
         @@ -3,7 +3,7 @@ class Deploy 
     | 
|
| 
       3 
3 
     | 
    
         
             
                include ModeHelper
         
     | 
| 
       4 
4 
     | 
    
         
             
                include RepoHelper
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
                def deploy(env: nil, repo_ref: nil, dry_run: false, force_local: false)
         
     | 
| 
      
 6 
     | 
    
         
            +
                def deploy(env: nil, repo_ref: nil, dry_run: false, verbose: false, force_local: false)
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                    dry_run_banner if dry_run
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
         @@ -37,18 +37,23 @@ class Deploy 
     | 
|
| 
       37 
37 
     | 
    
         
             
                        repo.checkout_revision(desired_revision, dry_run: dry_run)
         
     | 
| 
       38 
38 
     | 
    
         
             
                    end
         
     | 
| 
       39 
39 
     | 
    
         | 
| 
      
 40 
     | 
    
         
            +
                    # Mode Logistics
         
     | 
| 
      
 41 
     | 
    
         
            +
                    mode.mode_start(mode_opts: mode_opts, dry_run: dry_run, verbose: verbose)
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
       40 
43 
     | 
    
         
             
                    # Upload Starting File
         
     | 
| 
       41 
     | 
    
         
            -
                    mode.upload_versionfile(desired_revision_long, "start", mode_opts: mode_opts ) unless dry_run
         
     | 
| 
      
 44 
     | 
    
         
            +
                    mode.upload_versionfile(desired_revision_long, "start", mode_opts: mode_opts, verbose: verbose ) unless dry_run
         
     | 
| 
       42 
45 
     | 
    
         | 
| 
       43 
46 
     | 
    
         
             
                    # Upload Files
         
     | 
| 
      
 47 
     | 
    
         
            +
                    mode.transfer_start(mode_opts: mode_opts, dry_run: dry_run, verbose: verbose)
         
     | 
| 
       44 
48 
     | 
    
         
             
                    if environment["files"]
         
     | 
| 
       45 
49 
     | 
    
         
             
                        environment["files"].each do |key, value|
         
     | 
| 
       46 
     | 
    
         
            -
                            mode.transfer(key, value, mode_opts: mode_opts, dry_run: dry_run, verbose:  
     | 
| 
      
 50 
     | 
    
         
            +
                            mode.transfer(key, value, mode_opts: mode_opts, dry_run: dry_run, verbose: verbose)
         
     | 
| 
       47 
51 
     | 
    
         
             
                        end
         
     | 
| 
       48 
52 
     | 
    
         
             
                    end
         
     | 
| 
      
 53 
     | 
    
         
            +
                    mode.transfer_complete(mode_opts: mode_opts, dry_run: dry_run, verbose: verbose)
         
     | 
| 
       49 
54 
     | 
    
         | 
| 
       50 
55 
     | 
    
         
             
                    # Upload Success File
         
     | 
| 
       51 
     | 
    
         
            -
                    mode.upload_versionfile(desired_revision_long, "success", mode_opts: mode_opts ) unless dry_run
         
     | 
| 
      
 56 
     | 
    
         
            +
                    mode.upload_versionfile(desired_revision_long, "success", mode_opts: mode_opts, verbose: verbose ) unless dry_run
         
     | 
| 
       52 
57 
     | 
    
         | 
| 
       53 
58 
     | 
    
         
             
                    # Revert to our previous checkout
         
     | 
| 
       54 
59 
     | 
    
         
             
                    if desired_revision != starting_revision
         
     | 
    
        data/lib/punt/mode/mode_scp.rb
    CHANGED
    
    | 
         @@ -4,26 +4,48 @@ class ModeScp 
     | 
|
| 
       4 
4 
     | 
    
         
             
                    return environment["scp"]
         
     | 
| 
       5 
5 
     | 
    
         
             
                end
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
                def  
     | 
| 
      
 7 
     | 
    
         
            +
                def mode_start(mode_opts: nil, dry_run: false, verbose: true)
         
     | 
| 
      
 8 
     | 
    
         
            +
                    @has_sshpass = feature_detect_sshpass
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                    if @has_sshpass && !mode_opts['ssh_key']
         
     | 
| 
      
 11 
     | 
    
         
            +
                        print "(using sshpass) enter the ssh password: "
         
     | 
| 
      
 12 
     | 
    
         
            +
                        @ssh_password = gets.chomp
         
     | 
| 
      
 13 
     | 
    
         
            +
                    elsif !mode_opts['ssh_key']
         
     | 
| 
      
 14 
     | 
    
         
            +
                        puts "sshpass is not installed. You will need to enter your password for every scp action that is generated. To avoid entering your password for every scp action, you can switch to key-based authentication by setting ssh_key. If key based authentication is not possible, try installing sshpass (https://gist.github.com/arunoda/7790979)"
         
     | 
| 
      
 15 
     | 
    
         
            +
                        puts ""
         
     | 
| 
      
 16 
     | 
    
         
            +
                    end
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                def transfer_start(mode_opts: nil, dry_run: false, verbose: true)
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                def transfer_complete(mode_opts: nil, dry_run: false, verbose: true)
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                def transfer(local_path, remote_path, mode_opts: nil, dry_run: false, verbose: false)
         
     | 
| 
       8 
26 
     | 
    
         
             
                    scp_args = ["scp"]
         
     | 
| 
       9 
     | 
    
         
            -
                    scp_common_options(mode_opts, scp_args)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    scp_common_options(mode_opts, verbose, scp_args)
         
     | 
| 
       10 
28 
     | 
    
         | 
| 
       11 
29 
     | 
    
         
             
                    if (File.directory?(local_path))
         
     | 
| 
       12 
30 
     | 
    
         
             
                        scp_args << "-r"
         
     | 
| 
       13 
31 
     | 
    
         
             
                    end
         
     | 
| 
       14 
32 
     | 
    
         | 
| 
      
 33 
     | 
    
         
            +
                    if (@has_sshpass && @ssh_password)
         
     | 
| 
      
 34 
     | 
    
         
            +
                        scp_args.unshift(@ssh_password).unshift("-p").unshift("sshpass")
         
     | 
| 
      
 35 
     | 
    
         
            +
                    end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
       15 
37 
     | 
    
         
             
                    scp_args << local_path
         
     | 
| 
       16 
38 
     | 
    
         
             
                    scp_args << scp_remote_file(remote_path, mode_opts)
         
     | 
| 
       17 
39 
     | 
    
         | 
| 
       18 
40 
     | 
    
         
             
                    scp_command = scp_args.join(" ")
         
     | 
| 
       19 
41 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
                    puts scp_command 
     | 
| 
      
 42 
     | 
    
         
            +
                    puts scp_command
         
     | 
| 
       21 
43 
     | 
    
         
             
                    `#{scp_command}` unless dry_run
         
     | 
| 
       22 
44 
     | 
    
         
             
                end
         
     | 
| 
       23 
45 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                def download(local_path, remote_path, mode_opts: nil, dry_run: false, verbose:  
     | 
| 
      
 46 
     | 
    
         
            +
                def download(local_path, remote_path, mode_opts: nil, dry_run: false, verbose: false)
         
     | 
| 
       25 
47 
     | 
    
         
             
                    scp_args = ["scp"]
         
     | 
| 
       26 
     | 
    
         
            -
                    scp_common_options(mode_opts, scp_args)
         
     | 
| 
      
 48 
     | 
    
         
            +
                    scp_common_options(mode_opts, verbose, scp_args)
         
     | 
| 
       27 
49 
     | 
    
         | 
| 
       28 
50 
     | 
    
         
             
                    if (File.directory?(local_path))
         
     | 
| 
       29 
51 
     | 
    
         
             
                        scp_args << "-r"
         
     | 
| 
         @@ -38,7 +60,8 @@ class ModeScp 
     | 
|
| 
       38 
60 
     | 
    
         
             
                    `#{scp_command}` unless dry_run
         
     | 
| 
       39 
61 
     | 
    
         
             
                end
         
     | 
| 
       40 
62 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
                def upload_versionfile(version, deploystage, mode_opts: nil)
         
     | 
| 
      
 63 
     | 
    
         
            +
                def upload_versionfile(version, deploystage, mode_opts: nil, verbose: false)
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
       42 
65 
     | 
    
         
             
                    filename = ".punt_#{deploystage}"
         
     | 
| 
       43 
66 
     | 
    
         | 
| 
       44 
67 
     | 
    
         
             
                    versionfile = Tempfile.new(filename)
         
     | 
| 
         @@ -50,15 +73,12 @@ class ModeScp 
     | 
|
| 
       50 
73 
     | 
    
         
             
                    versionfile.unlink
         
     | 
| 
       51 
74 
     | 
    
         
             
                end
         
     | 
| 
       52 
75 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
                def download_versionfile(deploystage, mode_opts: nil)
         
     | 
| 
      
 76 
     | 
    
         
            +
                def download_versionfile(deploystage, mode_opts: nil, verbose: false)
         
     | 
| 
       54 
77 
     | 
    
         
             
                    filename = ".punt_#{deploystage}"
         
     | 
| 
       55 
78 
     | 
    
         | 
| 
       56 
79 
     | 
    
         
             
                    versionfile = Tempfile.new(filename)
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                    download(versionfile.path, filename, mode_opts: mode_opts, verbose: false)
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
      
 80 
     | 
    
         
            +
                    download(versionfile.path, filename, mode_opts: mode_opts, verbose: verbose)
         
     | 
| 
       60 
81 
     | 
    
         
             
                    version = versionfile.read
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
82 
     | 
    
         
             
                    versionfile.unlink
         
     | 
| 
       63 
83 
     | 
    
         | 
| 
       64 
84 
     | 
    
         
             
                    return version
         
     | 
| 
         @@ -66,11 +86,26 @@ class ModeScp 
     | 
|
| 
       66 
86 
     | 
    
         | 
| 
       67 
87 
     | 
    
         
             
                private
         
     | 
| 
       68 
88 
     | 
    
         | 
| 
       69 
     | 
    
         
            -
                def  
     | 
| 
      
 89 
     | 
    
         
            +
                def feature_detect_sshpass
         
     | 
| 
      
 90 
     | 
    
         
            +
                    feature_check = `command -v sshpass >/dev/null 2>&1 || { echo "NOSCP"; }`.chomp
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                    return feature_check != "NOSCP";
         
     | 
| 
      
 93 
     | 
    
         
            +
                end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                def scp_common_options(scp_opts, verbose, scp_args)
         
     | 
| 
       70 
96 
     | 
    
         
             
                    if (scp_opts["ssh_key"])
         
     | 
| 
       71 
97 
     | 
    
         
             
                        scp_args << "-i"
         
     | 
| 
       72 
98 
     | 
    
         
             
                        scp_args << scp_opts["ssh_key"]
         
     | 
| 
       73 
99 
     | 
    
         
             
                    end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
                    if (verbose)
         
     | 
| 
      
 102 
     | 
    
         
            +
                        scp_args << "-v"
         
     | 
| 
      
 103 
     | 
    
         
            +
                    end
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                    if (scp_opts["port"])
         
     | 
| 
      
 106 
     | 
    
         
            +
                        scp_args << "-P"
         
     | 
| 
      
 107 
     | 
    
         
            +
                        scp_args << scp_opts["port"]
         
     | 
| 
      
 108 
     | 
    
         
            +
                    end
         
     | 
| 
       74 
109 
     | 
    
         
             
                end
         
     | 
| 
       75 
110 
     | 
    
         | 
| 
       76 
111 
     | 
    
         
             
                def scp_remote_file(remote_path, scp_opts)
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: punt
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.7
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Noah Callaway
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-04-21 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       13 
13 
     | 
    
         
             
            description: Minimal deployment tool that can copy files to specific hosts over SCP
         
     | 
| 
       14 
14 
     | 
    
         
             
              and/or SFTP
         
     |