Sha256: e82fde008758cd1d6f6276bd33d4c40fe60c944ae6d3671f11b882c3d9946238

Contents?: true

Size: 1.46 KB

Versions: 5

Compression:

Stored size: 1.46 KB

Contents

# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'contrast/utils/duck_utils'
require 'contrast/utils/object_share'
require 'contrast/components/config/sources'
require 'contrast/config/diagnostics/tools'

module Contrast
  module Config
    # This class will hold all the references for the configuration files. It will safe read values used to
    # identify the source of configuration in Configuration Diagnostics reported to TS.
    class ConfigurationFiles
      # @return [String] path of the main configuration file.
      attr_accessor :main_file

      # @return [Array<Contrast::Config::LocalSourceValue>]
      def source_files
        @_source_files ||= []
      end

      # @param path [String]
      # @param values [Hash]
      def add_source_file path, values
        source_files << Contrast::Config::LocalSourceValue.new(path, values)
        @main_file = path if source_files.length == 1
      end
    end

    # This class will hold all the info about the read file.
    class LocalSourceValue
      YML_EXT = '.yml'
      YAML_EXT = '.yaml'
      # @return [String]
      attr_reader :path
      # @return [Hash]
      attr_reader :values

      # @param path [String]
      # @param values [Hash]
      def initialize path = '', values = {}
        @path = path unless Contrast::Utils::DuckUtils.empty_duck?(path)
        @values = values
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
contrast-agent-7.3.2 lib/contrast/config/configuration_files.rb
contrast-agent-7.3.1 lib/contrast/config/configuration_files.rb
contrast-agent-7.3.0 lib/contrast/config/configuration_files.rb
contrast-agent-7.2.0 lib/contrast/config/configuration_files.rb
contrast-agent-7.1.0 lib/contrast/config/configuration_files.rb