Class: Umami::PolicyfileServices::Push

Inherits:
ChefDK::PolicyfileServices::Push
  • Object
show all
Defined in:
lib/chef-umami/policyfile_services/push.rb

Instance Method Summary collapse

Constructor Details

#initialize(policyfile: nil, ui: nil, policy_group: nil, config: nil, root_dir: nil) ⇒ Push

Returns a new instance of Push.



20
21
22
23
# File 'lib/chef-umami/policyfile_services/push.rb', line 20

def initialize(policyfile: nil, ui: nil, policy_group: nil, config: nil, root_dir: nil)
  super(policyfile: policyfile, ui: ui, policy_group: policy_group,
        config: config, root_dir: root_dir)
end

Instance Method Details

#api_versionObject

Keep up with the times and force use of the newer API.



26
27
28
# File 'lib/chef-umami/policyfile_services/push.rb', line 26

def api_version
  '2'
end

#http_clientObject

We’ll override the #http_client method to ensure we set the appropriate API version we expect to be used. Chef::Authenticator#request_version will use this to set the appropriate header that Chef Server (Zero) uses to determine how to generate cookbook manifests. Without this, we see issues during the Umami::Client#compile phase where Chef cannot locate recipes within a cookbook and ‘umami` fails miserably. I spent a week debugging this when trying to update `umami` to support newer Chef libraries. That, too, was miserable.



38
39
40
41
42
43
# File 'lib/chef-umami/policyfile_services/push.rb', line 38

def http_client
  @http_client ||= Chef::ServerAPI.new(config.chef_server_url,
                                       signing_key_filename: config.client_key,
                                       client_name: config.node_name,
                                       api_version: api_version)
end