diff --git a/ee/lib/remote_development/workspaces/create/personal_access_token_creator.rb b/ee/lib/remote_development/workspaces/create/personal_access_token_creator.rb index 3ffe88b3f6b8b179d851763868bf3273dd6374af..17c3422769908d30cde80df5712141f85cb3ae59 100644 --- a/ee/lib/remote_development/workspaces/create/personal_access_token_creator.rb +++ b/ee/lib/remote_development/workspaces/create/personal_access_token_creator.rb @@ -22,7 +22,7 @@ def self.create(context) personal_access_token = user.personal_access_tokens.build( name: workspace_name, impersonation: false, - scopes: [:write_repository], + scopes: [:write_repository, :api], # Since expires_at is a date, we need to set it to the round it off to the next day. # e.g. If the max_hours_before_termination of the workspace is 1 hour # and the workspace is created at 2023-08-20 05:30:00, diff --git a/ee/lib/remote_development/workspaces/create/workspace_variables.rb b/ee/lib/remote_development/workspaces/create/workspace_variables.rb index fd4eebcc7546cd8e6bd3059694fba219889c5a7e..1924675d100f86a4e5c87c6f151386e84da4dfa5 100644 --- a/ee/lib/remote_development/workspaces/create/workspace_variables.rb +++ b/ee/lib/remote_development/workspaces/create/workspace_variables.rb @@ -134,6 +134,19 @@ def self.variables( value: vscode_extensions_gallery_resource_url_template, variable_type: RemoteDevelopment::Enums::Workspace::WORKSPACE_VARIABLE_TYPES[:environment], workspace_id: workspace_id + }, + # variables with prefix `GITLAB_WORKFLOW_` are used for configured GitLab Workflow extension for VS Code + { + key: 'GITLAB_WORKFLOW_INSTANCE_URL', + value: Gitlab::Routing.url_helpers.root_url, + variable_type: RemoteDevelopment::Enums::Workspace::WORKSPACE_VARIABLE_TYPES[:environment], + workspace_id: workspace_id + }, + { + key: 'GITLAB_WORKFLOW_TOKEN_FILE', + value: RemoteDevelopment::Workspaces::FileMounts::GITLAB_TOKEN_FILE, + variable_type: RemoteDevelopment::Enums::Workspace::WORKSPACE_VARIABLE_TYPES[:environment], + workspace_id: workspace_id } ] diff --git a/ee/spec/fixtures/remote_development/example.processed-devfile-v2.yaml b/ee/spec/fixtures/remote_development/example.processed-devfile-v2.yaml index 913610586a25a69d37306847fc6b930f24d910b6..0afce736c8d6927afd9dcb7f1542f32e5b56ead6 100644 --- a/ee/spec/fixtures/remote_development/example.processed-devfile-v2.yaml +++ b/ee/spec/fixtures/remote_development/example.processed-devfile-v2.yaml @@ -59,7 +59,7 @@ components: mountSources: true - name: gl-tools-injector container: - image: registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:1.0.0 + image: registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:2.0.0 volumeMounts: - name: gl-workspace-data path: /projects diff --git a/ee/spec/fixtures/remote_development/example.processed-devfile.yaml b/ee/spec/fixtures/remote_development/example.processed-devfile.yaml index 913610586a25a69d37306847fc6b930f24d910b6..0afce736c8d6927afd9dcb7f1542f32e5b56ead6 100644 --- a/ee/spec/fixtures/remote_development/example.processed-devfile.yaml +++ b/ee/spec/fixtures/remote_development/example.processed-devfile.yaml @@ -59,7 +59,7 @@ components: mountSources: true - name: gl-tools-injector container: - image: registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:1.0.0 + image: registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:2.0.0 volumeMounts: - name: gl-workspace-data path: /projects diff --git a/ee/spec/fixtures/remote_development/example.processed-marketplace-disabled-devfile.yaml b/ee/spec/fixtures/remote_development/example.processed-marketplace-disabled-devfile.yaml index 8f7e9d9f171d2147301700b1f103908711339588..6379e25fa347e14dec18cf12ccb070053e8554cf 100644 --- a/ee/spec/fixtures/remote_development/example.processed-marketplace-disabled-devfile.yaml +++ b/ee/spec/fixtures/remote_development/example.processed-marketplace-disabled-devfile.yaml @@ -51,7 +51,7 @@ components: size: 15Gi - name: gl-tools-injector container: - image: registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:1.0.0 + image: registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:2.0.0 volumeMounts: - name: gl-workspace-data path: /projects diff --git a/ee/spec/fixtures/remote_development/example.project-cloner-injected-devfile.yaml b/ee/spec/fixtures/remote_development/example.project-cloner-injected-devfile.yaml index 8119477f945cd456d56f6e40e200e2e47ee58419..e5f2079028d888f8881451dda8b154e3372d8027 100644 --- a/ee/spec/fixtures/remote_development/example.project-cloner-injected-devfile.yaml +++ b/ee/spec/fixtures/remote_development/example.project-cloner-injected-devfile.yaml @@ -53,7 +53,7 @@ components: mountSources: true - name: gl-tools-injector container: - image: registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:1.0.0 + image: registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:2.0.0 env: - name: GL_TOOLS_DIR value: "/projects/.gl-tools" diff --git a/ee/spec/fixtures/remote_development/example.tools-injected-devfile.yaml b/ee/spec/fixtures/remote_development/example.tools-injected-devfile.yaml index 29d790b46ec25597387191eda3ff2514bcb1c3a1..f59219400a2938b0c8b587cd7f133a2ac5e8d14b 100644 --- a/ee/spec/fixtures/remote_development/example.tools-injected-devfile.yaml +++ b/ee/spec/fixtures/remote_development/example.tools-injected-devfile.yaml @@ -53,7 +53,7 @@ components: mountSources: true - name: gl-tools-injector container: - image: registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:1.0.0 + image: registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:2.0.0 env: - name: GL_TOOLS_DIR value: "/projects/.gl-tools" diff --git a/ee/spec/fixtures/remote_development/example.tools-injected-marketplace-disabled-devfile.yaml b/ee/spec/fixtures/remote_development/example.tools-injected-marketplace-disabled-devfile.yaml index 8c50450f4c2c349fea591ad599a3590ce667ed1c..06178b6fcfc636b973ba988483a78b2dd9e26802 100644 --- a/ee/spec/fixtures/remote_development/example.tools-injected-marketplace-disabled-devfile.yaml +++ b/ee/spec/fixtures/remote_development/example.tools-injected-marketplace-disabled-devfile.yaml @@ -53,7 +53,7 @@ components: mountSources: true - name: gl-tools-injector container: - image: registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:1.0.0 + image: registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:2.0.0 env: - name: GL_TOOLS_DIR value: "/projects/.gl-tools" diff --git a/ee/spec/lib/remote_development/workspaces/create/main_integration_spec.rb b/ee/spec/lib/remote_development/workspaces/create/main_integration_spec.rb index 440aaa0c46f8a0bcb95e4c83884319cf4aa132bb..4ba810fecb052f94953d6e4508e7a34fe04cd0b0 100644 --- a/ee/spec/lib/remote_development/workspaces/create/main_integration_spec.rb +++ b/ee/spec/lib/remote_development/workspaces/create/main_integration_spec.rb @@ -52,7 +52,7 @@ end let(:tools_injector_image_from_settings) do - "registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:1.0.0" + "registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:2.0.0" end let(:settings) do diff --git a/ee/spec/lib/remote_development/workspaces/create/tools_component_injector_spec.rb b/ee/spec/lib/remote_development/workspaces/create/tools_component_injector_spec.rb index 6c67740bdf7a1ff2d27be47759e361c2fa957569..3634dea9a0b47196a5b5fab36a76f742ddc9fbf7 100644 --- a/ee/spec/lib/remote_development/workspaces/create/tools_component_injector_spec.rb +++ b/ee/spec/lib/remote_development/workspaces/create/tools_component_injector_spec.rb @@ -10,7 +10,7 @@ let(:expected_processed_devfile_name) { 'example.tools-injected-devfile.yaml' } let(:expected_processed_devfile) { YAML.safe_load(read_devfile(expected_processed_devfile_name)).to_h } let(:tools_injector_image_from_settings) do - "registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:1.0.0" + "registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:2.0.0" end let(:settings) do diff --git a/ee/spec/lib/remote_development/workspaces/create/workspace_variables_spec.rb b/ee/spec/lib/remote_development/workspaces/create/workspace_variables_spec.rb index 56a3ab0cd163fc22d23b3e285ab4660a4914af0d..98dd3df0c8293e69201892f2f4e9b20e10f4a1e1 100644 --- a/ee/spec/lib/remote_development/workspaces/create/workspace_variables_spec.rb +++ b/ee/spec/lib/remote_development/workspaces/create/workspace_variables_spec.rb @@ -128,6 +128,18 @@ variable_type: RemoteDevelopment::Enums::Workspace::WORKSPACE_VARIABLE_TYPES[:environment], workspace_id: workspace_id }, + { + key: 'GITLAB_WORKFLOW_INSTANCE_URL', + value: Gitlab::Routing.url_helpers.root_url, + variable_type: RemoteDevelopment::Enums::Workspace::WORKSPACE_VARIABLE_TYPES[:environment], + workspace_id: workspace_id + }, + { + key: 'GITLAB_WORKFLOW_TOKEN_FILE', + value: "/.workspace-data/variables/file/gl_token", + variable_type: RemoteDevelopment::Enums::Workspace::WORKSPACE_VARIABLE_TYPES[:environment], + workspace_id: workspace_id + }, { key: "VAR1", value: "value 1", @@ -173,6 +185,10 @@ ) end + before do + allow(Gitlab::Routing).to receive_message_chain(:url_helpers, :root_url).and_return("https://gitlab.com") + end + it 'defines correct variables' do expect(variables).to eq(expected_variables) end diff --git a/ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb b/ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb index 4771c78f7e82ea2cb79719da41b736448a7b8ddd..f2d09cfd8891650b21baf66a8ab01c57c8ad7873 100644 --- a/ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb +++ b/ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb @@ -808,7 +808,7 @@ def workspace_deployment( value: "/projects" } ], - image: "registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:1.0.0", + image: "registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:2.0.0", imagePullPolicy: "Always", name: "gl-tools-injector-gl-tools-injector-command-2", resources: { diff --git a/lib/remote_development/settings/default_settings.rb b/lib/remote_development/settings/default_settings.rb index 2691b215c08284bcc5c070802b2577ab914424fb..efe577329d1ef2b1898928fee3858aabc7a60447 100644 --- a/lib/remote_development/settings/default_settings.rb +++ b/lib/remote_development/settings/default_settings.rb @@ -20,7 +20,7 @@ def self.default_settings max_hours_before_termination_limit: [120, Integer], project_cloner_image: ['alpine/git:2.36.3', String], tools_injector_image: [ - "registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:1.0.0", String + "registry.gitlab.com/gitlab-org/remote-development/gitlab-workspaces-tools:2.0.0", String ], vscode_extensions_gallery: [ {