Commit 918d9b5c authored by Kamil Trzciński's avatar Kamil Trzciński

Rename access token to instances

parent e7e66184
......@@ -2,10 +2,10 @@
module FeatureFlagsHelper
def unleash_api_url(project)
"#{root_url(only_path: false)}api/v4/feature_flags/projects/#{project.id}/unleash"
"#{root_url(only_path: false)}api/v4/feature_flags/unleash/#{project.id}"
end
def unleash_api_instanceid(project)
project.feature_flag_access_token
project.feature_flag_instance_token
end
end
......@@ -51,7 +51,7 @@ module EE
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'
has_one :operations_feature_flags_instance, class_name: 'Operations::FeatureFlagsInstance'
scope :with_shared_runners_limit_enabled, -> { with_shared_runners.non_public_only }
......@@ -562,8 +562,9 @@ 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
def feature_flags_instance_token
instance = operations_feature_flags_instance || create_operations_feature_flags_instance!
instance.token
end
private
......
module Operations
class FeatureFlagsAccessToken < ActiveRecord::Base
class FeatureFlagsInstance < ActiveRecord::Base
include TokenAuthenticatable
self.table_name = 'operations_feature_flags_access_tokens'
self.table_name = 'operations_feature_flags_instances'
belongs_to :project
......
FactoryBot.define do
factory :operations_feature_flags_access_token, class: Operations::FeatureFlagsAccessToken do
factory :operations_feature_flags_instance, class: Operations::FeatureFlagsInstance do
project
end
end
......@@ -1780,7 +1780,7 @@ describe Project do
end
context 'when there is access token' do
let!(:access_token) { create(:operations_feature_flags_access_token, project: project, token: 'token') }
let!(:instance) { create(:operations_feature_flags_instance, project: project, token: 'token') }
it "provides an existing one" do
is_expected.to eq('token')
......
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