Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let artifact_file respect owner/group/mode #154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions providers/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
# limitations under the License.
#
require 'chef/mixin/create_path'
require 'chef/mixin/enforce_ownership_and_permissions'

attr_reader :file_location
attr_reader :nexus_configuration
attr_reader :nexus_connection

include Chef::Artifact::Helpers
include Chef::Mixin::CreatePath
include Chef::Mixin::EnforceOwnershipAndPermissions

def load_current_resource
create_cache_path
Expand Down Expand Up @@ -55,6 +57,7 @@ def load_current_resource
if Chef::Artifact.from_s3?(file_location)
unless ::File.exists?(new_resource.path) && checksum_valid?
Chef::Artifact.retrieve_from_s3(node, file_location, new_resource.path)
enforce_ownership_and_permissions
run_proc :after_download
end
elsif Chef::Artifact.from_nexus?(file_location)
Expand All @@ -70,6 +73,7 @@ def load_current_resource
if nexus_connection.get_artifact_filename(file_location) != ::File.basename(new_resource.path)
::File.rename(::File.join(::File.dirname(new_resource.path), nexus_connection.get_artifact_filename(file_location)), new_resource.path)
end
enforce_ownership_and_permissions
run_proc :after_download
rescue NexusCli::PermissionsException => e
msg = "The artifact server returned 401 (Unauthorized) when attempting to retrieve this artifact. Confirm that your credentials are correct."
Expand All @@ -78,6 +82,7 @@ def load_current_resource
end
else
remote_file_resource.run_action(:create)
enforce_ownership_and_permissions
end
raise Chef::Artifact::ArtifactChecksumError unless checksum_valid?
write_checksum if Chef::Artifact.from_nexus?(file_location) || Chef::Artifact.from_s3?(file_location)
Expand Down Expand Up @@ -137,6 +142,10 @@ def remote_file_resource
end
end

def manage_symlink_access?
false
end

private
# A wrapper that calls Chef::Artifact:run_proc
#
Expand Down
5 changes: 3 additions & 2 deletions resources/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
# limitations under the License.
#

require 'chef/mixin/securable'
include Chef::Mixin::Securable

actions :create
default_action :create

attribute :path, :kind_of => String, :name_attribute => true, :required => true
attribute :location, :kind_of => String
attribute :checksum, :kind_of => String
attribute :owner, :kind_of => String, :required => true, :regex => Chef::Config[:user_valid_regex]
attribute :group, :kind_of => String, :required => true, :regex => Chef::Config[:user_valid_regex]
attribute :download_retries, :kind_of => Integer, :default => 1
attribute :after_download, :kind_of => Proc
attribute :nexus_configuration, :kind_of => Chef::Artifact::NexusConfiguration, :default => Chef::Artifact::NexusConfiguration.from_data_bag