class Chef::Server

Attributes

root_url[RW]

Public Class Methods

from_chef_server_url(url) click to toggle source
# File lib/chef/server.rb, line 13
def self.from_chef_server_url(url)
  url = url.gsub(/\/organizations\/+[^\/]+\/*$/, '')
  Chef::Server.new(url)
end
new(root_url) click to toggle source
# File lib/chef/server.rb, line 9
def initialize(root_url)
  @root_url = root_url
end

Public Instance Methods

direct_account_access?() click to toggle source
# File lib/chef/server.rb, line 35
def direct_account_access?
  Chef::ServerAPI.new("http://127.0.0.1:9465").get("users")
  true
rescue
  false
end
parse_server_version(line) click to toggle source
# File lib/chef/server.rb, line 18
def parse_server_version(line)
  # first line from the /version endpoint will either be this format "chef-server 12.17.5\n"
  # or, when habitat, this format "Package: chef-server/chef-server-nginx/12.17.42/20180413212943\n"
  Gem::Version.new(line.include?('/') ? line.split('/')[2] : line.split(' ').last.gsub(/\+.*$/, ''))
end
supports_defaulting_to_pivotal?() click to toggle source
# File lib/chef/server.rb, line 42
def supports_defaulting_to_pivotal?
  version >= Gem::Version.new('12.1.0')
end
supports_public_key_read_access?() click to toggle source
# File lib/chef/server.rb, line 46
def supports_public_key_read_access?
  version >= Gem::Version.new('12.5.0')
end
supports_user_acls?() click to toggle source
# File lib/chef/server.rb, line 31
def supports_user_acls?
  version >= Gem::Version.new("11.0.1")
end
version() click to toggle source
# File lib/chef/server.rb, line 24
def version
  @version ||= begin
                 ver_line = Chef::ServerAPI.new(root_url).get('version').each_line.first
                 parse_server_version(ver_line)
               end
end