diff --git a/app/assets/javascripts/alerts_settings/components/alerts_integrations_list.vue b/app/assets/javascripts/alerts_settings/components/alerts_integrations_list.vue index 2810c9273dc..217442e6131 100644 --- a/app/assets/javascripts/alerts_settings/components/alerts_integrations_list.vue +++ b/app/assets/javascripts/alerts_settings/components/alerts_integrations_list.vue @@ -1,6 +1,8 @@ diff --git a/app/assets/javascripts/alerts_settings/components/alerts_settings_form.vue b/app/assets/javascripts/alerts_settings/components/alerts_settings_form.vue index 7036910f85f..9a746d2baa7 100644 --- a/app/assets/javascripts/alerts_settings/components/alerts_settings_form.vue +++ b/app/assets/javascripts/alerts_settings/components/alerts_settings_form.vue @@ -16,7 +16,6 @@ import { import { debounce } from 'lodash'; import { s__ } from '~/locale'; import { doesHashExistInUrl } from '~/lib/utils/url_utility'; -import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import ToggleButton from '~/vue_shared/components/toggle_button.vue'; import IntegrationsList from './alerts_integrations_list.vue'; @@ -56,7 +55,6 @@ export default { directives: { 'gl-modal': GlModalDirective, }, - mixins: [glFeatureFlagsMixin()], inject: ['prometheus', 'generic', 'opsgenie'], data() { return { diff --git a/app/assets/javascripts/alerts_settings/constants.js b/app/assets/javascripts/alerts_settings/constants.js index 3dbe692e419..5025a14fdc9 100644 --- a/app/assets/javascripts/alerts_settings/constants.js +++ b/app/assets/javascripts/alerts_settings/constants.js @@ -51,3 +51,13 @@ export const targetPrometheusUrlPlaceholder = 'http://prometheus.example.com/'; export const targetOpsgenieUrlPlaceholder = 'https://app.opsgenie.com/alert/list/'; export const sectionHash = 'js-alert-management-settings'; + +/* eslint-disable @gitlab/require-i18n-strings */ + +/** + * Tracks snowplow event when user views alerts intergration list + */ +export const trackAlertIntergrationsViewsOptions = { + category: 'Alert Intergrations', + action: 'view_alert_integrations_list', +}; diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index 14de8d6c6ab..93be0130e12 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -27,17 +27,10 @@ class HelpController < ApplicationController respond_to do |format| format.any(:markdown, :md, :html) do - # Note: We are purposefully NOT using `Rails.root.join` because of https://gitlab.com/gitlab-org/gitlab/-/issues/216028. - path = File.join(Rails.root, 'doc', "#{@path}.md") - - if File.exist?(path) - # Remove YAML frontmatter so that it doesn't look weird - @markdown = File.read(path).gsub(YAML_FRONT_MATTER_REGEXP, '') - - render 'show.html.haml' + if redirect_to_documentation_website? + redirect_to documentation_url else - # Force template to Haml - render 'errors/not_found.html.haml', layout: 'errors', status: :not_found + render_documentation end end @@ -76,4 +69,48 @@ class HelpController < ApplicationController params end + + def redirect_to_documentation_website? + return false unless Feature.enabled?(:help_page_documentation_redirect) + return false unless Gitlab::UrlSanitizer.valid_web?(documentation_url) + + true + end + + def documentation_url + return unless documentation_base_url + + @documentation_url ||= [ + documentation_base_url.chomp('/'), + version_segment, + 'ee', + "#{@path}.html" + ].compact.join('/') + end + + def documentation_base_url + @documentation_base_url ||= Gitlab::CurrentSettings.current_application_settings.help_page_documentation_base_url.presence + end + + def version_segment + return if Gitlab.pre_release? + + version = Gitlab.version_info + [version.major, version.minor].join('.') + end + + def render_documentation + # Note: We are purposefully NOT using `Rails.root.join` because of https://gitlab.com/gitlab-org/gitlab/-/issues/216028. + path = File.join(Rails.root, 'doc', "#{@path}.md") + + if File.exist?(path) + # Remove YAML frontmatter so that it doesn't look weird + @markdown = File.read(path).gsub(YAML_FRONT_MATTER_REGEXP, '') + + render 'show.html.haml' + else + # Force template to Haml + render 'errors/not_found.html.haml', layout: 'errors', status: :not_found + end + end end diff --git a/app/models/ci_platform_metric.rb b/app/models/ci_platform_metric.rb index 5e6e3eddce9..ac4ab391bbf 100644 --- a/app/models/ci_platform_metric.rb +++ b/app/models/ci_platform_metric.rb @@ -14,7 +14,7 @@ class CiPlatformMetric < ApplicationRecord numericality: { only_integer: true, greater_than: 0 } CI_VARIABLE_KEY = 'AUTO_DEVOPS_PLATFORM_TARGET' - ALLOWED_TARGETS = %w[ECS FARGATE].freeze + ALLOWED_TARGETS = %w[ECS FARGATE EC2].freeze def self.insert_auto_devops_platform_targets! recorded_at = Time.zone.now diff --git a/changelogs/unreleased/247449_auto-purchased-storage-allocation.yml b/changelogs/unreleased/247449_auto-purchased-storage-allocation.yml new file mode 100644 index 00000000000..5c87ea2fb22 --- /dev/null +++ b/changelogs/unreleased/247449_auto-purchased-storage-allocation.yml @@ -0,0 +1,5 @@ +--- +title: Enable automatic allocation of purchased storage +merge_request: 44376 +author: +type: changed diff --git a/changelogs/unreleased/32328_use_documentation_url_to_configure_path_to_help_pages.yml b/changelogs/unreleased/32328_use_documentation_url_to_configure_path_to_help_pages.yml new file mode 100644 index 00000000000..0ddf35eebb5 --- /dev/null +++ b/changelogs/unreleased/32328_use_documentation_url_to_configure_path_to_help_pages.yml @@ -0,0 +1,5 @@ +--- +title: Redirect to documentation pages URL when configuration option is set +merge_request: 43157 +author: +type: added diff --git a/changelogs/unreleased/patch-migration.yml b/changelogs/unreleased/patch-migration.yml new file mode 100644 index 00000000000..6335c041a5a --- /dev/null +++ b/changelogs/unreleased/patch-migration.yml @@ -0,0 +1,5 @@ +--- +title: Fix rollback portion of migration that adds temporary index for container scanning findings +merge_request: 44593 +author: +type: fixed diff --git a/db/migrate/20200820105408_add_index_to_container_scanning_findings.rb b/db/migrate/20200820105408_add_index_to_container_scanning_findings.rb index 834e11e3d6e..dd474b57602 100644 --- a/db/migrate/20200820105408_add_index_to_container_scanning_findings.rb +++ b/db/migrate/20200820105408_add_index_to_container_scanning_findings.rb @@ -15,6 +15,6 @@ class AddIndexToContainerScanningFindings < ActiveRecord::Migration[6.0] end def down - remove_concurrent_index_by_name(:project_registry, INDEX_NAME) + remove_concurrent_index_by_name(:vulnerability_occurrences, INDEX_NAME) end end diff --git a/db/migrate/20201006014605_add_automatic_purchased_storage_allocation_to_application_settings.rb b/db/migrate/20201006014605_add_automatic_purchased_storage_allocation_to_application_settings.rb new file mode 100644 index 00000000000..f88bd177b98 --- /dev/null +++ b/db/migrate/20201006014605_add_automatic_purchased_storage_allocation_to_application_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddAutomaticPurchasedStorageAllocationToApplicationSettings < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :application_settings, :automatic_purchased_storage_allocation, :boolean, default: false, null: false + end +end diff --git a/db/schema_migrations/20201006014605 b/db/schema_migrations/20201006014605 new file mode 100644 index 00000000000..92209fcd127 --- /dev/null +++ b/db/schema_migrations/20201006014605 @@ -0,0 +1 @@ +d1a636c0b0c7f11bf5d6e882970a5286a28c3f060f89df3ac51df2e7c86f042e \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 254cf40cf26..fe9e0477002 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -9293,6 +9293,7 @@ CREATE TABLE application_settings ( abuse_notification_email character varying, require_admin_approval_after_user_signup boolean DEFAULT false NOT NULL, help_page_documentation_base_url text, + automatic_purchased_storage_allocation boolean DEFAULT false NOT NULL, CONSTRAINT check_2dba05b802 CHECK ((char_length(gitpod_url) <= 255)), CONSTRAINT check_51700b31b5 CHECK ((char_length(default_branch_name) <= 255)), CONSTRAINT check_57123c9593 CHECK ((char_length(help_page_documentation_base_url) <= 255)), diff --git a/doc/administration/gitaly/index.md b/doc/administration/gitaly/index.md index 7178db3be6d..aed8a0d0a7f 100644 --- a/doc/administration/gitaly/index.md +++ b/doc/administration/gitaly/index.md @@ -406,8 +406,8 @@ server (with `gitaly_address`) unless you setup with special ``` 1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure). -1. Run `sudo gitlab-rake gitlab:gitaly:check` to confirm the Gitaly client can connect to Gitaly - servers. +1. Run `sudo gitlab-rake gitlab:gitaly:check` on the Gitaly client (for example, the + Rails application) to confirm it can connect to Gitaly servers. 1. Tail the logs to see the requests: ```shell diff --git a/doc/administration/gitaly/praefect.md b/doc/administration/gitaly/praefect.md index 7361579c280..d091ae5895a 100644 --- a/doc/administration/gitaly/praefect.md +++ b/doc/administration/gitaly/praefect.md @@ -182,7 +182,7 @@ failure. For greater fault tolerance, the following options are available: - For Geo instances, either: - Set up a separate [PostgreSQL instance](https://www.postgresql.org/docs/11/high-availability.html). - Use a cloud-managed PostgreSQL service. AWS - [Relational Database Service](https://aws.amazon.com/rds/)) is recommended. + [Relational Database Service](https://aws.amazon.com/rds/) is recommended. To complete this section you will need: diff --git a/doc/api/settings.md b/doc/api/settings.md index deff2535f9c..3fc0aaf4125 100644 --- a/doc/api/settings.md +++ b/doc/api/settings.md @@ -209,6 +209,7 @@ listed in the descriptions of the relevant settings. | `authorized_keys_enabled` | boolean | no | By default, we write to the `authorized_keys` file to support Git over SSH without additional configuration. GitLab can be optimized to authenticate SSH keys via the database file. Only disable this if you have configured your OpenSSH server to use the AuthorizedKeysCommand. | | `auto_devops_domain` | string | no | Specify a domain to use by default for every project's Auto Review Apps and Auto Deploy stages. | | `auto_devops_enabled` | boolean | no | Enable Auto DevOps for projects by default. It will automatically build, test, and deploy applications based on a predefined CI/CD configuration. | +| `automatic_purchased_storage_allocation` | boolean | no | Enabling this permits automatic allocation of purchased storage within a namespace. | | `check_namespace_plan` | boolean | no | **(PREMIUM)** Enabling this will make only licensed EE features available to projects if the project namespace's plan includes the feature or if the project is public. | | `commit_email_hostname` | string | no | Custom hostname (for private commit emails). | | `container_registry_token_expire_delay` | integer | no | Container Registry token duration in minutes. | diff --git a/lib/gitlab/ci/templates/AWS/CF-Provision-and-Deploy-EC2.gitlab-ci.yml b/lib/gitlab/ci/templates/AWS/CF-Provision-and-Deploy-EC2.gitlab-ci.yml new file mode 100644 index 00000000000..267027a1b8a --- /dev/null +++ b/lib/gitlab/ci/templates/AWS/CF-Provision-and-Deploy-EC2.gitlab-ci.yml @@ -0,0 +1,11 @@ +stages: + - provision + - review + - production + +variables: + AUTO_DEVOPS_PLATFORM_TARGET: EC2 + +include: + - template: Jobs/CF-Provision.gitlab-ci.yml + - template: Jobs/Deploy/EC2.gitlab-ci.yml diff --git a/lib/gitlab/ci/templates/Jobs/CF-Provision.gitlab-ci.yml b/lib/gitlab/ci/templates/Jobs/CF-Provision.gitlab-ci.yml new file mode 100644 index 00000000000..31ca68c57d7 --- /dev/null +++ b/lib/gitlab/ci/templates/Jobs/CF-Provision.gitlab-ci.yml @@ -0,0 +1,14 @@ +stages: + - provision + +cloud_formation: + image: 'registry.gitlab.com/gitlab-org/cloud-deploy/aws-cloudformation:latest' + stage: provision + script: + - gl-cloudformation create-stack + rules: + - if: '($AUTO_DEVOPS_PLATFORM_TARGET != "EC2") || ($AUTO_DEVOPS_PLATFORM_TARGET != "ECS")' + when: never + - if: '$CI_KUBERNETES_ACTIVE' + when: never + - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' diff --git a/lib/gitlab/ci/templates/Jobs/Deploy/EC2.gitlab-ci.yml b/lib/gitlab/ci/templates/Jobs/Deploy/EC2.gitlab-ci.yml new file mode 100644 index 00000000000..ed2172ef7f5 --- /dev/null +++ b/lib/gitlab/ci/templates/Jobs/Deploy/EC2.gitlab-ci.yml @@ -0,0 +1,39 @@ +stages: + - review + - production + +.push-and-deploy: + image: 'registry.gitlab.com/gitlab-org/cloud-deploy/aws-ec2:latest' + script: + - gl-ec2 push-to-s3 + - gl-ec2 deploy-to-ec2 + +review_ec2: + extends: .push-and-deploy + stage: review + environment: + name: review/$CI_COMMIT_REF_NAME + rules: + - if: '$AUTO_DEVOPS_PLATFORM_TARGET != "EC2"' + when: never + - if: '$CI_KUBERNETES_ACTIVE' + when: never + - if: '$REVIEW_DISABLED' + when: never + - if: '$CI_COMMIT_BRANCH == "master"' + when: never + - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' + +production_ec2: + extends: .push-and-deploy + stage: production + environment: + name: production + rules: + - if: '$AUTO_DEVOPS_PLATFORM_TARGET != "EC2"' + when: never + - if: '$CI_KUBERNETES_ACTIVE' + when: never + - if: '$CI_COMMIT_BRANCH != "master"' + when: never + - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb index 3049396dd0f..9ac42cbc3ec 100644 --- a/spec/controllers/help_controller_spec.rb +++ b/spec/controllers/help_controller_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe HelpController do + include StubVersion + let(:user) { create(:user) } before do @@ -108,8 +110,56 @@ RSpec.describe HelpController do end it 'renders HTML' do - expect(response).to render_template('show.html.haml') - expect(response.media_type).to eq 'text/html' + aggregate_failures do + expect(response).to render_template('show.html.haml') + expect(response.media_type).to eq 'text/html' + end + end + end + + context 'when a custom help_page_documentation_url is set' do + before do + stub_application_setting(help_page_documentation_base_url: documentation_base_url) + stub_version(gitlab_version, 'deadbeaf') + end + + subject { get :show, params: { path: path }, format: 'html' } + + let(:gitlab_version) { '13.4.0-ee' } + let(:documentation_base_url) { 'https://docs.gitlab.com' } + let(:path) { 'ssh/README' } + + it 'redirects user to custom documentation url with a specified version' do + is_expected.to redirect_to("#{documentation_base_url}/13.4/ee/#{path}.html") + end + + context 'when documentation url ends with a slash' do + let(:documentation_base_url) { 'https://docs.gitlab.com/' } + + it 'redirects user to custom documentation url without slash duplicates' do + is_expected.to redirect_to("https://docs.gitlab.com/13.4/ee/#{path}.html") + end + end + + context 'when it is a pre-release' do + let(:gitlab_version) { '13.4.0-pre' } + + it 'redirects user to custom documentation url without a version' do + is_expected.to redirect_to("#{documentation_base_url}/ee/#{path}.html") + end + end + + context 'when feature flag is disabled' do + before do + stub_feature_flags(help_page_documentation_redirect: false) + end + + it 'renders HTML' do + aggregate_failures do + is_expected.to render_template('show.html.haml') + expect(response.media_type).to eq 'text/html' + end + end end end @@ -129,9 +179,12 @@ RSpec.describe HelpController do path: 'user/img/markdown_logo' }, format: :png - expect(response).to be_successful - expect(response.media_type).to eq 'image/png' - expect(response.headers['Content-Disposition']).to match(/^inline;/) + + aggregate_failures do + expect(response).to be_successful + expect(response.media_type).to eq 'image/png' + expect(response.headers['Content-Disposition']).to match(/^inline;/) + end end end diff --git a/spec/frontend/alert_settings/alerts_integrations_list_spec.js b/spec/frontend/alert_settings/alerts_integrations_list_spec.js index b7a388300e9..6fc9901db2a 100644 --- a/spec/frontend/alert_settings/alerts_integrations_list_spec.js +++ b/spec/frontend/alert_settings/alerts_integrations_list_spec.js @@ -1,8 +1,10 @@ import { GlTable, GlIcon } from '@gitlab/ui'; import { mount } from '@vue/test-utils'; +import Tracking from '~/tracking'; import AlertIntegrationsList, { i18n, } from '~/alerts_settings/components/alerts_integrations_list.vue'; +import { trackAlertIntergrationsViewsOptions } from '~/alerts_settings/constants'; const mockIntegrations = [ { @@ -72,4 +74,16 @@ describe('AlertIntegrationsList', () => { expect(notActivatedIcon.attributes('title')).toBe(i18n.status.disabled.tooltip); }); }); + + describe('Snowplow tracking', () => { + beforeEach(() => { + jest.spyOn(Tracking, 'event'); + mountComponent(); + }); + + it('should track alert list page views', () => { + const { category, action } = trackAlertIntergrationsViewsOptions; + expect(Tracking.event).toHaveBeenCalledWith(category, action); + }); + }); });