06892e88f5
Enables frozen string for the following: * lib/gitlab/ci/*.rb * lib/gitlab/ci/build/**/*.rb * lib/gitlab/ci/config/**/*.rb * lib/gitlab/ci/pipeline/**/*.rb * lib/gitlab/ci/reports/**/*.rb Partially addresses #47424.
29 lines
583 B
Ruby
29 lines
583 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
module Ci
|
|
class Config
|
|
class Loader
|
|
FormatError = Class.new(StandardError)
|
|
|
|
def initialize(config)
|
|
@config = YAML.safe_load(config, [Symbol], [], true)
|
|
rescue Psych::Exception => e
|
|
raise FormatError, e.message
|
|
end
|
|
|
|
def valid?
|
|
@config.is_a?(Hash)
|
|
end
|
|
|
|
def load!
|
|
unless valid?
|
|
raise FormatError, 'Invalid configuration format'
|
|
end
|
|
|
|
@config.deep_symbolize_keys
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|