Class: Kettle::Dev::ReleaseSecrets::OnePassword
- Defined in:
- lib/kettle/dev/release_secrets.rb
Constant Summary collapse
- PROVIDER_NAMES =
%w[1password onepassword op].freeze
- DEFAULTS =
{ "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.
- #rubygems_otp ⇒ Object
Constructor Details
#initialize(config) ⇒ OnePassword
Returns a new instance of OnePassword.
32 33 34 35 36 |
# File 'lib/kettle/dev/release_secrets.rb', line 32 def initialize(config) @config = DEFAULTS.merge(config || {}) @gem_signing_passphrase = nil @gem_signing_passphrase_loaded = false end |
Class Method Details
.configured?(name) ⇒ Boolean
28 29 30 |
# File 'lib/kettle/dev/release_secrets.rb', line 28 def self.configured?(name) PROVIDER_NAMES.include?(name.to_s.downcase) end |
Instance Method Details
#gem_signing_passphrase ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/kettle/dev/release_secrets.rb', line 38 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 |
#rubygems_otp ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/kettle/dev/release_secrets.rb', line 55 def rubygems_otp reference = string_config("rubygems_otp_reference") return read_reference(reference) unless reference.empty? item = required_config("item") argv = ["op", "item", "get", item, "--otp"] account = string_config("account") argv.concat(["--account", account]) unless account.empty? run_op(argv, purpose: "RubyGems OTP") end |