Method: Params#initialize

Defined in:
lib/params/params.rb

#initialize(params) ⇒ Params

Returns a new instance of Params.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/params/params.rb', line 57

def initialize(params)
  self.merge!(params)

  @application = params["application"]
  @component = params["component"]
  @component_version = params["component_version"]

  @request_id = params["request_id"]
  @request_name = params["request_name"]
  @request_number = params["request_number"]
  @request_environment = params["request_environment"]
  @request_scheduled_at = params["request_scheduled_at"]
  @request_started_at = params["request_started_at"]
  @request_status = params["request_status"]

  @request_plan = params["request_plan"]
  @request_plan_id = params["request_plan_id"]
  @request_plan_member_id = params["request_plan_member_id"]
  @request_plan_stage = params["request_plan_stage"]

  @request_run_id = params["request_run_id"]
  @request_run_name = params["request_run_name"]

  @step_id = params["step_id"]
  @step_number = params["step_number"]
  @step_name = params["step_name"]
  @step_description = params["step_description"]
  @step_estimate = params["step_estimate"]

  @step_version = params["step_version"]
  @step_version_artifact_url = params["step_version_artifact_url"]

  @servers = get_server_list

  @ticket_ids = params["ticket_ids"]
  @tickets_foreign_ids = params["tickets_foreign_ids"]

  @run_key = params["SS_run_key"] || params["run_key"]

  if params["SS_automation_results_dir"]
    @home_dir = params["SS_automation_results_dir"].sub("/automation_results", "")
  else
    @home_dir = params["home_dir"] || ENV["BRPM_HOME"] || Dir.pwd
  end
  @automation_results_dir = params["SS_automation_results_dir"]
  @output_dir = params["SS_output_dir"] || params["output_dir"] || Dir.pwd
  @output_file = params["SS_output_file"]
  @config_dir = "#{@home_dir}/config"

  @log_file = params["log_file"] || "#{@output_dir}/brpm_auto.log"

  @brpm_url = params["SS_base_url"] || params["brpm_url"]
  @brpm_api_token = params["SS_api_token"] || params["brpm_api_token"]

  @run_from_brpm = (@run_key != nil)
  @unit_test = (params["unit_test"] == "true" || params["unit_test"] == 'true')
  @also_log_to_console = (params["also_log_to_console"] == "true" || params["also_log_to_console"] == 'true')

  @private_params = {}
  if self.run_from_brpm
    params.each do |k,v|
      if k.end_with?("_encrypt") || k.end_with?("_enc")
        if k.end_with?("_encrypt")
          key_decrypted = k.gsub("_encrypt","")
        elsif k.end_with?("_enc")
          key_decrypted = k.gsub("_enc","")
        end
        value_decrypted = decrypt_string_with_prefix(v)
        @private_params[key_decrypted] = value_decrypted
      end
    end
  end
  self.merge!(@private_params)
end