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 ...@@ -284,7 +284,7 @@ module ProjectsHelper
nav_tabs << :pipelines nav_tabs << :pipelines
end 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 nav_tabs << :operations
end end
...@@ -304,7 +304,6 @@ module ProjectsHelper ...@@ -304,7 +304,6 @@ module ProjectsHelper
def tab_ability_map def tab_ability_map
{ {
environments: :read_environment, environments: :read_environment,
feature_flags: :read_feature_flags,
milestones: :read_milestone, milestones: :read_milestone,
snippets: :read_project_snippet, snippets: :read_project_snippet,
settings: :admin_project, settings: :admin_project,
......
...@@ -266,9 +266,6 @@ class Project < ActiveRecord::Base ...@@ -266,9 +266,6 @@ class Project < ActiveRecord::Base
has_many :project_deploy_tokens has_many :project_deploy_tokens
has_many :deploy_tokens, through: :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_one :auto_devops, class_name: 'ProjectAutoDevops'
has_many :custom_attributes, class_name: 'ProjectCustomAttribute' has_many :custom_attributes, class_name: 'ProjectCustomAttribute'
...@@ -2105,10 +2102,6 @@ class Project < ActiveRecord::Base ...@@ -2105,10 +2102,6 @@ class Project < ActiveRecord::Base
auto_cancel_pending_pipelines == 'enabled' auto_cancel_pending_pipelines == 'enabled'
end end
def feature_flag_access_token
(operations_feature_flags_access_token || create_operations_feature_flags_access_token!).token
end
private private
# rubocop: disable CodeReuse/ServiceClass # rubocop: disable CodeReuse/ServiceClass
......
...@@ -235,7 +235,6 @@ class ProjectPolicy < BasePolicy ...@@ -235,7 +235,6 @@ class ProjectPolicy < BasePolicy
enable :update_container_image enable :update_container_image
enable :create_environment enable :create_environment
enable :create_deployment enable :create_deployment
enable :read_feature_flags
end end
rule { can?(:maintainer_access) }.policy do rule { can?(:maintainer_access) }.policy do
...@@ -260,9 +259,6 @@ class ProjectPolicy < BasePolicy ...@@ -260,9 +259,6 @@ class ProjectPolicy < BasePolicy
enable :read_cluster enable :read_cluster
enable :create_cluster enable :create_cluster
enable :create_environment_terminal enable :create_environment_terminal
enable :create_feature_flags
enable :update_feature_flags
enable :admin_feature_flags
end end
rule { (mirror_available & can?(:admin_project)) | admin }.enable :admin_remote_mirror rule { (mirror_available & can?(:admin_project)) | admin }.enable :admin_remote_mirror
......
...@@ -352,7 +352,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -352,7 +352,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resource :lint, only: [:show, :create] resource :lint, only: [:show, :create]
end end
## EE-specific
resources :feature_flags resources :feature_flags
## EE-specific
end end
draw :legacy_builds draw :legacy_builds
......
...@@ -25,8 +25,19 @@ module EE ...@@ -25,8 +25,19 @@ module EE
nav_tabs << :packages nav_tabs << :packages
end end
if can?(current_user, :read_feature_flags, project) && !nav_tabs.include?(:operations)
nav_tabs << :operations
end
nav_tabs nav_tabs
end 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 override :project_permissions_settings
def project_permissions_settings(project) def project_permissions_settings(project)
......
...@@ -50,6 +50,9 @@ module EE ...@@ -50,6 +50,9 @@ module EE
has_many :prometheus_alerts, inverse_of: :project has_many :prometheus_alerts, inverse_of: :project
has_many :prometheus_alert_events, 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 :with_shared_runners_limit_enabled, -> { with_shared_runners.non_public_only }
scope :mirror, -> { where(mirror: true) } scope :mirror, -> { where(mirror: true) }
...@@ -559,6 +562,10 @@ module EE ...@@ -559,6 +562,10 @@ module EE
change_head(root_ref) if root_ref.present? && root_ref != default_branch change_head(root_ref) if root_ref.present? && root_ref != default_branch
end end
def feature_flag_access_token
(operations_feature_flags_access_token || create_operations_feature_flags_access_token!).token
end
private private
def set_override_pull_mirror_available def set_override_pull_mirror_available
......
...@@ -99,6 +99,9 @@ module EE ...@@ -99,6 +99,9 @@ module EE
enable :admin_board enable :admin_board
enable :admin_vulnerability_feedback enable :admin_vulnerability_feedback
enable :create_package enable :create_package
enable :read_feature_flags
enable :create_feature_flags
enable :update_feature_flags
end end
rule { can?(:public_access) }.enable :read_package rule { can?(:public_access) }.enable :read_package
...@@ -122,6 +125,7 @@ module EE ...@@ -122,6 +125,7 @@ module EE
enable :admin_path_locks enable :admin_path_locks
enable :update_approvers enable :update_approvers
enable :destroy_package enable :destroy_package
enable :admin_feature_flags
end end
rule { license_management_enabled & can?(:maintainer_access) }.enable :admin_software_license_policy rule { license_management_enabled & can?(:maintainer_access) }.enable :admin_software_license_policy
......
module API module API
class FeatureFlags < Grape::API class Unleash < Grape::API
include PaginationParams include PaginationParams
resource :feature_flags do resource :feature_flags do
......
...@@ -427,6 +427,23 @@ module EE ...@@ -427,6 +427,23 @@ module EE
object.geo_node.missing_oauth_application? object.geo_node.missing_oauth_application?
end end
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 end
end end
...@@ -28,6 +28,15 @@ module EE ...@@ -28,6 +28,15 @@ module EE
def maven_app_group_regex def maven_app_group_regex
maven_app_name_regex maven_app_name_regex
end 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 end
end end
...@@ -108,7 +108,6 @@ module API ...@@ -108,7 +108,6 @@ module API
mount ::API::Environments mount ::API::Environments
mount ::API::Events mount ::API::Events
mount ::API::Features mount ::API::Features
mount ::API::FeatureFlags
mount ::API::Files mount ::API::Files
mount ::API::GroupBoards mount ::API::GroupBoards
mount ::API::GroupMilestones mount ::API::GroupMilestones
...@@ -167,6 +166,7 @@ module API ...@@ -167,6 +166,7 @@ module API
## EE-specific API V4 endpoints START ## EE-specific API V4 endpoints START
mount ::EE::API::Boards mount ::EE::API::Boards
mount ::EE::API::GroupBoards mount ::EE::API::GroupBoards
mount ::API::Unleash
mount ::API::EpicIssues mount ::API::EpicIssues
mount ::API::Epics mount ::API::Epics
......
...@@ -1516,26 +1516,6 @@ module API ...@@ -1516,26 +1516,6 @@ module API
expose :label, using: Entities::LabelBasic expose :label, using: Entities::LabelBasic
expose :action expose :action
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
def features
end
end
end end
end end
......
...@@ -71,15 +71,6 @@ module Gitlab ...@@ -71,15 +71,6 @@ module Gitlab
"Must start with a letter, and cannot end with '-'" "Must start with a letter, and cannot end with '-'"
end 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 def build_trace_section_regex
@build_trace_section_regexp ||= /section_((?:start)|(?:end)):(\d+):([a-zA-Z0-9_.-]+)\r\033\[0K/.freeze @build_trace_section_regexp ||= /section_((?:start)|(?:end)):(\d+):([a-zA-Z0-9_.-]+)\r\033\[0K/.freeze
end 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