Class: Kettle::Dev::ReleaseSecrets::OnePassword
- Defined in:
- lib/kettle/dev/release_secrets.rb
Constant Summary collapse
- PROVIDER_NAMES =
%w[1password onepassword op].freeze
- DEFAULTS =
{ "cli" => "op", "item" => "Rubygems", "gem_signing_passphrase_field" => "GEM-SIGN-PASSPHRASE", "rubygems_otp_field" => "one-time password" }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #gem_signing_passphrase ⇒ Object
-
#initialize(config) ⇒ OnePassword
constructor
A new instance of OnePassword.
- #keepalive!(elapsed: nil) ⇒ Object
- #keepalive_required? ⇒ Boolean
- #rubygems_otp ⇒ Object
Constructor Details
#initialize(config) ⇒ OnePassword
Returns a new instance of OnePassword.
102 103 104 105 106 |
# File 'lib/kettle/dev/release_secrets.rb', line 102 def initialize(config) @config = DEFAULTS.merge(config || {}) @gem_signing_passphrase = nil @gem_signing_passphrase_loaded = false end |
Class Method Details
.configured?(name) ⇒ Boolean
98 99 100 |
# File 'lib/kettle/dev/release_secrets.rb', line 98 def self.configured?(name) PROVIDER_NAMES.include?(name.to_s.downcase) end |
Instance Method Details
#gem_signing_passphrase ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/kettle/dev/release_secrets.rb', line 108 def gem_signing_passphrase return @gem_signing_passphrase if @gem_signing_passphrase_loaded return cached_gem_signing_passphrase if cached_gem_signing_passphrase? reference = string_config("gem_signing_passphrase_reference") value = if reference.empty? item_field("gem_signing_passphrase_field") else read_reference(reference) end @gem_signing_passphrase = value @gem_signing_passphrase_loaded = true value end |
#keepalive!(elapsed: nil) ⇒ Object
136 137 138 139 140 141 |
# File 'lib/kettle/dev/release_secrets.rb', line 136 def keepalive!(elapsed: nil) # 1Password CLI authentication is session-scoped. Starting a fresh # `op account get` for every release poll does not keep it alive; it # only creates repeated authorization prompts and noise. true end |
#keepalive_required? ⇒ Boolean
143 144 145 |
# File 'lib/kettle/dev/release_secrets.rb', line 143 def keepalive_required? false end |
#rubygems_otp ⇒ Object
125 126 127 128 129 130 131 132 133 134 |
# File 'lib/kettle/dev/release_secrets.rb', line 125 def rubygems_otp reference = string_config("rubygems_otp_reference") return read_reference(reference) unless reference.empty? item = required_config("item") argv = [op_cli, "item", "get", item, "--otp"] account = string_config("account") argv.concat(["--account", account]) unless account.empty? run_op(argv, purpose: "RubyGems OTP") end |