Skip to content

Commit

Permalink
fix(subcommand): clarify config load behavior (no logic change)
Browse files Browse the repository at this point in the history
Signed-off-by: Robin H. Johnson <[email protected]>
Resolves: #360 (comment)
  • Loading branch information
robbat2 committed Dec 25, 2023
1 parent f77a580 commit 46e7c71
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/hiera/backend/eyaml/subcommand.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,20 @@ class << self

def self.load_config_file
config = { options: {}, sources: [] }
config_paths = [
'/etc/eyaml/config.yaml',
"#{ENV.fetch('HOME', nil)}/.eyaml/config.yaml",
'.eyaml/config.yaml',
"#{ENV.fetch('EYAML_CONFIG', nil)}",
]

config_paths = []
# Global
config_paths += ['/etc/eyaml/config.yaml']
# Home directory
env_home = ENV.fetch('HOME', nil)
config_paths += [ "#{env_home}/.eyaml/config.yaml" ] if env_home
# Relative to current directory
config_paths += [ ".eyaml/config.yaml" ]
# Explicit ENV variable.
env_eyaml_config = ENV.fetch('EYAML_CONFIG', nil)
config_paths += [env_eyaml_config] if env_eyaml_config

# Load each path and stack configs.
config_paths.each do |config_file|
next unless config_file and File.file? config_file

Expand Down

0 comments on commit 46e7c71

Please sign in to comment.