Class: Neetob::CLI::NeetoDeploy::ConfigVars::Upsert

Inherits:
Base
  • Object
show all
Defined in:
lib/neetob/cli/neeto_deploy/config_vars/upsert.rb

Constant Summary

Constants inherited from Base

Base::NEETO_APPS_LIST_LINK

Instance Attribute Summary collapse

Attributes inherited from Base

#client

Attributes inherited from Base

#ui

Instance Method Summary collapse

Methods included from Utils

#camel_case_to_slug, #is_upper?, #symbolize_keys

Constructor Details

#initialize(apps, required_config_vars_json_file_path, required_config_vars_with_project_keys_json_file_path, sandbox = false) ⇒ Upsert

Returns a new instance of Upsert.



13
14
15
16
17
18
19
20
21
# File 'lib/neetob/cli/neeto_deploy/config_vars/upsert.rb', line 13

def initialize(apps, required_config_vars_json_file_path,
required_config_vars_with_project_keys_json_file_path, sandbox = false)
  super()
  @apps = apps
  @required_config_vars_json_file_path = required_config_vars_json_file_path
  @required_config_vars_with_project_keys_json_file_path =
    required_config_vars_with_project_keys_json_file_path
  @sandbox = sandbox
end

Instance Attribute Details

#appsObject

Returns the value of attribute apps.



10
11
12
# File 'lib/neetob/cli/neeto_deploy/config_vars/upsert.rb', line 10

def apps
  @apps
end

#required_config_vars_json_file_pathObject

Returns the value of attribute required_config_vars_json_file_path.



10
11
12
# File 'lib/neetob/cli/neeto_deploy/config_vars/upsert.rb', line 10

def required_config_vars_json_file_path
  @required_config_vars_json_file_path
end

#required_config_vars_with_project_keys_json_file_pathObject

Returns the value of attribute required_config_vars_with_project_keys_json_file_path.



10
11
12
# File 'lib/neetob/cli/neeto_deploy/config_vars/upsert.rb', line 10

def required_config_vars_with_project_keys_json_file_path
  @required_config_vars_with_project_keys_json_file_path
end

#sandboxObject

Returns the value of attribute sandbox.



10
11
12
# File 'lib/neetob/cli/neeto_deploy/config_vars/upsert.rb', line 10

def sandbox
  @sandbox
end

Instance Method Details

#runObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/neetob/cli/neeto_deploy/config_vars/upsert.rb', line 23

def run
  check_the_given_arguments
  inform_about_current_working_mode(sandbox) if apps.nil?
  apps_to_be_updated = apps.nil? ?
  read_json_file(required_config_vars_with_project_keys_json_file_path) :
  find_all_matching_apps_or_repos(apps, :neetodeploy, sandbox)
  inform_about_default_config_vars_file

  apps_to_be_updated.each do |app|
    required_config = apps.nil? ?
      app[1]
      : read_json_file(required_config_vars_json_file_path || default_config_vars_upsert_file_path)
    app = app[0] if apps.nil?

    if apps.nil? && sandbox && app != "neeto-dummy"
      ui.error("The \"#{app}\" app is not available in sandbox mode.")
      next
    end

    upsert_config_variables(app, required_config)
  end
end