Class: ChefCLI::PolicyfileServices::Push
- Inherits:
 - 
      Object
      
        
- Object
 - ChefCLI::PolicyfileServices::Push
 
 
- Defined in:
 - lib/chef-cli/policyfile_services/push.rb
 
Instance Attribute Summary collapse
- 
  
    
      #config  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute config.
 - 
  
    
      #policy_group  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute policy_group.
 - 
  
    
      #root_dir  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute root_dir.
 - 
  
    
      #storage_config  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute storage_config.
 - 
  
    
      #ui  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute ui.
 
Instance Method Summary collapse
- #http_client ⇒ Object
 - 
  
    
      #initialize(policyfile: nil, ui: nil, policy_group: nil, config: nil, root_dir: nil)  ⇒ Push 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Push.
 - #policy_data ⇒ Object
 - #policyfile_lock ⇒ Object
 - #run ⇒ Object
 - #uploader ⇒ Object
 
Methods included from Helpers
#err, #git_bin_dir, #git_windows_bin_dir, #msg, #omnibus_bin_dir, #omnibus_embedded_bin_dir, #omnibus_env, #omnibus_expand_path, #omnibus_install?, #omnibus_root, #package_home, #stderr, #stdout, #system_command, #usr_bin_path, #usr_bin_prefix
Methods included from ChefCLI::Policyfile::StorageConfigDelegation
#cache_path, #policyfile_expanded_path, #policyfile_filename, #policyfile_lock_expanded_path, #relative_paths_root
Constructor Details
#initialize(policyfile: nil, ui: nil, policy_group: nil, config: nil, root_dir: nil) ⇒ Push
Returns a new instance of Push.
      39 40 41 42 43 44 45 46 47 48 49 50 51  | 
    
      # File 'lib/chef-cli/policyfile_services/push.rb', line 39 def initialize(policyfile: nil, ui: nil, policy_group: nil, config: nil, root_dir: nil) @root_dir = root_dir @ui = ui @config = config @policy_group = policy_group policyfile_rel_path = policyfile || "Policyfile.rb" policyfile_full_path = File.(policyfile_rel_path, root_dir) @storage_config = Policyfile::StorageConfig.new.use_policyfile(policyfile_full_path) @http_client = nil @policy_data = nil end  | 
  
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
      34 35 36  | 
    
      # File 'lib/chef-cli/policyfile_services/push.rb', line 34 def config @config end  | 
  
#policy_group ⇒ Object (readonly)
Returns the value of attribute policy_group.
      35 36 37  | 
    
      # File 'lib/chef-cli/policyfile_services/push.rb', line 35 def policy_group @policy_group end  | 
  
#root_dir ⇒ Object (readonly)
Returns the value of attribute root_dir.
      33 34 35  | 
    
      # File 'lib/chef-cli/policyfile_services/push.rb', line 33 def root_dir @root_dir end  | 
  
#storage_config ⇒ Object (readonly)
Returns the value of attribute storage_config.
      37 38 39  | 
    
      # File 'lib/chef-cli/policyfile_services/push.rb', line 37 def storage_config @storage_config end  | 
  
#ui ⇒ Object (readonly)
Returns the value of attribute ui.
      36 37 38  | 
    
      # File 'lib/chef-cli/policyfile_services/push.rb', line 36 def ui @ui end  | 
  
Instance Method Details
#http_client ⇒ Object
      53 54 55 56 57  | 
    
      # File 'lib/chef-cli/policyfile_services/push.rb', line 53 def http_client @http_client ||= Chef::ServerAPI.new(config.chef_server_url, signing_key_filename: config.client_key, client_name: config.node_name) end  | 
  
#policy_data ⇒ Object
      59 60 61 62 63  | 
    
      # File 'lib/chef-cli/policyfile_services/push.rb', line 59 def policy_data @policy_data ||= FFI_Yajl::Parser.parse(IO.read()) rescue => error raise PolicyfilePushError.new("Error reading lockfile #{}", error) end  | 
  
#policyfile_lock ⇒ Object
      82 83 84  | 
    
      # File 'lib/chef-cli/policyfile_services/push.rb', line 82 def policyfile_lock @policyfile_lock || validate_lockfile end  | 
  
#run ⇒ Object
      72 73 74 75 76 77 78 79 80  | 
    
      # File 'lib/chef-cli/policyfile_services/push.rb', line 72 def run unless File.exist?() raise LockfileNotFound, "No lockfile at #{} - you need to run `install` before `push`" end validate_lockfile write_updated_lockfile upload_policy end  | 
  
#uploader ⇒ Object
      65 66 67 68 69 70  | 
    
      # File 'lib/chef-cli/policyfile_services/push.rb', line 65 def uploader ChefCLI::Policyfile::Uploader.new(policyfile_lock, policy_group, ui:, http_client:, policy_document_native_api: config.policy_document_native_api) end  |