Class: Chef::Knife::StashRepos

Inherits:
Chef::Knife show all
Includes:
StashBase
Defined in:
lib/chef/knife/stash_repos.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
# File 'lib/chef/knife/stash_repos.rb', line 17

def run
  $stdout.sync = true

  stash = get_stash_connection
  url = "projects"
  project_response = stash.get url

  if project_response.success?
    get_all_values stash,url,project_response do |project_values|
      project_values.each do |project|
        url = "projects/#{project['key']}/repos"
        repo_response = stash.get url

        if repo_response.success?
          get_all_values stash,url,repo_response do |repo_values|
            repo_values.each do |repo|
              ui.info "#{project['key']}/#{repo['slug']}"
            end
          end
        else
          display_stash_error "Could not list Stash project repositories!", repo_response
          exit 1
        end
      end
    end
  else
    display_stash_error "Could not list Stash projects!", project_response
    exit 1
  end
  
end