diff options
Diffstat (limited to 'lib/gitlab/web_ide/config.rb')
-rw-r--r-- | lib/gitlab/web_ide/config.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/gitlab/web_ide/config.rb b/lib/gitlab/web_ide/config.rb new file mode 100644 index 00000000000..3b1fa162b53 --- /dev/null +++ b/lib/gitlab/web_ide/config.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +module Gitlab + module WebIde + # + # Base GitLab WebIde Configuration facade + # + class Config + ConfigError = Class.new(StandardError) + + def initialize(config, opts = {}) + @config = build_config(config, opts) + + @global = Entry::Global.new(@config, + with_image_ports: true) + @global.compose! + rescue Gitlab::Config::Loader::FormatError => e + raise Config::ConfigError, e.message + end + + def valid? + @global.valid? + end + + def errors + @global.errors + end + + def to_hash + @config + end + + def terminal_value + @global.terminal_value + end + + private + + def build_config(config, opts = {}) + Gitlab::Config::Loader::Yaml.new(config).load! + end + end + end +end |