Class: Chef::Knife::StashRepoDelete

Inherits:
Chef::Knife show all
Includes:
StashBase
Defined in:
lib/chef/knife/stash_repo_delete.rb

Instance Method Summary collapse

Methods included from StashBase

#display_stash_error, #get_all_values, #get_config, #get_repo_https_url, #get_repo_ssh_url, #get_stash_connection, included

Instance Method Details

#runObject



17
18
19
20
21
22
23
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/stash_repo_delete.rb', line 17

def run
  $stdout.sync = true
  
  key = name_args.first

  if key.nil?
    ui.fatal "You need a project key!"
    show_usage
    exit 1
  end

  repo = name_args[1]

  if repo.nil?
    ui.fatal "You need a repository name!"
    show_usage
    exit 1
  end

  stash = get_stash_connection

  if get_config(:noop)
    ui.info "#{ui.color "Skipping project repository deletion process because --noop specified.", :red}"
  else
    response = stash.delete "projects/#{key}/repos/#{repo}"
    if response.success?
      ui.info "Deleted Stash Repository: #{key}/#{repo}"
    else
      display_stash_error "Could not delete Stash respository!", response
      exit 1
    end
  end
  
end