Class: ChefCLI::PolicyfileServices::PushArchive
- Inherits:
-
Object
- Object
- ChefCLI::PolicyfileServices::PushArchive
- Defined in:
- lib/chef-cli/policyfile_services/push_archive.rb
Constant Summary collapse
- USTAR_INDICATOR =
"ustar\0".force_encoding(Encoding::ASCII_8BIT).freeze
Instance Attribute Summary collapse
-
#archive_file ⇒ Object
readonly
Returns the value of attribute archive_file.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#policy_group ⇒ Object
readonly
Returns the value of attribute policy_group.
-
#policyfile_lock ⇒ Object
readonly
Returns the value of attribute policyfile_lock.
-
#root_dir ⇒ Object
readonly
Returns the value of attribute root_dir.
-
#ui ⇒ Object
readonly
Returns the value of attribute ui.
Instance Method Summary collapse
- #archive_file_path ⇒ Object
- #http_client ⇒ Object private
-
#initialize(archive_file: nil, policy_group: nil, root_dir: nil, ui: nil, config: nil) ⇒ PushArchive
constructor
A new instance of PushArchive.
- #run ⇒ Object
- #uploader ⇒ Object private
Constructor Details
#initialize(archive_file: nil, policy_group: nil, root_dir: nil, ui: nil, config: nil) ⇒ PushArchive
Returns a new instance of PushArchive.
40 41 42 43 44 45 46 47 48 |
# File 'lib/chef-cli/policyfile_services/push_archive.rb', line 40 def initialize(archive_file: nil, policy_group: nil, root_dir: nil, ui: nil, config: nil) @archive_file = archive_file @policy_group = policy_group @root_dir = root_dir || Dir.pwd @ui = ui @config = config @policyfile_lock = nil end |
Instance Attribute Details
#archive_file ⇒ Object (readonly)
Returns the value of attribute archive_file.
32 33 34 |
# File 'lib/chef-cli/policyfile_services/push_archive.rb', line 32 def archive_file @archive_file end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
36 37 38 |
# File 'lib/chef-cli/policyfile_services/push_archive.rb', line 36 def config @config end |
#policy_group ⇒ Object (readonly)
Returns the value of attribute policy_group.
33 34 35 |
# File 'lib/chef-cli/policyfile_services/push_archive.rb', line 33 def policy_group @policy_group end |
#policyfile_lock ⇒ Object (readonly)
Returns the value of attribute policyfile_lock.
38 39 40 |
# File 'lib/chef-cli/policyfile_services/push_archive.rb', line 38 def policyfile_lock @policyfile_lock end |
#root_dir ⇒ Object (readonly)
Returns the value of attribute root_dir.
34 35 36 |
# File 'lib/chef-cli/policyfile_services/push_archive.rb', line 34 def root_dir @root_dir end |
#ui ⇒ Object (readonly)
Returns the value of attribute ui.
35 36 37 |
# File 'lib/chef-cli/policyfile_services/push_archive.rb', line 35 def ui @ui end |
Instance Method Details
#archive_file_path ⇒ Object
50 51 52 |
# File 'lib/chef-cli/policyfile_services/push_archive.rb', line 50 def archive_file_path File.(archive_file, root_dir) end |
#http_client ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
78 79 80 81 82 |
# File 'lib/chef-cli/policyfile_services/push_archive.rb', line 78 def http_client @http_client ||= Chef::ServerAPI.new(config.chef_server_url, signing_key_filename: config.client_key, client_name: config.node_name) end |
#run ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/chef-cli/policyfile_services/push_archive.rb', line 54 def run unless File.exist?(archive_file_path) raise InvalidPolicyArchive, "Archive file #{archive_file_path} not found" end stage_unpacked_archive do |staging_dir| read_policyfile_lock(staging_dir) uploader.upload end rescue => e raise PolicyfilePushArchiveError.new("Failed to publish archived policy", e) end |
#uploader ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
70 71 72 73 74 75 |
# File 'lib/chef-cli/policyfile_services/push_archive.rb', line 70 def uploader ChefCLI::Policyfile::Uploader.new(policyfile_lock, policy_group, ui:, http_client:, policy_document_native_api: config.policy_document_native_api) end |