Class: S3crets::Actions::Get
Overview
Fetch a single secret
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Attributes inherited from Base
Instance Method Summary collapse
- #fetch_secret(path) ⇒ Object
-
#initialize(ui, options, path) ⇒ Get
constructor
A new instance of Get.
- #run ⇒ Object
Constructor Details
#initialize(ui, options, path) ⇒ Get
Returns a new instance of Get.
12 13 14 15 |
# File 'lib/s3crets/actions/get.rb', line 12 def initialize(ui, , path) super(ui, ) @path = path end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
10 11 12 |
# File 'lib/s3crets/actions/get.rb', line 10 def path @path end |
Instance Method Details
#fetch_secret(path) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/s3crets/actions/get.rb', line 21 def fetch_secret(path) filename = File.basename(path) s3 = ::Aws::S3::Client.new(region: ['region']) resp = s3.get_object(bucket: ['bucket'], key: path) File.write(filename, resp.body.read) end |
#run ⇒ Object
17 18 19 |
# File 'lib/s3crets/actions/get.rb', line 17 def run fetch_secret(@path) end |