64b1044e7a
This decouples Ci::Config to provide a common interface for handling user configuration files.
27 lines
554 B
Ruby
27 lines
554 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
module Config
|
|
module Loader
|
|
class Yaml
|
|
def initialize(config)
|
|
@config = YAML.safe_load(config, [Symbol], [], true)
|
|
rescue Psych::Exception => e
|
|
raise Loader::FormatError, e.message
|
|
end
|
|
|
|
def valid?
|
|
@config.is_a?(Hash)
|
|
end
|
|
|
|
def load!
|
|
unless valid?
|
|
raise Loader::FormatError, 'Invalid configuration format'
|
|
end
|
|
|
|
@config.deep_symbolize_keys
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|