Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2020-09-17 06:09:32 +00:00
parent a770b4e83a
commit 9e3e71602c
14 changed files with 323 additions and 120 deletions

View File

@ -25,7 +25,8 @@ export default {
},
descriptionText: {
type: String,
required: true,
required: false,
default: '',
},
taskStatus: {
type: String,

View File

@ -0,0 +1,44 @@
# frozen_string_literal: true
class FeatureFlagsFinder
attr_reader :project, :params, :current_user
def initialize(project, current_user, params = {})
@project = project
@current_user = current_user
@params = params
end
def execute(preload: true)
unless Ability.allowed?(current_user, :read_feature_flag, project)
return Operations::FeatureFlag.none
end
items = feature_flags
items = by_scope(items)
items = items.preload_relations if preload
items.ordered
end
private
def feature_flags
if Feature.enabled?(:feature_flags_new_version, project, default_enabled: true)
project.operations_feature_flags
else
project.operations_feature_flags.legacy_flag
end
end
def by_scope(items)
case params[:scope]
when 'enabled'
items.enabled
when 'disabled'
items.disabled
else
items
end
end
end

View File

@ -0,0 +1,7 @@
# frozen_string_literal: true
module Operations
class FeatureFlagPolicy < BasePolicy
delegate { @subject.project }
end
end

View File

@ -325,6 +325,12 @@ class ProjectPolicy < BasePolicy
enable :destroy_design
enable :read_terraform_state
enable :read_pod_logs
enable :read_feature_flag
enable :create_feature_flag
enable :update_feature_flag
enable :destroy_feature_flag
enable :admin_feature_flag
enable :admin_feature_flags_user_lists
end
rule { can?(:developer_access) & user_confirmed? }.policy do
@ -371,6 +377,7 @@ class ProjectPolicy < BasePolicy
enable :read_freeze_period
enable :update_freeze_period
enable :destroy_freeze_period
enable :admin_feature_flags_client
end
rule { public_project & metrics_dashboard_allowed }.policy do
@ -447,6 +454,8 @@ class ProjectPolicy < BasePolicy
prevent :read_pipeline
prevent :read_pipeline_schedule
prevent(*create_read_update_admin_destroy(:release))
prevent(*create_read_update_admin_destroy(:feature_flag))
prevent(:admin_feature_flags_user_lists)
end
rule { container_registry_disabled }.policy do

View File

@ -44190,59 +44190,6 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "variables",
"description": "List of supported variables",
"args": [
{
"name": "after",
"description": "Returns the elements in the list that come after the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "before",
"description": "Returns the elements in the list that come before the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "first",
"description": "Returns the first _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
},
{
"name": "last",
"description": "Returns the last _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "SastCiConfigurationEntityConnection",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
@ -44312,6 +44259,59 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "variables",
"description": "List of supported variables",
"args": [
{
"name": "after",
"description": "Returns the elements in the list that come after the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "before",
"description": "Returns the elements in the list that come before the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "first",
"description": "Returns the first _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
},
{
"name": "last",
"description": "Returns the last _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "SastCiConfigurationEntityConnection",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,

View File

@ -86,30 +86,31 @@ GitLab CI/CD and [shared runners](runners/README.md#shared-runners) are enabled
GitLab CI/CD uses a number of concepts to describe and run your build and deploy.
| Concept | Description |
|:--------------|:-------------|
| [Pipelines](pipelines/index.md) | Structure your CI/CD process through pipelines. |
| [Environment variables](variables/README.md) | Reuse values based on a variable/value key pair. |
| [Environments](environments/index.md) | Deploy your application to different environments (e.g., staging, production). |
| [Job artifacts](pipelines/job_artifacts.md) | Output, use, and reuse job artifacts. |
| [Cache dependencies](caching/index.md) | Cache your dependencies for a faster execution. |
| [GitLab Runner](https://docs.gitlab.com/runner/) | Configure your own runners to execute your scripts. |
| Concept | Description |
|:--------------------------------------------------------|:-------------------------------------------------------------------------------|
| [Pipelines](pipelines/index.md) | Structure your CI/CD process through pipelines. |
| [Environment variables](variables/README.md) | Reuse values based on a variable/value key pair. |
| [Environments](environments/index.md) | Deploy your application to different environments (e.g., staging, production). |
| [Job artifacts](pipelines/job_artifacts.md) | Output, use, and reuse job artifacts. |
| [Cache dependencies](caching/index.md) | Cache your dependencies for a faster execution. |
| [GitLab Runner](https://docs.gitlab.com/runner/) | Configure your own runners to execute your scripts. |
| [Pipeline efficiency](pipelines/pipeline_efficiency.md) | Configure your pipelines to run quickly and effienctly. |
## Configuration
GitLab CI/CD supports numerous configuration options:
| Configuration | Description |
|:--------------|:-------------|
| [Schedule pipelines](pipelines/schedules.md) | Schedule pipelines to run as often as you need. |
| [Custom path for `.gitlab-ci.yml`](pipelines/settings.md#custom-ci-configuration-path) | Define a custom path for the CI/CD configuration file. |
| [Git submodules for CI/CD](git_submodules.md) | Configure jobs for using Git submodules.|
| [SSH keys for CI/CD](ssh_keys/README.md) | Using SSH keys in your CI pipelines. |
| [Pipeline triggers](triggers/README.md) | Trigger pipelines through the API. |
| [Pipelines for Merge Requests](merge_request_pipelines/index.md) | Design a pipeline structure for running a pipeline in merge requests. |
| [Integrate with Kubernetes clusters](../user/project/clusters/index.md) | Connect your project to Google Kubernetes Engine (GKE) or an existing Kubernetes cluster. |
| [Optimize GitLab and GitLab Runner for large repositories](large_repositories/index.md) | Recommended strategies for handling large repositories. |
| [`.gitlab-ci.yml` full reference](yaml/README.md) | All the attributes you can use with GitLab CI/CD. |
| Configuration | Description |
|:----------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------|
| [Schedule pipelines](pipelines/schedules.md) | Schedule pipelines to run as often as you need. |
| [Custom path for `.gitlab-ci.yml`](pipelines/settings.md#custom-ci-configuration-path) | Define a custom path for the CI/CD configuration file. |
| [Git submodules for CI/CD](git_submodules.md) | Configure jobs for using Git submodules. |
| [SSH keys for CI/CD](ssh_keys/README.md) | Using SSH keys in your CI pipelines. |
| [Pipeline triggers](triggers/README.md) | Trigger pipelines through the API. |
| [Pipelines for Merge Requests](merge_request_pipelines/index.md) | Design a pipeline structure for running a pipeline in merge requests. |
| [Integrate with Kubernetes clusters](../user/project/clusters/index.md) | Connect your project to Google Kubernetes Engine (GKE) or an existing Kubernetes cluster. |
| [Optimize GitLab and GitLab Runner for large repositories](large_repositories/index.md) | Recommended strategies for handling large repositories. |
| [`.gitlab-ci.yml` full reference](yaml/README.md) | All the attributes you can use with GitLab CI/CD. |
Note that certain operations can only be performed according to the
[user](../user/permissions.md#gitlab-cicd-permissions) and [job](../user/permissions.md#job-permissions) permissions.
@ -191,41 +192,25 @@ been necessary. These are:
#### 13.0
- [Remove Backported
`os.Expand`](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4915)
- [Remove Fedora 29 package
support](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/16158)
- [Remove macOS 32-bit
support](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/25466)
- [Removed `debug/jobs/list?v=1`
endpoint](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/6361)
- [Remove support for array of strings when defining services for Docker
executor](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4922)
- [Remove `--docker-services` flag on register
command](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/6404)
- [Remove legacy build directory
caching](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4180)
- [Remove `FF_USE_LEGACY_VOLUMES_MOUNTING_ORDER` feature
flag](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/6581)
- [Remove support for Windows Server
1803](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/6553)
- [Remove Backported `os.Expand`](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4915).
- [Remove Fedora 29 package support](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/16158).
- [Remove macOS 32-bit support](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/25466).
- [Removed `debug/jobs/list?v=1` endpoint](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/6361).
- [Remove support for array of strings when defining services for Docker executor](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4922).
- [Remove `--docker-services` flag on register command](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/6404).
- [Remove legacy build directory caching](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4180).
- [Remove `FF_USE_LEGACY_VOLUMES_MOUNTING_ORDER` feature flag](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/6581).
- [Remove support for Windows Server 1803](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/6553).
#### 12.0
- [Use refspec to clone/fetch Git
repository](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4069).
- [Old cache
configuration](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4070).
- [Old metrics server
configuration](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4072).
- [Remove
`FF_K8S_USE_ENTRYPOINT_OVER_COMMAND`](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4073).
- [Remove Linux distributions that reach
EOL](https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/1130).
- [Update command line API for helper
images](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4013).
- [Remove old `git clean`
flow](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4175).
- [Use refspec to clone/fetch Git repository](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4069).
- [Old cache configuration](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4070).
- [Old metrics server configuration](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4072).
- [Remove `FF_K8S_USE_ENTRYPOINT_OVER_COMMAND`](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4073).
- [Remove Linux distributions that reach EOL](https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/1130).
- [Update command line API for helper images](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4013).
- [Remove old `git clean` flow](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4175).
#### 11.0

View File

@ -237,3 +237,6 @@ existing one) for any application.
For a deep view of GitLab's CI/CD configuration options, check the
[`.gitlab-ci.yml` full reference](../yaml/README.md).
For help making your pipelines faster and more efficient, see the
[pipeline efficiency documentation](../pipelines/pipeline_efficiency.md).

View File

@ -26,6 +26,8 @@ that were able to quickly complete this migration:
1. Migrate the deployment jobs using [cloud deployment templates](../cloud_deployment/index.md), adding [environments](../environments/index.md), and [deploy boards](../..//user/project/deploy_boards.md).
1. Work to unwrap any jobs still running with the use of the Jenkins wrapper.
1. Take stock of any common CI/CD job definitions then create and share [templates](#templates) for them.
1. Check the [pipeline efficiency documentation](../pipelines/pipeline_efficiency.md)
to learn how to make your GitLab CI/CD pipelines faster and more efficient.
For an example of how to convert a Jenkins pipeline into a GitLab CI/CD pipeline,
or how to use Auto DevOps to test your code automatically, watch the
@ -354,3 +356,8 @@ our very powerful [`only/except` rules system](../yaml/README.md#onlyexcept-basi
my_job:
only: [branches]
```
## Additional resources
For help making your pipelines faster and more efficient, see the
[pipeline efficiency documentation](../pipelines/pipeline_efficiency.md).

View File

@ -28,17 +28,17 @@ The easiest indicators to check for inefficient pipelines are the runtimes of th
stages, and the total runtime of the pipeline itself. The total pipeline duration is
heavily influenced by the:
- Total number of stages and jobs
- Dependencies between jobs
- Total number of stages and jobs.
- Dependencies between jobs.
- The ["critical path"](#directed-acyclic-graphs-dag-visualization), which represents
the minimum and maximum pipeline duration
the minimum and maximum pipeline duration.
Additional points to pay attention relate to [GitLab Runners](../runners/README.md):
- Availability of the runners and the resources they are provisioned with
- Build dependencies and their installation time
- [Container image size](#docker-images)
- Network latency and slow connections
- Availability of the runners and the resources they are provisioned with.
- Build dependencies and their installation time.
- [Container image size](#docker-images).
- Network latency and slow connections.
Pipelines frequently failing unnecessarily also causes slowdowns in the development
lifecycle. You should look for problematic patterns with failed jobs:
@ -54,9 +54,9 @@ lifecycle. You should look for problematic patterns with failed jobs:
Analyze the performance of your pipeline to find ways to improve efficiency. Analysis
can help identify possible blockers in the CI/CD infrastructure. This includes analyzing:
- Job workloads
- Bottlenecks in the execution times
- The overall pipeline architecture
- Job workloads.
- Bottlenecks in the execution times.
- The overall pipeline architecture.
It's important to understand and document the pipeline workflows, and discuss possible
actions and changes. Refactoring pipelines may need careful interaction between teams
@ -212,7 +212,8 @@ that download and run faster.
Try to use custom Docker images with the software pre-installed. It's usually much
faster to download a larger pre-configured image than to use a common image and install
software on it each time.
software on it each time. Docker's [Best practices for writing Dockerfiles](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/)
has more information about building efficient Docker images.
Methods to reduce Docker image size:

View File

@ -216,7 +216,10 @@ you expected.
You are also able to view the status of any commit in the various pages in
GitLab, such as **Commits** and **Merge requests**.
## Examples
## Additional resources
Visit the [examples README](../examples/README.md) to see a list of examples using GitLab
CI with various languages.
For help making your new pipelines faster and more efficient, see the
[pipeline efficiency documentation](../pipelines/pipeline_efficiency.md).

View File

@ -4,9 +4,10 @@ group: Progressive Delivery
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers
---
# Feature Flags **(PREMIUM)**
# Feature Flags **(STARTER)**
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/7433) in GitLab 11.4.
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/7433) in GitLab 11.4.
> - [Moved](https://gitlab.com/gitlab-org/gitlab/-/issues/212318) to [GitLab Starter](https://about.gitlab.com/pricing/) in 13.4
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.
@ -349,7 +350,7 @@ else
end
```
## Feature Flag Related Issues
## Feature Flag Related Issues **(PREMIUM)**
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/36617) in GitLab 13.2.
> - It's deployed behind a feature flag, enabled by default.

View File

@ -18,6 +18,14 @@ RSpec.describe 'Project navbar' do
project.add_maintainer(user)
sign_in(user)
if Gitlab.ee?
insert_after_sub_nav_item(
_('Kubernetes'),
within: _('Operations'),
new_sub_nav_item_name: _('Feature Flags')
)
end
end
it_behaves_like 'verified navigation bar' do

View File

@ -0,0 +1,94 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe FeatureFlagsFinder do
include FeatureFlagHelpers
let(:finder) { described_class.new(project, user, params) }
let(:project) { create(:project) }
let(:user) { developer }
let(:developer) { create(:user) }
let(:reporter) { create(:user) }
let(:params) { {} }
before do
project.add_developer(developer)
project.add_reporter(reporter)
end
describe '#execute' do
subject { finder.execute(args) }
let!(:feature_flag_1) { create(:operations_feature_flag, name: 'flag-a', project: project) }
let!(:feature_flag_2) { create(:operations_feature_flag, name: 'flag-b', project: project) }
let(:args) { {} }
it 'returns feature flags ordered by name' do
is_expected.to eq([feature_flag_1, feature_flag_2])
end
it 'preloads relations by default' do
expect(Operations::FeatureFlag).to receive(:preload_relations).and_call_original
subject
end
context 'when user is a reporter' do
let(:user) { reporter }
it 'returns an empty list' do
is_expected.to be_empty
end
end
context 'when scope is given' do
let!(:feature_flag_1) { create(:operations_feature_flag, project: project, active: true) }
let!(:feature_flag_2) { create(:operations_feature_flag, project: project, active: false) }
context 'when scope is enabled' do
let(:params) { { scope: 'enabled' } }
it 'returns active feature flag' do
is_expected.to eq([feature_flag_1])
end
end
context 'when scope is disabled' do
let(:params) { { scope: 'disabled' } }
it 'returns inactive feature flag' do
is_expected.to eq([feature_flag_2])
end
end
end
context 'when preload option is false' do
let(:args) { { preload: false } }
it 'does not preload relations' do
expect(Operations::FeatureFlag).not_to receive(:preload_relations)
subject
end
end
context 'when new version flags are enabled' do
let!(:feature_flag_3) { create(:operations_feature_flag, :new_version_flag, name: 'flag-c', project: project) }
it 'returns new and legacy flags' do
is_expected.to eq([feature_flag_1, feature_flag_2, feature_flag_3])
end
end
context 'when new version flags are disabled' do
let!(:feature_flag_3) { create(:operations_feature_flag, :new_version_flag, name: 'flag-c', project: project) }
it 'returns only legacy flags' do
stub_feature_flags(feature_flags_new_version: false)
is_expected.to eq([feature_flag_1, feature_flag_2])
end
end
end
end

View File

@ -901,4 +901,44 @@ RSpec.describe ProjectPolicy do
it { is_expected.to be_allowed(:read_package) }
end
end
describe 'read_feature_flag' do
subject { described_class.new(current_user, project) }
context 'with maintainer' do
let(:current_user) { maintainer }
context 'when repository is available' do
it { is_expected.to be_allowed(:read_feature_flag) }
end
context 'when repository is disabled' do
before do
project.project_feature.update!(
merge_requests_access_level: ProjectFeature::DISABLED,
builds_access_level: ProjectFeature::DISABLED,
repository_access_level: ProjectFeature::DISABLED
)
end
it { is_expected.to be_disallowed(:read_feature_flag) }
end
end
context 'with developer' do
let(:current_user) { developer }
context 'when repository is available' do
it { is_expected.to be_allowed(:read_feature_flag) }
end
end
context 'with reporter' do
let(:current_user) { reporter }
context 'when repository is available' do
it { is_expected.to be_disallowed(:read_feature_flag) }
end
end
end
end