Class: Berkshelf::API::CacheBuilder::Worker::Github
- Includes:
- Logging
- Defined in:
- lib/berkshelf/api/cache_builder/worker/github.rb
Instance Attribute Summary collapse
- #organization ⇒ String readonly
Attributes inherited from Base
Instance Method Summary collapse
-
#cookbooks ⇒ Array<RemoteCookbook>
The list of cookbooks this builder can find.
-
#initialize(options = {}) ⇒ Github
constructor
A new instance of Github.
-
#metadata(remote) ⇒ Ridley::Chef::Cookbook::Metadata?
Return the metadata of the given RemoteCookbook.
- #to_s ⇒ String
Methods included from Logging
Methods inherited from Base
Methods included from Mixin::Services
Constructor Details
#initialize(options = {}) ⇒ Github
Returns a new instance of Github.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/berkshelf/api/cache_builder/worker/github.rb', line 21 def initialize( = {}) @connection = Octokit::Client.new(access_token: [:access_token], auto_paginate: true, api_endpoint: [:api_endpoint], web_endpoint: [:web_endpoint], connection_options: {ssl: {verify: [:ssl_verify].nil? ? true : [:ssl_verify]}}) @organization = [:organization] log.warn "You have configured a GitHub endpoint to index the #{@organization} organization." log.warn "Using unfinalized artifacts, such as cookbooks retrieved from Git, to satisfiy your" log.warn "dependencies is *STRONGLY FROWNED UPON* and potentially *DANGEROUS*." log.warn "" log.warn "Please consider setting up a release process for the cookbooks you wish to retrieve from this" log.warn "GitHub organization where the cookbook is uploaded into a Hosted Chef organization, an internal" log.warn "Chef Server, or the community site, and then replace this endpoint with a chef_server endpoint." super() end |
Instance Attribute Details
#organization ⇒ String (readonly)
14 15 16 |
# File 'lib/berkshelf/api/cache_builder/worker/github.rb', line 14 def organization @organization end |
Instance Method Details
#cookbooks ⇒ Array<RemoteCookbook>
Returns The list of cookbooks this builder can find.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/berkshelf/api/cache_builder/worker/github.rb', line 45 def cookbooks [].tap do |cookbook_versions| connection.organization_repositories(organization).each do |repo| connection.(repo.full_name).each do |tag| if match = /^v(?<version>.*)$/.match(tag.name) begin next unless = (repo.name, tag.name) if .version.to_s == match[:version].to_s cookbook_versions << RemoteCookbook.new(.name, .version, self.class.worker_type, repo.html_url, priority, {:repo_name => repo.name} ) else log.warn "Version found in metadata for #{repo.name} (#{tag.name}) does not " + "match the tag. Got #{.version}." end rescue Semverse::InvalidVersionFormat log.debug "Ignoring tag #{tag.name} for: #{repo.name}. Does not conform to semver." rescue Octokit::NotFound log.debug "Ignoring tag #{tag.name} for: #{repo.name}. No raw metadata found." end else log.debug "Version number cannot be parsed" end end end end end |
#metadata(remote) ⇒ Ridley::Chef::Cookbook::Metadata?
Return the metadata of the given RemoteCookbook. If the metadata could not be found or parsed nil is returned.
79 80 81 |
# File 'lib/berkshelf/api/cache_builder/worker/github.rb', line 79 def (remote) (remote.info[:repo_name], "v#{remote.version}") end |
#to_s ⇒ String
39 40 41 |
# File 'lib/berkshelf/api/cache_builder/worker/github.rb', line 39 def to_s friendly_name(organization) end |