Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
These can fail with "uninitialized constant Berkshelf" if the `module Berkshelf` hasn't already been declared, which under some kind of extremely strange conditions is failing on sles-11 and el-6 in our CI system. There is probably some fascinating reason why this is failing on only those two distros, and I am hoping I don't have to actually learn why. If you'd like a plausible story, something about LC_COLLATE env vars being different and leading to different file globbing behavior would be my guess. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
- Loading branch information
1 parent
13840e6
commit fa6488c
Showing
4 changed files
with
188 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
require "berkshelf/ridley_compat" | ||
|
||
module Berkshelf::APIClient | ||
require_relative "errors" | ||
module Berkshelf | ||
module APIClient | ||
require_relative "errors" | ||
|
||
class ChefServerConnection | ||
attr_reader :client | ||
class ChefServerConnection | ||
attr_reader :client | ||
|
||
def initialize(*args) | ||
@client = Berkshelf::RidleyCompat.new(*args) | ||
@url = args[0][:server_url] | ||
end | ||
def initialize(*args) | ||
@client = Berkshelf::RidleyCompat.new(*args) | ||
@url = args[0][:server_url] | ||
end | ||
|
||
def universe | ||
response = client.get("universe") | ||
def universe | ||
response = client.get("universe") | ||
|
||
[].tap do |cookbooks| | ||
response.each do |name, versions| | ||
versions.each do |version, attributes| | ||
attributes[:location_path] = @url | ||
cookbooks << RemoteCookbook.new(name, version, attributes) end | ||
[].tap do |cookbooks| | ||
response.each do |name, versions| | ||
versions.each do |version, attributes| | ||
attributes[:location_path] = @url | ||
cookbooks << RemoteCookbook.new(name, version, attributes) end | ||
end | ||
end | ||
rescue Ridley::Errors::HTTPNotFound | ||
raise ServiceNotFound, "service not found at: #{@url}" | ||
end | ||
rescue Ridley::Errors::HTTPNotFound | ||
raise ServiceNotFound, "service not found at: #{@url}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,56 @@ | ||
require "json" | ||
require "chef/mash" | ||
|
||
module Berkshelf::APIClient | ||
# A representation of cookbook metadata indexed by a Berkshelf API Server. Returned | ||
# by sending messages to a {Berkshelf::APIClient} and used to download cookbooks | ||
# indexed by the Berkshelf API Server. | ||
class RemoteCookbook | ||
# @return [String] | ||
attr_reader :name | ||
# @return [String] | ||
attr_reader :version | ||
|
||
# @param [String] name | ||
# @param [String] version | ||
# @param [Hash] attributes | ||
def initialize(name, version, attributes = {}) | ||
@name = name | ||
@version = version | ||
@attributes = ::Mash.new(attributes) | ||
end | ||
|
||
# @return [Hash] | ||
def dependencies | ||
@attributes[:dependencies] | ||
end | ||
|
||
# @return [Hash] | ||
def platforms | ||
@attributes[:platforms] | ||
end | ||
|
||
# @return [Symbol] | ||
def location_type | ||
@attributes[:location_type].to_sym | ||
end | ||
|
||
# @return [String] | ||
def location_path | ||
@attributes[:location_path] | ||
end | ||
|
||
def to_hash | ||
{ | ||
name: name, | ||
version: version, | ||
} | ||
end | ||
|
||
def to_json(options = {}) | ||
::JSON.pretty_generate(to_hash, options) | ||
module Berkshelf | ||
module APIClient | ||
# A representation of cookbook metadata indexed by a Berkshelf API Server. Returned | ||
# by sending messages to a {Berkshelf::APIClient} and used to download cookbooks | ||
# indexed by the Berkshelf API Server. | ||
class RemoteCookbook | ||
# @return [String] | ||
attr_reader :name | ||
# @return [String] | ||
attr_reader :version | ||
|
||
# @param [String] name | ||
# @param [String] version | ||
# @param [Hash] attributes | ||
def initialize(name, version, attributes = {}) | ||
@name = name | ||
@version = version | ||
@attributes = ::Mash.new(attributes) | ||
end | ||
|
||
# @return [Hash] | ||
def dependencies | ||
@attributes[:dependencies] | ||
end | ||
|
||
# @return [Hash] | ||
def platforms | ||
@attributes[:platforms] | ||
end | ||
|
||
# @return [Symbol] | ||
def location_type | ||
@attributes[:location_type].to_sym | ||
end | ||
|
||
# @return [String] | ||
def location_path | ||
@attributes[:location_path] | ||
end | ||
|
||
def to_hash | ||
{ | ||
name: name, | ||
version: version, | ||
} | ||
end | ||
|
||
def to_json(options = {}) | ||
::JSON.pretty_generate(to_hash, options) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.