Class: Pvectl::Services::PullConfig
- Inherits:
-
Object
- Object
- Pvectl::Services::PullConfig
- Defined in:
- lib/pvectl/services/pull_config.rb
Overview
Orchestrates pulling resource configurations from the cluster and converting them to YAML manifests.
Instance Method Summary collapse
-
#execute(type:, ids: [], all: false, node: nil, selector: nil) ⇒ Hash
Executes the pull operation.
-
#initialize(vm_repository:, container_repository:) ⇒ PullConfig
constructor
A new instance of PullConfig.
Constructor Details
#initialize(vm_repository:, container_repository:) ⇒ PullConfig
Returns a new instance of PullConfig.
15 16 17 18 |
# File 'lib/pvectl/services/pull_config.rb', line 15 def initialize(vm_repository:, container_repository:) @vm_repository = vm_repository @container_repository = container_repository end |
Instance Method Details
#execute(type:, ids: [], all: false, node: nil, selector: nil) ⇒ Hash
Executes the pull operation.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/pvectl/services/pull_config.rb', line 28 def execute(type:, ids: [], all: false, node: nil, selector: nil) repo = repository_for(type) manifests = [] errors = [] if all || selector resources = repo.list(node: node) resources = selector.apply(resources) if selector resources.reject!(&:template?) else resources = ids.filter_map do |id| resource = repo.get(id.to_i) unless resource errors << "#{type_label(type)} #{id} not found" nil else resource end end end resources.each do |resource| result = pull_single(repo, resource, type) if result[:error] errors << result[:error] else manifests << result end end { manifests: manifests, errors: errors } end |