From 3dfff0b8aab2ae10ef8b7df5904532b4cdde7023 Mon Sep 17 00:00:00 2001 From: Muhammed Ali Date: Fri, 24 Nov 2023 16:15:33 +0000 Subject: [PATCH 01/10] Allow User to be specified for a CI Image or Service --- app/assets/javascripts/editor/schema/ci.json | 10 ++++ doc/ci/yaml/index.md | 6 +++ .../schemas/imageable/executor_opts.json | 4 ++ .../ci/yaml_tests/negative_tests/image.yml | 6 +++ .../ci/yaml_tests/negative_tests/services.yml | 7 +++ .../ci/yaml_tests/positive_tests/image.yml | 13 +++++ .../ci/yaml_tests/positive_tests/services.yml | 15 ++++++ spec/lib/gitlab/ci/build/image_spec.rb | 4 +- spec/lib/gitlab/ci/config/entry/image_spec.rb | 33 ++++++++++++- .../gitlab/ci/config/entry/service_spec.rb | 47 ++++++++++++++----- spec/lib/gitlab/ci/yaml_processor_spec.rb | 6 ++- .../api/ci/runner/jobs_request_post_spec.rb | 6 ++- .../yamls/image-executor_opts-platform.yml | 2 + .../yamls/service-executor_opts-platform.yml | 2 + 14 files changed, 141 insertions(+), 20 deletions(-) diff --git a/app/assets/javascripts/editor/schema/ci.json b/app/assets/javascripts/editor/schema/ci.json index 5fcf547a4ed7eb..5e1120234479a9 100644 --- a/app/assets/javascripts/editor/schema/ci.json +++ b/app/assets/javascripts/editor/schema/ci.json @@ -518,6 +518,11 @@ "type": "string", "minLength": 1, "description": "Image architecture to pull." + }, + "user": { + "type": "string", + "minLength": 1, + "description": "Username or UID to use for the container." } } }, @@ -593,6 +598,11 @@ "type": "string", "minLength": 1, "description": "Image architecture to pull." + }, + "user": { + "type": "string", + "minLength": 1, + "description": "Username or UID to use for the container." } } }, diff --git a/doc/ci/yaml/index.md b/doc/ci/yaml/index.md index 10b603d4d92f39..aa8a04aa44c1b9 100644 --- a/doc/ci/yaml/index.md +++ b/doc/ci/yaml/index.md @@ -2457,6 +2457,7 @@ A hash of options for the Docker executor, which can include: - `platform`: Selects the architecture of the image to pull. When not specified, the default is the same platform as the host runner. +- `user`: Specify the user or UID to use when running the container. **Example of `image:docker`**: @@ -2467,11 +2468,13 @@ arm-sql-job: name: super/sql:experimental docker: platform: arm64/v8 + user: dave ``` **Additional details**: - `image:docker:platform` maps to the [`docker pull --platform` option](https://docs.docker.com/engine/reference/commandline/pull/#options). +- `image:docker:user` maps to the [`docker run --user` option](https://docs.docker.com/engine/reference/commandline/run/#options). #### `image:pull_policy` @@ -4304,6 +4307,7 @@ A hash of options for the Docker executor, which can include: - `platform`: Selects the architecture of the image to pull. When not specified, the default is the same platform as the host runner. +- `user`: Specify the user or UID to use when running the container. **Example of `services:docker`**: @@ -4315,11 +4319,13 @@ arm-sql-job: - name: super/sql:experimental docker: platform: arm64/v8 + user: dave ``` **Additional details**: - `services:docker:platform` maps to the [`docker pull --platform` option](https://docs.docker.com/engine/reference/commandline/pull/#options). +- `services:docker:user` maps to the [`docker run --user` option](https://docs.docker.com/engine/reference/commandline/run/#options). #### `services:pull_policy` diff --git a/lib/gitlab/ci/config/entry/schemas/imageable/executor_opts.json b/lib/gitlab/ci/config/entry/schemas/imageable/executor_opts.json index a31374650e6eb7..7cffee1b7a1d5d 100644 --- a/lib/gitlab/ci/config/entry/schemas/imageable/executor_opts.json +++ b/lib/gitlab/ci/config/entry/schemas/imageable/executor_opts.json @@ -10,6 +10,10 @@ "type": "string", "minLength": 1, "maxLength": 64 + }, + "user": { + "type": "string", + "minLength": 1 } }, "additionalProperties": false diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/image.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/image.yml index ad37cd6c3bac8c..546dacecd32588 100644 --- a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/image.yml +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/image.yml @@ -26,6 +26,12 @@ invalid_image_platform: docker: platform: ["arm64"] # The expected value is a string, not an array +invalid_image_user: + image: + name: alpine:latest + docker: + user: ["dave"] # The expected value is a string, not an array + invalid_image_executor_opts: image: name: alpine:latest diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/services.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/services.yml index e14ac9ca86ec6c..c3f25a8030724c 100644 --- a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/services.yml +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/services.yml @@ -50,3 +50,10 @@ invalid_service_platform: - name: mysql:5.7 docker: platform: ["arm64"] # The expected value is a string, not an array + +invalid_service_user: + script: echo "Specifying platform." + services: + - name: mysql:5.7 + docker: + user: ["dave"] # The expected value is a string, not an array diff --git a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/image.yml b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/image.yml index 4c2559d0800e00..020cce80fd32d6 100644 --- a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/image.yml +++ b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/image.yml @@ -30,6 +30,19 @@ valid_image_with_docker: docker: platform: linux/amd64 +valid_image_with_docker_user: + image: + name: ubuntu:latest + docker: + user: ubuntu + +valid_image_with_docker_multiple_options: + image: + name: ubuntu:latest + docker: + platform: linux/arm64 + user: ubuntu + valid_image_full: image: name: alpine:latest diff --git a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/services.yml b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/services.yml index 1d19ee52cc3b03..0f45b075f53756 100644 --- a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/services.yml +++ b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/services.yml @@ -36,3 +36,18 @@ services_platform_string: - name: mysql:5.7 docker: platform: arm64 + +services_with_docker_user: + script: echo "Specifying platform." + services: + - name: mysql:5.7 + docker: + user: ubuntu + +services_with_docker_multiple_options: + script: echo "Specifying platform." + services: + - name: mysql:5.7 + docker: + platform: linux/arm64 + user: ubuntu diff --git a/spec/lib/gitlab/ci/build/image_spec.rb b/spec/lib/gitlab/ci/build/image_spec.rb index f8c0d69be2e1f4..3854437483d238 100644 --- a/spec/lib/gitlab/ci/build/image_spec.rb +++ b/spec/lib/gitlab/ci/build/image_spec.rb @@ -29,7 +29,7 @@ context 'when image is defined as hash' do let(:entrypoint) { '/bin/sh' } let(:pull_policy) { %w[always if-not-present] } - let(:executor_opts) { { docker: { platform: 'arm64' } } } + let(:executor_opts) { { docker: { platform: 'arm64', user: 'dave' } } } let(:job) do create(:ci_build, options: { image: { name: image_name, @@ -101,7 +101,7 @@ let(:service_entrypoint) { '/bin/sh' } let(:service_alias) { 'db' } let(:service_command) { 'sleep 30' } - let(:executor_opts) { { docker: { platform: 'amd64' } } } + let(:executor_opts) { { docker: { platform: 'amd64', user: 'dave' } } } let(:pull_policy) { %w[always if-not-present] } let(:job) do create(:ci_build, options: { services: [{ name: service_image_name, entrypoint: service_entrypoint, diff --git a/spec/lib/gitlab/ci/config/entry/image_spec.rb b/spec/lib/gitlab/ci/config/entry/image_spec.rb index 99a6e25b313863..6dd051f13bf507 100644 --- a/spec/lib/gitlab/ci/config/entry/image_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/image_spec.rb @@ -112,7 +112,7 @@ end end - context "when docker specifies an option" do + context "when docker specifies platform" do let(:config) { { name: 'image:1.0', docker: { platform: 'amd64' } } } it 'is valid' do @@ -131,7 +131,26 @@ end end - context "when docker specifies an invalid option" do + context "when docker specifies user" do + let(:config) { { name: 'image:1.0', docker: { user: 'dave' } } } + + it 'is valid' do + expect(entry).to be_valid + end + + describe '#value' do + it "returns value" do + expect(entry.value).to eq( + name: 'image:1.0', + executor_opts: { + docker: { user: 'dave' } + } + ) + end + end + end + + context "when docker specifies an invalid value for platform" do let(:config) { { name: 'image:1.0', docker: { platform: 1 } } } it 'is not valid' do @@ -140,6 +159,16 @@ .to match %r{image executor opts '/docker/platform' must be a valid 'string'} end end + + context "when docker specifies an invalid option" do + let(:config) { { name: 'image:1.0', docker: { unknown_key: 'foo' } } } + + it 'is not valid' do + expect(entry).not_to be_valid + expect(entry.errors.first) + .to match %r{xyz} + end + end end context 'when configuration has ports' do diff --git a/spec/lib/gitlab/ci/config/entry/service_spec.rb b/spec/lib/gitlab/ci/config/entry/service_spec.rb index 82747e7b521e01..8ce0f890b46ee0 100644 --- a/spec/lib/gitlab/ci/config/entry/service_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/service_spec.rb @@ -154,22 +154,45 @@ end context 'when configuration has docker options' do - let(:config) { { name: 'postgresql:9.5', docker: { platform: 'amd64' } } } + context "with platform option" do + let(:config) { { name: 'postgresql:9.5', docker: { platform: 'amd64' } } } - describe '#valid?' do - it 'is valid' do - expect(entry).to be_valid + describe '#valid?' do + it 'is valid' do + expect(entry).to be_valid + end + end + + describe '#value' do + it "returns value" do + expect(entry.value).to eq( + name: 'postgresql:9.5', + executor_opts: { + docker: { platform: 'amd64' } + } + ) + end end end - describe '#value' do - it "returns value" do - expect(entry.value).to eq( - name: 'postgresql:9.5', - executor_opts: { - docker: { platform: 'amd64' } - } - ) + context "with user option" do + let(:config) { { name: 'postgresql:9.5', docker: { user: 'dave' } } } + + describe '#valid?' do + it 'is valid' do + expect(entry).to be_valid + end + end + + describe '#value' do + it "returns value" do + expect(entry.value).to eq( + name: 'postgresql:9.5', + executor_opts: { + docker: { user: 'dave' } + } + ) + end end end end diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index e44e01b2ffa23e..aab7aa2180a79b 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -1323,10 +1323,12 @@ module Ci name: ruby:2.7 docker: platform: linux/amd64 + user: dave services: - name: postgres:11.9 docker: platform: linux/amd64 + user: john YAML end @@ -1341,9 +1343,9 @@ module Ci options: { script: ["exit 0"], image: { name: "ruby:2.7", - executor_opts: { docker: { platform: 'linux/amd64' } } }, + executor_opts: { docker: { platform: 'linux/amd64', user: 'dave' } } }, services: [{ name: "postgres:11.9", - executor_opts: { docker: { platform: 'linux/amd64' } } }] + executor_opts: { docker: { platform: 'linux/amd64', user: 'john' } } }] }, allow_failure: false, when: "on_success", diff --git a/spec/requests/api/ci/runner/jobs_request_post_spec.rb b/spec/requests/api/ci/runner/jobs_request_post_spec.rb index 3d6d86335eb812..e118ef9a384091 100644 --- a/spec/requests/api/ci/runner/jobs_request_post_spec.rb +++ b/spec/requests/api/ci/runner/jobs_request_post_spec.rb @@ -932,7 +932,8 @@ name: 'ruby', executor_opts: { docker: { - platform: 'amd64' + platform: 'amd64', + user: 'dave' } } } @@ -948,7 +949,8 @@ 'image' => { 'name' => 'ruby', 'executor_opts' => { 'docker' => { - 'platform' => 'amd64' + 'platform' => 'amd64', + 'user' => 'dave' } }, 'pull_policy' => nil, diff --git a/spec/requests/api/ci/runner/yamls/image-executor_opts-platform.yml b/spec/requests/api/ci/runner/yamls/image-executor_opts-platform.yml index 62e301f2e9a55a..380aaf43506357 100644 --- a/spec/requests/api/ci/runner/yamls/image-executor_opts-platform.yml +++ b/spec/requests/api/ci/runner/yamls/image-executor_opts-platform.yml @@ -4,6 +4,7 @@ gitlab_ci: name: alpine:latest docker: platform: amd64 + user: dave script: echo Hello World request_response: @@ -13,6 +14,7 @@ request_response: executor_opts: docker: platform: amd64 + user: dave ports: [] pull_policy: null steps: diff --git a/spec/requests/api/ci/runner/yamls/service-executor_opts-platform.yml b/spec/requests/api/ci/runner/yamls/service-executor_opts-platform.yml index 6483d749c4595e..970a6f2cb21106 100644 --- a/spec/requests/api/ci/runner/yamls/service-executor_opts-platform.yml +++ b/spec/requests/api/ci/runner/yamls/service-executor_opts-platform.yml @@ -4,6 +4,7 @@ gitlab_ci: - name: docker:dind docker: platform: amd64 + user: john script: echo Hello World request_response: @@ -22,6 +23,7 @@ request_response: executor_opts: docker: platform: amd64 + user: john ports: [] pull_policy: null variables: [] -- GitLab From 49cab49756d0c2f123ab79dcac74da5c2a8700ef Mon Sep 17 00:00:00 2001 From: Muhammed Ali Date: Fri, 24 Nov 2023 17:20:18 +0000 Subject: [PATCH 02/10] Add regex spec error message --- spec/lib/gitlab/ci/config/entry/image_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/gitlab/ci/config/entry/image_spec.rb b/spec/lib/gitlab/ci/config/entry/image_spec.rb index 6dd051f13bf507..110dd0142fd00c 100644 --- a/spec/lib/gitlab/ci/config/entry/image_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/image_spec.rb @@ -166,7 +166,7 @@ it 'is not valid' do expect(entry).not_to be_valid expect(entry.errors.first) - .to match %r{xyz} + .to match %r{image executor opts '/docker/unknown_key' must be a valid 'schema'} end end end -- GitLab From d735a3bde0b6c55acea950431f5d329361a5375e Mon Sep 17 00:00:00 2001 From: Muhammed Ali Date: Fri, 1 Dec 2023 22:40:03 +0000 Subject: [PATCH 03/10] fix: Add missing spec, maxLength on user and update docs --- app/assets/javascripts/editor/schema/ci.json | 2 ++ doc/ci/yaml/index.md | 4 ++-- .../schemas/imageable/executor_opts.json | 3 ++- spec/lib/gitlab/ci/config/entry/image_spec.rb | 24 +++++++++++++------ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/editor/schema/ci.json b/app/assets/javascripts/editor/schema/ci.json index 5e1120234479a9..d755a113851df2 100644 --- a/app/assets/javascripts/editor/schema/ci.json +++ b/app/assets/javascripts/editor/schema/ci.json @@ -522,6 +522,7 @@ "user": { "type": "string", "minLength": 1, + "maxLength": 255, "description": "Username or UID to use for the container." } } @@ -602,6 +603,7 @@ "user": { "type": "string", "minLength": 1, + "maxLength": 255, "description": "Username or UID to use for the container." } } diff --git a/doc/ci/yaml/index.md b/doc/ci/yaml/index.md index aa8a04aa44c1b9..35ad80f1ca7c04 100644 --- a/doc/ci/yaml/index.md +++ b/doc/ci/yaml/index.md @@ -2457,7 +2457,7 @@ A hash of options for the Docker executor, which can include: - `platform`: Selects the architecture of the image to pull. When not specified, the default is the same platform as the host runner. -- `user`: Specify the user or UID to use when running the container. +- `user`: Specify the user name or UID to use when running the container. **Example of `image:docker`**: @@ -4307,7 +4307,7 @@ A hash of options for the Docker executor, which can include: - `platform`: Selects the architecture of the image to pull. When not specified, the default is the same platform as the host runner. -- `user`: Specify the user or UID to use when running the container. +- `user`: Specify the user name or UID to use when running the container. **Example of `services:docker`**: diff --git a/lib/gitlab/ci/config/entry/schemas/imageable/executor_opts.json b/lib/gitlab/ci/config/entry/schemas/imageable/executor_opts.json index 7cffee1b7a1d5d..1098da0111a166 100644 --- a/lib/gitlab/ci/config/entry/schemas/imageable/executor_opts.json +++ b/lib/gitlab/ci/config/entry/schemas/imageable/executor_opts.json @@ -13,7 +13,8 @@ }, "user": { "type": "string", - "minLength": 1 + "minLength": 1, + "maxLength": 255 } }, "additionalProperties": false diff --git a/spec/lib/gitlab/ci/config/entry/image_spec.rb b/spec/lib/gitlab/ci/config/entry/image_spec.rb index 110dd0142fd00c..082b83b22f3240 100644 --- a/spec/lib/gitlab/ci/config/entry/image_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/image_spec.rb @@ -129,6 +129,16 @@ ) end end + + context "when platform is invalid" do + let(:config) { { name: 'image:1.0', docker: { platform: 1 } } } + + it 'is not valid' do + expect(entry).not_to be_valid + expect(entry.errors.first) + .to match %r{image executor opts '/docker/platform' must be a valid 'string'} + end + end end context "when docker specifies user" do @@ -148,15 +158,15 @@ ) end end - end - context "when docker specifies an invalid value for platform" do - let(:config) { { name: 'image:1.0', docker: { platform: 1 } } } + context "when user is invalid" do + let(:config) { { name: 'image:1.0', docker: { user: 1 } } } - it 'is not valid' do - expect(entry).not_to be_valid - expect(entry.errors.first) - .to match %r{image executor opts '/docker/platform' must be a valid 'string'} + it 'is not valid' do + expect(entry).not_to be_valid + expect(entry.errors.first) + .to match %r{image executor opts '/docker/user' must be a valid 'string'} + end end end -- GitLab From 50a02f79749b69b175fe4e6836f598d95e316424 Mon Sep 17 00:00:00 2001 From: Kasia Misirli Date: Mon, 4 Dec 2023 10:59:32 +0000 Subject: [PATCH 04/10] Apply 4 suggestion(s) to 1 file(s) --- spec/lib/gitlab/ci/config/entry/image_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/lib/gitlab/ci/config/entry/image_spec.rb b/spec/lib/gitlab/ci/config/entry/image_spec.rb index 082b83b22f3240..da48e62c76ba3b 100644 --- a/spec/lib/gitlab/ci/config/entry/image_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/image_spec.rb @@ -130,10 +130,10 @@ end end - context "when platform is invalid" do + context "when invalid data type is specified for platform option" do let(:config) { { name: 'image:1.0', docker: { platform: 1 } } } - it 'is not valid' do + it 'raises an error' do expect(entry).not_to be_valid expect(entry.errors.first) .to match %r{image executor opts '/docker/platform' must be a valid 'string'} @@ -159,10 +159,10 @@ end end - context "when user is invalid" do + context "when invalid data type is specified for user option" do let(:config) { { name: 'image:1.0', docker: { user: 1 } } } - it 'is not valid' do + it 'raises an error' do expect(entry).not_to be_valid expect(entry.errors.first) .to match %r{image executor opts '/docker/user' must be a valid 'string'} -- GitLab From b740ff7c5ddc146ee8591fbc24fed942b6d1a486 Mon Sep 17 00:00:00 2001 From: Muhammed Ali Date: Mon, 4 Dec 2023 11:51:00 +0000 Subject: [PATCH 05/10] Add UID Spec --- spec/lib/gitlab/ci/config/entry/image_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/lib/gitlab/ci/config/entry/image_spec.rb b/spec/lib/gitlab/ci/config/entry/image_spec.rb index da48e62c76ba3b..0a82010c20c273 100644 --- a/spec/lib/gitlab/ci/config/entry/image_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/image_spec.rb @@ -159,6 +159,25 @@ end end + context "when user is a UID" do + let(:config) { { name: 'image:1.0', docker: { user: '1001' } } } + + it 'is valid' do + expect(entry).to be_valid + end + + describe '#value' do + it "returns value" do + expect(entry.value).to eq( + name: 'image:1.0', + executor_opts: { + docker: { user: '1001' } + } + ) + end + end + end + context "when invalid data type is specified for user option" do let(:config) { { name: 'image:1.0', docker: { user: 1 } } } -- GitLab From fb457689326fceee253607505d5f9f42b1f8e0ae Mon Sep 17 00:00:00 2001 From: Avielle Wolfe Date: Mon, 4 Dec 2023 22:33:57 +0000 Subject: [PATCH 06/10] Apply 2 suggestion(s) to 1 file(s) --- doc/ci/yaml/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ci/yaml/index.md b/doc/ci/yaml/index.md index 35ad80f1ca7c04..3d83c543fc40f9 100644 --- a/doc/ci/yaml/index.md +++ b/doc/ci/yaml/index.md @@ -2457,7 +2457,7 @@ A hash of options for the Docker executor, which can include: - `platform`: Selects the architecture of the image to pull. When not specified, the default is the same platform as the host runner. -- `user`: Specify the user name or UID to use when running the container. +- `user`: Specify the username or UID to use when running the container. **Example of `image:docker`**: @@ -4307,7 +4307,7 @@ A hash of options for the Docker executor, which can include: - `platform`: Selects the architecture of the image to pull. When not specified, the default is the same platform as the host runner. -- `user`: Specify the user name or UID to use when running the container. +- `user`: Specify the username or UID to use when running the container. **Example of `services:docker`**: -- GitLab From 6bc8702198d671100b79c015e8d18a39fe177b5e Mon Sep 17 00:00:00 2001 From: Muhammed Ali Date: Wed, 6 Dec 2023 17:17:15 +0000 Subject: [PATCH 07/10] Create separate API Spec YAMLs for User option --- .../yamls/image-executor_opts-platform.yml | 2 -- .../runner/yamls/image-executor_opts-user.yml | 25 +++++++++++++++++ .../yamls/service-executor_opts-platform.yml | 2 -- .../yamls/service-executor_opts-user.yml | 27 +++++++++++++++++++ 4 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 spec/requests/api/ci/runner/yamls/image-executor_opts-user.yml create mode 100644 spec/requests/api/ci/runner/yamls/service-executor_opts-user.yml diff --git a/spec/requests/api/ci/runner/yamls/image-executor_opts-platform.yml b/spec/requests/api/ci/runner/yamls/image-executor_opts-platform.yml index 380aaf43506357..62e301f2e9a55a 100644 --- a/spec/requests/api/ci/runner/yamls/image-executor_opts-platform.yml +++ b/spec/requests/api/ci/runner/yamls/image-executor_opts-platform.yml @@ -4,7 +4,6 @@ gitlab_ci: name: alpine:latest docker: platform: amd64 - user: dave script: echo Hello World request_response: @@ -14,7 +13,6 @@ request_response: executor_opts: docker: platform: amd64 - user: dave ports: [] pull_policy: null steps: diff --git a/spec/requests/api/ci/runner/yamls/image-executor_opts-user.yml b/spec/requests/api/ci/runner/yamls/image-executor_opts-user.yml new file mode 100644 index 00000000000000..9fb56b941c9694 --- /dev/null +++ b/spec/requests/api/ci/runner/yamls/image-executor_opts-user.yml @@ -0,0 +1,25 @@ +gitlab_ci: + rspec: + image: + name: alpine:latest + docker: + user: dave + script: echo Hello World + +request_response: + image: + name: alpine:latest + entrypoint: null + executor_opts: + docker: + user: dave + ports: [] + pull_policy: null + steps: + - name: script + script: ["echo Hello World"] + timeout: 3600 + when: on_success + allow_failure: false + services: [] + diff --git a/spec/requests/api/ci/runner/yamls/service-executor_opts-platform.yml b/spec/requests/api/ci/runner/yamls/service-executor_opts-platform.yml index 970a6f2cb21106..6483d749c4595e 100644 --- a/spec/requests/api/ci/runner/yamls/service-executor_opts-platform.yml +++ b/spec/requests/api/ci/runner/yamls/service-executor_opts-platform.yml @@ -4,7 +4,6 @@ gitlab_ci: - name: docker:dind docker: platform: amd64 - user: john script: echo Hello World request_response: @@ -23,7 +22,6 @@ request_response: executor_opts: docker: platform: amd64 - user: john ports: [] pull_policy: null variables: [] diff --git a/spec/requests/api/ci/runner/yamls/service-executor_opts-user.yml b/spec/requests/api/ci/runner/yamls/service-executor_opts-user.yml new file mode 100644 index 00000000000000..ea824110e63736 --- /dev/null +++ b/spec/requests/api/ci/runner/yamls/service-executor_opts-user.yml @@ -0,0 +1,27 @@ +gitlab_ci: + rspec: + services: + - name: docker:dind + docker: + user: john + script: echo Hello World + +request_response: + image: null + steps: + - name: script + script: ["echo Hello World"] + timeout: 3600 + when: on_success + allow_failure: false + services: + - name: docker:dind + alias: null + command: null + entrypoint: null + executor_opts: + docker: + user: john + ports: [] + pull_policy: null + variables: [] -- GitLab From 9cfe419f88a5ac2b657fe947375c593c569e7213 Mon Sep 17 00:00:00 2001 From: Marcel Amirault Date: Tue, 19 Dec 2023 09:44:48 +0000 Subject: [PATCH 08/10] Apply 2 suggestion(s) to 1 file(s) --- doc/ci/yaml/index.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/ci/yaml/index.md b/doc/ci/yaml/index.md index 3d83c543fc40f9..41ec9d6f43e798 100644 --- a/doc/ci/yaml/index.md +++ b/doc/ci/yaml/index.md @@ -2444,7 +2444,8 @@ image: #### `image:docker` -> [Introduced](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27919) in GitLab 16.7. Requires GitLab Runner 16.7 or later. +> - [Introduced](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27919) in GitLab 16.7. Requires GitLab Runner 16.7 or later. +> - `user` input option [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/137907) in Gitlab 16.8. Use `image:docker` to pass options to the Docker executor of a GitLab Runner. @@ -4294,7 +4295,8 @@ In this example, GitLab launches two containers for the job: #### `services:docker` -> [Introduced](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27919) in GitLab 16.7. Requires GitLab Runner 16.7 or later. +> - [Introduced](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27919) in GitLab 16.7. Requires GitLab Runner 16.7 or later. +> - `user` input option [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/137907) in Gitlab 16.8. Use `services:docker` to pass options to the Docker executor of a GitLab Runner. -- GitLab From 53663a60f0b7b49ea6fa78f7180dddb0db524b31 Mon Sep 17 00:00:00 2001 From: Muhammed Ali Date: Tue, 19 Dec 2023 12:23:07 +0000 Subject: [PATCH 09/10] Apply 2 suggestion(s) to 1 file(s) --- doc/ci/yaml/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ci/yaml/index.md b/doc/ci/yaml/index.md index 41ec9d6f43e798..47a3db38a7877e 100644 --- a/doc/ci/yaml/index.md +++ b/doc/ci/yaml/index.md @@ -2445,7 +2445,7 @@ image: #### `image:docker` > - [Introduced](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27919) in GitLab 16.7. Requires GitLab Runner 16.7 or later. -> - `user` input option [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/137907) in Gitlab 16.8. +> - `user` input option [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/137907) in GitLab 16.8. Use `image:docker` to pass options to the Docker executor of a GitLab Runner. @@ -4296,7 +4296,7 @@ In this example, GitLab launches two containers for the job: #### `services:docker` > - [Introduced](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27919) in GitLab 16.7. Requires GitLab Runner 16.7 or later. -> - `user` input option [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/137907) in Gitlab 16.8. +> - `user` input option [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/137907) in GitLab 16.8. Use `services:docker` to pass options to the Docker executor of a GitLab Runner. -- GitLab From 9ed07ff5abc19f702356f06f3264e96e2b5edeb7 Mon Sep 17 00:00:00 2001 From: Muhammed Ali Date: Wed, 20 Dec 2023 15:15:09 +0000 Subject: [PATCH 10/10] Apply 3 suggestion(s) to 2 file(s) --- .../editor/schema/ci/yaml_tests/negative_tests/image.yml | 5 +++++ .../schema/ci/yaml_tests/negative_tests/services.yml | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/image.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/image.yml index 546dacecd32588..d6bc3cccf41ea0 100644 --- a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/image.yml +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/image.yml @@ -32,6 +32,11 @@ invalid_image_user: docker: user: ["dave"] # The expected value is a string, not an array +empty_image_user: + image: + name: alpine:latest + docker: + user: "" invalid_image_executor_opts: image: name: alpine:latest diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/services.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/services.yml index c3f25a8030724c..fd05d2606e5adc 100644 --- a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/services.yml +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/services.yml @@ -52,8 +52,15 @@ invalid_service_platform: platform: ["arm64"] # The expected value is a string, not an array invalid_service_user: - script: echo "Specifying platform." + script: echo "Specifying user." services: - name: mysql:5.7 docker: user: ["dave"] # The expected value is a string, not an array + +empty_service_user: + script: echo "Specifying user" + services: + - name: alpine:latest + docker: + user: "" -- GitLab