Sha256: 58004399c6327b00d751806b63514d0ddad4c362f87af91859e758ebd7be6ebc

Contents?: true

Size: 895 Bytes

Versions: 4

Compression:

Stored size: 895 Bytes

Contents

def run_with_prompt(command)
  run command do |input, stream, out|
    puts out
    if stream == :out and out =~ /^Enter/
      input.send_data STDIN.gets
    end
  end
end

Capistrano::Configuration.instance(:must_exist).load do
  namespace :secret_service do

    desc "Store a secret using secret_service"
    task :store, :roles => :db, :only => { :primary => true } do
      rake = fetch(:rake, "rake")
      rails_env = fetch(:rails_env, "production")

      run_with_prompt("cd #{current_path} && #{rake} RAILS_ENV=#{rails_env} secret_service:store")
    end

    desc "Show a secret previously stored with secret_service"
    task :show, :roles => :db, :only => { :primary => true } do
      rake = fetch(:rake, "rake")
      rails_env = fetch(:rails_env, "production")

      run_with_prompt("cd #{current_path} && #{rake} RAILS_ENV=#{rails_env} secret_service:show")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
secret_service-0.1.5 lib/secret_service/capistrano.rb
secret_service-0.1.4 lib/secret_service/capistrano.rb
secret_service-0.1.3 lib/secret_service/capistrano.rb
secret_service-0.1.2 lib/secret_service/capistrano.rb