Class: Kettle::Dev::ReleaseSecretsDoctor
- Inherits:
-
Object
- Object
- Kettle::Dev::ReleaseSecretsDoctor
- Defined in:
- lib/kettle/dev/release_secrets_doctor.rb
Constant Summary collapse
- DEFAULT_SLEEP_SECONDS =
30.0- DEFAULT_KEEPALIVE_SECONDS =
0.0- DEFAULT_PROVIDER =
"op"- DEFAULT_SHAPE =
"same-process"- CHILD_SHAPE =
"same-process"- SHAPES =
%w[same-process child-process parent-child thread bundler-child env-reset-child].freeze
- BUNDLER_ENV_UNSETS =
%w[ BUNDLE_BIN_PATH BUNDLE_FROZEN BUNDLE_GEMFILE BUNDLE_LOCKFILE BUNDLER_SETUP BUNDLER_VERSION RUBYLIB RUBYOPT ].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #bundler_child_args(otp: options.fetch(:otp)) ⇒ Object
- #child_args(otp: options.fetch(:otp)) ⇒ Object
- #child_env(shape:, options: self.options) ⇒ Object
-
#initialize(options:, program_name:, output: $stdout, system_runner: Kernel) ⇒ ReleaseSecretsDoctor
constructor
A new instance of ReleaseSecretsDoctor.
- #run ⇒ Object
Constructor Details
#initialize(options:, program_name:, output: $stdout, system_runner: Kernel) ⇒ ReleaseSecretsDoctor
Returns a new instance of ReleaseSecretsDoctor.
37 38 39 40 41 42 |
# File 'lib/kettle/dev/release_secrets_doctor.rb', line 37 def initialize(options:, program_name:, output: $stdout, system_runner: Kernel) @options = () @program_name = program_name @output = output @system_runner = system_runner end |
Class Method Details
.options_from_env(env = ENV) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/kettle/dev/release_secrets_doctor.rb', line 27 def self.(env = ENV) { provider: env.fetch("KETTLE_RELEASE_SECRETS_PROVIDER", DEFAULT_PROVIDER), sleep_seconds: Float(env.fetch("KETTLE_RELEASE_SECRETS_DOCTOR_SLEEP", DEFAULT_SLEEP_SECONDS.to_s)), keepalive_seconds: Float(env.fetch("KETTLE_RELEASE_SECRETS_DOCTOR_KEEPALIVE", DEFAULT_KEEPALIVE_SECONDS.to_s)), shape: env.fetch("KETTLE_RELEASE_SECRETS_DOCTOR_SHAPE", DEFAULT_SHAPE), otp: false } end |
Instance Method Details
#bundler_child_args(otp: options.fetch(:otp)) ⇒ Object
80 81 82 83 84 |
# File 'lib/kettle/dev/release_secrets_doctor.rb', line 80 def bundler_child_args(otp: .fetch(:otp)) args = ["bundle", "exec", RbConfig.ruby, program_name] args << "--otp" if otp args end |
#child_args(otp: options.fetch(:otp)) ⇒ Object
74 75 76 77 78 |
# File 'lib/kettle/dev/release_secrets_doctor.rb', line 74 def child_args(otp: .fetch(:otp)) args = [RbConfig.ruby, program_name] args << "--otp" if otp args end |
#child_env(shape:, options: self.options) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/kettle/dev/release_secrets_doctor.rb', line 63 def child_env(shape:, options: self.) env = { "KETTLE_RELEASE_SECRETS_PROVIDER" => .fetch(:provider), "KETTLE_RELEASE_SECRETS_DOCTOR_SHAPE" => shape, "KETTLE_RELEASE_SECRETS_DOCTOR_SLEEP" => .fetch(:sleep_seconds).to_s, "KETTLE_RELEASE_SECRETS_DOCTOR_KEEPALIVE" => .fetch(:keepalive_seconds).to_s } env["KETTLE_RELEASE_SECRETS_DOCTOR_CHILD"] = "true" env end |
#run ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/kettle/dev/release_secrets_doctor.rb', line 44 def run case .fetch(:shape) when "same-process" run_same_process() when "child-process" run_child_process() when "parent-child" run_parent_child() when "thread" run_thread() when "bundler-child" run_bundler_child() when "env-reset-child" run_env_reset_child() else raise Kettle::Dev::Error, "unknown shape #{.fetch(:shape).inspect}; expected #{SHAPES.join(", ")}" end end |