24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/chef/knife/artifactory_unshare.rb', line 24
def run
@cookbook_name = @name_args[0]
if @cookbook_name.nil?
show_usage
ui.fatal "You must provide the name of the cookbook to unshare"
exit 1
end
@cookbook_version = @name_args[1]
if @cookbook_version.nil?
show_usage
ui.fatal "You must provide a version to unshare"
exit 1
end
confirm "Are you sure you want to delete version #{@cookbook_version} of the cookbook #{@cookbook_name} from Artifactory"
begin
url = "#{cookbooks_api_url}/#{@cookbook_name}/#{@cookbook_version}"
noauth_rest.delete(url, )
rescue Net::HTTPServerException => e
raise e unless e.message =~ /Forbidden/ || e.message =~ /Unauthorized/
ui.error "Forbidden: You must have delete permissions on the target repo to delete #{@cookbook_name}."
exit 1
end
ui.info "Deleted version #{@cookbook_version} of the cookbook #{@cookbook_name}"
end
|