Sha256: ca3b50ff0a3168531764eb443211ddca24524a7da99938b58069444e69889321

Contents?: true

Size: 1.35 KB

Versions: 20

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

require_relative 'catalog'
require_relative 'common'
require_relative '../../util/catalogs'

module OctocatalogDiff
  module API
    module V1
      # This class allows octocatalog-diff to be used to compile catalogs.
      class CatalogCompile
        # Public: Compile a catalog given the options provided.
        #
        # Parameters are to be passed in a hash.
        # @param :logger [Logger] Logger object (be sure to configure log level)
        # @param :node [String] Node name (FQDN)
        # Other catalog building parameters are also accepted
        # @return [OctocatalogDiff::Catalog] Compiled catalogs

        def self.catalog(options = nil)
          # Validate the required options.
          unless options.is_a?(Hash)
            raise ArgumentError, 'Usage: #catalog(options_hash)'
          end

          pass_opts, logger = OctocatalogDiff::API::V1::Common.logger_from_options(options)
          logger.debug "Compiling catalog for #{options[:node]}"

          # Compile catalog
          catalog_opts = pass_opts.merge(
            from_catalog: '-', # Prevents a compile
            to_catalog: nil, # Forces a compile
          )
          cat_obj = OctocatalogDiff::Util::Catalogs.new(catalog_opts, logger)
          OctocatalogDiff::API::V1::Catalog.new(cat_obj.catalogs[:to])
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
octocatalog-diff-2.3.1 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-2.3.0 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-2.1.0 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-2.0.0 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-1.6.0 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-1.5.4 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-1.5.3 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-1.5.2 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-1.5.1 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-1.5.0 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-1.4.1 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-1.4.0 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-1.3.0 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-1.2.0 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-1.1.0 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-1.0.4 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-1.0.3 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-1.0.2 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-1.0.1 lib/octocatalog-diff/api/v1/catalog-compile.rb
octocatalog-diff-1.0.0 lib/octocatalog-diff/api/v1/catalog-compile.rb