Class: DInstaller::ConfigReader
- Inherits:
-
Object
- Object
- DInstaller::ConfigReader
- Includes:
- Yast::I18n, Yast::Transfer::FileFromUrl
- Defined in:
- lib/dinstaller/config_reader.rb
Overview
This class is responsible for reading DInstaller configuration from different locations including kernel cmdline options
Constant Summary collapse
- SYSTEM_PATH =
Default DInstaller configuration which should define all the possible values
"/etc/d-installer.yaml"
- GIT_PATH =
File.("#{__dir__}/../../etc/d-installer.yaml")
- REMOTE_BOOT_CONFIG =
"d-installer_boot.yaml"
- PATHS =
[ "/usr/lib/d-installer.d", "/etc/d-installer.d", "/run/d-installer.d" ].freeze
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#workdir ⇒ Object
readonly
Returns the value of attribute workdir.
Instance Method Summary collapse
-
#config ⇒ Config
Return a Config oject.
-
#config_from_file(path = nil) ⇒ Object
loads correct yaml file.
-
#configs ⇒ Object
Return an Array with the different Config objects read from the different locations.
-
#initialize(logger: nil, workdir: "/") ⇒ ConfigReader
constructor
Constructor.
Constructor Details
#initialize(logger: nil, workdir: "/") ⇒ ConfigReader
Constructor
57 58 59 60 |
# File 'lib/dinstaller/config_reader.rb', line 57 def initialize(logger: nil, workdir: "/") @logger = logger || ::Logger.new($stdout) @workdir = workdir end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
50 51 52 |
# File 'lib/dinstaller/config_reader.rb', line 50 def logger @logger end |
#workdir ⇒ Object (readonly)
Returns the value of attribute workdir.
51 52 53 |
# File 'lib/dinstaller/config_reader.rb', line 51 def workdir @workdir end |
Instance Method Details
#config ⇒ Config
Return a DInstaller::Config oject
85 86 87 88 89 |
# File 'lib/dinstaller/config_reader.rb', line 85 def config config = configs.first || Config.new (configs[1..-1] || []).each { |c| config = config.merge(c) } config end |
#config_from_file(path = nil) ⇒ Object
loads correct yaml file
63 64 65 66 67 |
# File 'lib/dinstaller/config_reader.rb', line 63 def config_from_file(path = nil) raise "Missing config file at #{path}" unless File.exist?(path) Config.from_file(path) end |
#configs ⇒ Object
Return an Array with the different DInstaller::Config objects read from the different locations
TODO: handle precedence correctly
74 75 76 77 78 79 80 81 |
# File 'lib/dinstaller/config_reader.rb', line 74 def configs return @configs if @configs @configs = config_paths.map { |path| config_from_file(path) } @configs << remote_config if remote_config @configs << cmdline_config if cmdline_config @configs end |