diff --git a/ee/lib/remote_development/workspace_operations/reconcile/output/response_payload_builder.rb b/ee/lib/remote_development/workspace_operations/reconcile/output/response_payload_builder.rb index 339d904b1c2d6b120c9868e9e90965fcc414a397..522b1da136a332b0bd6f4126f42569d555152c67 100644 --- a/ee/lib/remote_development/workspace_operations/reconcile/output/response_payload_builder.rb +++ b/ee/lib/remote_development/workspace_operations/reconcile/output/response_payload_builder.rb @@ -84,25 +84,11 @@ def self.generate_config_to_apply(workspace:, update_type:, logger:) include_all_resources = should_include_all_resources?(update_type: update_type, workspace: workspace) resources_include_type = include_all_resources ? ALL_RESOURCES_INCLUDED : PARTIAL_RESOURCES_INCLUDED - workspace_resources = - case workspace.desired_config_generator_version - when DesiredConfigGeneratorVersion::LATEST_VERSION - DesiredConfigGenerator.generate_desired_config( - workspace: workspace, - include_all_resources: include_all_resources, - logger: logger - ) - else - namespace = "RemoteDevelopment::WorkspaceOperations::Reconcile::Output" - generator_class_name = - "#{namespace}::DesiredConfigGeneratorV#{workspace.desired_config_generator_version}" - generator_class = Object.const_get(generator_class_name, false) - generator_class.generate_desired_config( - workspace: workspace, - include_all_resources: include_all_resources, - logger: logger - ) - end + workspace_resources = DesiredConfigGenerator.generate_desired_config( + workspace: workspace, + include_all_resources: include_all_resources, + logger: logger + ) stable_sorted_workspace_resources = workspace_resources.map do |resource| Gitlab::Utils.deep_sort_hash(resource) diff --git a/ee/spec/lib/remote_development/workspace_operations/reconcile/output/response_payload_builder_spec.rb b/ee/spec/lib/remote_development/workspace_operations/reconcile/output/response_payload_builder_spec.rb index 6f5fb513a8e21b037e9e628731dc1a8921730c1f..edb91d14748c1d4f44dbdbb9a38504dcbee22c06 100644 --- a/ee/spec/lib/remote_development/workspace_operations/reconcile/output/response_payload_builder_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/reconcile/output/response_payload_builder_spec.rb @@ -222,36 +222,4 @@ end end end - - context "when workspace.desired_config_generator_version is a previous version" do - let(:previous_desired_config_generator_version) { 2 } - - let(:desired_config_generator_version) { previous_desired_config_generator_version } - let(:update_type) { update_types::FULL } - let(:desired_state_updated_more_recently_than_last_response_to_agent) { false } - let(:actual_state_updated_more_recently_than_last_response_to_agent) { false } - let(:desired_state_terminated_and_actual_state_not_terminated) { false } - let(:expected_include_all_resources) { true } - - before do - stub_const( - "RemoteDevelopment::WorkspaceOperations::Reconcile::Output::DesiredConfigGeneratorV2", - Class.new do - # @param [Object] _ - # @return [Hash] - def self.generate_desired_config(_) - {} - end - end - ) - end - - it "includes config_to_apply with all resources included" do - # noinspection RubyResolve -- This constant is stubbed - allow(RemoteDevelopment::WorkspaceOperations::Reconcile::Output::DesiredConfigGeneratorV2) - .to(receive(:generate_desired_config)) { generated_config_to_apply } - - expect(returned_value).to eq(expected_returned_value) - end - end 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 5d667ba17665aa6a8fc8e58345300a937b8ec5e6..e9a23e44b2c107cb60614924206bc979e29e0d64 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 @@ -322,20 +322,6 @@ def create_config_to_apply_yaml_stream(workspace:, **args) create_config_to_apply(workspace: workspace, **args).map { |resource| YAML.dump(resource.deep_stringify_keys) }.join end - # @param [RemoteDevelopment::Workspace] workspace - # @param [Hash] args - # @return [Array] - def create_config_to_apply(workspace:, **args) - validate_hash_is_deep_symbolized(args) - - desired_config_generator_version = workspace.desired_config_generator_version - - method_name = "create_config_to_apply_v#{desired_config_generator_version}" - # rubocop:disable GitlabSecurity/PublicSend -- We are intentionally doing this send to dynamically select the generator version method - send(method_name, workspace: workspace, **args) - # rubocop:enable GitlabSecurity/PublicSend - end - # rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/PerceivedComplexity -- Cleanup as part of https://gitlab.com/gitlab-org/gitlab/-/issues/421687 # @param [RemoteDevelopment::Workspace] workspace @@ -366,7 +352,7 @@ def create_config_to_apply(workspace:, **args) # @param [String] shared_namespace # @param [Boolean] core_resources_only # @return [Array] - def create_config_to_apply_v3( + def create_config_to_apply( workspace:, started: true, desired_state_is_terminated: false, @@ -398,6 +384,15 @@ def create_config_to_apply_v3( shared_namespace: "", core_resources_only: false ) + all_parameters = + method(__method__.to_s) + .parameters + .map(&:last) + .index_with { |name| binding.local_variable_get(name) } + .to_h + + validate_hash_is_deep_symbolized(all_parameters) + spec_replicas = started ? 1 : 0 host_template_annotation = get_workspace_host_template_annotation(workspace.name, dns_zone)