Commit f8a140c8 authored by Kamil Trzciński's avatar Kamil Trzciński

Move feature flags to ee/

parent d77cf4f0
......@@ -284,7 +284,7 @@ module ProjectsHelper
nav_tabs << :pipelines
end
if can?(current_user, :read_environment, project) || can?(current_user, :read_cluster, project) || can?(current_user, :read_feature_flags, project)
if can?(current_user, :read_environment, project) || can?(current_user, :read_cluster, project)
nav_tabs << :operations
end
......@@ -304,7 +304,6 @@ module ProjectsHelper
def tab_ability_map
{
environments: :read_environment,
feature_flags: :read_feature_flags,
milestones: :read_milestone,
snippets: :read_project_snippet,
settings: :admin_project,
......
......@@ -266,9 +266,6 @@ class Project < ActiveRecord::Base
has_many :project_deploy_tokens
has_many :deploy_tokens, through: :project_deploy_tokens
has_many :operations_feature_flags, class_name: 'Operations::FeatureFlag'
has_one :operations_feature_flags_access_token, class_name: 'Operations::FeatureFlagsAccessToken'
has_one :auto_devops, class_name: 'ProjectAutoDevops'
has_many :custom_attributes, class_name: 'ProjectCustomAttribute'
......@@ -2105,10 +2102,6 @@ class Project < ActiveRecord::Base
auto_cancel_pending_pipelines == 'enabled'
end
def feature_flag_access_token
(operations_feature_flags_access_token || create_operations_feature_flags_access_token!).token
end
private
# rubocop: disable CodeReuse/ServiceClass
......
......@@ -235,7 +235,6 @@ class ProjectPolicy < BasePolicy
enable :update_container_image
enable :create_environment
enable :create_deployment
enable :read_feature_flags
end
rule { can?(:maintainer_access) }.policy do
......@@ -260,9 +259,6 @@ class ProjectPolicy < BasePolicy
enable :read_cluster
enable :create_cluster
enable :create_environment_terminal
enable :create_feature_flags
enable :update_feature_flags
enable :admin_feature_flags
end
rule { (mirror_available & can?(:admin_project)) | admin }.enable :admin_remote_mirror
......
......@@ -352,7 +352,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resource :lint, only: [:show, :create]
end
## EE-specific
resources :feature_flags
## EE-specific
end
draw :legacy_builds
......
......@@ -25,8 +25,19 @@ module EE
nav_tabs << :packages
end
if can?(current_user, :read_feature_flags, project) && !nav_tabs.include?(:operations)
nav_tabs << :operations
end
nav_tabs
end
override :tab_ability_map
def tab_ability_map
tab_ability_map = super
tab_ability_map[:feature_flags] = read_feature_flags
tab_ability_map
end
override :project_permissions_settings
def project_permissions_settings(project)
......
......@@ -50,6 +50,9 @@ module EE
has_many :prometheus_alerts, inverse_of: :project
has_many :prometheus_alert_events, inverse_of: :project
has_many :operations_feature_flags, class_name: 'Operations::FeatureFlag'
has_one :operations_feature_flags_access_token, class_name: 'Operations::FeatureFlagsAccessToken'
scope :with_shared_runners_limit_enabled, -> { with_shared_runners.non_public_only }
scope :mirror, -> { where(mirror: true) }
......@@ -559,6 +562,10 @@ module EE
change_head(root_ref) if root_ref.present? && root_ref != default_branch
end
def feature_flag_access_token
(operations_feature_flags_access_token || create_operations_feature_flags_access_token!).token
end
private
def set_override_pull_mirror_available
......
......@@ -99,6 +99,9 @@ module EE
enable :admin_board
enable :admin_vulnerability_feedback
enable :create_package
enable :read_feature_flags
enable :create_feature_flags
enable :update_feature_flags
end
rule { can?(:public_access) }.enable :read_package
......@@ -122,6 +125,7 @@ module EE
enable :admin_path_locks
enable :update_approvers
enable :destroy_package
enable :admin_feature_flags
end
rule { license_management_enabled & can?(:maintainer_access) }.enable :admin_software_license_policy
......
module API
class FeatureFlags < Grape::API
class Unleash < Grape::API
include PaginationParams
resource :feature_flags do
......
......@@ -427,6 +427,23 @@ module EE
object.geo_node.missing_oauth_application?
end
end
class UnleashFeature < Grape::Entity
expose :name
expose :description, unless: ->(feature) { feature.description.nil? }
expose :active, as: :enabled
end
class UnleashFeatures < Grape::Entity
expose :version
expose :operations_feature_flags, as: :features, with: UnleashFeature
private
def version
1
end
end
end
end
end
......@@ -28,6 +28,15 @@ module EE
def maven_app_group_regex
maven_app_name_regex
end
def feature_flag_regex
/\A[a-z]([-_a-z0-9]*[a-z0-9])?\z/
end
def feature_flag_regex_message
"can contain only lowercase letters, digits, '_' and '-'. " \
"Must start with a letter, and cannot end with '-' or '_'"
end
end
end
end
......@@ -108,7 +108,6 @@ module API
mount ::API::Environments
mount ::API::Events
mount ::API::Features
mount ::API::FeatureFlags
mount ::API::Files
mount ::API::GroupBoards
mount ::API::GroupMilestones
......@@ -167,6 +166,7 @@ module API
## EE-specific API V4 endpoints START
mount ::EE::API::Boards
mount ::EE::API::GroupBoards
mount ::API::Unleash
mount ::API::EpicIssues
mount ::API::Epics
......
......@@ -1516,26 +1516,6 @@ module API
expose :label, using: Entities::LabelBasic
expose :action
end
class UnleashFeature < Grape::Entity
expose :name
expose :description, unless: ->(feature) { feature.description.nil? }
expose :active, as: :enabled
end
class UnleashFeatures < Grape::Entity
expose :version
expose :operations_feature_flags, as: :features, with: UnleashFeature
private
def version
1
end
def features
end
end
end
end
......
......@@ -71,15 +71,6 @@ module Gitlab
"Must start with a letter, and cannot end with '-'"
end
def feature_flag_regex
/\A[a-z]([-_a-z0-9]*[a-z0-9])?\z/
end
def feature_flag_regex_message
"can contain only lowercase letters, digits, '_' and '-'. " \
"Must start with a letter, and cannot end with '-' or '_'"
end
def build_trace_section_regex
@build_trace_section_regexp ||= /section_((?:start)|(?:end)):(\d+):([a-zA-Z0-9_.-]+)\r\033\[0K/.freeze
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment