Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Include more information about the policy in chef push output #1704

Merged
merged 1 commit into from
Sep 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/chef-dk/policyfile/uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def initialize(policyfile_lock, policy_group, ui: nil, http_client: nil, policy_
@ui = ui || UI.null
@policy_document_native_api = policy_document_native_api

@policy_lock_for_transport = nil
@cookbook_versions_for_policy = nil
end

Expand All @@ -49,7 +50,7 @@ def policy_name
end

def upload
ui.msg("Uploading policy to policy group #{policy_group}")
ui.msg("Uploading policy #{policy_name} (#{short_revision_id}) to policy group #{policy_group}")

if !using_policy_document_native_api?
ui.msg(<<-DRAGONS)
Expand All @@ -73,7 +74,7 @@ def upload_policy
end

def upload_policy_native
http_client.put("/policy_groups/#{policy_group}/policies/#{policy_name}", policyfile_lock.to_lock)
http_client.put("/policy_groups/#{policy_group}/policies/#{policy_name}", policy_lock_for_transport)
end

def data_bag_create
Expand All @@ -84,7 +85,7 @@ def data_bag_create

def data_bag_item_create
policy_id = "#{policy_name}-#{policy_group}"
lock_data = policyfile_lock.to_lock.dup
lock_data = policy_lock_for_transport.dup

lock_data["id"] = policy_id

Expand Down Expand Up @@ -180,6 +181,14 @@ def using_policy_document_native_api?

private

def short_revision_id
policy_lock_for_transport["revision_id"][0, 10]
end

def policy_lock_for_transport
@policy_lock_for_transport ||= policyfile_lock.to_lock
end

def list_cookbooks_url
if using_policy_document_native_api?
"cookbook_artifacts?num_versions=all"
Expand Down
1 change: 1 addition & 0 deletions spec/unit/policyfile/uploader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
{
"name" => "example",
"run_list" => [ "recipe[omnibus::default]" ],
"revision_id" => "f4b29d87c36de67cbfd9aa3147df77cebf9f719e8c884036b3cf34ba94773ca5",
"cookbook_locks" => {
"omnibus" => {
"version" => "2.2.0",
Expand Down