Class: ChefCLI::Policyfile::ComparisonBase::PolicyGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-cli/policyfile/comparison_base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group, policy_name, http_client) ⇒ PolicyGroup

Returns a new instance of PolicyGroup.



102
103
104
105
106
# File 'lib/chef-cli/policyfile/comparison_base.rb', line 102

def initialize(group, policy_name, http_client)
  @group = group
  @policy_name = policy_name
  @http_client = http_client
end

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group.



98
99
100
# File 'lib/chef-cli/policyfile/comparison_base.rb', line 98

def group
  @group
end

#http_clientObject (readonly)

Returns the value of attribute http_client.



100
101
102
# File 'lib/chef-cli/policyfile/comparison_base.rb', line 100

def http_client
  @http_client
end

#policy_nameObject (readonly)

Returns the value of attribute policy_name.



99
100
101
# File 'lib/chef-cli/policyfile/comparison_base.rb', line 99

def policy_name
  @policy_name
end

Instance Method Details

#lockObject



112
113
114
115
116
117
118
119
120
121
122
# File 'lib/chef-cli/policyfile/comparison_base.rb', line 112

def lock
  http_client.get("policy_groups/#{group}/policies/#{policy_name}")
rescue Net::ProtocolError => e
  if e.respond_to?(:response) && e.response.code.to_s == "404"
    raise PolicyfileDownloadError.new("No Policyfile lock named '#{policy_name}' found in policy_group '#{group}' at #{http_client.url}", e)
  else
    raise PolicyfileDownloadError.new("HTTP error attempting to fetch Policyfile lock from #{http_client.url}", e)
  end
rescue => e
  raise PolicyfileDownloadError.new("Failed to fetch Policyfile lock from #{http_client.url}", e)
end

#nameObject



108
109
110
# File 'lib/chef-cli/policyfile/comparison_base.rb', line 108

def name
  "policy_group:#{group}"
end