Class: Gitlab::Seeders::Ci::VariablesGroupSeeder

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/seeders/ci/variables_group_seeder.rb

Constant Summary collapse

DEFAULT_SEED_COUNT =
10
DEFAULT_PREFIX =
'GROUP_VAR_'
DEFAULT_ENV =
'*'

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ VariablesGroupSeeder

Returns a new instance of VariablesGroupSeeder.



11
12
13
14
15
16
# File 'lib/gitlab/seeders/ci/variables_group_seeder.rb', line 11

def initialize(params)
  @group = Group.find_by_name(params[:name])
  @seed_count = params[:seed_count] || DEFAULT_SEED_COUNT
  @environment_scope = params[:environment_scope] || DEFAULT_ENV
  @prefix = params[:prefix] || DEFAULT_PREFIX
end

Instance Method Details

#seedObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/seeders/ci/variables_group_seeder.rb', line 18

def seed
  if @group.nil?
    warn 'ERROR: Group name is invalid.'
    return
  end

  max_id = group.variables.maximum(:id).to_i
  seed_count.times do
    max_id += 1
    create_ci_variable(max_id)
  end
end