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

Configurable shared and releases folder names #161

Open
wants to merge 4 commits 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
14 changes: 9 additions & 5 deletions providers/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

include Chef::Artifact::Helpers

use_inline_resources

def load_current_resource
if Chef::Artifact.latest?(@new_resource.version) && Chef::Artifact.from_http?(@new_resource.artifact_location)
Chef::Application.fatal! "You cannot specify the latest version for an artifact when attempting to download an artifact using http(s)!"
Expand Down Expand Up @@ -336,7 +338,7 @@ def delete_current_if_forcing!
level :info
end

directory ::File.join(new_resource.deploy_to, 'releases', artifact_version) do
directory ::File.join(new_resource.deploy_to, new_resource.releases_name, artifact_version) do
recursive true
action :delete
end
Expand Down Expand Up @@ -370,7 +372,7 @@ def delete_previous_versions!
action :delete
end

directory ::File.join(new_resource.deploy_to, 'releases', version.basename) do
directory ::File.join(new_resource.deploy_to, new_resource.releases_name, version.basename) do
recursive true
action :delete
end
Expand Down Expand Up @@ -503,7 +505,7 @@ def is_current_using_symlinks?
#
# @return [String] the artifacts release path
def get_release_path
::File.join(new_resource.deploy_to, "releases", artifact_version)
::File.join(new_resource.deploy_to, new_resource.releases_name, artifact_version)
end

# Searches the releases directory and returns an Array of version folders. After
Expand All @@ -512,11 +514,13 @@ def get_release_path
#
# @return [Array] the mtime sorted array of currently installed versions
def get_previous_version_paths
versions = Dir[::File.join(new_resource.deploy_to, "releases", '**')].collect do |v|
versions = Dir[::File.join(new_resource.deploy_to, new_resource.releases_name, '**')].collect do |v|
Pathname.new(v)
end

versions.reject! { |v| v.basename.to_s == get_current_release_version }
exclude_filter = [get_current_release_version, 'current', new_resource.shared_name]

versions.reject! { |v| exclude_filter.include?(v.basename.to_s) || v.file? }

versions.sort_by(&:mtime)
end
Expand Down
3 changes: 3 additions & 0 deletions providers/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
include Chef::Artifact::Helpers
include Chef::Mixin::CreatePath

use_inline_resources

def load_current_resource
create_cache_path
if Chef::Artifact.from_nexus?(new_resource.location)
Expand Down Expand Up @@ -78,6 +80,7 @@ def load_current_resource
end
else
remote_file_resource.run_action(:create)
run_proc :after_download if @remote_file_resource.updated_by_last_action?
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
2 changes: 2 additions & 0 deletions providers/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
attr_reader :extension
attr_reader :file_name

use_inline_resources

def load_current_resource
if Chef::Artifact.from_nexus?(new_resource.location)
chef_gem "nexus_cli" do
Expand Down
4 changes: 3 additions & 1 deletion resources/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
attribute :artifact_location, :kind_of => String
attribute :artifact_checksum, :kind_of => String
attribute :deploy_to, :kind_of => String, :required => true
attribute :shared_name, :kind_of => String, :default => 'shared'
attribute :releases_name, :kind_of => String, :default => 'releases'
attribute :download_retries, :kind_of => Integer, :default => 1
attribute :version, :kind_of => String, :required => true
attribute :owner, :kind_of => String, :required => true, :regex => Chef::Config[:user_valid_regex]
Expand Down Expand Up @@ -72,5 +74,5 @@ def current_path
end

def shared_path
::File.join(self.deploy_to, "shared")
::File.join(self.deploy_to, self.shared_name)
end