diff --git a/db/migrate/20241001163638_add_default_valueto_editor_column.rb b/db/migrate/20241001163638_add_default_valueto_editor_column.rb new file mode 100644 index 0000000000000000000000000000000000000000..e0a7cd7e2c7c13d33381f94d0498ddf60bf42d0a --- /dev/null +++ b/db/migrate/20241001163638_add_default_valueto_editor_column.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddDefaultValuetoEditorColumn < Gitlab::Database::Migration[2.2] + milestone '17.5' + + def change + change_column_default :workspaces, :editor, from: nil, to: 'webide' + end +end diff --git a/db/schema_migrations/20241001163638 b/db/schema_migrations/20241001163638 new file mode 100644 index 0000000000000000000000000000000000000000..bf9532c2ea53dedb8085d3c7792d3854795e23db --- /dev/null +++ b/db/schema_migrations/20241001163638 @@ -0,0 +1 @@ +8200c0f506522b56aea29d87eb62bda7c259947232c1740ec073488aa8eac9d0 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 139449b331637ad3f448dbf0ff793bed2f281642..21e76cbffb76e58a892201b265ef519240b221ad 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -21250,7 +21250,7 @@ CREATE TABLE workspaces ( namespace text NOT NULL, desired_state text NOT NULL, actual_state text NOT NULL, - editor text NOT NULL, + editor text DEFAULT 'webide'::text NOT NULL, devfile_ref text NOT NULL, devfile_path text NOT NULL, devfile text, diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 347219459f7c2d4d1a4506d8ec89b4efee2ea760..ffaeca3d94533a8bb0c572551f69123e1a7b23a3 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -10974,7 +10974,7 @@ Input type: `WorkspaceCreateInput` | `desiredState` | [`String!`](#string) | Desired state of the created workspace. | | `devfilePath` | [`String!`](#string) | Project repo git path containing the devfile used to configure the workspace. | | `devfileRef` | [`String!`](#string) | Project repo git ref containing the devfile used to configure the workspace. | -| `editor` | [`String!`](#string) | Editor to inject into the created workspace. Must match a configured template. | +| `editor` **{warning-solid}** | [`String`](#string) | **Deprecated:** Argument is not used. Deprecated in GitLab 17.5. | | `maxHoursBeforeTermination` | [`Int!`](#int) | Maximum hours the workspace can exist before it is automatically terminated. | | `projectId` | [`ProjectID!`](#projectid) | ID of the project that will provide the Devfile for the created workspace. | | `variables` | [`[WorkspaceVariableInput!]`](#workspacevariableinput) | Variables to inject into the workspace. | @@ -36036,7 +36036,7 @@ Represents a remote development workspace. | `devfilePath` | [`String!`](#string) | Path to the devfile used to configure the workspace. | | `devfileRef` | [`String!`](#string) | Git reference that contains the devfile used to configure the workspace. | | `devfileWebUrl` | [`String!`](#string) | Web URL of the devfile used to configure the workspace. | -| `editor` | [`String!`](#string) | Editor used to configure the workspace. Must match a configured template. | +| `editor` **{warning-solid}** | [`String!`](#string) | **Deprecated** in GitLab 17.5. Field is not used. | | `id` | [`RemoteDevelopmentWorkspaceID!`](#remotedevelopmentworkspaceid) | Global ID of the workspace. | | `maxHoursBeforeTermination` | [`Int!`](#int) | Number of hours until the workspace automatically terminates. | | `name` | [`String!`](#string) | Name of the workspace in Kubernetes. | diff --git a/ee/app/assets/javascripts/workspaces/user/constants.js b/ee/app/assets/javascripts/workspaces/user/constants.js index 7142590034e7341f6954aab07e722777003d1f5c..f5365bdbf4b224611d971cc13efb75d3e69ed49e 100644 --- a/ee/app/assets/javascripts/workspaces/user/constants.js +++ b/ee/app/assets/javascripts/workspaces/user/constants.js @@ -19,7 +19,6 @@ export const PROJECT_VISIBILITY = { export const DEFAULT_DESIRED_STATE = WORKSPACE_STATES.running; export const DEFAULT_DEVFILE_PATH = '.devfile.yaml'; -export const DEFAULT_EDITOR = 'webide'; export const WORKSPACE_VARIABLE_INPUT_TYPE_ENUM = { env: 'ENVIRONMENT', diff --git a/ee/app/assets/javascripts/workspaces/user/pages/create.vue b/ee/app/assets/javascripts/workspaces/user/pages/create.vue index e4bd6d515b901ce8743feee3abef784a565ca8bc..4f569125d6297102049928e7156d220e266b4160 100644 --- a/ee/app/assets/javascripts/workspaces/user/pages/create.vue +++ b/ee/app/assets/javascripts/workspaces/user/pages/create.vue @@ -29,7 +29,6 @@ import { addWorkspace } from '../services/apollo_cache_mutators'; import { DEFAULT_DESIRED_STATE, DEFAULT_DEVFILE_PATH, - DEFAULT_EDITOR, ROUTES, PROJECT_VISIBILITY, } from '../constants'; @@ -218,7 +217,6 @@ export default { input: { projectId: this.projectId, clusterAgentId: this.selectedAgent, - editor: DEFAULT_EDITOR, desiredState: DEFAULT_DESIRED_STATE, devfileRef: this.devfileRef, devfilePath: this.devfilePath, diff --git a/ee/app/graphql/mutations/remote_development/workspace_operations/create.rb b/ee/app/graphql/mutations/remote_development/workspace_operations/create.rb index 9cbb05da36abf6287f6d252899813ef4feb5932c..215f9fa596786bc957c379bc9dc29d8a49555896 100644 --- a/ee/app/graphql/mutations/remote_development/workspace_operations/create.rb +++ b/ee/app/graphql/mutations/remote_development/workspace_operations/create.rb @@ -26,10 +26,12 @@ class Create < BaseMutation required: true, description: 'Desired state of the created workspace.' + # TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/498322 - Remove in 18.0 argument :editor, GraphQL::Types::String, - required: true, - description: 'Editor to inject into the created workspace. Must match a configured template.' + required: false, + description: 'Editor to inject into the created workspace. Must match a configured template.', + deprecated: { reason: 'Argument is not used', milestone: '17.5' } argument :max_hours_before_termination, GraphQL::Types::Int, diff --git a/ee/app/graphql/types/remote_development/workspace_type.rb b/ee/app/graphql/types/remote_development/workspace_type.rb index 3789b2ba26f11f9b5f42d6dbeb9cf506eac27ae6..c1f0ca5356fa539a94f4cbb825ae802a2689d7a0 100644 --- a/ee/app/graphql/types/remote_development/workspace_type.rb +++ b/ee/app/graphql/types/remote_development/workspace_type.rb @@ -46,8 +46,11 @@ class WorkspaceType < ::Types::BaseObject field :url, GraphQL::Types::String, null: false, description: 'URL of the workspace.' + # TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/498322 - Remove in 18.0 field :editor, GraphQL::Types::String, - null: false, description: 'Editor used to configure the workspace. Must match a configured template.' + null: false, + description: 'Editor used to configure the workspace. Must match a configured template.', + deprecated: { reason: 'Field is not used', milestone: '17.5' } field :max_hours_before_termination, GraphQL::Types::Int, null: false, description: 'Number of hours until the workspace automatically terminates.' @@ -79,6 +82,10 @@ class WorkspaceType < ::Types::BaseObject def project_id "gid://gitlab/Project/#{object.project_id}" end + + def editor + 'webide' + end end end end diff --git a/ee/app/models/remote_development/workspace.rb b/ee/app/models/remote_development/workspace.rb index 675c8477946389b707d945c224ff4708cb6b4756..56dedcb7976810823324cdb7817ccea60a7e29f9 100644 --- a/ee/app/models/remote_development/workspace.rb +++ b/ee/app/models/remote_development/workspace.rb @@ -11,6 +11,7 @@ class Workspace < ApplicationRecord ignore_column :dns_zone, remove_with: '17.5', remove_after: '2024-10-11' ignore_column :config_version, remove_with: '17.6', remove_after: '2024-10-18' + ignore_column :editor, remove_with: '17.7', remove_after: '2024-11-21' belongs_to :user, inverse_of: :workspaces belongs_to :project, inverse_of: :workspaces @@ -24,7 +25,6 @@ class Workspace < ApplicationRecord validates :user, presence: true validates :agent, presence: true - validates :editor, presence: true validates :personal_access_token, presence: true # TODO: uncomment this line with below issue in 17.6 # https://gitlab.com/gitlab-org/gitlab/-/issues/493992 @@ -34,7 +34,6 @@ class Workspace < ApplicationRecord # for state validation rules validates :desired_state, inclusion: { in: VALID_DESIRED_STATES } validates :actual_state, inclusion: { in: VALID_ACTUAL_STATES } - validates :editor, inclusion: { in: ['webide'], message: "'webide' is currently the only supported editor" } validate :validate_workspaces_agent_config_present, if: -> { agent } validate :validate_workspaces_agent_config_version_is_within_range, if: -> do diff --git a/ee/lib/remote_development/workspace_operations/create/workspace_creator.rb b/ee/lib/remote_development/workspace_operations/create/workspace_creator.rb index 197923472016aff0e694adc2767f4e1a938f4d7d..417f7007cd93858a6435092712a7b7cf8ef5b62a 100644 --- a/ee/lib/remote_development/workspace_operations/create/workspace_creator.rb +++ b/ee/lib/remote_development/workspace_operations/create/workspace_creator.rb @@ -27,7 +27,6 @@ def self.create(context) } params => { desired_state: String => desired_state, - editor: String => editor, max_hours_before_termination: Integer => max_hours_before_termination, devfile_ref: String => devfile_ref, devfile_path: String => devfile_path, @@ -44,7 +43,6 @@ def self.create(context) workspace.actual_state = CREATION_REQUESTED workspace.desired_config_generator_version = RemoteDevelopment::WorkspaceOperations::DesiredConfigGeneratorVersion::LATEST_VERSION - workspace.editor = editor workspace.max_hours_before_termination = max_hours_before_termination workspace.devfile_ref = devfile_ref workspace.devfile_path = devfile_path diff --git a/ee/spec/factories/remote_development/workspaces.rb b/ee/spec/factories/remote_development/workspaces.rb index 00c14d0c0b205f3504d92d59cc2adac5960ce09f..dfe61a3989679b0a4379efde075051a128b23cca 100644 --- a/ee/spec/factories/remote_development/workspaces.rb +++ b/ee/spec/factories/remote_development/workspaces.rb @@ -19,7 +19,6 @@ desired_state { RemoteDevelopment::WorkspaceOperations::States::STOPPED } actual_state { RemoteDevelopment::WorkspaceOperations::States::STOPPED } deployment_resource_version { 2 } - editor { 'webide' } max_hours_before_termination { 24 } devfile_ref { 'main' } diff --git a/ee/spec/frontend/workspaces/user/pages/create_spec.js b/ee/spec/frontend/workspaces/user/pages/create_spec.js index ed442fdb1ac15673a3a48af22a980c8f5654ec4f..c4a1a973cda328d70ef927f6374dfebd51829727 100644 --- a/ee/spec/frontend/workspaces/user/pages/create_spec.js +++ b/ee/spec/frontend/workspaces/user/pages/create_spec.js @@ -22,7 +22,6 @@ import createMockApollo from 'helpers/mock_apollo_helper'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { DEFAULT_DESIRED_STATE, - DEFAULT_EDITOR, ROUTES, WORKSPACE_VARIABLE_INPUT_TYPE_ENUM, WORKSPACES_LIST_PAGE_SIZE, @@ -428,7 +427,6 @@ describe('workspaces/user/pages/create.vue', () => { input: { clusterAgentId: selectedClusterAgentOneIDFixture, projectId: projectGid, - editor: DEFAULT_EDITOR, desiredState: DEFAULT_DESIRED_STATE, devfilePath, maxHoursBeforeTermination, diff --git a/ee/spec/lib/remote_development/workspace_operations/create/devfile_fetcher_spec.rb b/ee/spec/lib/remote_development/workspace_operations/create/devfile_fetcher_spec.rb index 8b30acd81d3a0f254179fcddfbd089f940a3686b..e2a87db435bbaedd541cc23e3925d20c7b22730a 100644 --- a/ee/spec/lib/remote_development/workspace_operations/create/devfile_fetcher_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/create/devfile_fetcher_spec.rb @@ -19,14 +19,12 @@ let(:devfile_path) { '.devfile.yaml' } let(:devfile_fixture_name) { 'example.devfile.yaml' } let(:devfile_yaml) { read_devfile(devfile_fixture_name) } - let(:editor) { 'webide' } let(:workspace_root) { '/projects' } let(:params) do { agent: agent, user: user, project: project, - editor: editor, max_hours_before_termination: 24, desired_state: RemoteDevelopment::WorkspaceOperations::States::RUNNING, devfile_ref: devfile_ref, diff --git a/ee/spec/lib/remote_development/workspace_operations/create/main_integration_spec.rb b/ee/spec/lib/remote_development/workspace_operations/create/main_integration_spec.rb index ebcacc7e8850344b0347fe177481cff8e675bcf0..566ab811e50050a0537ce60f740e51e71777eb14 100644 --- a/ee/spec/lib/remote_development/workspace_operations/create/main_integration_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/create/main_integration_spec.rb @@ -19,7 +19,6 @@ let(:devfile_fixture_name) { 'example.devfile.yaml' } let(:devfile_yaml) { read_devfile(devfile_fixture_name) } let(:expected_processed_devfile) { YAML.safe_load(example_processed_devfile).to_h } - let(:editor) { 'webide' } let(:workspace_root) { '/projects' } let(:dns_zone) { 'dns.zone.me' } let(:variables) do @@ -45,7 +44,6 @@ agent: agent, user: user, project: project, - editor: editor, max_hours_before_termination: 24, desired_state: RemoteDevelopment::WorkspaceOperations::States::RUNNING, devfile_ref: devfile_ref, @@ -116,7 +114,6 @@ expect(workspace.actual_state).to eq(RemoteDevelopment::WorkspaceOperations::States::CREATION_REQUESTED) expect(workspace.name).to eq("workspace-#{agent.id}-#{user.id}-#{random_string}") expect(workspace.namespace).to eq("gl-rd-ns-#{agent.id}-#{user.id}-#{random_string}") - expect(workspace.editor).to eq('webide') expect(workspace.workspaces_agent_config_version).to eq(expected_workspaces_agent_config_version) expect(workspace.url).to eq(URI::HTTPS.build({ host: "60001-#{workspace.name}.#{dns_zone}", diff --git a/ee/spec/lib/remote_development/workspace_operations/create/workspace_creator_spec.rb b/ee/spec/lib/remote_development/workspace_operations/create/workspace_creator_spec.rb index 0052fdcdddc896e5a2fdd583d0f56d66b45b6509..2794bfdbc135b4253031d4dfeb181f968699e473 100644 --- a/ee/spec/lib/remote_development/workspace_operations/create/workspace_creator_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/create/workspace_creator_spec.rb @@ -18,14 +18,12 @@ let(:desired_state) { RemoteDevelopment::WorkspaceOperations::States::RUNNING } let(:processed_devfile_yaml) { YAML.safe_load(example_processed_devfile) } - let(:editor) { 'webide' } let(:workspace_root) { '/projects' } let(:params) do { agent: agent, user: user, project: project, - editor: editor, max_hours_before_termination: 24, desired_state: desired_state, devfile_ref: 'main', diff --git a/ee/spec/models/remote_development/workspace_spec.rb b/ee/spec/models/remote_development/workspace_spec.rb index 436bc43bd7b99982651e1e994fb65729ae5cf320..e161410caa1f413a3d6f175475744b70cbf2ad40 100644 --- a/ee/spec/models/remote_development/workspace_spec.rb +++ b/ee/spec/models/remote_development/workspace_spec.rb @@ -359,13 +359,6 @@ end end - context "on editor" do - it 'validates editor is webide' do - workspace.editor = 'not-webide' - expect(workspace).not_to be_valid - end - end - context 'on max_hours_before_termination' do context 'when max_hours_before_termination is greater than the agent max_hours_before_termination limit' do context 'when it is created' do diff --git a/ee/spec/requests/api/graphql/mutations/remote_development/workspace_operations/update_spec.rb b/ee/spec/requests/api/graphql/mutations/remote_development/workspace_operations/update_spec.rb index cf9fa134ed9b0b48879102c0007885bbc76b8893..9da1cc0c0de21414bd276fa2cc633f11e40c6695 100644 --- a/ee/spec/requests/api/graphql/mutations/remote_development/workspace_operations/update_spec.rb +++ b/ee/spec/requests/api/graphql/mutations/remote_development/workspace_operations/update_spec.rb @@ -22,8 +22,7 @@ agent: agent, project: project, user: user, - desired_state: RemoteDevelopment::WorkspaceOperations::States::RUNNING, - editor: 'webide' + desired_state: RemoteDevelopment::WorkspaceOperations::States::RUNNING ) end diff --git a/ee/spec/requests/remote_development/integration_spec.rb b/ee/spec/requests/remote_development/integration_spec.rb index 2b51b3bc3edfc836073b984b37279800e81365c1..8bc6bbecf64d46acad891b20ed63f5af4c37194b 100644 --- a/ee/spec/requests/remote_development/integration_spec.rb +++ b/ee/spec/requests/remote_development/integration_spec.rb @@ -97,7 +97,6 @@ end let(:expected_processed_devfile) { YAML.safe_load(expected_processed_devfile_yaml).to_h } - let(:editor) { "webide" } let(:workspace_root) { "/projects" } let(:user_provided_variables) do [ @@ -217,7 +216,6 @@ def do_create_workspace(cluster_agent_id) expect(workspace.desired_state_updated_at).to eq(Time.current) expect(workspace.name).to eq("workspace-#{agent.id}-#{user.id}-#{random_string}") expect(workspace.namespace).to eq("gl-rd-ns-#{agent.id}-#{user.id}-#{random_string}") - expect(workspace.editor).to eq("webide") expect(workspace.url).to eq(URI::HTTPS.build({ host: "60001-#{workspace.name}.#{dns_zone}", query: {