lib/chef/knife/s3_source.rb in knife-ec2-0.18.2 vs lib/chef/knife/s3_source.rb in knife-ec2-0.19.10
- old
+ new
@@ -1,5 +1,21 @@
+#
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
class Chef
class Knife
class S3Source
attr_accessor :url
@@ -17,29 +33,32 @@
def bucket_obj
@bucket_obj ||= fog.directories.get(bucket)
end
+ # @return [URI]
def bucket
uri = URI(@url)
if uri.scheme == "s3"
URI(@url).host
else
URI(@url).path.split("/")[1]
end
end
+ # @return [URI]
def path
uri = URI(@url)
if uri.scheme == "s3"
- URI(@url).path.sub(/^\//, '')
+ URI(@url).path.sub(/^\//, "")
else
- URI(@url).path.split(bucket).last.sub(/^\//, '')
+ URI(@url).path.split(bucket).last.sub(/^\//, "")
end
end
+ # @return [Fog::Storage::AWS]
def fog
- require 'fog/aws' # lazy load the fog library to speed up the knife run
+ require "fog/aws" # lazy load the fog library to speed up the knife run
@fog ||= Fog::Storage::AWS.new(
aws_access_key_id: Chef::Config[:knife][:aws_access_key_id],
aws_secret_access_key: Chef::Config[:knife][:aws_secret_access_key]
)
end