Skip to content

Add environment scope to group CI variables API [RUN ALL RSPEC] [RUN AS-IF-FOSS]

Tiger Watson requested to merge scoped-group-variables-api into master

What does this MR do?

Extends the existing group variables API to support
EE-only params, and allows setting the environment_scope
if the :group_scoped_ci_variables licensed feature is available.

If the feature is not available (pricing tier is not Premium or
higher), the param is silently removed and the update continues
without presenting an error to the user. This behaviour is the
same as when project level scoped variables were a premium feature.

New finder queries

Without environment:

SELECT
  "ci_group_variables".*
FROM
  "ci_group_variables"
WHERE
  "ci_group_variables"."group_id" = 9970
  AND "ci_group_variables"."key" = <key>
 Index Scan using index_ci_group_variables_on_group_id_and_key_and_environment on public.ci_group_variables  (cost=0.42..3.44 rows=1 width=222) (actual time=0.026..0.028 rows=1 loops=1)  
   Index Cond: ((ci_group_variables.group_id = 9970) AND ((ci_group_variables.key)::text = <key>::text))  
   Buffers: shared hit=4  

With environment

SELECT
  "ci_group_variables".*
FROM
  "ci_group_variables"
WHERE
  "ci_group_variables"."group_id" = 9970
  AND "ci_group_variables"."key" = <key>
  AND "ci_group_variables"."environment_scope" = 'production'
 Index Scan using index_ci_group_variables_on_group_id_and_key_and_environment on public.ci_group_variables  (cost=0.42..3.20 rows=1 width=222) (actual time=0.023..0.023 rows=0 loops=1)  
   Index Cond: ((ci_group_variables.group_id = 9970) AND ((ci_group_variables.key)::text = <key>::text) AND (ci_group_variables.environment_scope = 'production'::text))  
   Buffers: shared hit=3  

Screenshots

There is one visible change - the environment scope is added to the "inherited variables" section (if the feature flag is enabled):

image

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

#2874 (closed)

Edited by Tiger Watson

Merge request reports

Loading