diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-21 13:40:52 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-21 13:40:52 +0300 |
commit | fc00c545b27ab2f4bf713ae246c197f809dd4c11 (patch) | |
tree | 39afd58eb9469a314aedca39a02b8f91ba63e927 /lib | |
parent | cd6a2afbbb508e96f67c1f192cee2c1d379b1749 (diff) |
Handle CI services config in new CI config classes
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ci/gitlab_ci_yaml_processor.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/ci/config.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/config/node/global.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/ci/config/node/services.rb | 22 |
4 files changed, 28 insertions, 7 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb index f4ef449c84c..2cb46448e76 100644 --- a/lib/ci/gitlab_ci_yaml_processor.rb +++ b/lib/ci/gitlab_ci_yaml_processor.rb @@ -14,7 +14,7 @@ module Ci ALLOWED_CACHE_KEYS = [:key, :untracked, :paths] ALLOWED_ARTIFACTS_KEYS = [:name, :untracked, :paths, :when, :expire_in] - attr_reader :after_script, :services, :path, :cache + attr_reader :after_script, :path, :cache def initialize(config, path = nil) @ci_config = Gitlab::Ci::Config.new(config) @@ -68,7 +68,7 @@ module Ci @after_script = @config[:after_script] @image = @config[:image] - @services = @config[:services] + @services = @ci_config.services @stages = @config[:stages] || @config[:types] @variables = @config[:variables] || {} @cache = @config[:cache] @@ -127,10 +127,6 @@ module Ci raise ValidationError, "after_script should be an array of strings" end - unless @services.nil? || validate_array_of_strings(@services) - raise ValidationError, "services should be an array of strings" - end - unless @stages.nil? || validate_array_of_strings(@stages) raise ValidationError, "stages should be an array of strings" end diff --git a/lib/gitlab/ci/config.rb b/lib/gitlab/ci/config.rb index d02902a110a..fb93d36c48f 100644 --- a/lib/gitlab/ci/config.rb +++ b/lib/gitlab/ci/config.rb @@ -7,7 +7,7 @@ module Gitlab ## # Temporary delegations that should be removed after refactoring # - delegate :before_script, :image, to: :@global + delegate :before_script, :image, :services, to: :@global def initialize(config) @config = Loader.new(config).load! diff --git a/lib/gitlab/ci/config/node/global.rb b/lib/gitlab/ci/config/node/global.rb index fa5f75beb9f..03ed7808d2f 100644 --- a/lib/gitlab/ci/config/node/global.rb +++ b/lib/gitlab/ci/config/node/global.rb @@ -14,6 +14,9 @@ module Gitlab allow_node :image, Image, description: 'Docker image that will be used to execute jobs.' + + allow_node :services, Services, + description: 'Docker images that will be linked to the container.' end end end diff --git a/lib/gitlab/ci/config/node/services.rb b/lib/gitlab/ci/config/node/services.rb new file mode 100644 index 00000000000..d9898d9a4a1 --- /dev/null +++ b/lib/gitlab/ci/config/node/services.rb @@ -0,0 +1,22 @@ +module Gitlab + module Ci + class Config + module Node + ## + # Entry that represents a configuration of Docker services. + # + class Services < Entry + include Validatable + + validations do + validates :config, array_of_strings: true + end + + def value + @config + end + end + end + end + end +end |