-
Notifications
You must be signed in to change notification settings - Fork 90
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
After download callback for artifact_package #107
Changes from all commits
7c17b73
baa0f7a
0d515ec
cbee734
47b7ea8
68ca783
2ef5552
470579e
47d9fc4
698e7ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
# Recipe:: nexus_anon | ||
# | ||
# Author:: Kyle Allan (<[email protected]>) | ||
# | ||
# | ||
# Copyright 2013, Riot Games | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
@@ -26,14 +26,20 @@ | |
node[:artifact_test][:other_nexus][:url], node[:artifact_test][:other_nexus][:repository] | ||
) | ||
|
||
artifact_deploy "artifact_test" do | ||
version node[:artifact_test][:version] | ||
artifact_location node[:artifact_test][:location] | ||
artifact_checksum node[:artifact_test][:checksum] | ||
location_parts = node[:artifact_test][:other_nexus][:location].split(":") | ||
version = location_parts[-1] | ||
type = location_parts[-2] | ||
# notice: replacing the extension and adding classifier | ||
location = node[:artifact_test][:other_nexus][:location].gsub(":#{type}:#{version}", ":jar:sources") | ||
deploy_to = "/srv/" + node[:artifact_test][:other_nexus][:app_name] | ||
|
||
artifact_deploy deploy_to do | ||
after_download Proc.new { Chef::Log.info "*** artifact_deploy after_download was called ***" } | ||
version version | ||
artifact_location location | ||
nexus_configuration nexus_configuration | ||
deploy_to node[:artifact_test][:deploy_to] | ||
deploy_to deploy_to | ||
owner "artifacts" | ||
group "artifact" | ||
|
||
action :deploy | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# | ||
# Cookbook Name:: artifact_test | ||
# Recipe:: nexus_package | ||
# | ||
# Author:: Aaron Feng (<[email protected]>) | ||
# | ||
# Copyright 2013, Riot Games | ||
# | ||
# 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. | ||
# | ||
|
||
group "artifact" | ||
user "artifacts" | ||
|
||
nexus_configuration = Chef::Artifact::NexusConfiguration.new( | ||
node[:artifact_test][:other_nexus][:url], node[:artifact_test][:other_nexus][:repository] | ||
) | ||
|
||
after_download_prc = Proc.new { | ||
Chef::Log.info "*** after download proc was executed! ***" | ||
} | ||
|
||
# make sure it works without after_download proc | ||
artifact_package "without after download proc" do | ||
location node[:artifact_test][:other_nexus][:location] | ||
nexus_configuration nexus_configuration | ||
owner "artifacts" | ||
group "artifact" | ||
action :install | ||
end | ||
|
||
rpm_package node[:artifact_test][:other_nexus][:app_name] do | ||
action :remove | ||
end | ||
|
||
file "/var/chef/cache/artifact_packages/#{node[:artifact_test][:other_nexus][:rpm_name]}" do | ||
action :delete | ||
end | ||
|
||
# make sure it works with after_download proc | ||
artifact_package "with after download proc" do | ||
nexus_configuration nexus_configuration | ||
after_download after_download_prc | ||
location node[:artifact_test][:other_nexus][:location] | ||
owner "artifacts" | ||
group "artifact" | ||
action :install | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class Chef | ||
module Artifact | ||
module Helpers | ||
# A wrapper that adds debug logging for running a recipe_eval on the | ||
# numerous Proc attributes defined for this resource. | ||
# | ||
# @param from [String] location where the proc is executed from | ||
# @param resource [Chef::Resource::ArtifactDeploy] resource being executed on | ||
# @param name [Symbol] the name of the proc to execute | ||
# | ||
# @return [void] | ||
def execute_run_proc(from, resource, name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to remove the It might make it cleaner to have this method be called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you can if you want to preserve the same style of logging before. |
||
proc = resource.send(name) | ||
proc_name = name.to_s | ||
Chef::Log.debug "#{from}[run_proc::#{proc_name}] Determining whether to execute #{proc_name} proc." | ||
if proc | ||
Chef::Log.debug "#{from}[run_proc::#{proc_name}] Beginning execution of #{proc_name} proc." | ||
recipe_eval(&proc) | ||
Chef::Log.debug "#{from}[run_proc::#{proc_name}] Ending execution of #{proc_name} proc." | ||
else | ||
Chef::Log.debug "#{from}[run_proc::#{proc_name}] Skipping execution of #{proc_name} proc because it was not defined." | ||
end | ||
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just
Chef::Resource
here