Class: Habitat::Profile
- Inherits:
-
Object
- Object
- Habitat::Profile
- Defined in:
- lib/bundles/inspec-habitat/profile.rb
Overview
rubocop:disable Metrics/ClassLength
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
Class Method Summary collapse
Instance Method Summary collapse
- #copy(hart_file) ⇒ Object
- #create ⇒ Object
- #delete_work_dir ⇒ Object
-
#initialize(path, options = {}) ⇒ Profile
constructor
A new instance of Profile.
- #upload ⇒ Object
Constructor Details
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/bundles/inspec-habitat/profile.rb', line 10 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/bundles/inspec-habitat/profile.rb', line 10 def path @path end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
10 11 12 |
# File 'lib/bundles/inspec-habitat/profile.rb', line 10 def profile @profile end |
Class Method Details
.create(path, options = {}) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/bundles/inspec-habitat/profile.rb', line 12 def self.create(path, = {}) creator = new(path, ) hart_file = creator.create creator.copy(hart_file) ensure creator.delete_work_dir end |
.upload(path, options = {}) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/bundles/inspec-habitat/profile.rb', line 20 def self.upload(path, = {}) uploader = new(path, ) uploader.upload ensure uploader.delete_work_dir end |
Instance Method Details
#copy(hart_file) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/bundles/inspec-habitat/profile.rb', line 58 def copy(hart_file) validate_output_dir Habitat::Log.info("Copying artifact to #{output_dir}...") copy_hart(hart_file) end |
#create ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bundles/inspec-habitat/profile.rb', line 35 def create Habitat::Log.info("Creating a Habitat artifact for profile: #{path}") validate_habitat_installed validate_habitat_origin create_profile_object verify_profile vendor_profile_dependencies copy_profile_to_work_dir create_plan create_run_hook create_default_config # returns the path to the .hart file in the work directory build_hart rescue => e Habitat::Log.debug(e.backtrace.join("\n")) exit_with_error( 'Unable to generate Habitat artifact.', "#{e.class} -- #{e.}", ) end |
#delete_work_dir ⇒ Object
77 78 79 80 |
# File 'lib/bundles/inspec-habitat/profile.rb', line 77 def delete_work_dir Habitat::Log.debug("Deleting work directory #{work_dir}") FileUtils.rm_rf(work_dir) if Dir.exist?(work_dir) end |
#upload ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/bundles/inspec-habitat/profile.rb', line 65 def upload validate_habitat_auth_token hart_file = create upload_hart(hart_file) rescue => e Habitat::Log.debug(e.backtrace.join("\n")) exit_with_error( 'Unable to upload Habitat artifact.', "#{e.class} -- #{e.}", ) end |