Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2020-05-25 06:08:38 +00:00
parent 6c577c9ada
commit 0ebaa8a2fd
42 changed files with 211 additions and 189 deletions

View File

@ -147,7 +147,7 @@ export default {
<template>
<div>
<div class="d-flex board-card-header" dir="auto">
<h4 class="board-card-title append-bottom-0 gl-mt-0">
<h4 class="board-card-title gl-mb-0 gl-mt-0">
<icon
v-if="issue.blocked"
v-gl-tooltip

View File

@ -249,7 +249,7 @@ export default {
<gl-link href="/help/ci/variables/README#masked-variables">
<gl-icon name="question" :size="12" />
</gl-link>
<p class="prepend-top-4 append-bottom-0 text-secondary">
<p class="prepend-top-4 gl-mb-0 text-secondary">
{{ __('Variable will be masked in job logs.') }}
<span
:class="{

View File

@ -322,7 +322,7 @@ export default {
></span>
<slot name="description"></slot>
<div v-if="hasError" class="cluster-application-error text-danger prepend-top-10">
<p class="js-cluster-application-general-error-message append-bottom-0">
<p class="js-cluster-application-general-error-message gl-mb-0">
{{ generalErrorDescription }}
</p>
<ul v-if="statusReason || requestReason">

View File

@ -272,7 +272,7 @@ Crossplane runs inside your Kubernetes cluster and supports secure connectivity
<template>
<section id="cluster-applications">
<p class="append-bottom-0">
<p class="gl-mb-0">
{{
s__(`ClusterIntegration|Choose which applications to install on your Kubernetes cluster.
Helm Tiller is required to install any of the following applications.`)
@ -614,7 +614,7 @@ Crossplane runs inside your Kubernetes cluster and supports secure connectivity
>
<div slot="description">
<span v-if="!rbac">
<p v-if="!rbac" class="rbac-notice bs-callout bs-callout-info append-bottom-0">
<p v-if="!rbac" class="rbac-notice bs-callout bs-callout-info gl-mb-0">
{{
s__(`ClusterIntegration|You must have an RBAC-enabled cluster
to install Knative.`)

View File

@ -98,7 +98,7 @@ export default {
</div>
</div>
</header>
<ul v-if="filesLength" class="multi-file-commit-list list-unstyled append-bottom-0">
<ul v-if="filesLength" class="multi-file-commit-list list-unstyled gl-mb-0">
<li v-for="file in fileList" :key="file.key">
<list-item
:file="file"

View File

@ -82,9 +82,9 @@ export default {
class="mb-auto mt-auto"
/>
<div v-else-if="latestPipeline.yamlError" class="bs-callout bs-callout-danger">
<p class="append-bottom-0">{{ __('Found errors in your .gitlab-ci.yml:') }}</p>
<p class="append-bottom-0 break-word">{{ latestPipeline.yamlError }}</p>
<p class="append-bottom-0" v-html="ciLintText"></p>
<p class="gl-mb-0">{{ __('Found errors in your .gitlab-ci.yml:') }}</p>
<p class="gl-mb-0 break-word">{{ latestPipeline.yamlError }}</p>
<p class="gl-mb-0" v-html="ciLintText"></p>
</div>
<tabs v-else class="ide-pipeline-list">
<tab :active="!pipelineFailed">

View File

@ -49,7 +49,7 @@ export default {
<template>
<div class="multi-file-tabs">
<ul ref="tabsScroller" class="list-unstyled append-bottom-0">
<ul ref="tabsScroller" class="list-unstyled gl-mb-0">
<repo-tab v-for="tab in files" :key="tab.key" :tab="tab" />
</ul>
</div>

View File

@ -53,6 +53,6 @@ export default {
</span>
</p>
<p class="append-bottom-0">{{ commit.title }}</p>
<p class="gl-mb-0">{{ commit.title }}</p>
</div>
</template>

View File

@ -277,7 +277,7 @@ export default {
<div class="prepend-top-default append-bottom-default js-environment-container">
<div class="environment-information">
<ci-icon :status="iconStatus" />
<p class="inline append-bottom-0" v-html="environment"></p>
<p class="inline gl-mb-0" v-html="environment"></p>
</div>
</div>
</template>

View File

@ -26,7 +26,7 @@ export default {
</script>
<template>
<div class="bs-callout bs-callout-warning">
<p v-if="tags.length" class="js-stuck-with-tags append-bottom-0">
<p v-if="tags.length" class="js-stuck-with-tags gl-mb-0">
{{
s__(`This job is stuck because you don't have
any active runners online with any of these tags assigned to them:`)
@ -35,13 +35,13 @@ export default {
{{ tag }}
</span>
</p>
<p v-else-if="hasNoRunnersForProject" class="js-stuck-no-runners append-bottom-0">
<p v-else-if="hasNoRunnersForProject" class="js-stuck-no-runners gl-mb-0">
{{
s__(`Job|This job is stuck because the project
doesn't have any runners online assigned to it.`)
}}
</p>
<p v-else class="js-stuck-no-active-runner append-bottom-0">
<p v-else class="js-stuck-no-active-runner gl-mb-0">
{{
s__(`This job is stuck because you don't
have any active runners that can run this job.`)

View File

@ -46,7 +46,7 @@ export default {
<p
v-if="trigger.short_token"
class="js-short-token"
:class="{ 'append-bottom-5': hasVariables, 'append-bottom-0': !hasVariables }"
:class="{ 'append-bottom-5': hasVariables, 'gl-mb-0': !hasVariables }"
>
<span class="font-weight-bold">{{ __('Trigger token:') }}</span> {{ trigger.short_token }}
</p>

View File

@ -17,7 +17,7 @@ export default {
</script>
<template>
<div class="bs-callout bs-callout-danger">
<p class="js-failed-unmet-prerequisites append-bottom-0">
<p class="js-failed-unmet-prerequisites gl-mb-0">
{{
s__(`Job|This job failed because the necessary resources were not successfully created.`)
}}

View File

@ -75,11 +75,11 @@ export default {
rel="noopener noreferrer nofollow"
class="js-deploy-url-menu-item menu-item"
>
<strong class="str-truncated-100 append-bottom-0 d-block">
<strong class="str-truncated-100 gl-mb-0 d-block">
{{ slotProps.result.path }}
</strong>
<p class="text-secondary str-truncated-100 append-bottom-0 d-block">
<p class="text-secondary str-truncated-100 gl-mb-0 d-block">
{{ slotProps.result.external_url }}
</p>
</gl-link>

View File

@ -14,7 +14,7 @@ export default {
</script>
<template>
<p v-once class="mr-info-list mr-links append-bottom-0">
<p v-once class="mr-info-list mr-links gl-mb-0">
<span class="status-text" v-html="removesBranchText"> </span>
<i v-tooltip :title="tooltipTitle" :aria-label="tooltipTitle" class="fa fa-question-circle">
</i>

View File

@ -426,7 +426,6 @@ img.emoji {
.append-right-32 { margin-right: 32px; }
.append-right-48 { margin-right: 48px; }
.prepend-right-32 { margin-right: 32px; }
.append-bottom-0 { margin-bottom: 0; }
.append-bottom-2 { margin-bottom: 2px; }
.append-bottom-4 { margin-bottom: $gl-padding-4; }
.append-bottom-5 { margin-bottom: 5px; }

View File

@ -33,7 +33,7 @@ class SearchController < ApplicationController
render_commits if @scope == 'commits'
eager_load_user_status if @scope == 'users'
increment_navbar_searches_counter
increment_search_counters
check_single_commit_result
end
@ -98,9 +98,11 @@ class SearchController < ApplicationController
end
end
def increment_navbar_searches_counter
def increment_search_counters
Gitlab::UsageDataCounters::SearchCounter.count(:all_searches)
return if params[:nav_source] != 'navbar'
Gitlab::UsageDataCounters::SearchCounter.increment_navbar_searches_count
Gitlab::UsageDataCounters::SearchCounter.count(:navbar_searches)
end
end

View File

@ -4,7 +4,7 @@
.d-flex.align-items-center
%h4.pr-2.m-0
= s_('ClusterIntegration|GitLab Integration')
%label.append-bottom-0.js-cluster-enable-toggle-area{ title: s_('ClusterIntegration|Enable or disable GitLab\'s connection to your Kubernetes cluster.'), data: { toggle: 'tooltip', container: 'body' } }
%label.gl-mb-0.js-cluster-enable-toggle-area{ title: s_('ClusterIntegration|Enable or disable GitLab\'s connection to your Kubernetes cluster.'), data: { toggle: 'tooltip', container: 'body' } }
= render "shared/buttons/project_feature_toggle", is_checked: @cluster.enabled?, label: s_("ClusterIntegration|Toggle Kubernetes cluster"), disabled: !can?(current_user, :update_cluster, @cluster), data: { qa_selector: 'integration_status_toggle' } do
= field.hidden_field :enabled, { class: 'js-project-feature-toggle-input'}

View File

@ -7,7 +7,7 @@
%p= _('Export this group with all related data to a new GitLab instance. Once complete, you can import the data file from the "New Group" page.')
.bs-callout.bs-callout-info
%p.append-bottom-0
%p.gl-mb-0
%p= _('The following items will be exported:')
%ul
- group_export_descriptions.each do |description|

View File

@ -33,13 +33,13 @@
= raw @qr_code
.col-md-8
.account-well
%p.gl-mt-0.append-bottom-0
%p.gl-mt-0.gl-mb-0
= _("Can't scan the code?")
%p.gl-mt-0.append-bottom-0
%p.gl-mt-0.gl-mb-0
= _('To add the entry manually, provide the following details to the application on your phone.')
%p.gl-mt-0.append-bottom-0
%p.gl-mt-0.gl-mb-0
= _('Account: %{account}') % { account: @account_string }
%p.gl-mt-0.append-bottom-0
%p.gl-mt-0.gl-mb-0
= _('Key: %{key}') %{ key: current_user.otp_secret.scan(/.{4}/).join(' ') }
%p.two-factor-new-manual-content
= _('Time based: Yes')

View File

@ -7,7 +7,7 @@
%p= _('Export this project with all its related data in order to move your project to a new GitLab instance. Once the export is finished, you can import the file from the "New Project" page.')
.bs-callout.bs-callout-info
%p.append-bottom-0
%p.gl-mb-0
%p= _('The following items will be exported:')
%ul
- project_export_descriptions.each do |desc|

View File

@ -10,7 +10,7 @@
= _('The repository for this project is empty')
- if @project.can_current_user_push_code?
%p.append-bottom-0
%p.gl-mb-0
= _('You can get started by cloning the repository or start adding files to it with one of the following options.')
.project-buttons.qa-quick-actions

View File

@ -9,7 +9,7 @@
.col-lg-9
- if @namespaces.present?
.fork-thumbnail-container.js-fork-content
%h5.gl-mt-0.append-bottom-0.prepend-left-default.append-right-default
%h5.gl-mt-0.gl-mb-0.prepend-left-default.append-right-default
= _("Select a namespace to fork the project")
- @namespaces.each do |namespace|
= render 'fork_button', namespace: namespace

View File

@ -11,7 +11,7 @@
.controls.d-flex.align-items-center
%a.btn.btn-default.append-right-10{ href: template.preview, rel: 'noopener noreferrer', target: '_blank', data: { track_label: "template_preview", track_property: template.name, track_event: "click_button", track_value: "" } }
= _("Preview")
%label.btn.btn-success.template-button.choose-template.append-bottom-0{ for: template.name }
%label.btn.btn-success.template-button.choose-template.gl-mb-0{ for: template.name }
%input{ type: "radio", autocomplete: "off", name: "project[template_name]", id: template.name, value: template.name, data: { track_label: "template_use", track_property: template.name, track_event: "click_button", track_value: "" } }
%span{ data: { qa_selector: 'use_template_button' } }
= _("Use template")

View File

@ -14,7 +14,7 @@
= link_to _('Submit as spam'), mark_as_spam_project_snippet_path(@project, @snippet), method: :post, class: 'btn btn-grouped btn-spam', title: _('Submit as spam')
- if can?(current_user, :create_snippet, @project) || can?(current_user, :update_snippet, @snippet)
.d-block.d-sm-none.dropdown
%button.btn.btn-default.btn-block.append-bottom-0.prepend-top-5{ data: { toggle: "dropdown" } }
%button.btn.btn-default.btn-block.gl-mb-0.prepend-top-5{ data: { toggle: "dropdown" } }
= _('Options')
= icon('caret-down')
.dropdown-menu.dropdown-menu-full-width

View File

@ -96,6 +96,6 @@
%p.light
With webhook:
%pre.append-bottom-0
%pre.gl-mb-0
:plain
#{builds_trigger_url(@project.id, ref: 'REF_NAME')}?token=TOKEN&variables[RUN_NIGHTLY_BUILD]=true

View File

@ -2,7 +2,7 @@
.form-group.visibility-level-setting
- if with_label
= f.label :visibility_level, _('Visibility level'), class: 'label-bold append-bottom-0'
= f.label :visibility_level, _('Visibility level'), class: 'label-bold gl-mb-0'
%p
= _('Who can see this group?')
- visibility_docs_path = help_page_path('public_access/public_access')

View File

@ -30,5 +30,5 @@
= deploy_keys_project_form.label :can_push do
= deploy_keys_project_form.check_box :can_push
%strong= _('Write access allowed')
%p.light.append-bottom-0
%p.light.gl-mb-0
= _('Allow this key to push to repository as well? (Default only allows pull access.)')

View File

@ -7,7 +7,7 @@
= f.label :key, class: "label-bold"
= f.text_area :key, class: "form-control", rows: 5, required: true
.form-group.row
%p.light.append-bottom-0
%p.light.gl-mb-0
= _('Paste a machine public key here. Read more about how to generate it')
= link_to "here", help_page_path("ssh/README")
@ -17,7 +17,7 @@
= deploy_keys_project_form.check_box :can_push
%strong= _('Write access allowed')
.form-group.row
%p.light.append-bottom-0
%p.light.gl-mb-0
= _('Allow this key to push to repository as well? (Default only allows pull access.)')
.form-group.row

View File

@ -8,7 +8,7 @@
%template.js-milestone-deprecation-message-template
.milestone-popover-body
%ol.milestone-popover-instructions-list.append-bottom-0
%ol.milestone-popover-instructions-list.gl-mb-0
%li= _('Click any <strong>project name</strong> in the project list below to navigate to the project milestone.').html_safe
%li= _('Click the <strong>Promote</strong> button in the top right corner to promote it to a group milestone.').html_safe
%hr.popover-hr

View File

@ -6,7 +6,7 @@
%td
= _('Scopes')
%td
%ul.scopes-list.append-bottom-0
%ul.scopes-list.gl-mb-0
- token.scopes.each do |scope|
%li
%span.bold= scope

View File

@ -13,7 +13,7 @@
- if @snippet.submittable_as_spam_by?(current_user)
= link_to _('Submit as spam'), mark_as_spam_snippet_path(@snippet), method: :post, class: 'btn btn-grouped btn-spam', title: _('Submit as spam')
.d-block.d-sm-none.dropdown
%button.btn.btn-default.btn-block.append-bottom-0.prepend-top-5{ data: { toggle: "dropdown" } }
%button.btn.btn-default.btn-block.gl-mb-0.prepend-top-5{ data: { toggle: "dropdown" } }
= _("Options")
= icon('caret-down')
.dropdown-menu.dropdown-menu-full-width

View File

@ -0,0 +1,5 @@
---
title: Add Usage Ping count for all searches
merge_request: 32111
author:
type: changed

View File

@ -394,7 +394,7 @@ Once you set them, they will be available for all subsequent pipelines. Any grou
![CI/CD settings - inherited variables](img/inherited_group_variables_v12_5.png)
### Inherit environment variables
## Inherit environment variables
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/22638) in GitLab 13.0.
> - It's deployed behind a feature flag (`ci_dependency_variables`), disabled by default.

View File

@ -3525,8 +3525,8 @@ You can set them globally or per-job in the [`variables`](#variables) section.
> Introduced in GitLab 8.9 as an experimental feature.
CAUTION: **Caution:**
May change in future releases or be removed completely.
NOTE: **Note**:
As of GitLab 12.0, newly created projects will automatically have a [default `git depth` value of `50`](../pipelines/settings.md#git-shallow-clone).
You can specify the depth of fetching and cloning using `GIT_DEPTH`. This allows
shallow cloning of the repository which can significantly speed up cloning for
@ -3833,6 +3833,7 @@ the use of the `SAMPLE_VARIABLE` variable:
# global variables
variables: &global-variables
SAMPLE_VARIABLE: sample_variable_value
ANOTHER_SAMPLE_VARIABLE: another_sample_variable_value
# a job that needs to set the GIT_STRATEGY variable, yet depend on global variables
job_no_git_strategy:
@ -3856,7 +3857,7 @@ lines where the job is defined:
# - run test
```
you can instead start its name with a dot (`.`) and it won't be processed by
You can instead start its name with a dot (`.`) and it won't be processed by
GitLab CI/CD. In the following example, `.hidden_job` will be ignored:
```yaml

View File

@ -8,100 +8,73 @@ info: To determine the technical writer assigned to the Stage/Group associated w
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/7433) in GitLab 11.4.
Feature flags allow you to ship a project in different flavors by
dynamically toggling certain functionality.
With Feature Flags, you can deploy your application's new features to production in smaller batches.
You can toggle a feature on and off to subsets of users, helping you achieve Continuous Delivery.
Feature flags help reduce risk, allowing you to do controlled testing, and separate feature
delivery from customer launch.
## Overview
Feature Flags offer a feature toggle system for your application. They enable teams
to achieve Continuous Delivery by deploying new features to production at smaller
batches for controlled testing, separating feature delivery from customer launch.
This helps reducing risk and allows you to easily manage which features to enable.
GitLab offers a Feature Flags interface that allows you to create, toggle and
remove feature flags.
<div class="video-fallback">
<a href="https://www.youtube.com/watch?v=5tw2p6lwXxo">Watch</a> a use case between Feature Flags and Sentry Error Tracking
</div>
<figure class="video-container">
<iframe src="https://www.youtube.com/embed/5tw2p6lwXxo" frameborder="0" allowfullscreen="true"> </iframe>
</figure>
<i class="fa fa-youtube-play youtube" aria-hidden="true"></i>
For an example of feature flags in action, see [GitLab for Deploys, Feature Flags, and Error Tracking](https://www.youtube.com/embed/5tw2p6lwXxo).
## How it works
Underneath, GitLab uses [unleash](https://github.com/Unleash/unleash), a feature
toggle service. GitLab provides an API where your application can talk to and get the
list of feature flags you set in GitLab.
GitLab uses [Unleash](https://github.com/Unleash/unleash), a feature
toggle service.
The application must be configured to talk to GitLab, so that's up to the
developers to use a compatible [client library](#client-libraries) and
integrate it in their app.
By enabling or disabling a flag in GitLab, your application
can determine which features to enable or disable.
By setting a flag active or inactive via GitLab, your application will automatically
know which features to enable or disable respectively.
You can create feature flags in GitLab and use the API from your application
to get the list of feature flags and their statuses. The application must be configured to communicate
with GitLab, so it's up to developers to use a compatible client library and
[integrate the feature flags in your app](#integrate-feature-flags-with-your-application).
## Adding a new feature flag
## Create a feature flag
To add a new feature flag:
To create and enable a feature flag:
1. Navigate to your project's **Operations > Feature Flags**.
1. Click on the **New Feature Flag** button.
1. Give it a name.
NOTE: **Note:**
A name can contain only lowercase letters, digits, underscores (`_`)
and dashes (`-`), must start with a letter, and cannot end with a dash (`-`)
or an underscore (`_`).
1. Give it a description (optional, 255 characters max).
1. Define environment [specs](#define-environment-specs). If you want the flag on by default, enable the catch-all [wildcard spec (`*`)](#define-environment-specs)
1. Click the **New feature flag** button.
1. Enter a name that starts with a letter and contains only lowercase letters, digits, underscores (`_`)
and dashes (`-`), and does not end with a dash (`-`) or underscore (`_`).
1. Enter a description (optional, 255 characters max).
1. Enter details about how the flag should be applied:
- In GitLab 13.0 and earlier: Enter an environment spec,
enable or disable the flag in this environment, and select a rollout strategy.
- In GitLab 13.1 and later (when [this feature flag](#feature-flag-behavior-change-in-130) is enabled): Select a strategy and then
the environments to apply the strategy to.
1. Click **Create feature flag**.
Once a feature flag is created, the list of existing feature flags will be presented
with ability to edit or remove them.
The feature flag is displayed in the list. It is enabled by default.
To make a feature flag active or inactive, click the pencil icon to edit it,
and toggle the status for each [spec](#define-environment-specs).
## Disable a feature flag for a specific environment
The toggles next to each feature flag on the list page function as global shutoff switches.
If a toggle is off, that feature flag is disabled for every environment.
![Feature flags list](img/feature_flags_list_v12_7.png)
## Define environment specs
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/8621) in GitLab 11.8.
In general, an application is deployed to multiple environments, such as
production, staging and [review apps](../../../ci/review_apps/index.md).
For example, you may not want to enable a feature flag on production until your QA team has
first confirmed that the feature is working correctly on testing environments.
To handle these situations, you can enable a feature flag on a particular environment
with [Environment specs](../../../ci/environments/index.md#scoping-environments-with-specs).
You can define multiple specs per flag so that you can control your feature flag more granularly.
To define specs for each environment:
In [GitLab 13.0 and earlier](https://gitlab.com/gitlab-org/gitlab/-/issues/8621),
to disable a feature flag for a specific environment:
1. Navigate to your project's **Operations > Feature Flags**.
1. Click on the **New Feature Flag** button or edit an existing flag.
1. Set the status of the default [spec](../../../ci/environments/index.md#scoping-environments-with-specs) (`*`). Choose a rollout strategy. This status and rollout strategy combination will be used for _all_ environments.
1. If you want to enable/disable the feature on a specific environment, create a new [spec](../../../ci/environments/index.md#scoping-environments-with-specs) and type the environment name.
1. Set the status and rollout strategy of the additional spec. This status and rollout strategy combination takes precedence over the default spec since we always use the most specific match available.
1. Click **Create feature flag** or **Update feature flag**.
1. For the feature flag you want to disable, click the Pencil icon.
1. To disable the flag:
- In GitLab 13.0 and earlier: Slide the Status toggle for the environment. Or, to delete the
environment spec, on the right, click the **Remove (X)** icon.
- In GitLab 13.1 and later (when [this feature flag](#feature-flag-behavior-change-in-130) is
enabled): For each strategy it applies to, under **Environments**, delete the environment.
1. Click **Save changes**.
![Feature flag specs list](img/specs_list_v12_6.png)
## Disable a feature flag for all environments
NOTE: **NOTE**
We'd highly recommend you to use the [Environment](../../../ci/environments/index.md)
feature in order to quickly assess which flag is enabled per environment.
To disable a feature flag for all environments:
1. Navigate to your project's **Operations > Feature Flags**.
1. For the feature flag you want to disable, slide the Status toggle to **Disabled**.
The feature flag is displayed on the **Disabled** tab.
## Feature flag behavior change in 13.0
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/35555) in GitLab 13.0.
Starting in GitLab 13.0, you can apply a feature flag strategy across multiple environment specs,
Starting in GitLab 13.0, you can apply a feature flag strategy across multiple environments,
without defining the strategy multiple times.
This feature is under development and not ready for production use. It is
@ -121,21 +94,10 @@ To disable it:
Feature.disable(:feature_flags_new_version)
```
### Applying a strategy to environments
## Feature flag strategies
After a strategy is defined, it applies to **All Environments** by default. To
make a strategy apply to a specific environment spec:
1. Click the **Add Environment** button.
1. Create a new
[spec](../../../ci/environments/index.md#scoping-environments-with-specs).
To apply the strategy to multiple environment specs, repeat these steps.
## Feature Flag strategies
GitLab Feature Flag adopts [Unleash](https://unleash.github.io)
as the feature flag engine. In unleash, there is a concept of rulesets for granular feature flag controls,
GitLab Feature Flag uses [Unleash](https://unleash.github.io)
as the feature flag engine. In Unleash, there is a concept of rulesets for granular feature flag controls,
called [strategies](https://unleash.github.io/docs/activation_strategy).
Supported strategies for GitLab Feature Flags are described below.
@ -143,7 +105,7 @@ Supported strategies for GitLab Feature Flags are described below.
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/8240) in GitLab 12.2.
The selected rollout strategy affects which users will experience the feature enabled.
The selected rollout strategy affects which users will experience the feature as enabled.
The status of an environment spec ultimately determines whether or not a feature is enabled at all.
For instance, a feature will always be disabled for every user if the matching environment spec has a disabled status, regardless of the chosen rollout strategy.
@ -178,30 +140,28 @@ A feature flag may be enabled for a list of target users. It is implemented
using the Unleash [`userWithId`](https://unleash.github.io/docs/activation_strategy#userwithid)
activation strategy.
User IDs should be a comma separated list of values. For example, `user@example.com, user2@example.com`, or `username1,username2,username3`, etc.
User IDs should be a comma-separated list of values. For example, `user@example.com, user2@example.com`, or `username1,username2,username3`, etc.
CAUTION: **Caution:**
The Unleash client **must** be given a user ID for the feature to be enabled for
target users. See the [Ruby example](#ruby-application-example) below.
## Integrating with your application
## Integrate feature flags with your application
In order to use Feature Flags, you need to first
[get the access credentials](#configuring-feature-flags) from GitLab and then
prepare your application and hook it with a [client library](#client-libraries).
To use feature flags with your application, get access credentials from GitLab.
Then prepare your application with a client library.
## Configuring Feature Flags
### Get access credentials
To get the access credentials that your application will need to talk to GitLab:
To get the access credentials that your application needs to communicate with GitLab:
1. Navigate to your project's **Operations > Feature Flags**.
1. Click on the **Configure** button to see the values:
1. Click the **Configure** button to view the following:
- **API URL**: URL where the client (application) connects to get a list of feature flags.
- **Instance ID**: Unique token that authorizes the retrieval of the feature flags.
- **Application name**: The name of the running environment. For instance,
if the application runs for a production server, application name would be
`production` or similar. This value is used for
[the environment spec evaluation](#define-environment-specs).
if the application runs for a production server, the application name would be
`production` or similar. This value is used for the environment spec evaluation.
NOTE: **Note:**
The meaning of these fields might change over time. For example, we are not sure
@ -209,17 +169,17 @@ if **Instance ID** will be single token or multiple tokens, assigned to the
**Environment**. Also, **Application name** could describe the version of
application instead of the running environment.
## Client libraries
### Choose a client library
GitLab currently implements a single backend that is compatible with
GitLab implements a single backend that is compatible with
[Unleash](https://github.com/Unleash/unleash#client-implementations) clients.
Unleash clients allow the developers to define in the app's code the default
values for flags. Each feature flag evaluation can express the desired
outcome in case the flag isn't present on the provided configuration file.
With the Unleash client, developers can define, in the application code, the default values for flags.
Each feature flag evaluation can express the desired outcome if the flag isn't present in the
provided configuration file.
Unleash currently offers a number of official SDKs for various frameworks and
a number of community contributed libraries.
Unleash currently offers several official SDKs for various frameworks and
several community-contributed libraries.
Official clients:
@ -234,9 +194,18 @@ Community contributed clients:
- [Unofficial .Net Core Unleash client](https://github.com/onybo/unleash-client-core)
- [Unleash client for Python 3](https://github.com/aes/unleash-client-python)
## Golang application example
### Feature flags API information
Here's an example of how to integrate the feature flags in a Golang application:
For API content, see:
- [Feature Flags API](../../../api/feature_flags.md)
- [Feature Flag Specs API](../../../api/feature_flag_specs.md) (Deprecated and [scheduled for removal in GitLab 14.0](https://gitlab.com/gitlab-org/gitlab/-/issues/213369).)
- [Feature Flag User Lists API](../../../api/feature_flag_user_lists.md)
- [Legacy Feature Flags API](../../../api/feature_flags_legacy.md)
### Golang application example
Here's an example of how to integrate feature flags in a Golang application:
```golang
package main
@ -275,9 +244,9 @@ func main() {
}
```
## Ruby application example
### Ruby application example
Here's an example of how to integrate the feature flags in a Ruby application.
Here's an example of how to integrate feature flags in a Ruby application.
The Unleash client is given a user ID for use with a **Percent rollout (logged in users)** rollout strategy or a list of **Target Users**.
@ -305,12 +274,3 @@ else
puts "hello, world!"
end
```
## Feature Flags API
You can create, update, read, and delete Feature Flags via API
to control them in an automated flow:
- [Legacy Feature Flags API](../../../api/feature_flags_legacy.md)
- [Feature Flag Specs API](../../../api/feature_flag_specs.md)
- [Feature Flag User Lists API](../../../api/feature_flag_user_lists.md)

View File

@ -36,6 +36,8 @@ module API
results = SearchService.new(current_user, search_params).search_objects(preload_method)
Gitlab::UsageDataCounters::SearchCounter.count(:all_searches)
paginate(results)
end

View File

@ -8,7 +8,7 @@ module Gitlab::UsageDataCounters
class << self
def redis_key(event)
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(UnknownEvent.new, event: event) unless known_events.include?(event.to_s)
require_known_event(event)
"USAGE_#{prefix}_#{event}".upcase
end
@ -31,6 +31,10 @@ module Gitlab::UsageDataCounters
private
def require_known_event(event)
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(UnknownEvent.new, event: event) unless known_events.include?(event.to_s)
end
def counter_key(event)
"#{prefix}_#{event}".to_sym
end

View File

@ -4,7 +4,7 @@ module Gitlab::UsageDataCounters
class DesignsCounter
extend Gitlab::UsageDataCounters::RedisCounter
KNOWN_EVENTS = %w[create update delete].map(&:freeze).freeze
KNOWN_EVENTS = %w[create update delete].freeze
UnknownEvent = Class.new(StandardError)

View File

@ -2,28 +2,20 @@
module Gitlab
module UsageDataCounters
class SearchCounter
extend RedisCounter
NAVBAR_SEARCHES_COUNT_KEY = 'NAVBAR_SEARCHES_COUNT'
class SearchCounter < BaseCounter
KNOWN_EVENTS = %w[all_searches navbar_searches].freeze
class << self
def increment_navbar_searches_count
increment(NAVBAR_SEARCHES_COUNT_KEY)
def redis_key(event)
require_known_event(event)
"#{event}_COUNT".upcase
end
def total_navbar_searches_count
total_count(NAVBAR_SEARCHES_COUNT_KEY)
end
private
def totals
{
navbar_searches: total_navbar_searches_count
}
end
def fallback_totals
{ navbar_searches: -1 }
def counter_key(event)
"#{event}".to_sym
end
end
end

View File

@ -14,7 +14,8 @@ describe 'Global search' do
end
it 'increases usage ping searches counter' do
expect(Gitlab::UsageDataCounters::SearchCounter).to receive(:increment_navbar_searches_count)
expect(Gitlab::UsageDataCounters::SearchCounter).to receive(:count).with(:navbar_searches)
expect(Gitlab::UsageDataCounters::SearchCounter).to receive(:count).with(:all_searches)
submit_search('foobar')
end

View File

@ -3,11 +3,21 @@
require 'spec_helper'
describe Gitlab::UsageDataCounters::SearchCounter, :clean_gitlab_redis_shared_state do
it 'increments counter and return the total count' do
expect(described_class.total_navbar_searches_count).to eq(0)
shared_examples_for 'usage counter with totals' do |counter|
it 'increments counter and returns total count' do
expect(described_class.read(counter)).to eq(0)
2.times { described_class.increment_navbar_searches_count }
2.times { described_class.count(counter) }
expect(described_class.total_navbar_searches_count).to eq(2)
expect(described_class.read(counter)).to eq(2)
end
end
context 'all_searches counter' do
it_behaves_like 'usage counter with totals', :all_searches
end
context 'navbar_searches counter' do
it_behaves_like 'usage counter with totals', :navbar_searches
end
end

View File

@ -15,6 +15,14 @@ describe API::Search do
it { expect(json_response.size).to eq(size) }
end
shared_examples 'ping counters' do |scope:, search: ''|
it 'increases usage ping searches counter' do
expect(Gitlab::UsageDataCounters::SearchCounter).to receive(:count).with(:all_searches)
get api(endpoint, user), params: { scope: scope, search: search }
end
end
shared_examples 'pagination' do |scope:, search: ''|
it 'returns a different result for each page' do
get api(endpoint, user), params: { scope: scope, search: search, page: 1, per_page: 1 }
@ -75,6 +83,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/projects'
it_behaves_like 'pagination', scope: :projects
it_behaves_like 'ping counters', scope: :projects
end
context 'for issues scope' do
@ -86,6 +96,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/issues'
it_behaves_like 'ping counters', scope: :issues
describe 'pagination' do
before do
create(:issue, project: project, title: 'another issue')
@ -104,6 +116,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/merge_requests'
it_behaves_like 'ping counters', scope: :merge_requests
describe 'pagination' do
before do
create(:merge_request, source_project: repo_project, title: 'another mr', target_branch: 'another_branch')
@ -125,6 +139,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/milestones'
it_behaves_like 'ping counters', scope: :milestones
describe 'pagination' do
before do
create(:milestone, project: project, title: 'another milestone')
@ -161,6 +177,8 @@ describe API::Search do
it_behaves_like 'pagination', scope: :users
it_behaves_like 'ping counters', scope: :users
context 'when users search feature is disabled' do
before do
stub_feature_flags(users_search: false)
@ -183,6 +201,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/snippets'
it_behaves_like 'ping counters', scope: :snippet_titles
describe 'pagination' do
before do
create(:snippet, :public, title: 'another snippet', content: 'snippet content')
@ -248,6 +268,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/projects'
it_behaves_like 'pagination', scope: :projects
it_behaves_like 'ping counters', scope: :projects
end
context 'for issues scope' do
@ -259,6 +281,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/issues'
it_behaves_like 'ping counters', scope: :issues
describe 'pagination' do
before do
create(:issue, project: project, title: 'another issue')
@ -277,6 +301,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/merge_requests'
it_behaves_like 'ping counters', scope: :merge_requests
describe 'pagination' do
before do
create(:merge_request, source_project: repo_project, title: 'another mr', target_branch: 'another_branch')
@ -295,6 +321,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/milestones'
it_behaves_like 'ping counters', scope: :milestones
describe 'pagination' do
before do
create(:milestone, project: project, title: 'another milestone')
@ -326,6 +354,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/user/basics'
it_behaves_like 'ping counters', scope: :users
describe 'pagination' do
before do
create(:group_member, :developer, group: group)
@ -395,7 +425,7 @@ describe API::Search do
end
end
context 'when user does can not see the project' do
context 'when user can not see the project' do
it 'returns 404 error' do
project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
@ -415,6 +445,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/issues'
it_behaves_like 'ping counters', scope: :issues
describe 'pagination' do
before do
create(:issue, project: project, title: 'another issue')
@ -435,6 +467,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/merge_requests'
it_behaves_like 'ping counters', scope: :merge_requests
describe 'pagination' do
before do
create(:merge_request, source_project: repo_project, title: 'another mr', target_branch: 'another_branch')
@ -456,6 +490,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/milestones'
it_behaves_like 'ping counters', scope: :milestones
describe 'pagination' do
before do
create(:milestone, project: project, title: 'another milestone')
@ -491,6 +527,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/user/basics'
it_behaves_like 'ping counters', scope: :users
describe 'pagination' do
before do
create(:project_member, :developer, project: project)
@ -521,6 +559,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/notes'
it_behaves_like 'ping counters', scope: :notes
describe 'pagination' do
before do
mr = create(:merge_request, source_project: project, target_branch: 'another_branch')
@ -542,6 +582,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/blobs'
it_behaves_like 'ping counters', scope: :wiki_blobs
describe 'pagination' do
before do
create(:wiki_page, wiki: wiki, title: 'home 2', content: 'Another page')
@ -561,6 +603,8 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/commits_details'
it_behaves_like 'pagination', scope: :commits, search: 'merge'
it_behaves_like 'ping counters', scope: :commits
end
context 'for commits scope with project path as id' do
@ -582,6 +626,8 @@ describe API::Search do
it_behaves_like 'pagination', scope: :blobs, search: 'monitors'
it_behaves_like 'ping counters', scope: :blobs
context 'filters' do
it 'by filename' do
get api(endpoint, user), params: { scope: 'blobs', search: 'mon filename:PROCESS.md' }