diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-10-18 10:45:47 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-10-18 10:45:47 +0900 |
commit | d957ea229cc25821d0a290b01ac73f0985b626cc (patch) | |
tree | 5f4c19a485927c2f2ed0eeb2f6a9f99d87b37694 | |
parent | 28d412e5b2b8499fba22e8fabb1d44f44449228e (diff) | |
download | gitlab-ce-allow-user-over-ride-for-image-keyword.tar.gz |
Allow user override for image keywordallow-user-over-ride-for-image-keyword
-rw-r--r-- | lib/api/entities.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/build/image.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/ci/config/entry/image.rb | 19 |
3 files changed, 12 insertions, 12 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 5a4b85f98cf..7d6a9f7ab4c 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -1299,7 +1299,7 @@ module API end class Image < Grape::Entity - expose :name, :entrypoint + expose :name, :entrypoint, :user end class Service < Image diff --git a/lib/gitlab/ci/build/image.rb b/lib/gitlab/ci/build/image.rb index c811f88f483..2714707cd67 100644 --- a/lib/gitlab/ci/build/image.rb +++ b/lib/gitlab/ci/build/image.rb @@ -2,7 +2,7 @@ module Gitlab module Ci module Build class Image - attr_reader :alias, :command, :entrypoint, :name + attr_reader :alias, :command, :entrypoint, :name, :user class << self def from_image(job) @@ -29,6 +29,7 @@ module Gitlab @command = image[:command] @entrypoint = image[:entrypoint] @name = image[:name] + @user = image[:user] end end diff --git a/lib/gitlab/ci/config/entry/image.rb b/lib/gitlab/ci/config/entry/image.rb index 2844be80a84..fc424f30948 100644 --- a/lib/gitlab/ci/config/entry/image.rb +++ b/lib/gitlab/ci/config/entry/image.rb @@ -7,15 +7,22 @@ module Gitlab # class Image < Node include Validatable + include Attributable - ALLOWED_KEYS = %i[name entrypoint].freeze + ALLOWED_KEYS = %i[name entrypoint user].freeze + + attributes ALLOWED_KEYS validations do validates :config, hash_or_string: true validates :config, allowed_keys: ALLOWED_KEYS validates :name, type: String, presence: true - validates :entrypoint, array_of_strings: true, allow_nil: true + + with_options allow_nil: true do + validates :entrypoint, array_of_strings: true + validates :user, type: String + end end def hash? @@ -26,14 +33,6 @@ module Gitlab @config.is_a?(String) end - def name - value[:name] - end - - def entrypoint - value[:entrypoint] - end - def value return { name: @config } if string? return @config if hash? |